babylon.gui.js 679 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666
  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:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/perfCounter");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /**
  516. * Define type to string to ensure compatibility across browsers
  517. * Safari doesn't support DataTransfer constructor
  518. */
  519. _this._clipboardData = "";
  520. /**
  521. * Observable event triggered each time an clipboard event is received from the rendering canvas
  522. */
  523. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  524. /**
  525. * Observable event triggered each time a pointer down is intercepted by a control
  526. */
  527. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered before layout is evaluated
  530. */
  531. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered after the layout was evaluated
  534. */
  535. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered before the texture is rendered
  538. */
  539. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered after the texture was rendered
  542. */
  543. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Gets or sets a boolean defining if alpha is stored as premultiplied
  546. */
  547. _this.premulAlpha = false;
  548. _this._useInvalidateRectOptimization = true;
  549. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  550. _this._invalidatedRectangle = null;
  551. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  552. /** @hidden */
  553. _this.onClipboardCopy = function (rawEvt) {
  554. var evt = rawEvt;
  555. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  556. _this.onClipboardObservable.notifyObservers(ev);
  557. evt.preventDefault();
  558. };
  559. /** @hidden */
  560. _this.onClipboardCut = function (rawEvt) {
  561. var evt = rawEvt;
  562. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  563. _this.onClipboardObservable.notifyObservers(ev);
  564. evt.preventDefault();
  565. };
  566. /** @hidden */
  567. _this.onClipboardPaste = function (rawEvt) {
  568. var evt = rawEvt;
  569. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  570. _this.onClipboardObservable.notifyObservers(ev);
  571. evt.preventDefault();
  572. };
  573. scene = _this.getScene();
  574. if (!scene || !_this._texture) {
  575. return _this;
  576. }
  577. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  578. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  579. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  580. if (!_this._focusedControl) {
  581. return;
  582. }
  583. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  584. _this._focusedControl.processKeyboard(info.event);
  585. }
  586. info.skipOnPointerObservable = true;
  587. });
  588. _this._rootContainer._link(_this);
  589. _this.hasAlpha = true;
  590. if (!width || !height) {
  591. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  592. _this._onResize();
  593. }
  594. _this._texture.isReady = true;
  595. return _this;
  596. }
  597. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  598. /**
  599. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  600. * Useful when you want more antialiasing
  601. */
  602. get: function () {
  603. return this._renderScale;
  604. },
  605. set: function (value) {
  606. if (value === this._renderScale) {
  607. return;
  608. }
  609. this._renderScale = value;
  610. this._onResize();
  611. },
  612. enumerable: true,
  613. configurable: true
  614. });
  615. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  616. /** Gets or sets the background color */
  617. get: function () {
  618. return this._background;
  619. },
  620. set: function (value) {
  621. if (this._background === value) {
  622. return;
  623. }
  624. this._background = value;
  625. this.markAsDirty();
  626. },
  627. enumerable: true,
  628. configurable: true
  629. });
  630. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  631. /**
  632. * Gets or sets the ideal width used to design controls.
  633. * The GUI will then rescale everything accordingly
  634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  635. */
  636. get: function () {
  637. return this._idealWidth;
  638. },
  639. set: function (value) {
  640. if (this._idealWidth === value) {
  641. return;
  642. }
  643. this._idealWidth = value;
  644. this.markAsDirty();
  645. this._rootContainer._markAllAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  651. /**
  652. * Gets or sets the ideal height used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealHeight;
  658. },
  659. set: function (value) {
  660. if (this._idealHeight === value) {
  661. return;
  662. }
  663. this._idealHeight = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  671. /**
  672. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  673. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  674. */
  675. get: function () {
  676. return this._useSmallestIdeal;
  677. },
  678. set: function (value) {
  679. if (this._useSmallestIdeal === value) {
  680. return;
  681. }
  682. this._useSmallestIdeal = value;
  683. this.markAsDirty();
  684. this._rootContainer._markAllAsDirty();
  685. },
  686. enumerable: true,
  687. configurable: true
  688. });
  689. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  690. /**
  691. * Gets or sets a boolean indicating if adaptive scaling must be used
  692. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  693. */
  694. get: function () {
  695. return this._renderAtIdealSize;
  696. },
  697. set: function (value) {
  698. if (this._renderAtIdealSize === value) {
  699. return;
  700. }
  701. this._renderAtIdealSize = value;
  702. this._onResize();
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  708. /**
  709. * Gets the underlying layer used to render the texture when in fullscreen mode
  710. */
  711. get: function () {
  712. return this._layerToDispose;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  718. /**
  719. * Gets the root container control
  720. */
  721. get: function () {
  722. return this._rootContainer;
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. /**
  728. * Returns an array containing the root container.
  729. * This is mostly used to let the Inspector introspects the ADT
  730. * @returns an array containing the rootContainer
  731. */
  732. AdvancedDynamicTexture.prototype.getChildren = function () {
  733. return [this._rootContainer];
  734. };
  735. /**
  736. * Will return all controls that are inside this texture
  737. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  738. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  739. * @return all child controls
  740. */
  741. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  742. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  743. };
  744. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  745. /**
  746. * Gets or sets the current focused control
  747. */
  748. get: function () {
  749. return this._focusedControl;
  750. },
  751. set: function (control) {
  752. if (this._focusedControl == control) {
  753. return;
  754. }
  755. if (this._focusedControl) {
  756. this._focusedControl.onBlur();
  757. }
  758. if (control) {
  759. control.onFocus();
  760. }
  761. this._focusedControl = control;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  767. /**
  768. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  769. */
  770. get: function () {
  771. if (!this.layer) {
  772. return true;
  773. }
  774. return (!this.layer.isBackground);
  775. },
  776. set: function (value) {
  777. if (!this.layer) {
  778. return;
  779. }
  780. if (this.layer.isBackground === !value) {
  781. return;
  782. }
  783. this.layer.isBackground = !value;
  784. },
  785. enumerable: true,
  786. configurable: true
  787. });
  788. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  789. /**
  790. * Gets or set information about clipboardData
  791. */
  792. get: function () {
  793. return this._clipboardData;
  794. },
  795. set: function (value) {
  796. this._clipboardData = value;
  797. },
  798. enumerable: true,
  799. configurable: true
  800. });
  801. /**
  802. * Get the current class name of the texture useful for serialization or dynamic coding.
  803. * @returns "AdvancedDynamicTexture"
  804. */
  805. AdvancedDynamicTexture.prototype.getClassName = function () {
  806. return "AdvancedDynamicTexture";
  807. };
  808. /**
  809. * Function used to execute a function on all controls
  810. * @param func defines the function to execute
  811. * @param container defines the container where controls belong. If null the root container will be used
  812. */
  813. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  814. if (!container) {
  815. container = this._rootContainer;
  816. }
  817. func(container);
  818. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  819. var child = _a[_i];
  820. if (child.children) {
  821. this.executeOnAllControls(func, child);
  822. continue;
  823. }
  824. func(child);
  825. }
  826. };
  827. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  828. /**
  829. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  830. */
  831. get: function () {
  832. return this._useInvalidateRectOptimization;
  833. },
  834. set: function (value) {
  835. this._useInvalidateRectOptimization = value;
  836. },
  837. enumerable: true,
  838. configurable: true
  839. });
  840. /**
  841. * Invalidates a rectangle area on the gui texture
  842. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  843. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  844. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  845. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  846. */
  847. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  848. if (!this._useInvalidateRectOptimization) {
  849. return;
  850. }
  851. if (!this._invalidatedRectangle) {
  852. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  853. }
  854. else {
  855. // Compute intersection
  856. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  857. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  858. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  859. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  860. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  861. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  862. }
  863. };
  864. /**
  865. * Marks the texture as dirty forcing a complete update
  866. */
  867. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  868. this._isDirty = true;
  869. };
  870. /**
  871. * Helper function used to create a new style
  872. * @returns a new style
  873. * @see http://doc.babylonjs.com/how_to/gui#styles
  874. */
  875. AdvancedDynamicTexture.prototype.createStyle = function () {
  876. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  877. };
  878. /**
  879. * Adds a new control to the root container
  880. * @param control defines the control to add
  881. * @returns the current texture
  882. */
  883. AdvancedDynamicTexture.prototype.addControl = function (control) {
  884. this._rootContainer.addControl(control);
  885. return this;
  886. };
  887. /**
  888. * Removes a control from the root container
  889. * @param control defines the control to remove
  890. * @returns the current texture
  891. */
  892. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  893. this._rootContainer.removeControl(control);
  894. return this;
  895. };
  896. /**
  897. * Release all resources
  898. */
  899. AdvancedDynamicTexture.prototype.dispose = function () {
  900. var scene = this.getScene();
  901. if (!scene) {
  902. return;
  903. }
  904. this._rootCanvas = null;
  905. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  906. if (this._resizeObserver) {
  907. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  908. }
  909. if (this._pointerMoveObserver) {
  910. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  911. }
  912. if (this._pointerObserver) {
  913. scene.onPointerObservable.remove(this._pointerObserver);
  914. }
  915. if (this._preKeyboardObserver) {
  916. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  917. }
  918. if (this._canvasPointerOutObserver) {
  919. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  920. }
  921. if (this._layerToDispose) {
  922. this._layerToDispose.texture = null;
  923. this._layerToDispose.dispose();
  924. this._layerToDispose = null;
  925. }
  926. this._rootContainer.dispose();
  927. this.onClipboardObservable.clear();
  928. this.onControlPickedObservable.clear();
  929. this.onBeginRenderObservable.clear();
  930. this.onEndRenderObservable.clear();
  931. this.onBeginLayoutObservable.clear();
  932. this.onEndLayoutObservable.clear();
  933. _super.prototype.dispose.call(this);
  934. };
  935. AdvancedDynamicTexture.prototype._onResize = function () {
  936. var scene = this.getScene();
  937. if (!scene) {
  938. return;
  939. }
  940. // Check size
  941. var engine = scene.getEngine();
  942. var textureSize = this.getSize();
  943. var renderWidth = engine.getRenderWidth() * this._renderScale;
  944. var renderHeight = engine.getRenderHeight() * this._renderScale;
  945. if (this._renderAtIdealSize) {
  946. if (this._idealWidth) {
  947. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  948. renderWidth = this._idealWidth;
  949. }
  950. else if (this._idealHeight) {
  951. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  952. renderHeight = this._idealHeight;
  953. }
  954. }
  955. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  956. this.scaleTo(renderWidth, renderHeight);
  957. this.markAsDirty();
  958. if (this._idealWidth || this._idealHeight) {
  959. this._rootContainer._markAllAsDirty();
  960. }
  961. }
  962. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  963. };
  964. /** @hidden */
  965. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  966. var engine = scene.getEngine();
  967. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  968. };
  969. /**
  970. * Get screen coordinates for a vector3
  971. * @param position defines the position to project
  972. * @param worldMatrix defines the world matrix to use
  973. * @returns the projected position
  974. */
  975. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  976. var scene = this.getScene();
  977. if (!scene) {
  978. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  979. }
  980. var globalViewport = this._getGlobalViewport(scene);
  981. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  982. projectedPosition.scaleInPlace(this.renderScale);
  983. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  984. };
  985. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  986. if (this._layerToDispose) {
  987. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  988. return;
  989. }
  990. }
  991. if (this._isFullscreen && this._linkedControls.length) {
  992. var scene = this.getScene();
  993. if (!scene) {
  994. return;
  995. }
  996. var globalViewport = this._getGlobalViewport(scene);
  997. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  998. var control = _a[_i];
  999. if (!control.isVisible) {
  1000. continue;
  1001. }
  1002. var mesh = control._linkedMesh;
  1003. if (!mesh || mesh.isDisposed()) {
  1004. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1005. control.linkWithMesh(null);
  1006. });
  1007. continue;
  1008. }
  1009. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1010. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1011. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1012. control.notRenderable = true;
  1013. continue;
  1014. }
  1015. control.notRenderable = false;
  1016. // Account for RenderScale.
  1017. projectedPosition.scaleInPlace(this.renderScale);
  1018. control._moveToProjectedPosition(projectedPosition);
  1019. }
  1020. }
  1021. if (!this._isDirty && !this._rootContainer.isDirty) {
  1022. return;
  1023. }
  1024. this._isDirty = false;
  1025. this._render();
  1026. this.update(true, this.premulAlpha);
  1027. };
  1028. AdvancedDynamicTexture.prototype._render = function () {
  1029. var textureSize = this.getSize();
  1030. var renderWidth = textureSize.width;
  1031. var renderHeight = textureSize.height;
  1032. var context = this.getContext();
  1033. context.font = "18px Arial";
  1034. context.strokeStyle = "white";
  1035. // Layout
  1036. this.onBeginLayoutObservable.notifyObservers(this);
  1037. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1038. this._rootContainer._layout(measure, context);
  1039. this.onEndLayoutObservable.notifyObservers(this);
  1040. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1041. // Clear
  1042. if (this._invalidatedRectangle) {
  1043. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1044. }
  1045. else {
  1046. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1047. }
  1048. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1049. if (this._background) {
  1050. context.save();
  1051. context.fillStyle = this._background;
  1052. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1053. context.restore();
  1054. }
  1055. // Render
  1056. this.onBeginRenderObservable.notifyObservers(this);
  1057. this._rootContainer._render(context, this._invalidatedRectangle);
  1058. this.onEndRenderObservable.notifyObservers(this);
  1059. this._invalidatedRectangle = null;
  1060. };
  1061. /** @hidden */
  1062. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1063. if (this._rootCanvas) {
  1064. this._rootCanvas.style.cursor = cursor;
  1065. this._cursorChanged = true;
  1066. }
  1067. };
  1068. /** @hidden */
  1069. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1070. this._lastControlDown[pointerId] = control;
  1071. this.onControlPickedObservable.notifyObservers(control);
  1072. };
  1073. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1074. var scene = this.getScene();
  1075. if (!scene) {
  1076. return;
  1077. }
  1078. var engine = scene.getEngine();
  1079. var textureSize = this.getSize();
  1080. if (this._isFullscreen) {
  1081. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1082. var viewport = camera.viewport;
  1083. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1084. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1085. }
  1086. if (this._capturingControl[pointerId]) {
  1087. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1088. return;
  1089. }
  1090. this._cursorChanged = false;
  1091. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1092. this._changeCursor("");
  1093. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1094. if (this._lastControlOver[pointerId]) {
  1095. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1096. delete this._lastControlOver[pointerId];
  1097. }
  1098. }
  1099. }
  1100. if (!this._cursorChanged) {
  1101. this._changeCursor("");
  1102. }
  1103. this._manageFocus();
  1104. };
  1105. /** @hidden */
  1106. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1107. for (var pointerId in list) {
  1108. if (!list.hasOwnProperty(pointerId)) {
  1109. continue;
  1110. }
  1111. var lastControlOver = list[pointerId];
  1112. if (lastControlOver === control) {
  1113. delete list[pointerId];
  1114. }
  1115. }
  1116. };
  1117. /** @hidden */
  1118. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1119. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1120. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1121. };
  1122. /** Attach to all scene events required to support pointer events */
  1123. AdvancedDynamicTexture.prototype.attach = function () {
  1124. var _this = this;
  1125. var scene = this.getScene();
  1126. if (!scene) {
  1127. return;
  1128. }
  1129. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1130. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1131. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1132. return;
  1133. }
  1134. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1135. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1136. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1137. return;
  1138. }
  1139. if (!scene) {
  1140. return;
  1141. }
  1142. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1143. var engine = scene.getEngine();
  1144. if (!camera) {
  1145. tempViewport.x = 0;
  1146. tempViewport.y = 0;
  1147. tempViewport.width = engine.getRenderWidth();
  1148. tempViewport.height = engine.getRenderHeight();
  1149. }
  1150. else {
  1151. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1152. }
  1153. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1154. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1155. _this._shouldBlockPointer = false;
  1156. // Do picking modifies _shouldBlockPointer
  1157. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1158. // Avoid overwriting a true skipOnPointerObservable to false
  1159. if (_this._shouldBlockPointer) {
  1160. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1161. }
  1162. });
  1163. this._attachToOnPointerOut(scene);
  1164. };
  1165. /**
  1166. * Register the clipboard Events onto the canvas
  1167. */
  1168. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1169. self.addEventListener("copy", this.onClipboardCopy, false);
  1170. self.addEventListener("cut", this.onClipboardCut, false);
  1171. self.addEventListener("paste", this.onClipboardPaste, false);
  1172. };
  1173. /**
  1174. * Unregister the clipboard Events from the canvas
  1175. */
  1176. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1177. self.removeEventListener("copy", this.onClipboardCopy);
  1178. self.removeEventListener("cut", this.onClipboardCut);
  1179. self.removeEventListener("paste", this.onClipboardPaste);
  1180. };
  1181. /**
  1182. * Connect the texture to a hosting mesh to enable interactions
  1183. * @param mesh defines the mesh to attach to
  1184. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1185. */
  1186. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1187. var _this = this;
  1188. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1189. var scene = this.getScene();
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1194. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1195. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1196. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1197. return;
  1198. }
  1199. var pointerId = pi.event.pointerId || 0;
  1200. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1201. var uv = pi.pickInfo.getTextureCoordinates();
  1202. if (uv) {
  1203. var size = _this.getSize();
  1204. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1205. }
  1206. }
  1207. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1208. if (_this._lastControlDown[pointerId]) {
  1209. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1210. }
  1211. delete _this._lastControlDown[pointerId];
  1212. if (_this.focusedControl) {
  1213. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1214. var canMoveFocus = true;
  1215. if (friendlyControls) {
  1216. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1217. var control = friendlyControls_1[_i];
  1218. // Same host, no need to keep the focus
  1219. if (_this === control._host) {
  1220. continue;
  1221. }
  1222. // Different hosts
  1223. var otherHost = control._host;
  1224. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1225. canMoveFocus = false;
  1226. break;
  1227. }
  1228. }
  1229. }
  1230. if (canMoveFocus) {
  1231. _this.focusedControl = null;
  1232. }
  1233. }
  1234. }
  1235. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1236. if (_this._lastControlOver[pointerId]) {
  1237. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1238. }
  1239. delete _this._lastControlOver[pointerId];
  1240. }
  1241. });
  1242. mesh.enablePointerMoveEvents = supportPointerMove;
  1243. this._attachToOnPointerOut(scene);
  1244. };
  1245. /**
  1246. * Move the focus to a specific control
  1247. * @param control defines the control which will receive the focus
  1248. */
  1249. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1250. this.focusedControl = control;
  1251. this._lastPickedControl = control;
  1252. this._blockNextFocusCheck = true;
  1253. };
  1254. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1255. if (this._blockNextFocusCheck) {
  1256. this._blockNextFocusCheck = false;
  1257. this._lastPickedControl = this._focusedControl;
  1258. return;
  1259. }
  1260. // Focus management
  1261. if (this._focusedControl) {
  1262. if (this._focusedControl !== this._lastPickedControl) {
  1263. if (this._lastPickedControl.isFocusInvisible) {
  1264. return;
  1265. }
  1266. this.focusedControl = null;
  1267. }
  1268. }
  1269. };
  1270. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1271. var _this = this;
  1272. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1273. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1274. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1275. }
  1276. delete _this._lastControlOver[pointerEvent.pointerId];
  1277. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1278. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1279. delete _this._lastControlDown[pointerEvent.pointerId];
  1280. }
  1281. });
  1282. };
  1283. // Statics
  1284. /**
  1285. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1286. * @param mesh defines the mesh which will receive the texture
  1287. * @param width defines the texture width (1024 by default)
  1288. * @param height defines the texture height (1024 by default)
  1289. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1290. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1291. * @returns a new AdvancedDynamicTexture
  1292. */
  1293. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1294. if (width === void 0) { width = 1024; }
  1295. if (height === void 0) { height = 1024; }
  1296. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1297. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1298. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1299. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1300. material.backFaceCulling = false;
  1301. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1302. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1303. if (onlyAlphaTesting) {
  1304. material.diffuseTexture = result;
  1305. material.emissiveTexture = result;
  1306. result.hasAlpha = true;
  1307. }
  1308. else {
  1309. material.emissiveTexture = result;
  1310. material.opacityTexture = result;
  1311. }
  1312. mesh.material = material;
  1313. result.attachToMesh(mesh, supportPointerMove);
  1314. return result;
  1315. };
  1316. /**
  1317. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1318. * In this mode the texture will rely on a layer for its rendering.
  1319. * This allows it to be treated like any other layer.
  1320. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1321. * LayerMask is set through advancedTexture.layer.layerMask
  1322. * @param name defines name for the texture
  1323. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1324. * @param scene defines the hsoting scene
  1325. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1326. * @returns a new AdvancedDynamicTexture
  1327. */
  1328. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1329. if (foreground === void 0) { foreground = true; }
  1330. if (scene === void 0) { scene = null; }
  1331. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1332. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1333. // Display
  1334. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1335. layer.texture = result;
  1336. result._layerToDispose = layer;
  1337. result._isFullscreen = true;
  1338. // Attach
  1339. result.attach();
  1340. return result;
  1341. };
  1342. return AdvancedDynamicTexture;
  1343. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1344. /***/ }),
  1345. /***/ "./2D/controls/button.ts":
  1346. /*!*******************************!*\
  1347. !*** ./2D/controls/button.ts ***!
  1348. \*******************************/
  1349. /*! exports provided: Button */
  1350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1351. "use strict";
  1352. __webpack_require__.r(__webpack_exports__);
  1353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1355. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1356. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1357. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1358. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1359. /**
  1360. * Class used to create 2D buttons
  1361. */
  1362. var Button = /** @class */ (function (_super) {
  1363. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1364. /**
  1365. * Creates a new Button
  1366. * @param name defines the name of the button
  1367. */
  1368. function Button(name) {
  1369. var _this = _super.call(this, name) || this;
  1370. _this.name = name;
  1371. _this.thickness = 1;
  1372. _this.isPointerBlocker = true;
  1373. var alphaStore = null;
  1374. _this.pointerEnterAnimation = function () {
  1375. alphaStore = _this.alpha;
  1376. _this.alpha -= 0.1;
  1377. };
  1378. _this.pointerOutAnimation = function () {
  1379. if (alphaStore !== null) {
  1380. _this.alpha = alphaStore;
  1381. }
  1382. };
  1383. _this.pointerDownAnimation = function () {
  1384. _this.scaleX -= 0.05;
  1385. _this.scaleY -= 0.05;
  1386. };
  1387. _this.pointerUpAnimation = function () {
  1388. _this.scaleX += 0.05;
  1389. _this.scaleY += 0.05;
  1390. };
  1391. return _this;
  1392. }
  1393. Object.defineProperty(Button.prototype, "image", {
  1394. /**
  1395. * Returns the image part of the button (if any)
  1396. */
  1397. get: function () {
  1398. return this._image;
  1399. },
  1400. enumerable: true,
  1401. configurable: true
  1402. });
  1403. Object.defineProperty(Button.prototype, "textBlock", {
  1404. /**
  1405. * Returns the image part of the button (if any)
  1406. */
  1407. get: function () {
  1408. return this._textBlock;
  1409. },
  1410. enumerable: true,
  1411. configurable: true
  1412. });
  1413. Button.prototype._getTypeName = function () {
  1414. return "Button";
  1415. };
  1416. // While being a container, the button behaves like a control.
  1417. /** @hidden */
  1418. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1419. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1420. return false;
  1421. }
  1422. if (!_super.prototype.contains.call(this, x, y)) {
  1423. return false;
  1424. }
  1425. this._processObservables(type, x, y, pointerId, buttonIndex);
  1426. return true;
  1427. };
  1428. /** @hidden */
  1429. Button.prototype._onPointerEnter = function (target) {
  1430. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1431. return false;
  1432. }
  1433. if (this.pointerEnterAnimation) {
  1434. this.pointerEnterAnimation();
  1435. }
  1436. return true;
  1437. };
  1438. /** @hidden */
  1439. Button.prototype._onPointerOut = function (target, force) {
  1440. if (force === void 0) { force = false; }
  1441. if (this.pointerOutAnimation) {
  1442. this.pointerOutAnimation();
  1443. }
  1444. _super.prototype._onPointerOut.call(this, target, force);
  1445. };
  1446. /** @hidden */
  1447. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1448. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1449. return false;
  1450. }
  1451. if (this.pointerDownAnimation) {
  1452. this.pointerDownAnimation();
  1453. }
  1454. return true;
  1455. };
  1456. /** @hidden */
  1457. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1458. if (this.pointerUpAnimation) {
  1459. this.pointerUpAnimation();
  1460. }
  1461. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1462. };
  1463. // Statics
  1464. /**
  1465. * Creates a new button made with an image and a text
  1466. * @param name defines the name of the button
  1467. * @param text defines the text of the button
  1468. * @param imageUrl defines the url of the image
  1469. * @returns a new Button
  1470. */
  1471. Button.CreateImageButton = function (name, text, imageUrl) {
  1472. var result = new Button(name);
  1473. // Adding text
  1474. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1475. textBlock.textWrapping = true;
  1476. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1477. textBlock.paddingLeft = "20%";
  1478. result.addControl(textBlock);
  1479. // Adding image
  1480. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1481. iconImage.width = "20%";
  1482. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1483. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1484. result.addControl(iconImage);
  1485. // Store
  1486. result._image = iconImage;
  1487. result._textBlock = textBlock;
  1488. return result;
  1489. };
  1490. /**
  1491. * Creates a new button made with an image
  1492. * @param name defines the name of the button
  1493. * @param imageUrl defines the url of the image
  1494. * @returns a new Button
  1495. */
  1496. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1497. var result = new Button(name);
  1498. // Adding image
  1499. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1500. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1501. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1502. result.addControl(iconImage);
  1503. // Store
  1504. result._image = iconImage;
  1505. return result;
  1506. };
  1507. /**
  1508. * Creates a new button made with a text
  1509. * @param name defines the name of the button
  1510. * @param text defines the text of the button
  1511. * @returns a new Button
  1512. */
  1513. Button.CreateSimpleButton = function (name, text) {
  1514. var result = new Button(name);
  1515. // Adding text
  1516. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1517. textBlock.textWrapping = true;
  1518. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1519. result.addControl(textBlock);
  1520. // Store
  1521. result._textBlock = textBlock;
  1522. return result;
  1523. };
  1524. /**
  1525. * Creates a new button made with an image and a centered text
  1526. * @param name defines the name of the button
  1527. * @param text defines the text of the button
  1528. * @param imageUrl defines the url of the image
  1529. * @returns a new Button
  1530. */
  1531. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1532. var result = new Button(name);
  1533. // Adding image
  1534. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1535. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1536. result.addControl(iconImage);
  1537. // Adding text
  1538. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1539. textBlock.textWrapping = true;
  1540. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1541. result.addControl(textBlock);
  1542. // Store
  1543. result._image = iconImage;
  1544. result._textBlock = textBlock;
  1545. return result;
  1546. };
  1547. return Button;
  1548. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1549. /***/ }),
  1550. /***/ "./2D/controls/checkbox.ts":
  1551. /*!*********************************!*\
  1552. !*** ./2D/controls/checkbox.ts ***!
  1553. \*********************************/
  1554. /*! exports provided: Checkbox */
  1555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1556. "use strict";
  1557. __webpack_require__.r(__webpack_exports__);
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1559. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1560. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1561. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1562. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1563. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1564. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1565. /**
  1566. * Class used to represent a 2D checkbox
  1567. */
  1568. var Checkbox = /** @class */ (function (_super) {
  1569. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1570. /**
  1571. * Creates a new CheckBox
  1572. * @param name defines the control name
  1573. */
  1574. function Checkbox(name) {
  1575. var _this = _super.call(this, name) || this;
  1576. _this.name = name;
  1577. _this._isChecked = false;
  1578. _this._background = "black";
  1579. _this._checkSizeRatio = 0.8;
  1580. _this._thickness = 1;
  1581. /**
  1582. * Observable raised when isChecked property changes
  1583. */
  1584. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1585. _this.isPointerBlocker = true;
  1586. return _this;
  1587. }
  1588. Object.defineProperty(Checkbox.prototype, "thickness", {
  1589. /** Gets or sets border thickness */
  1590. get: function () {
  1591. return this._thickness;
  1592. },
  1593. set: function (value) {
  1594. if (this._thickness === value) {
  1595. return;
  1596. }
  1597. this._thickness = value;
  1598. this._markAsDirty();
  1599. },
  1600. enumerable: true,
  1601. configurable: true
  1602. });
  1603. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1604. /** Gets or sets a value indicating the ratio between overall size and check size */
  1605. get: function () {
  1606. return this._checkSizeRatio;
  1607. },
  1608. set: function (value) {
  1609. value = Math.max(Math.min(1, value), 0);
  1610. if (this._checkSizeRatio === value) {
  1611. return;
  1612. }
  1613. this._checkSizeRatio = value;
  1614. this._markAsDirty();
  1615. },
  1616. enumerable: true,
  1617. configurable: true
  1618. });
  1619. Object.defineProperty(Checkbox.prototype, "background", {
  1620. /** Gets or sets background color */
  1621. get: function () {
  1622. return this._background;
  1623. },
  1624. set: function (value) {
  1625. if (this._background === value) {
  1626. return;
  1627. }
  1628. this._background = value;
  1629. this._markAsDirty();
  1630. },
  1631. enumerable: true,
  1632. configurable: true
  1633. });
  1634. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1635. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1636. get: function () {
  1637. return this._isChecked;
  1638. },
  1639. set: function (value) {
  1640. if (this._isChecked === value) {
  1641. return;
  1642. }
  1643. this._isChecked = value;
  1644. this._markAsDirty();
  1645. this.onIsCheckedChangedObservable.notifyObservers(value);
  1646. },
  1647. enumerable: true,
  1648. configurable: true
  1649. });
  1650. Checkbox.prototype._getTypeName = function () {
  1651. return "Checkbox";
  1652. };
  1653. /** @hidden */
  1654. Checkbox.prototype._draw = function (context) {
  1655. context.save();
  1656. this._applyStates(context);
  1657. var actualWidth = this._currentMeasure.width - this._thickness;
  1658. var actualHeight = this._currentMeasure.height - this._thickness;
  1659. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1660. context.shadowColor = this.shadowColor;
  1661. context.shadowBlur = this.shadowBlur;
  1662. context.shadowOffsetX = this.shadowOffsetX;
  1663. context.shadowOffsetY = this.shadowOffsetY;
  1664. }
  1665. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1666. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1667. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1668. context.shadowBlur = 0;
  1669. context.shadowOffsetX = 0;
  1670. context.shadowOffsetY = 0;
  1671. }
  1672. if (this._isChecked) {
  1673. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1674. var offsetWidth = actualWidth * this._checkSizeRatio;
  1675. var offseHeight = actualHeight * this._checkSizeRatio;
  1676. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1677. }
  1678. context.strokeStyle = this.color;
  1679. context.lineWidth = this._thickness;
  1680. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1681. context.restore();
  1682. };
  1683. // Events
  1684. /** @hidden */
  1685. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1686. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1687. return false;
  1688. }
  1689. this.isChecked = !this.isChecked;
  1690. return true;
  1691. };
  1692. /**
  1693. * Utility function to easily create a checkbox with a header
  1694. * @param title defines the label to use for the header
  1695. * @param onValueChanged defines the callback to call when value changes
  1696. * @returns a StackPanel containing the checkbox and a textBlock
  1697. */
  1698. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1699. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1700. panel.isVertical = false;
  1701. panel.height = "30px";
  1702. var checkbox = new Checkbox();
  1703. checkbox.width = "20px";
  1704. checkbox.height = "20px";
  1705. checkbox.isChecked = true;
  1706. checkbox.color = "green";
  1707. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1708. panel.addControl(checkbox);
  1709. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1710. header.text = title;
  1711. header.width = "180px";
  1712. header.paddingLeft = "5px";
  1713. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1714. header.color = "white";
  1715. panel.addControl(header);
  1716. return panel;
  1717. };
  1718. return Checkbox;
  1719. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1720. /***/ }),
  1721. /***/ "./2D/controls/colorpicker.ts":
  1722. /*!************************************!*\
  1723. !*** ./2D/controls/colorpicker.ts ***!
  1724. \************************************/
  1725. /*! exports provided: ColorPicker */
  1726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1727. "use strict";
  1728. __webpack_require__.r(__webpack_exports__);
  1729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1730. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1731. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1732. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1733. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1734. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1735. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1736. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1737. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1738. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1739. /** Class used to create color pickers */
  1740. var ColorPicker = /** @class */ (function (_super) {
  1741. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1742. /**
  1743. * Creates a new ColorPicker
  1744. * @param name defines the control name
  1745. */
  1746. function ColorPicker(name) {
  1747. var _this = _super.call(this, name) || this;
  1748. _this.name = name;
  1749. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1750. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1751. _this._pointerStartedOnSquare = false;
  1752. _this._pointerStartedOnWheel = false;
  1753. _this._squareLeft = 0;
  1754. _this._squareTop = 0;
  1755. _this._squareSize = 0;
  1756. _this._h = 360;
  1757. _this._s = 1;
  1758. _this._v = 1;
  1759. _this._lastPointerDownID = -1;
  1760. /**
  1761. * Observable raised when the value changes
  1762. */
  1763. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1764. // Events
  1765. _this._pointerIsDown = false;
  1766. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1767. _this.size = "200px";
  1768. _this.isPointerBlocker = true;
  1769. return _this;
  1770. }
  1771. Object.defineProperty(ColorPicker.prototype, "value", {
  1772. /** Gets or sets the color of the color picker */
  1773. get: function () {
  1774. return this._value;
  1775. },
  1776. set: function (value) {
  1777. if (this._value.equals(value)) {
  1778. return;
  1779. }
  1780. this._value.copyFrom(value);
  1781. this._value.toHSVToRef(this._tmpColor);
  1782. this._h = this._tmpColor.r;
  1783. this._s = Math.max(this._tmpColor.g, 0.00001);
  1784. this._v = Math.max(this._tmpColor.b, 0.00001);
  1785. this._markAsDirty();
  1786. if (this._value.r <= ColorPicker._Epsilon) {
  1787. this._value.r = 0;
  1788. }
  1789. if (this._value.g <= ColorPicker._Epsilon) {
  1790. this._value.g = 0;
  1791. }
  1792. if (this._value.b <= ColorPicker._Epsilon) {
  1793. this._value.b = 0;
  1794. }
  1795. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1796. this._value.r = 1.0;
  1797. }
  1798. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1799. this._value.g = 1.0;
  1800. }
  1801. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1802. this._value.b = 1.0;
  1803. }
  1804. this.onValueChangedObservable.notifyObservers(this._value);
  1805. },
  1806. enumerable: true,
  1807. configurable: true
  1808. });
  1809. Object.defineProperty(ColorPicker.prototype, "width", {
  1810. /**
  1811. * Gets or sets control width
  1812. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1813. */
  1814. get: function () {
  1815. return this._width.toString(this._host);
  1816. },
  1817. set: function (value) {
  1818. if (this._width.toString(this._host) === value) {
  1819. return;
  1820. }
  1821. if (this._width.fromString(value)) {
  1822. this._height.fromString(value);
  1823. this._markAsDirty();
  1824. }
  1825. },
  1826. enumerable: true,
  1827. configurable: true
  1828. });
  1829. Object.defineProperty(ColorPicker.prototype, "height", {
  1830. /**
  1831. * Gets or sets control height
  1832. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1833. */
  1834. get: function () {
  1835. return this._height.toString(this._host);
  1836. },
  1837. /** Gets or sets control height */
  1838. set: function (value) {
  1839. if (this._height.toString(this._host) === value) {
  1840. return;
  1841. }
  1842. if (this._height.fromString(value)) {
  1843. this._width.fromString(value);
  1844. this._markAsDirty();
  1845. }
  1846. },
  1847. enumerable: true,
  1848. configurable: true
  1849. });
  1850. Object.defineProperty(ColorPicker.prototype, "size", {
  1851. /** Gets or sets control size */
  1852. get: function () {
  1853. return this.width;
  1854. },
  1855. set: function (value) {
  1856. this.width = value;
  1857. },
  1858. enumerable: true,
  1859. configurable: true
  1860. });
  1861. ColorPicker.prototype._getTypeName = function () {
  1862. return "ColorPicker";
  1863. };
  1864. /** @hidden */
  1865. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1866. if (parentMeasure.width < parentMeasure.height) {
  1867. this._currentMeasure.height = parentMeasure.width;
  1868. }
  1869. else {
  1870. this._currentMeasure.width = parentMeasure.height;
  1871. }
  1872. };
  1873. ColorPicker.prototype._updateSquareProps = function () {
  1874. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1875. var wheelThickness = radius * .2;
  1876. var innerDiameter = (radius - wheelThickness) * 2;
  1877. var squareSize = innerDiameter / (Math.sqrt(2));
  1878. var offset = radius - squareSize * .5;
  1879. this._squareLeft = this._currentMeasure.left + offset;
  1880. this._squareTop = this._currentMeasure.top + offset;
  1881. this._squareSize = squareSize;
  1882. };
  1883. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1884. var lgh = context.createLinearGradient(left, top, width + left, top);
  1885. lgh.addColorStop(0, '#fff');
  1886. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1887. context.fillStyle = lgh;
  1888. context.fillRect(left, top, width, height);
  1889. var lgv = context.createLinearGradient(left, top, left, height + top);
  1890. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1891. lgv.addColorStop(1, '#000');
  1892. context.fillStyle = lgv;
  1893. context.fillRect(left, top, width, height);
  1894. };
  1895. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1896. context.beginPath();
  1897. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1898. context.lineWidth = 3;
  1899. context.strokeStyle = '#333333';
  1900. context.stroke();
  1901. context.beginPath();
  1902. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1903. context.lineWidth = 3;
  1904. context.strokeStyle = '#ffffff';
  1905. context.stroke();
  1906. };
  1907. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1908. var canvas = document.createElement("canvas");
  1909. canvas.width = radius * 2;
  1910. canvas.height = radius * 2;
  1911. var context = canvas.getContext("2d");
  1912. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1913. var data = image.data;
  1914. var color = this._tmpColor;
  1915. var maxDistSq = radius * radius;
  1916. var innerRadius = radius - thickness;
  1917. var minDistSq = innerRadius * innerRadius;
  1918. for (var x = -radius; x < radius; x++) {
  1919. for (var y = -radius; y < radius; y++) {
  1920. var distSq = x * x + y * y;
  1921. if (distSq > maxDistSq || distSq < minDistSq) {
  1922. continue;
  1923. }
  1924. var dist = Math.sqrt(distSq);
  1925. var ang = Math.atan2(y, x);
  1926. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1927. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1928. data[index] = color.r * 255;
  1929. data[index + 1] = color.g * 255;
  1930. data[index + 2] = color.b * 255;
  1931. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1932. //apply less alpha to bigger color pickers
  1933. var alphaAmount = .2;
  1934. var maxAlpha = .2;
  1935. var minAlpha = .04;
  1936. var lowerRadius = 50;
  1937. var upperRadius = 150;
  1938. if (radius < lowerRadius) {
  1939. alphaAmount = maxAlpha;
  1940. }
  1941. else if (radius > upperRadius) {
  1942. alphaAmount = minAlpha;
  1943. }
  1944. else {
  1945. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1946. }
  1947. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1948. if (alphaRatio < alphaAmount) {
  1949. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1950. }
  1951. else if (alphaRatio > 1 - alphaAmount) {
  1952. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1953. }
  1954. else {
  1955. data[index + 3] = 255;
  1956. }
  1957. }
  1958. }
  1959. context.putImageData(image, 0, 0);
  1960. return canvas;
  1961. };
  1962. /** @hidden */
  1963. ColorPicker.prototype._draw = function (context) {
  1964. context.save();
  1965. this._applyStates(context);
  1966. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1967. var wheelThickness = radius * .2;
  1968. var left = this._currentMeasure.left;
  1969. var top = this._currentMeasure.top;
  1970. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1971. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1972. }
  1973. this._updateSquareProps();
  1974. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1975. context.shadowColor = this.shadowColor;
  1976. context.shadowBlur = this.shadowBlur;
  1977. context.shadowOffsetX = this.shadowOffsetX;
  1978. context.shadowOffsetY = this.shadowOffsetY;
  1979. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  1980. }
  1981. context.drawImage(this._colorWheelCanvas, left, top);
  1982. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1983. context.shadowBlur = 0;
  1984. context.shadowOffsetX = 0;
  1985. context.shadowOffsetY = 0;
  1986. }
  1987. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  1988. var cx = this._squareLeft + this._squareSize * this._s;
  1989. var cy = this._squareTop + this._squareSize * (1 - this._v);
  1990. this._drawCircle(cx, cy, radius * .04, context);
  1991. var dist = radius - wheelThickness * .5;
  1992. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  1993. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  1994. this._drawCircle(cx, cy, wheelThickness * .35, context);
  1995. context.restore();
  1996. };
  1997. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  1998. if (this._pointerStartedOnWheel) {
  1999. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2000. var centerX = radius + this._currentMeasure.left;
  2001. var centerY = radius + this._currentMeasure.top;
  2002. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2003. }
  2004. else if (this._pointerStartedOnSquare) {
  2005. this._updateSquareProps();
  2006. this._s = (x - this._squareLeft) / this._squareSize;
  2007. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2008. this._s = Math.min(this._s, 1);
  2009. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2010. this._v = Math.min(this._v, 1);
  2011. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2012. }
  2013. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2014. this.value = this._tmpColor;
  2015. };
  2016. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2017. this._updateSquareProps();
  2018. var left = this._squareLeft;
  2019. var top = this._squareTop;
  2020. var size = this._squareSize;
  2021. if (x >= left && x <= left + size &&
  2022. y >= top && y <= top + size) {
  2023. return true;
  2024. }
  2025. return false;
  2026. };
  2027. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2028. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2029. var centerX = radius + this._currentMeasure.left;
  2030. var centerY = radius + this._currentMeasure.top;
  2031. var wheelThickness = radius * .2;
  2032. var innerRadius = radius - wheelThickness;
  2033. var radiusSq = radius * radius;
  2034. var innerRadiusSq = innerRadius * innerRadius;
  2035. var dx = x - centerX;
  2036. var dy = y - centerY;
  2037. var distSq = dx * dx + dy * dy;
  2038. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2039. return true;
  2040. }
  2041. return false;
  2042. };
  2043. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2044. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2045. return false;
  2046. }
  2047. this._pointerIsDown = true;
  2048. this._pointerStartedOnSquare = false;
  2049. this._pointerStartedOnWheel = false;
  2050. // Invert transform
  2051. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2052. var x = this._transformedPosition.x;
  2053. var y = this._transformedPosition.y;
  2054. if (this._isPointOnSquare(x, y)) {
  2055. this._pointerStartedOnSquare = true;
  2056. }
  2057. else if (this._isPointOnWheel(x, y)) {
  2058. this._pointerStartedOnWheel = true;
  2059. }
  2060. this._updateValueFromPointer(x, y);
  2061. this._host._capturingControl[pointerId] = this;
  2062. this._lastPointerDownID = pointerId;
  2063. return true;
  2064. };
  2065. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2066. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2067. if (pointerId != this._lastPointerDownID) {
  2068. return;
  2069. }
  2070. // Invert transform
  2071. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2072. var x = this._transformedPosition.x;
  2073. var y = this._transformedPosition.y;
  2074. if (this._pointerIsDown) {
  2075. this._updateValueFromPointer(x, y);
  2076. }
  2077. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2078. };
  2079. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2080. this._pointerIsDown = false;
  2081. delete this._host._capturingControl[pointerId];
  2082. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2083. };
  2084. /**
  2085. * This function expands the color picker by creating a color picker dialog with manual
  2086. * color value input and the ability to save colors into an array to be used later in
  2087. * subsequent launches of the dialogue.
  2088. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2089. * @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.
  2090. * @returns picked color as a hex string and the saved colors array as hex strings.
  2091. */
  2092. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2093. return new Promise(function (resolve, reject) {
  2094. // Default options
  2095. options.pickerWidth = options.pickerWidth || "640px";
  2096. options.pickerHeight = options.pickerHeight || "400px";
  2097. options.headerHeight = options.headerHeight || "35px";
  2098. options.lastColor = options.lastColor || "#000000";
  2099. options.swatchLimit = options.swatchLimit || 20;
  2100. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2101. // Window size settings
  2102. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2103. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2104. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2105. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2106. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2107. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2108. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2109. // Button Colors
  2110. var buttonColor = "#c0c0c0";
  2111. var buttonBackgroundColor = "#535353";
  2112. var buttonBackgroundHoverColor = "#414141";
  2113. var buttonBackgroundClickColor = "515151";
  2114. var buttonDisabledColor = "#555555";
  2115. var buttonDisabledBackgroundColor = "#454545";
  2116. var currentSwatchesOutlineColor = "#404040";
  2117. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2118. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2119. var iconColorDark = "#aaaaaa";
  2120. var iconColorLight = "#ffffff";
  2121. var closeIconColor;
  2122. // Button settings
  2123. var buttonFontSize;
  2124. var butEdit;
  2125. var buttonWidth;
  2126. var buttonHeight;
  2127. // Input Text Colors
  2128. var inputFieldLabels = ["R", "G", "B"];
  2129. var inputTextBackgroundColor = "#454545";
  2130. var inputTextColor = "#f0f0f0";
  2131. // This is the current color as set by either the picker or by entering a value
  2132. var currentColor;
  2133. // This int is used for naming swatches and serves as the index for calling them from the list
  2134. var swatchNumber;
  2135. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2136. var swatchDrawer;
  2137. var editSwatchMode = false;
  2138. // Color InputText fields that will be updated upon value change
  2139. var picker;
  2140. var rValInt;
  2141. var gValInt;
  2142. var bValInt;
  2143. var rValDec;
  2144. var gValDec;
  2145. var bValDec;
  2146. var hexVal;
  2147. var newSwatch;
  2148. var lastVal;
  2149. var activeField;
  2150. /**
  2151. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2152. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2153. * are will receive no update. This is to prevent the input from the user being overwritten.
  2154. */
  2155. function updateValues(value, inputField) {
  2156. activeField = inputField;
  2157. var pickedColor = value.toHexString();
  2158. newSwatch.background = pickedColor;
  2159. if (rValInt.name != activeField) {
  2160. rValInt.text = Math.floor(value.r * 255).toString();
  2161. }
  2162. if (gValInt.name != activeField) {
  2163. gValInt.text = Math.floor(value.g * 255).toString();
  2164. }
  2165. if (bValInt.name != activeField) {
  2166. bValInt.text = Math.floor(value.b * 255).toString();
  2167. }
  2168. if (rValDec.name != activeField) {
  2169. rValDec.text = value.r.toString();
  2170. }
  2171. if (gValDec.name != activeField) {
  2172. gValDec.text = value.g.toString();
  2173. }
  2174. if (bValDec.name != activeField) {
  2175. bValDec.text = value.b.toString();
  2176. }
  2177. if (hexVal.name != activeField) {
  2178. var minusPound = pickedColor.split("#");
  2179. hexVal.text = minusPound[1];
  2180. }
  2181. if (picker.name != activeField) {
  2182. picker.value = value;
  2183. }
  2184. }
  2185. // 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.
  2186. function updateInt(field, channel) {
  2187. var newValue = field.text;
  2188. var checkVal = /[^0-9]/g.test(newValue);
  2189. if (checkVal) {
  2190. field.text = lastVal;
  2191. return;
  2192. }
  2193. else {
  2194. if (newValue != "") {
  2195. if (Math.floor(parseInt(newValue)) < 0) {
  2196. newValue = "0";
  2197. }
  2198. else if (Math.floor(parseInt(newValue)) > 255) {
  2199. newValue = "255";
  2200. }
  2201. else if (isNaN(parseInt(newValue))) {
  2202. newValue = "0";
  2203. }
  2204. }
  2205. if (activeField == field.name) {
  2206. lastVal = newValue;
  2207. }
  2208. }
  2209. if (newValue != "") {
  2210. newValue = parseInt(newValue).toString();
  2211. field.text = newValue;
  2212. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2213. if (activeField == field.name) {
  2214. if (channel == "r") {
  2215. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2216. }
  2217. else if (channel == "g") {
  2218. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2219. }
  2220. else {
  2221. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2222. }
  2223. }
  2224. }
  2225. }
  2226. // 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.
  2227. function updateFloat(field, channel) {
  2228. var newValue = field.text;
  2229. var checkVal = /[^0-9\.]/g.test(newValue);
  2230. if (checkVal) {
  2231. field.text = lastVal;
  2232. return;
  2233. }
  2234. else {
  2235. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2236. if (parseFloat(newValue) < 0.0) {
  2237. newValue = "0.0";
  2238. }
  2239. else if (parseFloat(newValue) > 1.0) {
  2240. newValue = "1.0";
  2241. }
  2242. else if (isNaN(parseFloat(newValue))) {
  2243. newValue = "0.0";
  2244. }
  2245. }
  2246. if (activeField == field.name) {
  2247. lastVal = newValue;
  2248. }
  2249. }
  2250. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2251. newValue = parseFloat(newValue).toString();
  2252. field.text = newValue;
  2253. }
  2254. else {
  2255. newValue = "0.0";
  2256. }
  2257. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2258. if (activeField == field.name) {
  2259. if (channel == "r") {
  2260. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2261. }
  2262. else if (channel == "g") {
  2263. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2264. }
  2265. else {
  2266. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2267. }
  2268. }
  2269. }
  2270. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2271. function deleteSwatch(index) {
  2272. if (options.savedColors) {
  2273. options.savedColors.splice(index, 1);
  2274. }
  2275. if (options.savedColors && options.savedColors.length == 0) {
  2276. setEditButtonVisibility(false);
  2277. editSwatchMode = false;
  2278. }
  2279. }
  2280. // Creates and styles an individual swatch when updateSwatches is called.
  2281. function createSwatch() {
  2282. if (options.savedColors && options.savedColors[swatchNumber]) {
  2283. if (editSwatchMode) {
  2284. var icon = "b";
  2285. }
  2286. else {
  2287. var icon = "";
  2288. }
  2289. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2290. swatch.fontFamily = "BabylonJSglyphs";
  2291. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2292. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2293. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2294. if (swatchLuminence > luminanceLimit) {
  2295. swatch.color = iconColorDark;
  2296. }
  2297. else {
  2298. swatch.color = iconColorLight;
  2299. }
  2300. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2301. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2302. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2303. swatch.background = options.savedColors[swatchNumber];
  2304. swatch.thickness = 2;
  2305. var metadata_1 = swatchNumber;
  2306. swatch.pointerDownAnimation = function () {
  2307. swatch.thickness = 4;
  2308. };
  2309. swatch.pointerUpAnimation = function () {
  2310. swatch.thickness = 3;
  2311. };
  2312. swatch.pointerEnterAnimation = function () {
  2313. swatch.thickness = 3;
  2314. };
  2315. swatch.pointerOutAnimation = function () {
  2316. swatch.thickness = 2;
  2317. };
  2318. swatch.onPointerClickObservable.add(function () {
  2319. if (!editSwatchMode) {
  2320. if (options.savedColors) {
  2321. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2322. }
  2323. }
  2324. else {
  2325. deleteSwatch(metadata_1);
  2326. updateSwatches("", butSave);
  2327. }
  2328. });
  2329. return swatch;
  2330. }
  2331. else {
  2332. return null;
  2333. }
  2334. }
  2335. // Mode switch to render button text and close symbols on swatch controls
  2336. function editSwatches(mode) {
  2337. if (mode !== undefined) {
  2338. editSwatchMode = mode;
  2339. }
  2340. if (editSwatchMode) {
  2341. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2342. var thisButton = swatchDrawer.children[i];
  2343. thisButton.textBlock.text = "b";
  2344. }
  2345. if (butEdit !== undefined) {
  2346. butEdit.textBlock.text = "Done";
  2347. }
  2348. }
  2349. else {
  2350. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2351. var thisButton = swatchDrawer.children[i];
  2352. thisButton.textBlock.text = "";
  2353. }
  2354. if (butEdit !== undefined) {
  2355. butEdit.textBlock.text = "Edit";
  2356. }
  2357. }
  2358. }
  2359. /**
  2360. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2361. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2362. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2363. * saved colors there are and how many can be stored per row.
  2364. */
  2365. function updateSwatches(color, button) {
  2366. if (options.savedColors) {
  2367. if (color != "") {
  2368. options.savedColors.push(color);
  2369. }
  2370. swatchNumber = 0;
  2371. swatchDrawer.clearControls();
  2372. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2373. if (rowCount == 0) {
  2374. var gutterCount = 0;
  2375. }
  2376. else {
  2377. var gutterCount = rowCount + 1;
  2378. }
  2379. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2380. var currentRows = swatchDrawer.rowCount;
  2381. for (var i = 0; i < currentRows; i++) {
  2382. swatchDrawer.removeRowDefinition(0);
  2383. }
  2384. for (var i = 0; i < rowCount + gutterCount; i++) {
  2385. if (i % 2) {
  2386. swatchDrawer.addRowDefinition(swatchSize, true);
  2387. }
  2388. else {
  2389. swatchDrawer.addRowDefinition(gutterSize, true);
  2390. }
  2391. }
  2392. }
  2393. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2394. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2395. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2396. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2397. var totalButtonsThisRow = options.numSwatchesPerLine;
  2398. }
  2399. else {
  2400. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2401. }
  2402. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2403. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2404. if (x > options.numSwatchesPerLine) {
  2405. continue;
  2406. }
  2407. var swatch = createSwatch();
  2408. if (swatch != null) {
  2409. swatchDrawer.addControl(swatch, y, w);
  2410. w += 2;
  2411. swatchNumber++;
  2412. }
  2413. else {
  2414. continue;
  2415. }
  2416. }
  2417. }
  2418. if (options.savedColors.length >= options.swatchLimit) {
  2419. disableButton(button, true);
  2420. }
  2421. else {
  2422. disableButton(button, false);
  2423. }
  2424. }
  2425. }
  2426. // Shows or hides edit swatches button depending on if there are saved swatches
  2427. function setEditButtonVisibility(enableButton) {
  2428. if (enableButton) {
  2429. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2430. butEdit.width = buttonWidth;
  2431. butEdit.height = buttonHeight;
  2432. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2433. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2434. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2435. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2436. butEdit.thickness = 2;
  2437. butEdit.color = buttonColor;
  2438. butEdit.fontSize = buttonFontSize;
  2439. butEdit.background = buttonBackgroundColor;
  2440. butEdit.onPointerEnterObservable.add(function () {
  2441. butEdit.background = buttonBackgroundHoverColor;
  2442. });
  2443. butEdit.onPointerOutObservable.add(function () {
  2444. butEdit.background = buttonBackgroundColor;
  2445. });
  2446. butEdit.pointerDownAnimation = function () {
  2447. butEdit.background = buttonBackgroundClickColor;
  2448. };
  2449. butEdit.pointerUpAnimation = function () {
  2450. butEdit.background = buttonBackgroundHoverColor;
  2451. };
  2452. butEdit.onPointerClickObservable.add(function () {
  2453. if (editSwatchMode) {
  2454. editSwatchMode = false;
  2455. }
  2456. else {
  2457. editSwatchMode = true;
  2458. }
  2459. editSwatches();
  2460. });
  2461. pickerGrid.addControl(butEdit, 1, 0);
  2462. }
  2463. else {
  2464. pickerGrid.removeControl(butEdit);
  2465. }
  2466. }
  2467. // Called when the user hits the limit of saved colors in the drawer.
  2468. function disableButton(button, disabled) {
  2469. if (disabled) {
  2470. button.color = buttonDisabledColor;
  2471. button.background = buttonDisabledBackgroundColor;
  2472. }
  2473. else {
  2474. button.color = buttonColor;
  2475. button.background = buttonBackgroundColor;
  2476. }
  2477. }
  2478. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2479. function closePicker(color) {
  2480. if (options.savedColors && options.savedColors.length > 0) {
  2481. resolve({
  2482. savedColors: options.savedColors,
  2483. pickedColor: color
  2484. });
  2485. }
  2486. else {
  2487. resolve({
  2488. pickedColor: color
  2489. });
  2490. }
  2491. advancedTexture.removeControl(dialogContainer);
  2492. }
  2493. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2494. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2495. dialogContainer.name = "Dialog Container";
  2496. dialogContainer.width = options.pickerWidth;
  2497. if (options.savedColors) {
  2498. dialogContainer.height = containerSize;
  2499. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2500. dialogContainer.addRowDefinition(topRow, false);
  2501. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2502. }
  2503. else {
  2504. dialogContainer.height = options.pickerHeight;
  2505. dialogContainer.addRowDefinition(1.0, false);
  2506. }
  2507. advancedTexture.addControl(dialogContainer);
  2508. // Swatch drawer which contains all saved color buttons
  2509. if (options.savedColors) {
  2510. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2511. swatchDrawer.name = "Swatch Drawer";
  2512. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2513. swatchDrawer.background = buttonBackgroundColor;
  2514. swatchDrawer.width = options.pickerWidth;
  2515. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2516. if (initialRows == 0) {
  2517. var gutterCount = 0;
  2518. }
  2519. else {
  2520. var gutterCount = initialRows + 1;
  2521. }
  2522. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2523. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2524. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2525. if (i % 2 != 0) {
  2526. swatchDrawer.addRowDefinition(swatchSize, true);
  2527. }
  2528. else {
  2529. swatchDrawer.addRowDefinition(gutterSize, true);
  2530. }
  2531. }
  2532. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2533. if (i % 2 != 0) {
  2534. swatchDrawer.addColumnDefinition(swatchSize, true);
  2535. }
  2536. else {
  2537. swatchDrawer.addColumnDefinition(gutterSize, true);
  2538. }
  2539. }
  2540. dialogContainer.addControl(swatchDrawer, 1, 0);
  2541. }
  2542. // Picker container
  2543. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2544. pickerPanel.name = "Picker Panel";
  2545. pickerPanel.height = options.pickerHeight;
  2546. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2547. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2548. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2549. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2550. dialogContainer.addControl(pickerPanel, 0, 0);
  2551. // Picker container header
  2552. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2553. header.name = "Dialogue Header Bar";
  2554. header.background = "#cccccc";
  2555. header.thickness = 0;
  2556. pickerPanel.addControl(header, 0, 0);
  2557. // Header close button
  2558. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2559. closeButton.fontFamily = "BabylonJSglyphs";
  2560. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2561. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2562. closeButton.color = closeIconColor.toHexString();
  2563. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2564. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2565. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2566. closeButton.height = closeButton.width = options.headerHeight;
  2567. closeButton.background = header.background;
  2568. closeButton.thickness = 0;
  2569. closeButton.pointerDownAnimation = function () {
  2570. };
  2571. closeButton.pointerUpAnimation = function () {
  2572. closeButton.background = header.background;
  2573. };
  2574. closeButton.pointerEnterAnimation = function () {
  2575. closeButton.color = header.background;
  2576. closeButton.background = "red";
  2577. };
  2578. closeButton.pointerOutAnimation = function () {
  2579. closeButton.color = closeIconColor.toHexString();
  2580. closeButton.background = header.background;
  2581. };
  2582. closeButton.onPointerClickObservable.add(function () {
  2583. closePicker(currentSwatch.background);
  2584. });
  2585. pickerPanel.addControl(closeButton, 0, 0);
  2586. // Dialog container body
  2587. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2588. dialogBody.name = "Dialogue Body";
  2589. dialogBody.background = buttonBackgroundColor;
  2590. var dialogBodyCols = [0.4375, 0.5625];
  2591. dialogBody.addRowDefinition(1.0, false);
  2592. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2593. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2594. pickerPanel.addControl(dialogBody, 1, 0);
  2595. // Picker grid
  2596. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2597. pickerGrid.name = "Picker Grid";
  2598. pickerGrid.addRowDefinition(0.85, false);
  2599. pickerGrid.addRowDefinition(0.15, false);
  2600. dialogBody.addControl(pickerGrid, 0, 0);
  2601. // Picker control
  2602. picker = new ColorPicker();
  2603. picker.name = "GUI Color Picker";
  2604. if (options.pickerHeight < options.pickerWidth) {
  2605. picker.width = 0.89;
  2606. }
  2607. else {
  2608. picker.height = 0.89;
  2609. }
  2610. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2611. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2612. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2613. picker.onPointerDownObservable.add(function () {
  2614. activeField = picker.name;
  2615. lastVal = "";
  2616. editSwatches(false);
  2617. });
  2618. picker.onValueChangedObservable.add(function (value) {
  2619. if (activeField == picker.name) {
  2620. updateValues(value, picker.name);
  2621. }
  2622. });
  2623. pickerGrid.addControl(picker, 0, 0);
  2624. // Picker body right quarant
  2625. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2626. pickerBodyRight.name = "Dialogue Right Half";
  2627. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2628. var pickerBodyRightRows = [0.514, 0.486];
  2629. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2630. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2631. dialogBody.addControl(pickerBodyRight, 1, 1);
  2632. // Picker container swatches and buttons
  2633. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2634. pickerSwatchesButtons.name = "Swatches and Buttons";
  2635. var pickerButtonsCol = [0.417, 0.583];
  2636. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2637. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2638. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2639. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2640. // Picker Swatches quadrant
  2641. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2642. pickerSwatches.name = "New and Current Swatches";
  2643. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2644. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2645. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2646. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2647. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2648. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2649. // Active swatches
  2650. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2651. activeSwatches.name = "Active Swatches";
  2652. activeSwatches.width = 0.67;
  2653. activeSwatches.addRowDefinition(0.5, false);
  2654. activeSwatches.addRowDefinition(0.5, false);
  2655. pickerSwatches.addControl(activeSwatches, 2, 0);
  2656. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2657. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2658. if (options.pickerWidth > options.pickerHeight) {
  2659. var labelTextSize = labelHeight;
  2660. }
  2661. else {
  2662. var labelTextSize = labelWidth;
  2663. }
  2664. // New color swatch and previous color button
  2665. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2666. newText.text = "new";
  2667. newText.name = "New Color Label";
  2668. newText.color = buttonColor;
  2669. newText.fontSize = labelTextSize;
  2670. pickerSwatches.addControl(newText, 1, 0);
  2671. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2672. newSwatch.name = "New Color Swatch";
  2673. newSwatch.background = options.lastColor;
  2674. newSwatch.thickness = 0;
  2675. activeSwatches.addControl(newSwatch, 0, 0);
  2676. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2677. currentSwatch.background = options.lastColor;
  2678. currentSwatch.thickness = 0;
  2679. currentSwatch.onPointerClickObservable.add(function () {
  2680. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2681. updateValues(revertColor, currentSwatch.name);
  2682. editSwatches(false);
  2683. });
  2684. currentSwatch.pointerDownAnimation = function () { };
  2685. currentSwatch.pointerUpAnimation = function () { };
  2686. currentSwatch.pointerEnterAnimation = function () { };
  2687. currentSwatch.pointerOutAnimation = function () { };
  2688. activeSwatches.addControl(currentSwatch, 1, 0);
  2689. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2690. swatchOutline.name = "Swatch Outline";
  2691. swatchOutline.width = 0.67;
  2692. swatchOutline.thickness = 2;
  2693. swatchOutline.color = currentSwatchesOutlineColor;
  2694. swatchOutline.isHitTestVisible = false;
  2695. pickerSwatches.addControl(swatchOutline, 2, 0);
  2696. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2697. currentText.name = "Current Color Label";
  2698. currentText.text = "current";
  2699. currentText.color = buttonColor;
  2700. currentText.fontSize = labelTextSize;
  2701. pickerSwatches.addControl(currentText, 3, 0);
  2702. // Buttons grid
  2703. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2704. buttonGrid.name = "Button Grid";
  2705. buttonGrid.height = 0.8;
  2706. var buttonGridRows = 1 / 3;
  2707. buttonGrid.addRowDefinition(buttonGridRows, false);
  2708. buttonGrid.addRowDefinition(buttonGridRows, false);
  2709. buttonGrid.addRowDefinition(buttonGridRows, false);
  2710. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2711. // Determine pixel width and height for all buttons from overall panel dimensions
  2712. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2713. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2714. // Determine button type size
  2715. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2716. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2717. }
  2718. else {
  2719. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2720. }
  2721. // Panel Buttons
  2722. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2723. butOK.width = buttonWidth;
  2724. butOK.height = buttonHeight;
  2725. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2726. butOK.thickness = 2;
  2727. butOK.color = buttonColor;
  2728. butOK.fontSize = buttonFontSize;
  2729. butOK.background = buttonBackgroundColor;
  2730. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2731. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2732. butOK.pointerDownAnimation = function () {
  2733. butOK.background = buttonBackgroundClickColor;
  2734. };
  2735. butOK.pointerUpAnimation = function () {
  2736. butOK.background = buttonBackgroundHoverColor;
  2737. };
  2738. butOK.onPointerClickObservable.add(function () {
  2739. editSwatches(false);
  2740. closePicker(newSwatch.background);
  2741. });
  2742. buttonGrid.addControl(butOK, 0, 0);
  2743. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2744. butCancel.width = buttonWidth;
  2745. butCancel.height = buttonHeight;
  2746. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2747. butCancel.thickness = 2;
  2748. butCancel.color = buttonColor;
  2749. butCancel.fontSize = buttonFontSize;
  2750. butCancel.background = buttonBackgroundColor;
  2751. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2752. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2753. butCancel.pointerDownAnimation = function () {
  2754. butCancel.background = buttonBackgroundClickColor;
  2755. };
  2756. butCancel.pointerUpAnimation = function () {
  2757. butCancel.background = buttonBackgroundHoverColor;
  2758. };
  2759. butCancel.onPointerClickObservable.add(function () {
  2760. editSwatches(false);
  2761. closePicker(currentSwatch.background);
  2762. });
  2763. buttonGrid.addControl(butCancel, 1, 0);
  2764. if (options.savedColors) {
  2765. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2766. butSave.width = buttonWidth;
  2767. butSave.height = buttonHeight;
  2768. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2769. butSave.thickness = 2;
  2770. butSave.fontSize = buttonFontSize;
  2771. if (options.savedColors.length < options.swatchLimit) {
  2772. butSave.color = buttonColor;
  2773. butSave.background = buttonBackgroundColor;
  2774. }
  2775. else {
  2776. disableButton(butSave, true);
  2777. }
  2778. butSave.onPointerEnterObservable.add(function () {
  2779. if (options.savedColors) {
  2780. if (options.savedColors.length < options.swatchLimit) {
  2781. butSave.background = buttonBackgroundHoverColor;
  2782. }
  2783. }
  2784. });
  2785. butSave.onPointerOutObservable.add(function () {
  2786. if (options.savedColors) {
  2787. if (options.savedColors.length < options.swatchLimit) {
  2788. butSave.background = buttonBackgroundColor;
  2789. }
  2790. }
  2791. });
  2792. butSave.pointerDownAnimation = function () {
  2793. if (options.savedColors) {
  2794. if (options.savedColors.length < options.swatchLimit) {
  2795. butSave.background = buttonBackgroundClickColor;
  2796. }
  2797. }
  2798. };
  2799. butSave.pointerUpAnimation = function () {
  2800. if (options.savedColors) {
  2801. if (options.savedColors.length < options.swatchLimit) {
  2802. butSave.background = buttonBackgroundHoverColor;
  2803. }
  2804. }
  2805. };
  2806. butSave.onPointerClickObservable.add(function () {
  2807. if (options.savedColors) {
  2808. if (options.savedColors.length == 0) {
  2809. setEditButtonVisibility(true);
  2810. }
  2811. if (options.savedColors.length < options.swatchLimit) {
  2812. updateSwatches(newSwatch.background, butSave);
  2813. }
  2814. editSwatches(false);
  2815. }
  2816. });
  2817. if (options.savedColors.length > 0) {
  2818. setEditButtonVisibility(true);
  2819. }
  2820. buttonGrid.addControl(butSave, 2, 0);
  2821. }
  2822. // Picker color values input
  2823. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2824. pickerColorValues.name = "Dialog Lower Right";
  2825. pickerColorValues.addRowDefinition(0.02, false);
  2826. pickerColorValues.addRowDefinition(0.63, false);
  2827. pickerColorValues.addRowDefinition(0.21, false);
  2828. pickerColorValues.addRowDefinition(0.14, false);
  2829. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2830. // RGB values text boxes
  2831. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2832. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2833. rgbValuesQuadrant.name = "RGB Values";
  2834. rgbValuesQuadrant.width = 0.82;
  2835. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2836. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2837. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2838. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2839. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2840. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2841. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2842. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2843. for (var i = 0; i < inputFieldLabels.length; i++) {
  2844. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2845. labelText.text = inputFieldLabels[i];
  2846. labelText.color = buttonColor;
  2847. labelText.fontSize = buttonFontSize;
  2848. rgbValuesQuadrant.addControl(labelText, i, 0);
  2849. }
  2850. // Input fields for RGB values
  2851. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2852. rValInt.width = 0.83;
  2853. rValInt.height = 0.72;
  2854. rValInt.name = "rIntField";
  2855. rValInt.fontSize = buttonFontSize;
  2856. rValInt.text = (currentColor.r * 255).toString();
  2857. rValInt.color = inputTextColor;
  2858. rValInt.background = inputTextBackgroundColor;
  2859. rValInt.onFocusObservable.add(function () {
  2860. activeField = rValInt.name;
  2861. lastVal = rValInt.text;
  2862. editSwatches(false);
  2863. });
  2864. rValInt.onBlurObservable.add(function () {
  2865. if (rValInt.text == "") {
  2866. rValInt.text = "0";
  2867. }
  2868. updateInt(rValInt, "r");
  2869. if (activeField == rValInt.name) {
  2870. activeField = "";
  2871. }
  2872. });
  2873. rValInt.onTextChangedObservable.add(function () {
  2874. if (activeField == rValInt.name) {
  2875. updateInt(rValInt, "r");
  2876. }
  2877. });
  2878. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2879. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2880. gValInt.width = 0.83;
  2881. gValInt.height = 0.72;
  2882. gValInt.name = "gIntField";
  2883. gValInt.fontSize = buttonFontSize;
  2884. gValInt.text = (currentColor.g * 255).toString();
  2885. gValInt.color = inputTextColor;
  2886. gValInt.background = inputTextBackgroundColor;
  2887. gValInt.onFocusObservable.add(function () {
  2888. activeField = gValInt.name;
  2889. lastVal = gValInt.text;
  2890. editSwatches(false);
  2891. });
  2892. gValInt.onBlurObservable.add(function () {
  2893. if (gValInt.text == "") {
  2894. gValInt.text = "0";
  2895. }
  2896. updateInt(gValInt, "g");
  2897. if (activeField == gValInt.name) {
  2898. activeField = "";
  2899. }
  2900. });
  2901. gValInt.onTextChangedObservable.add(function () {
  2902. if (activeField == gValInt.name) {
  2903. updateInt(gValInt, "g");
  2904. }
  2905. });
  2906. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2907. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2908. bValInt.width = 0.83;
  2909. bValInt.height = 0.72;
  2910. bValInt.name = "bIntField";
  2911. bValInt.fontSize = buttonFontSize;
  2912. bValInt.text = (currentColor.b * 255).toString();
  2913. bValInt.color = inputTextColor;
  2914. bValInt.background = inputTextBackgroundColor;
  2915. bValInt.onFocusObservable.add(function () {
  2916. activeField = bValInt.name;
  2917. lastVal = bValInt.text;
  2918. editSwatches(false);
  2919. });
  2920. bValInt.onBlurObservable.add(function () {
  2921. if (bValInt.text == "") {
  2922. bValInt.text = "0";
  2923. }
  2924. updateInt(bValInt, "b");
  2925. if (activeField == bValInt.name) {
  2926. activeField = "";
  2927. }
  2928. });
  2929. bValInt.onTextChangedObservable.add(function () {
  2930. if (activeField == bValInt.name) {
  2931. updateInt(bValInt, "b");
  2932. }
  2933. });
  2934. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2935. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2936. rValDec.width = 0.95;
  2937. rValDec.height = 0.72;
  2938. rValDec.name = "rDecField";
  2939. rValDec.fontSize = buttonFontSize;
  2940. rValDec.text = currentColor.r.toString();
  2941. rValDec.color = inputTextColor;
  2942. rValDec.background = inputTextBackgroundColor;
  2943. rValDec.onFocusObservable.add(function () {
  2944. activeField = rValDec.name;
  2945. lastVal = rValDec.text;
  2946. editSwatches(false);
  2947. });
  2948. rValDec.onBlurObservable.add(function () {
  2949. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2950. rValDec.text = "0";
  2951. updateFloat(rValDec, "r");
  2952. }
  2953. if (activeField == rValDec.name) {
  2954. activeField = "";
  2955. }
  2956. });
  2957. rValDec.onTextChangedObservable.add(function () {
  2958. if (activeField == rValDec.name) {
  2959. updateFloat(rValDec, "r");
  2960. }
  2961. });
  2962. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2963. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2964. gValDec.width = 0.95;
  2965. gValDec.height = 0.72;
  2966. gValDec.name = "gDecField";
  2967. gValDec.fontSize = buttonFontSize;
  2968. gValDec.text = currentColor.g.toString();
  2969. gValDec.color = inputTextColor;
  2970. gValDec.background = inputTextBackgroundColor;
  2971. gValDec.onFocusObservable.add(function () {
  2972. activeField = gValDec.name;
  2973. lastVal = gValDec.text;
  2974. editSwatches(false);
  2975. });
  2976. gValDec.onBlurObservable.add(function () {
  2977. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2978. gValDec.text = "0";
  2979. updateFloat(gValDec, "g");
  2980. }
  2981. if (activeField == gValDec.name) {
  2982. activeField = "";
  2983. }
  2984. });
  2985. gValDec.onTextChangedObservable.add(function () {
  2986. if (activeField == gValDec.name) {
  2987. updateFloat(gValDec, "g");
  2988. }
  2989. });
  2990. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  2991. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2992. bValDec.width = 0.95;
  2993. bValDec.height = 0.72;
  2994. bValDec.name = "bDecField";
  2995. bValDec.fontSize = buttonFontSize;
  2996. bValDec.text = currentColor.b.toString();
  2997. bValDec.color = inputTextColor;
  2998. bValDec.background = inputTextBackgroundColor;
  2999. bValDec.onFocusObservable.add(function () {
  3000. activeField = bValDec.name;
  3001. lastVal = bValDec.text;
  3002. editSwatches(false);
  3003. });
  3004. bValDec.onBlurObservable.add(function () {
  3005. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3006. bValDec.text = "0";
  3007. updateFloat(bValDec, "b");
  3008. }
  3009. if (activeField == bValDec.name) {
  3010. activeField = "";
  3011. }
  3012. });
  3013. bValDec.onTextChangedObservable.add(function () {
  3014. if (activeField == bValDec.name) {
  3015. updateFloat(bValDec, "b");
  3016. }
  3017. });
  3018. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3019. // Hex value input
  3020. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3021. hexValueQuadrant.name = "Hex Value";
  3022. hexValueQuadrant.width = 0.82;
  3023. hexValueQuadrant.addRowDefinition(1.0, false);
  3024. hexValueQuadrant.addColumnDefinition(0.1, false);
  3025. hexValueQuadrant.addColumnDefinition(0.9, false);
  3026. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3027. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3028. labelText.text = "#";
  3029. labelText.color = buttonColor;
  3030. labelText.fontSize = buttonFontSize;
  3031. hexValueQuadrant.addControl(labelText, 0, 0);
  3032. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3033. hexVal.width = 0.96;
  3034. hexVal.height = 0.72;
  3035. hexVal.name = "hexField";
  3036. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3037. hexVal.fontSize = buttonFontSize;
  3038. var minusPound = options.lastColor.split("#");
  3039. hexVal.text = minusPound[1];
  3040. hexVal.color = inputTextColor;
  3041. hexVal.background = inputTextBackgroundColor;
  3042. hexVal.onFocusObservable.add(function () {
  3043. activeField = hexVal.name;
  3044. lastVal = hexVal.text;
  3045. editSwatches(false);
  3046. });
  3047. hexVal.onBlurObservable.add(function () {
  3048. if (hexVal.text.length == 3) {
  3049. var val = hexVal.text.split("");
  3050. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3051. }
  3052. if (hexVal.text == "") {
  3053. hexVal.text = "000000";
  3054. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3055. }
  3056. if (activeField == hexVal.name) {
  3057. activeField = "";
  3058. }
  3059. });
  3060. hexVal.onTextChangedObservable.add(function () {
  3061. var newHexValue = hexVal.text;
  3062. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3063. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3064. hexVal.text = lastVal;
  3065. }
  3066. else {
  3067. if (hexVal.text.length < 6) {
  3068. var leadingZero = 6 - hexVal.text.length;
  3069. for (var i = 0; i < leadingZero; i++) {
  3070. newHexValue = "0" + newHexValue;
  3071. }
  3072. }
  3073. if (hexVal.text.length == 3) {
  3074. var val = hexVal.text.split("");
  3075. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3076. }
  3077. newHexValue = "#" + newHexValue;
  3078. if (activeField == hexVal.name) {
  3079. lastVal = hexVal.text;
  3080. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3081. }
  3082. }
  3083. });
  3084. hexValueQuadrant.addControl(hexVal, 0, 1);
  3085. if (options.savedColors && options.savedColors.length > 0) {
  3086. updateSwatches("", butSave);
  3087. }
  3088. });
  3089. };
  3090. ColorPicker._Epsilon = 0.000001;
  3091. return ColorPicker;
  3092. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3093. /***/ }),
  3094. /***/ "./2D/controls/container.ts":
  3095. /*!**********************************!*\
  3096. !*** ./2D/controls/container.ts ***!
  3097. \**********************************/
  3098. /*! exports provided: Container */
  3099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3100. "use strict";
  3101. __webpack_require__.r(__webpack_exports__);
  3102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3103. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3104. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3105. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3106. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3107. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3108. /**
  3109. * Root class for 2D containers
  3110. * @see http://doc.babylonjs.com/how_to/gui#containers
  3111. */
  3112. var Container = /** @class */ (function (_super) {
  3113. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3114. /**
  3115. * Creates a new Container
  3116. * @param name defines the name of the container
  3117. */
  3118. function Container(name) {
  3119. var _this = _super.call(this, name) || this;
  3120. _this.name = name;
  3121. /** @hidden */
  3122. _this._children = new Array();
  3123. /** @hidden */
  3124. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3125. /** @hidden */
  3126. _this._background = "";
  3127. /** @hidden */
  3128. _this._adaptWidthToChildren = false;
  3129. /** @hidden */
  3130. _this._adaptHeightToChildren = false;
  3131. return _this;
  3132. }
  3133. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3134. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3135. get: function () {
  3136. return this._adaptHeightToChildren;
  3137. },
  3138. set: function (value) {
  3139. if (this._adaptHeightToChildren === value) {
  3140. return;
  3141. }
  3142. this._adaptHeightToChildren = value;
  3143. if (value) {
  3144. this.height = "100%";
  3145. }
  3146. this._markAsDirty();
  3147. },
  3148. enumerable: true,
  3149. configurable: true
  3150. });
  3151. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3152. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3153. get: function () {
  3154. return this._adaptWidthToChildren;
  3155. },
  3156. set: function (value) {
  3157. if (this._adaptWidthToChildren === value) {
  3158. return;
  3159. }
  3160. this._adaptWidthToChildren = value;
  3161. if (value) {
  3162. this.width = "100%";
  3163. }
  3164. this._markAsDirty();
  3165. },
  3166. enumerable: true,
  3167. configurable: true
  3168. });
  3169. Object.defineProperty(Container.prototype, "background", {
  3170. /** Gets or sets background color */
  3171. get: function () {
  3172. return this._background;
  3173. },
  3174. set: function (value) {
  3175. if (this._background === value) {
  3176. return;
  3177. }
  3178. this._background = value;
  3179. this._markAsDirty();
  3180. },
  3181. enumerable: true,
  3182. configurable: true
  3183. });
  3184. Object.defineProperty(Container.prototype, "children", {
  3185. /** Gets the list of children */
  3186. get: function () {
  3187. return this._children;
  3188. },
  3189. enumerable: true,
  3190. configurable: true
  3191. });
  3192. Container.prototype._getTypeName = function () {
  3193. return "Container";
  3194. };
  3195. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3196. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3197. var child = _a[_i];
  3198. child._markMatrixAsDirty();
  3199. }
  3200. };
  3201. /**
  3202. * Gets a child using its name
  3203. * @param name defines the child name to look for
  3204. * @returns the child control if found
  3205. */
  3206. Container.prototype.getChildByName = function (name) {
  3207. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3208. var child = _a[_i];
  3209. if (child.name === name) {
  3210. return child;
  3211. }
  3212. }
  3213. return null;
  3214. };
  3215. /**
  3216. * Gets a child using its type and its name
  3217. * @param name defines the child name to look for
  3218. * @param type defines the child type to look for
  3219. * @returns the child control if found
  3220. */
  3221. Container.prototype.getChildByType = function (name, type) {
  3222. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3223. var child = _a[_i];
  3224. if (child.typeName === type) {
  3225. return child;
  3226. }
  3227. }
  3228. return null;
  3229. };
  3230. /**
  3231. * Search for a specific control in children
  3232. * @param control defines the control to look for
  3233. * @returns true if the control is in child list
  3234. */
  3235. Container.prototype.containsControl = function (control) {
  3236. return this.children.indexOf(control) !== -1;
  3237. };
  3238. /**
  3239. * Adds a new control to the current container
  3240. * @param control defines the control to add
  3241. * @returns the current container
  3242. */
  3243. Container.prototype.addControl = function (control) {
  3244. if (!control) {
  3245. return this;
  3246. }
  3247. var index = this._children.indexOf(control);
  3248. if (index !== -1) {
  3249. return this;
  3250. }
  3251. control._link(this._host);
  3252. control._markAllAsDirty();
  3253. this._reOrderControl(control);
  3254. this._markAsDirty();
  3255. return this;
  3256. };
  3257. /**
  3258. * Removes all controls from the current container
  3259. * @returns the current container
  3260. */
  3261. Container.prototype.clearControls = function () {
  3262. var children = this.children.slice();
  3263. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3264. var child = children_1[_i];
  3265. this.removeControl(child);
  3266. }
  3267. return this;
  3268. };
  3269. /**
  3270. * Removes a control from the current container
  3271. * @param control defines the control to remove
  3272. * @returns the current container
  3273. */
  3274. Container.prototype.removeControl = function (control) {
  3275. var index = this._children.indexOf(control);
  3276. if (index !== -1) {
  3277. this._children.splice(index, 1);
  3278. control.parent = null;
  3279. }
  3280. control.linkWithMesh(null);
  3281. if (this._host) {
  3282. this._host._cleanControlAfterRemoval(control);
  3283. }
  3284. this._markAsDirty();
  3285. return this;
  3286. };
  3287. /** @hidden */
  3288. Container.prototype._reOrderControl = function (control) {
  3289. this.removeControl(control);
  3290. var wasAdded = false;
  3291. for (var index = 0; index < this._children.length; index++) {
  3292. if (this._children[index].zIndex > control.zIndex) {
  3293. this._children.splice(index, 0, control);
  3294. wasAdded = true;
  3295. break;
  3296. }
  3297. }
  3298. if (!wasAdded) {
  3299. this._children.push(control);
  3300. }
  3301. control.parent = this;
  3302. this._markAsDirty();
  3303. };
  3304. /** @hidden */
  3305. Container.prototype._offsetLeft = function (offset) {
  3306. _super.prototype._offsetLeft.call(this, offset);
  3307. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3308. var child = _a[_i];
  3309. child._offsetLeft(offset);
  3310. }
  3311. };
  3312. /** @hidden */
  3313. Container.prototype._offsetTop = function (offset) {
  3314. _super.prototype._offsetTop.call(this, offset);
  3315. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3316. var child = _a[_i];
  3317. child._offsetTop(offset);
  3318. }
  3319. };
  3320. /** @hidden */
  3321. Container.prototype._markAllAsDirty = function () {
  3322. _super.prototype._markAllAsDirty.call(this);
  3323. for (var index = 0; index < this._children.length; index++) {
  3324. this._children[index]._markAllAsDirty();
  3325. }
  3326. };
  3327. /** @hidden */
  3328. Container.prototype._localDraw = function (context) {
  3329. if (this._background) {
  3330. context.save();
  3331. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3332. context.shadowColor = this.shadowColor;
  3333. context.shadowBlur = this.shadowBlur;
  3334. context.shadowOffsetX = this.shadowOffsetX;
  3335. context.shadowOffsetY = this.shadowOffsetY;
  3336. }
  3337. context.fillStyle = this._background;
  3338. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3339. context.restore();
  3340. }
  3341. };
  3342. /** @hidden */
  3343. Container.prototype._link = function (host) {
  3344. _super.prototype._link.call(this, host);
  3345. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3346. var child = _a[_i];
  3347. child._link(host);
  3348. }
  3349. };
  3350. /** @hidden */
  3351. Container.prototype._beforeLayout = function () {
  3352. // Do nothing
  3353. };
  3354. /** @hidden */
  3355. Container.prototype._processMeasures = function (parentMeasure, context) {
  3356. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3357. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3358. this._evaluateClippingState(parentMeasure);
  3359. }
  3360. };
  3361. /** @hidden */
  3362. Container.prototype._layout = function (parentMeasure, context) {
  3363. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3364. return false;
  3365. }
  3366. if (this._isDirty) {
  3367. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3368. }
  3369. var rebuildCount = 0;
  3370. context.save();
  3371. this._applyStates(context);
  3372. this._beforeLayout();
  3373. do {
  3374. var computedWidth = -1;
  3375. var computedHeight = -1;
  3376. this._rebuildLayout = false;
  3377. this._processMeasures(parentMeasure, context);
  3378. if (!this._isClipped) {
  3379. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3380. var child = _a[_i];
  3381. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3382. if (child._layout(this._measureForChildren, context)) {
  3383. if (this.adaptWidthToChildren && child._width.isPixel) {
  3384. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3385. }
  3386. if (this.adaptHeightToChildren && child._height.isPixel) {
  3387. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3388. }
  3389. }
  3390. }
  3391. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3392. if (this.width !== computedWidth + "px") {
  3393. this.width = computedWidth + "px";
  3394. this._rebuildLayout = true;
  3395. }
  3396. }
  3397. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3398. if (this.height !== computedHeight + "px") {
  3399. this.height = computedHeight + "px";
  3400. this._rebuildLayout = true;
  3401. }
  3402. }
  3403. this._postMeasure();
  3404. }
  3405. rebuildCount++;
  3406. } while (this._rebuildLayout && rebuildCount < 3);
  3407. if (rebuildCount >= 3) {
  3408. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3409. }
  3410. context.restore();
  3411. if (this._isDirty) {
  3412. this.invalidateRect();
  3413. this._isDirty = false;
  3414. }
  3415. return true;
  3416. };
  3417. Container.prototype._postMeasure = function () {
  3418. // Do nothing by default
  3419. };
  3420. /** @hidden */
  3421. Container.prototype._draw = function (context, invalidatedRectangle) {
  3422. this._localDraw(context);
  3423. if (this.clipChildren) {
  3424. this._clipForChildren(context);
  3425. }
  3426. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3427. var child = _a[_i];
  3428. // Only redraw parts of the screen that are invalidated
  3429. if (invalidatedRectangle) {
  3430. if (!child._intersectsRect(invalidatedRectangle)) {
  3431. continue;
  3432. }
  3433. }
  3434. child._render(context, invalidatedRectangle);
  3435. }
  3436. };
  3437. /** @hidden */
  3438. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3439. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3440. if (!this.children) {
  3441. return;
  3442. }
  3443. for (var index = 0; index < this.children.length; index++) {
  3444. var item = this.children[index];
  3445. if (!predicate || predicate(item)) {
  3446. results.push(item);
  3447. }
  3448. if (!directDescendantsOnly) {
  3449. item._getDescendants(results, false, predicate);
  3450. }
  3451. }
  3452. };
  3453. /** @hidden */
  3454. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3455. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3456. return false;
  3457. }
  3458. if (!_super.prototype.contains.call(this, x, y)) {
  3459. return false;
  3460. }
  3461. // Checking backwards to pick closest first
  3462. for (var index = this._children.length - 1; index >= 0; index--) {
  3463. var child = this._children[index];
  3464. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3465. if (child.hoverCursor) {
  3466. this._host._changeCursor(child.hoverCursor);
  3467. }
  3468. return true;
  3469. }
  3470. }
  3471. if (!this.isHitTestVisible) {
  3472. return false;
  3473. }
  3474. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3475. };
  3476. /** @hidden */
  3477. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3478. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3479. this._measureForChildren.copyFrom(this._currentMeasure);
  3480. };
  3481. /** Releases associated resources */
  3482. Container.prototype.dispose = function () {
  3483. _super.prototype.dispose.call(this);
  3484. for (var index = this.children.length - 1; index >= 0; index--) {
  3485. this.children[index].dispose();
  3486. }
  3487. };
  3488. return Container;
  3489. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3490. /***/ }),
  3491. /***/ "./2D/controls/control.ts":
  3492. /*!********************************!*\
  3493. !*** ./2D/controls/control.ts ***!
  3494. \********************************/
  3495. /*! exports provided: Control */
  3496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3497. "use strict";
  3498. __webpack_require__.r(__webpack_exports__);
  3499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3500. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3501. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3502. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3503. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3504. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3505. /**
  3506. * Root class used for all 2D controls
  3507. * @see http://doc.babylonjs.com/how_to/gui#controls
  3508. */
  3509. var Control = /** @class */ (function () {
  3510. // Functions
  3511. /**
  3512. * Creates a new control
  3513. * @param name defines the name of the control
  3514. */
  3515. function Control(
  3516. /** defines the name of the control */
  3517. name) {
  3518. this.name = name;
  3519. this._alpha = 1;
  3520. this._alphaSet = false;
  3521. this._zIndex = 0;
  3522. /** @hidden */
  3523. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3524. this._fontFamily = "Arial";
  3525. this._fontStyle = "";
  3526. this._fontWeight = "";
  3527. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3528. /** @hidden */
  3529. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3530. /** @hidden */
  3531. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3532. this._color = "";
  3533. this._style = null;
  3534. /** @hidden */
  3535. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3536. /** @hidden */
  3537. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3538. /** @hidden */
  3539. this._isDirty = true;
  3540. /** @hidden */
  3541. this._wasDirty = false;
  3542. /** @hidden */
  3543. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3544. /** @hidden */
  3545. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3546. /** @hidden */
  3547. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3548. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3549. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3550. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3551. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3552. /** @hidden */
  3553. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3554. /** @hidden */
  3555. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3556. this._scaleX = 1.0;
  3557. this._scaleY = 1.0;
  3558. this._rotation = 0;
  3559. this._transformCenterX = 0.5;
  3560. this._transformCenterY = 0.5;
  3561. /** @hidden */
  3562. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3563. /** @hidden */
  3564. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3565. /** @hidden */
  3566. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3567. this._isMatrixDirty = true;
  3568. this._isVisible = true;
  3569. this._isHighlighted = false;
  3570. this._fontSet = false;
  3571. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3572. this._downCount = 0;
  3573. this._enterCount = -1;
  3574. this._doNotRender = false;
  3575. this._downPointerIds = {};
  3576. this._isEnabled = true;
  3577. this._disabledColor = "#9a9a9a";
  3578. /** @hidden */
  3579. this._rebuildLayout = false;
  3580. /** @hidden */
  3581. this._isClipped = false;
  3582. /**
  3583. * Gets or sets an object used to store user defined information for the node
  3584. */
  3585. this.metadata = null;
  3586. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3587. this.isHitTestVisible = true;
  3588. /** Gets or sets a boolean indicating if the control can block pointer events */
  3589. this.isPointerBlocker = false;
  3590. /** Gets or sets a boolean indicating if the control can be focusable */
  3591. this.isFocusInvisible = false;
  3592. /**
  3593. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3594. * 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
  3595. */
  3596. this.clipChildren = true;
  3597. /**
  3598. * Gets or sets a boolean indicating that control content must be clipped
  3599. * 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
  3600. */
  3601. this.clipContent = true;
  3602. /**
  3603. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3604. */
  3605. this.useBitmapCache = false;
  3606. this._shadowOffsetX = 0;
  3607. this._shadowOffsetY = 0;
  3608. this._shadowBlur = 0;
  3609. this._shadowColor = 'black';
  3610. /** Gets or sets the cursor to use when the control is hovered */
  3611. this.hoverCursor = "";
  3612. /** @hidden */
  3613. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3614. /** @hidden */
  3615. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3616. /**
  3617. * An event triggered when the pointer move over the control.
  3618. */
  3619. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3620. /**
  3621. * An event triggered when the pointer move out of the control.
  3622. */
  3623. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3624. /**
  3625. * An event triggered when the pointer taps the control
  3626. */
  3627. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3628. /**
  3629. * An event triggered when pointer up
  3630. */
  3631. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3632. /**
  3633. * An event triggered when a control is clicked on
  3634. */
  3635. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3636. /**
  3637. * An event triggered when pointer enters the control
  3638. */
  3639. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3640. /**
  3641. * An event triggered when the control is marked as dirty
  3642. */
  3643. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3644. /**
  3645. * An event triggered before drawing the control
  3646. */
  3647. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3648. /**
  3649. * An event triggered after the control was drawn
  3650. */
  3651. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3652. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3653. }
  3654. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3655. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3656. get: function () {
  3657. return this._shadowOffsetX;
  3658. },
  3659. set: function (value) {
  3660. if (this._shadowOffsetX === value) {
  3661. return;
  3662. }
  3663. this._shadowOffsetX = value;
  3664. this._markAsDirty();
  3665. },
  3666. enumerable: true,
  3667. configurable: true
  3668. });
  3669. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3670. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3671. get: function () {
  3672. return this._shadowOffsetY;
  3673. },
  3674. set: function (value) {
  3675. if (this._shadowOffsetY === value) {
  3676. return;
  3677. }
  3678. this._shadowOffsetY = value;
  3679. this._markAsDirty();
  3680. },
  3681. enumerable: true,
  3682. configurable: true
  3683. });
  3684. Object.defineProperty(Control.prototype, "shadowBlur", {
  3685. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3686. get: function () {
  3687. return this._shadowBlur;
  3688. },
  3689. set: function (value) {
  3690. if (this._shadowBlur === value) {
  3691. return;
  3692. }
  3693. this._shadowBlur = value;
  3694. this._markAsDirty();
  3695. },
  3696. enumerable: true,
  3697. configurable: true
  3698. });
  3699. Object.defineProperty(Control.prototype, "shadowColor", {
  3700. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3701. get: function () {
  3702. return this._shadowColor;
  3703. },
  3704. set: function (value) {
  3705. if (this._shadowColor === value) {
  3706. return;
  3707. }
  3708. this._shadowColor = value;
  3709. this._markAsDirty();
  3710. },
  3711. enumerable: true,
  3712. configurable: true
  3713. });
  3714. Object.defineProperty(Control.prototype, "typeName", {
  3715. // Properties
  3716. /** Gets the control type name */
  3717. get: function () {
  3718. return this._getTypeName();
  3719. },
  3720. enumerable: true,
  3721. configurable: true
  3722. });
  3723. /**
  3724. * Get the current class name of the control.
  3725. * @returns current class name
  3726. */
  3727. Control.prototype.getClassName = function () {
  3728. return this._getTypeName();
  3729. };
  3730. Object.defineProperty(Control.prototype, "host", {
  3731. /**
  3732. * Get the hosting AdvancedDynamicTexture
  3733. */
  3734. get: function () {
  3735. return this._host;
  3736. },
  3737. enumerable: true,
  3738. configurable: true
  3739. });
  3740. Object.defineProperty(Control.prototype, "fontOffset", {
  3741. /** Gets or set information about font offsets (used to render and align text) */
  3742. get: function () {
  3743. return this._fontOffset;
  3744. },
  3745. set: function (offset) {
  3746. this._fontOffset = offset;
  3747. },
  3748. enumerable: true,
  3749. configurable: true
  3750. });
  3751. Object.defineProperty(Control.prototype, "alpha", {
  3752. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3753. get: function () {
  3754. return this._alpha;
  3755. },
  3756. set: function (value) {
  3757. if (this._alpha === value) {
  3758. return;
  3759. }
  3760. this._alphaSet = true;
  3761. this._alpha = value;
  3762. this._markAsDirty();
  3763. },
  3764. enumerable: true,
  3765. configurable: true
  3766. });
  3767. Object.defineProperty(Control.prototype, "isHighlighted", {
  3768. /**
  3769. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3770. */
  3771. get: function () {
  3772. return this._isHighlighted;
  3773. },
  3774. set: function (value) {
  3775. if (this._isHighlighted === value) {
  3776. return;
  3777. }
  3778. this._isHighlighted = value;
  3779. this._markAsDirty();
  3780. },
  3781. enumerable: true,
  3782. configurable: true
  3783. });
  3784. Object.defineProperty(Control.prototype, "scaleX", {
  3785. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3786. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3787. */
  3788. get: function () {
  3789. return this._scaleX;
  3790. },
  3791. set: function (value) {
  3792. if (this._scaleX === value) {
  3793. return;
  3794. }
  3795. this._scaleX = value;
  3796. this._markAsDirty();
  3797. this._markMatrixAsDirty();
  3798. },
  3799. enumerable: true,
  3800. configurable: true
  3801. });
  3802. Object.defineProperty(Control.prototype, "scaleY", {
  3803. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3804. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3805. */
  3806. get: function () {
  3807. return this._scaleY;
  3808. },
  3809. set: function (value) {
  3810. if (this._scaleY === value) {
  3811. return;
  3812. }
  3813. this._scaleY = value;
  3814. this._markAsDirty();
  3815. this._markMatrixAsDirty();
  3816. },
  3817. enumerable: true,
  3818. configurable: true
  3819. });
  3820. Object.defineProperty(Control.prototype, "rotation", {
  3821. /** Gets or sets the rotation angle (0 by default)
  3822. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3823. */
  3824. get: function () {
  3825. return this._rotation;
  3826. },
  3827. set: function (value) {
  3828. if (this._rotation === value) {
  3829. return;
  3830. }
  3831. this._rotation = value;
  3832. this._markAsDirty();
  3833. this._markMatrixAsDirty();
  3834. },
  3835. enumerable: true,
  3836. configurable: true
  3837. });
  3838. Object.defineProperty(Control.prototype, "transformCenterY", {
  3839. /** Gets or sets the transformation center on Y axis (0 by default)
  3840. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3841. */
  3842. get: function () {
  3843. return this._transformCenterY;
  3844. },
  3845. set: function (value) {
  3846. if (this._transformCenterY === value) {
  3847. return;
  3848. }
  3849. this._transformCenterY = value;
  3850. this._markAsDirty();
  3851. this._markMatrixAsDirty();
  3852. },
  3853. enumerable: true,
  3854. configurable: true
  3855. });
  3856. Object.defineProperty(Control.prototype, "transformCenterX", {
  3857. /** Gets or sets the transformation center on X axis (0 by default)
  3858. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3859. */
  3860. get: function () {
  3861. return this._transformCenterX;
  3862. },
  3863. set: function (value) {
  3864. if (this._transformCenterX === value) {
  3865. return;
  3866. }
  3867. this._transformCenterX = value;
  3868. this._markAsDirty();
  3869. this._markMatrixAsDirty();
  3870. },
  3871. enumerable: true,
  3872. configurable: true
  3873. });
  3874. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3875. /**
  3876. * Gets or sets the horizontal alignment
  3877. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3878. */
  3879. get: function () {
  3880. return this._horizontalAlignment;
  3881. },
  3882. set: function (value) {
  3883. if (this._horizontalAlignment === value) {
  3884. return;
  3885. }
  3886. this._horizontalAlignment = value;
  3887. this._markAsDirty();
  3888. },
  3889. enumerable: true,
  3890. configurable: true
  3891. });
  3892. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3893. /**
  3894. * Gets or sets the vertical alignment
  3895. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3896. */
  3897. get: function () {
  3898. return this._verticalAlignment;
  3899. },
  3900. set: function (value) {
  3901. if (this._verticalAlignment === value) {
  3902. return;
  3903. }
  3904. this._verticalAlignment = value;
  3905. this._markAsDirty();
  3906. },
  3907. enumerable: true,
  3908. configurable: true
  3909. });
  3910. Object.defineProperty(Control.prototype, "width", {
  3911. /**
  3912. * Gets or sets control width
  3913. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3914. */
  3915. get: function () {
  3916. return this._width.toString(this._host);
  3917. },
  3918. set: function (value) {
  3919. if (this._width.toString(this._host) === value) {
  3920. return;
  3921. }
  3922. if (this._width.fromString(value)) {
  3923. this._markAsDirty();
  3924. }
  3925. },
  3926. enumerable: true,
  3927. configurable: true
  3928. });
  3929. Object.defineProperty(Control.prototype, "widthInPixels", {
  3930. /**
  3931. * Gets or sets the control width in pixel
  3932. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3933. */
  3934. get: function () {
  3935. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3936. },
  3937. set: function (value) {
  3938. if (isNaN(value)) {
  3939. return;
  3940. }
  3941. this.width = value + "px";
  3942. },
  3943. enumerable: true,
  3944. configurable: true
  3945. });
  3946. Object.defineProperty(Control.prototype, "height", {
  3947. /**
  3948. * Gets or sets control height
  3949. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3950. */
  3951. get: function () {
  3952. return this._height.toString(this._host);
  3953. },
  3954. set: function (value) {
  3955. if (this._height.toString(this._host) === value) {
  3956. return;
  3957. }
  3958. if (this._height.fromString(value)) {
  3959. this._markAsDirty();
  3960. }
  3961. },
  3962. enumerable: true,
  3963. configurable: true
  3964. });
  3965. Object.defineProperty(Control.prototype, "heightInPixels", {
  3966. /**
  3967. * Gets or sets control height in pixel
  3968. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3969. */
  3970. get: function () {
  3971. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  3972. },
  3973. set: function (value) {
  3974. if (isNaN(value)) {
  3975. return;
  3976. }
  3977. this.height = value + "px";
  3978. },
  3979. enumerable: true,
  3980. configurable: true
  3981. });
  3982. Object.defineProperty(Control.prototype, "fontFamily", {
  3983. /** Gets or set font family */
  3984. get: function () {
  3985. if (!this._fontSet) {
  3986. return "";
  3987. }
  3988. return this._fontFamily;
  3989. },
  3990. set: function (value) {
  3991. if (this._fontFamily === value) {
  3992. return;
  3993. }
  3994. this._fontFamily = value;
  3995. this._resetFontCache();
  3996. },
  3997. enumerable: true,
  3998. configurable: true
  3999. });
  4000. Object.defineProperty(Control.prototype, "fontStyle", {
  4001. /** Gets or sets font style */
  4002. get: function () {
  4003. return this._fontStyle;
  4004. },
  4005. set: function (value) {
  4006. if (this._fontStyle === value) {
  4007. return;
  4008. }
  4009. this._fontStyle = value;
  4010. this._resetFontCache();
  4011. },
  4012. enumerable: true,
  4013. configurable: true
  4014. });
  4015. Object.defineProperty(Control.prototype, "fontWeight", {
  4016. /** Gets or sets font weight */
  4017. get: function () {
  4018. return this._fontWeight;
  4019. },
  4020. set: function (value) {
  4021. if (this._fontWeight === value) {
  4022. return;
  4023. }
  4024. this._fontWeight = value;
  4025. this._resetFontCache();
  4026. },
  4027. enumerable: true,
  4028. configurable: true
  4029. });
  4030. Object.defineProperty(Control.prototype, "style", {
  4031. /**
  4032. * Gets or sets style
  4033. * @see http://doc.babylonjs.com/how_to/gui#styles
  4034. */
  4035. get: function () {
  4036. return this._style;
  4037. },
  4038. set: function (value) {
  4039. var _this = this;
  4040. if (this._style) {
  4041. this._style.onChangedObservable.remove(this._styleObserver);
  4042. this._styleObserver = null;
  4043. }
  4044. this._style = value;
  4045. if (this._style) {
  4046. this._styleObserver = this._style.onChangedObservable.add(function () {
  4047. _this._markAsDirty();
  4048. _this._resetFontCache();
  4049. });
  4050. }
  4051. this._markAsDirty();
  4052. this._resetFontCache();
  4053. },
  4054. enumerable: true,
  4055. configurable: true
  4056. });
  4057. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4058. /** @hidden */
  4059. get: function () {
  4060. return this._fontSize.isPercentage;
  4061. },
  4062. enumerable: true,
  4063. configurable: true
  4064. });
  4065. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4066. /** Gets or sets font size in pixels */
  4067. get: function () {
  4068. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4069. if (fontSizeToUse.isPixel) {
  4070. return fontSizeToUse.getValue(this._host);
  4071. }
  4072. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4073. },
  4074. set: function (value) {
  4075. if (isNaN(value)) {
  4076. return;
  4077. }
  4078. this.fontSize = value + "px";
  4079. },
  4080. enumerable: true,
  4081. configurable: true
  4082. });
  4083. Object.defineProperty(Control.prototype, "fontSize", {
  4084. /** Gets or sets font size */
  4085. get: function () {
  4086. return this._fontSize.toString(this._host);
  4087. },
  4088. set: function (value) {
  4089. if (this._fontSize.toString(this._host) === value) {
  4090. return;
  4091. }
  4092. if (this._fontSize.fromString(value)) {
  4093. this._markAsDirty();
  4094. this._resetFontCache();
  4095. }
  4096. },
  4097. enumerable: true,
  4098. configurable: true
  4099. });
  4100. Object.defineProperty(Control.prototype, "color", {
  4101. /** Gets or sets foreground color */
  4102. get: function () {
  4103. return this._color;
  4104. },
  4105. set: function (value) {
  4106. if (this._color === value) {
  4107. return;
  4108. }
  4109. this._color = value;
  4110. this._markAsDirty();
  4111. },
  4112. enumerable: true,
  4113. configurable: true
  4114. });
  4115. Object.defineProperty(Control.prototype, "zIndex", {
  4116. /** Gets or sets z index which is used to reorder controls on the z axis */
  4117. get: function () {
  4118. return this._zIndex;
  4119. },
  4120. set: function (value) {
  4121. if (this.zIndex === value) {
  4122. return;
  4123. }
  4124. this._zIndex = value;
  4125. if (this.parent) {
  4126. this.parent._reOrderControl(this);
  4127. }
  4128. },
  4129. enumerable: true,
  4130. configurable: true
  4131. });
  4132. Object.defineProperty(Control.prototype, "notRenderable", {
  4133. /** Gets or sets a boolean indicating if the control can be rendered */
  4134. get: function () {
  4135. return this._doNotRender;
  4136. },
  4137. set: function (value) {
  4138. if (this._doNotRender === value) {
  4139. return;
  4140. }
  4141. this._doNotRender = value;
  4142. this._markAsDirty();
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(Control.prototype, "isVisible", {
  4148. /** Gets or sets a boolean indicating if the control is visible */
  4149. get: function () {
  4150. return this._isVisible;
  4151. },
  4152. set: function (value) {
  4153. if (this._isVisible === value) {
  4154. return;
  4155. }
  4156. this._isVisible = value;
  4157. this._markAsDirty(true);
  4158. },
  4159. enumerable: true,
  4160. configurable: true
  4161. });
  4162. Object.defineProperty(Control.prototype, "isDirty", {
  4163. /** Gets a boolean indicating that the control needs to update its rendering */
  4164. get: function () {
  4165. return this._isDirty;
  4166. },
  4167. enumerable: true,
  4168. configurable: true
  4169. });
  4170. Object.defineProperty(Control.prototype, "linkedMesh", {
  4171. /**
  4172. * Gets the current linked mesh (or null if none)
  4173. */
  4174. get: function () {
  4175. return this._linkedMesh;
  4176. },
  4177. enumerable: true,
  4178. configurable: true
  4179. });
  4180. Object.defineProperty(Control.prototype, "paddingLeft", {
  4181. /**
  4182. * Gets or sets a value indicating the padding to use on the left of the control
  4183. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4184. */
  4185. get: function () {
  4186. return this._paddingLeft.toString(this._host);
  4187. },
  4188. set: function (value) {
  4189. if (this._paddingLeft.fromString(value)) {
  4190. this._markAsDirty();
  4191. }
  4192. },
  4193. enumerable: true,
  4194. configurable: true
  4195. });
  4196. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4197. /**
  4198. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4199. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4200. */
  4201. get: function () {
  4202. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4203. },
  4204. set: function (value) {
  4205. if (isNaN(value)) {
  4206. return;
  4207. }
  4208. this.paddingLeft = value + "px";
  4209. },
  4210. enumerable: true,
  4211. configurable: true
  4212. });
  4213. Object.defineProperty(Control.prototype, "paddingRight", {
  4214. /**
  4215. * Gets or sets a value indicating the padding to use on the right of the control
  4216. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4217. */
  4218. get: function () {
  4219. return this._paddingRight.toString(this._host);
  4220. },
  4221. set: function (value) {
  4222. if (this._paddingRight.fromString(value)) {
  4223. this._markAsDirty();
  4224. }
  4225. },
  4226. enumerable: true,
  4227. configurable: true
  4228. });
  4229. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4230. /**
  4231. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4232. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4233. */
  4234. get: function () {
  4235. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4236. },
  4237. set: function (value) {
  4238. if (isNaN(value)) {
  4239. return;
  4240. }
  4241. this.paddingRight = value + "px";
  4242. },
  4243. enumerable: true,
  4244. configurable: true
  4245. });
  4246. Object.defineProperty(Control.prototype, "paddingTop", {
  4247. /**
  4248. * Gets or sets a value indicating the padding to use on the top of the control
  4249. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4250. */
  4251. get: function () {
  4252. return this._paddingTop.toString(this._host);
  4253. },
  4254. set: function (value) {
  4255. if (this._paddingTop.fromString(value)) {
  4256. this._markAsDirty();
  4257. }
  4258. },
  4259. enumerable: true,
  4260. configurable: true
  4261. });
  4262. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4263. /**
  4264. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4265. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4266. */
  4267. get: function () {
  4268. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4269. },
  4270. set: function (value) {
  4271. if (isNaN(value)) {
  4272. return;
  4273. }
  4274. this.paddingTop = value + "px";
  4275. },
  4276. enumerable: true,
  4277. configurable: true
  4278. });
  4279. Object.defineProperty(Control.prototype, "paddingBottom", {
  4280. /**
  4281. * Gets or sets a value indicating the padding to use on the bottom of the control
  4282. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4283. */
  4284. get: function () {
  4285. return this._paddingBottom.toString(this._host);
  4286. },
  4287. set: function (value) {
  4288. if (this._paddingBottom.fromString(value)) {
  4289. this._markAsDirty();
  4290. }
  4291. },
  4292. enumerable: true,
  4293. configurable: true
  4294. });
  4295. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4296. /**
  4297. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4298. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4299. */
  4300. get: function () {
  4301. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4302. },
  4303. set: function (value) {
  4304. if (isNaN(value)) {
  4305. return;
  4306. }
  4307. this.paddingBottom = value + "px";
  4308. },
  4309. enumerable: true,
  4310. configurable: true
  4311. });
  4312. Object.defineProperty(Control.prototype, "left", {
  4313. /**
  4314. * Gets or sets a value indicating the left coordinate of the control
  4315. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4316. */
  4317. get: function () {
  4318. return this._left.toString(this._host);
  4319. },
  4320. set: function (value) {
  4321. if (this._left.fromString(value)) {
  4322. this._markAsDirty();
  4323. }
  4324. },
  4325. enumerable: true,
  4326. configurable: true
  4327. });
  4328. Object.defineProperty(Control.prototype, "leftInPixels", {
  4329. /**
  4330. * Gets or sets a value indicating the left coordinate in pixels of the control
  4331. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4332. */
  4333. get: function () {
  4334. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4335. },
  4336. set: function (value) {
  4337. if (isNaN(value)) {
  4338. return;
  4339. }
  4340. this.left = value + "px";
  4341. },
  4342. enumerable: true,
  4343. configurable: true
  4344. });
  4345. Object.defineProperty(Control.prototype, "top", {
  4346. /**
  4347. * Gets or sets a value indicating the top coordinate of the control
  4348. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4349. */
  4350. get: function () {
  4351. return this._top.toString(this._host);
  4352. },
  4353. set: function (value) {
  4354. if (this._top.fromString(value)) {
  4355. this._markAsDirty();
  4356. }
  4357. },
  4358. enumerable: true,
  4359. configurable: true
  4360. });
  4361. Object.defineProperty(Control.prototype, "topInPixels", {
  4362. /**
  4363. * Gets or sets a value indicating the top coordinate in pixels of the control
  4364. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4365. */
  4366. get: function () {
  4367. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4368. },
  4369. set: function (value) {
  4370. if (isNaN(value)) {
  4371. return;
  4372. }
  4373. this.top = value + "px";
  4374. },
  4375. enumerable: true,
  4376. configurable: true
  4377. });
  4378. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4379. /**
  4380. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4381. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4382. */
  4383. get: function () {
  4384. return this._linkOffsetX.toString(this._host);
  4385. },
  4386. set: function (value) {
  4387. if (this._linkOffsetX.fromString(value)) {
  4388. this._markAsDirty();
  4389. }
  4390. },
  4391. enumerable: true,
  4392. configurable: true
  4393. });
  4394. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4395. /**
  4396. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4397. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4398. */
  4399. get: function () {
  4400. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4401. },
  4402. set: function (value) {
  4403. if (isNaN(value)) {
  4404. return;
  4405. }
  4406. this.linkOffsetX = value + "px";
  4407. },
  4408. enumerable: true,
  4409. configurable: true
  4410. });
  4411. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4412. /**
  4413. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4414. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4415. */
  4416. get: function () {
  4417. return this._linkOffsetY.toString(this._host);
  4418. },
  4419. set: function (value) {
  4420. if (this._linkOffsetY.fromString(value)) {
  4421. this._markAsDirty();
  4422. }
  4423. },
  4424. enumerable: true,
  4425. configurable: true
  4426. });
  4427. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4428. /**
  4429. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4430. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4431. */
  4432. get: function () {
  4433. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4434. },
  4435. set: function (value) {
  4436. if (isNaN(value)) {
  4437. return;
  4438. }
  4439. this.linkOffsetY = value + "px";
  4440. },
  4441. enumerable: true,
  4442. configurable: true
  4443. });
  4444. Object.defineProperty(Control.prototype, "centerX", {
  4445. /** Gets the center coordinate on X axis */
  4446. get: function () {
  4447. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4448. },
  4449. enumerable: true,
  4450. configurable: true
  4451. });
  4452. Object.defineProperty(Control.prototype, "centerY", {
  4453. /** Gets the center coordinate on Y axis */
  4454. get: function () {
  4455. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4456. },
  4457. enumerable: true,
  4458. configurable: true
  4459. });
  4460. Object.defineProperty(Control.prototype, "isEnabled", {
  4461. /** Gets or sets if control is Enabled*/
  4462. get: function () {
  4463. return this._isEnabled;
  4464. },
  4465. set: function (value) {
  4466. if (this._isEnabled === value) {
  4467. return;
  4468. }
  4469. this._isEnabled = value;
  4470. this._markAsDirty();
  4471. },
  4472. enumerable: true,
  4473. configurable: true
  4474. });
  4475. Object.defineProperty(Control.prototype, "disabledColor", {
  4476. /** Gets or sets background color of control if it's disabled*/
  4477. get: function () {
  4478. return this._disabledColor;
  4479. },
  4480. set: function (value) {
  4481. if (this._disabledColor === value) {
  4482. return;
  4483. }
  4484. this._disabledColor = value;
  4485. this._markAsDirty();
  4486. },
  4487. enumerable: true,
  4488. configurable: true
  4489. });
  4490. /** @hidden */
  4491. Control.prototype._getTypeName = function () {
  4492. return "Control";
  4493. };
  4494. /**
  4495. * Gets the first ascendant in the hierarchy of the given type
  4496. * @param className defines the required type
  4497. * @returns the ascendant or null if not found
  4498. */
  4499. Control.prototype.getAscendantOfClass = function (className) {
  4500. if (!this.parent) {
  4501. return null;
  4502. }
  4503. if (this.parent.getClassName() === className) {
  4504. return this.parent;
  4505. }
  4506. return this.parent.getAscendantOfClass(className);
  4507. };
  4508. /** @hidden */
  4509. Control.prototype._resetFontCache = function () {
  4510. this._fontSet = true;
  4511. this._markAsDirty();
  4512. };
  4513. /**
  4514. * Determines if a container is an ascendant of the current control
  4515. * @param container defines the container to look for
  4516. * @returns true if the container is one of the ascendant of the control
  4517. */
  4518. Control.prototype.isAscendant = function (container) {
  4519. if (!this.parent) {
  4520. return false;
  4521. }
  4522. if (this.parent === container) {
  4523. return true;
  4524. }
  4525. return this.parent.isAscendant(container);
  4526. };
  4527. /**
  4528. * Gets coordinates in local control space
  4529. * @param globalCoordinates defines the coordinates to transform
  4530. * @returns the new coordinates in local space
  4531. */
  4532. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4533. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4534. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4535. return result;
  4536. };
  4537. /**
  4538. * Gets coordinates in local control space
  4539. * @param globalCoordinates defines the coordinates to transform
  4540. * @param result defines the target vector2 where to store the result
  4541. * @returns the current control
  4542. */
  4543. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4544. result.x = globalCoordinates.x - this._currentMeasure.left;
  4545. result.y = globalCoordinates.y - this._currentMeasure.top;
  4546. return this;
  4547. };
  4548. /**
  4549. * Gets coordinates in parent local control space
  4550. * @param globalCoordinates defines the coordinates to transform
  4551. * @returns the new coordinates in parent local space
  4552. */
  4553. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4554. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4555. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4556. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4557. return result;
  4558. };
  4559. /**
  4560. * Move the current control to a vector3 position projected onto the screen.
  4561. * @param position defines the target position
  4562. * @param scene defines the hosting scene
  4563. */
  4564. Control.prototype.moveToVector3 = function (position, scene) {
  4565. if (!this._host || this.parent !== this._host._rootContainer) {
  4566. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4567. return;
  4568. }
  4569. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4570. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4571. var globalViewport = this._host._getGlobalViewport(scene);
  4572. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4573. this._moveToProjectedPosition(projectedPosition);
  4574. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4575. this.notRenderable = true;
  4576. return;
  4577. }
  4578. this.notRenderable = false;
  4579. };
  4580. /** @hidden */
  4581. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4582. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4583. // Do nothing by default
  4584. };
  4585. /**
  4586. * Will return all controls that have this control as ascendant
  4587. * @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
  4588. * @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
  4589. * @return all child controls
  4590. */
  4591. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4592. var results = new Array();
  4593. this._getDescendants(results, directDescendantsOnly, predicate);
  4594. return results;
  4595. };
  4596. /**
  4597. * Link current control with a target mesh
  4598. * @param mesh defines the mesh to link with
  4599. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4600. */
  4601. Control.prototype.linkWithMesh = function (mesh) {
  4602. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4603. if (mesh) {
  4604. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4605. }
  4606. return;
  4607. }
  4608. var index = this._host._linkedControls.indexOf(this);
  4609. if (index !== -1) {
  4610. this._linkedMesh = mesh;
  4611. if (!mesh) {
  4612. this._host._linkedControls.splice(index, 1);
  4613. }
  4614. return;
  4615. }
  4616. else if (!mesh) {
  4617. return;
  4618. }
  4619. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4620. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4621. this._linkedMesh = mesh;
  4622. this._host._linkedControls.push(this);
  4623. };
  4624. /** @hidden */
  4625. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4626. var oldLeft = this._left.getValue(this._host);
  4627. var oldTop = this._top.getValue(this._host);
  4628. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4629. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4630. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4631. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4632. newLeft = oldLeft;
  4633. }
  4634. if (Math.abs(newTop - oldTop) < 0.5) {
  4635. newTop = oldTop;
  4636. }
  4637. }
  4638. this.left = newLeft + "px";
  4639. this.top = newTop + "px";
  4640. this._left.ignoreAdaptiveScaling = true;
  4641. this._top.ignoreAdaptiveScaling = true;
  4642. this._markAsDirty();
  4643. };
  4644. /** @hidden */
  4645. Control.prototype._offsetLeft = function (offset) {
  4646. this._isDirty = true;
  4647. this._currentMeasure.left += offset;
  4648. };
  4649. /** @hidden */
  4650. Control.prototype._offsetTop = function (offset) {
  4651. this._isDirty = true;
  4652. this._currentMeasure.top += offset;
  4653. };
  4654. /** @hidden */
  4655. Control.prototype._markMatrixAsDirty = function () {
  4656. this._isMatrixDirty = true;
  4657. this._flagDescendantsAsMatrixDirty();
  4658. };
  4659. /** @hidden */
  4660. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4661. // No child
  4662. };
  4663. /** @hidden */
  4664. Control.prototype._intersectsRect = function (rect) {
  4665. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4666. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4667. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4668. return false;
  4669. }
  4670. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4671. return false;
  4672. }
  4673. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4674. return false;
  4675. }
  4676. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4677. return false;
  4678. }
  4679. return true;
  4680. };
  4681. /** @hidden */
  4682. Control.prototype.invalidateRect = function () {
  4683. this._transform();
  4684. if (this.host && this.host.useInvalidateRectOptimization) {
  4685. // Rotate by transform to get the measure transformed to global space
  4686. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4687. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4688. // the previous measure is used to properly clear a control that is scaled down
  4689. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4690. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4691. // Expand rect based on shadows
  4692. var shadowOffsetX = this.shadowOffsetX;
  4693. var shadowOffsetY = this.shadowOffsetY;
  4694. var shadowBlur = this.shadowBlur;
  4695. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4696. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4697. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4698. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4699. 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));
  4700. }
  4701. else {
  4702. 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));
  4703. }
  4704. }
  4705. };
  4706. /** @hidden */
  4707. Control.prototype._markAsDirty = function (force) {
  4708. if (force === void 0) { force = false; }
  4709. if (!this._isVisible && !force) {
  4710. return;
  4711. }
  4712. this._isDirty = true;
  4713. // Redraw only this rectangle
  4714. if (this._host) {
  4715. this._host.markAsDirty();
  4716. }
  4717. };
  4718. /** @hidden */
  4719. Control.prototype._markAllAsDirty = function () {
  4720. this._markAsDirty();
  4721. if (this._font) {
  4722. this._prepareFont();
  4723. }
  4724. };
  4725. /** @hidden */
  4726. Control.prototype._link = function (host) {
  4727. this._host = host;
  4728. if (this._host) {
  4729. this.uniqueId = this._host.getScene().getUniqueId();
  4730. }
  4731. };
  4732. /** @hidden */
  4733. Control.prototype._transform = function (context) {
  4734. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4735. return;
  4736. }
  4737. // postTranslate
  4738. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4739. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4740. if (context) {
  4741. context.translate(offsetX, offsetY);
  4742. // rotate
  4743. context.rotate(this._rotation);
  4744. // scale
  4745. context.scale(this._scaleX, this._scaleY);
  4746. // preTranslate
  4747. context.translate(-offsetX, -offsetY);
  4748. }
  4749. // Need to update matrices?
  4750. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4751. this._cachedOffsetX = offsetX;
  4752. this._cachedOffsetY = offsetY;
  4753. this._isMatrixDirty = false;
  4754. this._flagDescendantsAsMatrixDirty();
  4755. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4756. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4757. }
  4758. };
  4759. /** @hidden */
  4760. Control.prototype._renderHighlight = function (context) {
  4761. if (!this.isHighlighted) {
  4762. return;
  4763. }
  4764. context.save();
  4765. context.strokeStyle = "#4affff";
  4766. context.lineWidth = 2;
  4767. this._renderHighlightSpecific(context);
  4768. context.restore();
  4769. };
  4770. /** @hidden */
  4771. Control.prototype._renderHighlightSpecific = function (context) {
  4772. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4773. };
  4774. /** @hidden */
  4775. Control.prototype._applyStates = function (context) {
  4776. if (this._isFontSizeInPercentage) {
  4777. this._fontSet = true;
  4778. }
  4779. if (this._fontSet) {
  4780. this._prepareFont();
  4781. this._fontSet = false;
  4782. }
  4783. if (this._font) {
  4784. context.font = this._font;
  4785. }
  4786. if (this._color) {
  4787. context.fillStyle = this._color;
  4788. }
  4789. if (Control.AllowAlphaInheritance) {
  4790. context.globalAlpha *= this._alpha;
  4791. }
  4792. else if (this._alphaSet) {
  4793. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4794. }
  4795. };
  4796. /** @hidden */
  4797. Control.prototype._layout = function (parentMeasure, context) {
  4798. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4799. return false;
  4800. }
  4801. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4802. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4803. context.save();
  4804. this._applyStates(context);
  4805. var rebuildCount = 0;
  4806. do {
  4807. this._rebuildLayout = false;
  4808. this._processMeasures(parentMeasure, context);
  4809. rebuildCount++;
  4810. } while (this._rebuildLayout && rebuildCount < 3);
  4811. if (rebuildCount >= 3) {
  4812. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4813. }
  4814. context.restore();
  4815. this.invalidateRect();
  4816. this._evaluateClippingState(parentMeasure);
  4817. }
  4818. this._wasDirty = this._isDirty;
  4819. this._isDirty = false;
  4820. return true;
  4821. };
  4822. /** @hidden */
  4823. Control.prototype._processMeasures = function (parentMeasure, context) {
  4824. this._currentMeasure.copyFrom(parentMeasure);
  4825. // Let children take some pre-measurement actions
  4826. this._preMeasure(parentMeasure, context);
  4827. this._measure();
  4828. this._computeAlignment(parentMeasure, context);
  4829. // Convert to int values
  4830. this._currentMeasure.left = this._currentMeasure.left | 0;
  4831. this._currentMeasure.top = this._currentMeasure.top | 0;
  4832. this._currentMeasure.width = this._currentMeasure.width | 0;
  4833. this._currentMeasure.height = this._currentMeasure.height | 0;
  4834. // Let children add more features
  4835. this._additionalProcessing(parentMeasure, context);
  4836. this._cachedParentMeasure.copyFrom(parentMeasure);
  4837. if (this.onDirtyObservable.hasObservers()) {
  4838. this.onDirtyObservable.notifyObservers(this);
  4839. }
  4840. };
  4841. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4842. if (this.parent && this.parent.clipChildren) {
  4843. // Early clip
  4844. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4845. this._isClipped = true;
  4846. return;
  4847. }
  4848. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4849. this._isClipped = true;
  4850. return;
  4851. }
  4852. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4853. this._isClipped = true;
  4854. return;
  4855. }
  4856. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4857. this._isClipped = true;
  4858. return;
  4859. }
  4860. }
  4861. this._isClipped = false;
  4862. };
  4863. /** @hidden */
  4864. Control.prototype._measure = function () {
  4865. // Width / Height
  4866. if (this._width.isPixel) {
  4867. this._currentMeasure.width = this._width.getValue(this._host);
  4868. }
  4869. else {
  4870. this._currentMeasure.width *= this._width.getValue(this._host);
  4871. }
  4872. if (this._height.isPixel) {
  4873. this._currentMeasure.height = this._height.getValue(this._host);
  4874. }
  4875. else {
  4876. this._currentMeasure.height *= this._height.getValue(this._host);
  4877. }
  4878. };
  4879. /** @hidden */
  4880. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4881. var width = this._currentMeasure.width;
  4882. var height = this._currentMeasure.height;
  4883. var parentWidth = parentMeasure.width;
  4884. var parentHeight = parentMeasure.height;
  4885. // Left / top
  4886. var x = 0;
  4887. var y = 0;
  4888. switch (this.horizontalAlignment) {
  4889. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4890. x = 0;
  4891. break;
  4892. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4893. x = parentWidth - width;
  4894. break;
  4895. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4896. x = (parentWidth - width) / 2;
  4897. break;
  4898. }
  4899. switch (this.verticalAlignment) {
  4900. case Control.VERTICAL_ALIGNMENT_TOP:
  4901. y = 0;
  4902. break;
  4903. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4904. y = parentHeight - height;
  4905. break;
  4906. case Control.VERTICAL_ALIGNMENT_CENTER:
  4907. y = (parentHeight - height) / 2;
  4908. break;
  4909. }
  4910. if (this._paddingLeft.isPixel) {
  4911. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4912. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4913. }
  4914. else {
  4915. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4916. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4917. }
  4918. if (this._paddingRight.isPixel) {
  4919. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4920. }
  4921. else {
  4922. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4923. }
  4924. if (this._paddingTop.isPixel) {
  4925. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4926. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4927. }
  4928. else {
  4929. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4930. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4931. }
  4932. if (this._paddingBottom.isPixel) {
  4933. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4934. }
  4935. else {
  4936. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4937. }
  4938. if (this._left.isPixel) {
  4939. this._currentMeasure.left += this._left.getValue(this._host);
  4940. }
  4941. else {
  4942. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4943. }
  4944. if (this._top.isPixel) {
  4945. this._currentMeasure.top += this._top.getValue(this._host);
  4946. }
  4947. else {
  4948. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4949. }
  4950. this._currentMeasure.left += x;
  4951. this._currentMeasure.top += y;
  4952. };
  4953. /** @hidden */
  4954. Control.prototype._preMeasure = function (parentMeasure, context) {
  4955. // Do nothing
  4956. };
  4957. /** @hidden */
  4958. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4959. // Do nothing
  4960. };
  4961. /** @hidden */
  4962. Control.prototype._clipForChildren = function (context) {
  4963. // DO nothing
  4964. };
  4965. Control.prototype._clip = function (context, invalidatedRectangle) {
  4966. context.beginPath();
  4967. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4968. if (invalidatedRectangle) {
  4969. // Rotate the invalidated rect into the control's space
  4970. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4971. // Get the intersection of the rect in context space and the current context
  4972. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4973. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4974. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4975. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4976. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4977. Control._ClipMeasure.copyFrom(intersection);
  4978. }
  4979. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4980. var shadowOffsetX = this.shadowOffsetX;
  4981. var shadowOffsetY = this.shadowOffsetY;
  4982. var shadowBlur = this.shadowBlur;
  4983. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4984. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4985. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4986. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4987. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  4988. }
  4989. else {
  4990. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  4991. }
  4992. context.clip();
  4993. };
  4994. /** @hidden */
  4995. Control.prototype._render = function (context, invalidatedRectangle) {
  4996. if (!this.isVisible || this.notRenderable || this._isClipped) {
  4997. this._isDirty = false;
  4998. return false;
  4999. }
  5000. context.save();
  5001. this._applyStates(context);
  5002. // Transform
  5003. this._transform(context);
  5004. // Clip
  5005. if (this.clipContent) {
  5006. this._clip(context, invalidatedRectangle);
  5007. }
  5008. if (this.onBeforeDrawObservable.hasObservers()) {
  5009. this.onBeforeDrawObservable.notifyObservers(this);
  5010. }
  5011. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5012. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5013. }
  5014. else {
  5015. this._draw(context, invalidatedRectangle);
  5016. }
  5017. if (this.useBitmapCache && this._wasDirty) {
  5018. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5019. }
  5020. this._renderHighlight(context);
  5021. if (this.onAfterDrawObservable.hasObservers()) {
  5022. this.onAfterDrawObservable.notifyObservers(this);
  5023. }
  5024. context.restore();
  5025. return true;
  5026. };
  5027. /** @hidden */
  5028. Control.prototype._draw = function (context, invalidatedRectangle) {
  5029. // Do nothing
  5030. };
  5031. /**
  5032. * Tests if a given coordinates belong to the current control
  5033. * @param x defines x coordinate to test
  5034. * @param y defines y coordinate to test
  5035. * @returns true if the coordinates are inside the control
  5036. */
  5037. Control.prototype.contains = function (x, y) {
  5038. // Invert transform
  5039. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5040. x = this._transformedPosition.x;
  5041. y = this._transformedPosition.y;
  5042. // Check
  5043. if (x < this._currentMeasure.left) {
  5044. return false;
  5045. }
  5046. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5047. return false;
  5048. }
  5049. if (y < this._currentMeasure.top) {
  5050. return false;
  5051. }
  5052. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5053. return false;
  5054. }
  5055. if (this.isPointerBlocker) {
  5056. this._host._shouldBlockPointer = true;
  5057. }
  5058. return true;
  5059. };
  5060. /** @hidden */
  5061. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5062. if (!this._isEnabled) {
  5063. return false;
  5064. }
  5065. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5066. return false;
  5067. }
  5068. if (!this.contains(x, y)) {
  5069. return false;
  5070. }
  5071. this._processObservables(type, x, y, pointerId, buttonIndex);
  5072. return true;
  5073. };
  5074. /** @hidden */
  5075. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5076. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5077. if (canNotify && this.parent != null) {
  5078. this.parent._onPointerMove(target, coordinates, pointerId);
  5079. }
  5080. };
  5081. /** @hidden */
  5082. Control.prototype._onPointerEnter = function (target) {
  5083. if (!this._isEnabled) {
  5084. return false;
  5085. }
  5086. if (this._enterCount > 0) {
  5087. return false;
  5088. }
  5089. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5090. this._enterCount = 0;
  5091. }
  5092. this._enterCount++;
  5093. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5094. if (canNotify && this.parent != null) {
  5095. this.parent._onPointerEnter(target);
  5096. }
  5097. return true;
  5098. };
  5099. /** @hidden */
  5100. Control.prototype._onPointerOut = function (target, force) {
  5101. if (force === void 0) { force = false; }
  5102. if (!force && (!this._isEnabled || target === this)) {
  5103. return;
  5104. }
  5105. this._enterCount = 0;
  5106. var canNotify = true;
  5107. if (!target.isAscendant(this)) {
  5108. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5109. }
  5110. if (canNotify && this.parent != null) {
  5111. this.parent._onPointerOut(target, force);
  5112. }
  5113. };
  5114. /** @hidden */
  5115. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5116. // Prevent pointerout to lose control context.
  5117. // Event redundancy is checked inside the function.
  5118. this._onPointerEnter(this);
  5119. if (this._downCount !== 0) {
  5120. return false;
  5121. }
  5122. this._downCount++;
  5123. this._downPointerIds[pointerId] = true;
  5124. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5125. if (canNotify && this.parent != null) {
  5126. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5127. }
  5128. return true;
  5129. };
  5130. /** @hidden */
  5131. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5132. if (!this._isEnabled) {
  5133. return;
  5134. }
  5135. this._downCount = 0;
  5136. delete this._downPointerIds[pointerId];
  5137. var canNotifyClick = notifyClick;
  5138. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5139. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5140. }
  5141. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5142. if (canNotify && this.parent != null) {
  5143. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5144. }
  5145. };
  5146. /** @hidden */
  5147. Control.prototype._forcePointerUp = function (pointerId) {
  5148. if (pointerId === void 0) { pointerId = null; }
  5149. if (pointerId !== null) {
  5150. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5151. }
  5152. else {
  5153. for (var key in this._downPointerIds) {
  5154. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5155. }
  5156. }
  5157. };
  5158. /** @hidden */
  5159. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5160. if (!this._isEnabled) {
  5161. return false;
  5162. }
  5163. this._dummyVector2.copyFromFloats(x, y);
  5164. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5165. this._onPointerMove(this, this._dummyVector2, pointerId);
  5166. var previousControlOver = this._host._lastControlOver[pointerId];
  5167. if (previousControlOver && previousControlOver !== this) {
  5168. previousControlOver._onPointerOut(this);
  5169. }
  5170. if (previousControlOver !== this) {
  5171. this._onPointerEnter(this);
  5172. }
  5173. this._host._lastControlOver[pointerId] = this;
  5174. return true;
  5175. }
  5176. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5177. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5178. this._host._registerLastControlDown(this, pointerId);
  5179. this._host._lastPickedControl = this;
  5180. return true;
  5181. }
  5182. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5183. if (this._host._lastControlDown[pointerId]) {
  5184. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5185. }
  5186. delete this._host._lastControlDown[pointerId];
  5187. return true;
  5188. }
  5189. return false;
  5190. };
  5191. Control.prototype._prepareFont = function () {
  5192. if (!this._font && !this._fontSet) {
  5193. return;
  5194. }
  5195. if (this._style) {
  5196. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5197. }
  5198. else {
  5199. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5200. }
  5201. this._fontOffset = Control._GetFontOffset(this._font);
  5202. };
  5203. /** Releases associated resources */
  5204. Control.prototype.dispose = function () {
  5205. this.onDirtyObservable.clear();
  5206. this.onBeforeDrawObservable.clear();
  5207. this.onAfterDrawObservable.clear();
  5208. this.onPointerDownObservable.clear();
  5209. this.onPointerEnterObservable.clear();
  5210. this.onPointerMoveObservable.clear();
  5211. this.onPointerOutObservable.clear();
  5212. this.onPointerUpObservable.clear();
  5213. this.onPointerClickObservable.clear();
  5214. if (this._styleObserver && this._style) {
  5215. this._style.onChangedObservable.remove(this._styleObserver);
  5216. this._styleObserver = null;
  5217. }
  5218. if (this.parent) {
  5219. this.parent.removeControl(this);
  5220. this.parent = null;
  5221. }
  5222. if (this._host) {
  5223. var index = this._host._linkedControls.indexOf(this);
  5224. if (index > -1) {
  5225. this.linkWithMesh(null);
  5226. }
  5227. }
  5228. };
  5229. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5230. /** HORIZONTAL_ALIGNMENT_LEFT */
  5231. get: function () {
  5232. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5233. },
  5234. enumerable: true,
  5235. configurable: true
  5236. });
  5237. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5238. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5239. get: function () {
  5240. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5241. },
  5242. enumerable: true,
  5243. configurable: true
  5244. });
  5245. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5246. /** HORIZONTAL_ALIGNMENT_CENTER */
  5247. get: function () {
  5248. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5249. },
  5250. enumerable: true,
  5251. configurable: true
  5252. });
  5253. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5254. /** VERTICAL_ALIGNMENT_TOP */
  5255. get: function () {
  5256. return Control._VERTICAL_ALIGNMENT_TOP;
  5257. },
  5258. enumerable: true,
  5259. configurable: true
  5260. });
  5261. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5262. /** VERTICAL_ALIGNMENT_BOTTOM */
  5263. get: function () {
  5264. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5265. },
  5266. enumerable: true,
  5267. configurable: true
  5268. });
  5269. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5270. /** VERTICAL_ALIGNMENT_CENTER */
  5271. get: function () {
  5272. return Control._VERTICAL_ALIGNMENT_CENTER;
  5273. },
  5274. enumerable: true,
  5275. configurable: true
  5276. });
  5277. /** @hidden */
  5278. Control._GetFontOffset = function (font) {
  5279. if (Control._FontHeightSizes[font]) {
  5280. return Control._FontHeightSizes[font];
  5281. }
  5282. var text = document.createElement("span");
  5283. text.innerHTML = "Hg";
  5284. text.style.font = font;
  5285. var block = document.createElement("div");
  5286. block.style.display = "inline-block";
  5287. block.style.width = "1px";
  5288. block.style.height = "0px";
  5289. block.style.verticalAlign = "bottom";
  5290. var div = document.createElement("div");
  5291. div.appendChild(text);
  5292. div.appendChild(block);
  5293. document.body.appendChild(div);
  5294. var fontAscent = 0;
  5295. var fontHeight = 0;
  5296. try {
  5297. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5298. block.style.verticalAlign = "baseline";
  5299. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5300. }
  5301. finally {
  5302. document.body.removeChild(div);
  5303. }
  5304. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5305. Control._FontHeightSizes[font] = result;
  5306. return result;
  5307. };
  5308. /** @hidden */
  5309. Control.drawEllipse = function (x, y, width, height, context) {
  5310. context.translate(x, y);
  5311. context.scale(width, height);
  5312. context.beginPath();
  5313. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5314. context.closePath();
  5315. context.scale(1 / width, 1 / height);
  5316. context.translate(-x, -y);
  5317. };
  5318. /**
  5319. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5320. */
  5321. Control.AllowAlphaInheritance = false;
  5322. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5323. // Statics
  5324. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5325. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5326. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5327. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5328. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5329. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5330. Control._FontHeightSizes = {};
  5331. /**
  5332. * Creates a stack panel that can be used to render headers
  5333. * @param control defines the control to associate with the header
  5334. * @param text defines the text of the header
  5335. * @param size defines the size of the header
  5336. * @param options defines options used to configure the header
  5337. * @returns a new StackPanel
  5338. * @ignore
  5339. * @hidden
  5340. */
  5341. Control.AddHeader = function () { };
  5342. return Control;
  5343. }());
  5344. /***/ }),
  5345. /***/ "./2D/controls/displayGrid.ts":
  5346. /*!************************************!*\
  5347. !*** ./2D/controls/displayGrid.ts ***!
  5348. \************************************/
  5349. /*! exports provided: DisplayGrid */
  5350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5351. "use strict";
  5352. __webpack_require__.r(__webpack_exports__);
  5353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5355. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5356. /** Class used to render a grid */
  5357. var DisplayGrid = /** @class */ (function (_super) {
  5358. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5359. /**
  5360. * Creates a new GridDisplayRectangle
  5361. * @param name defines the control name
  5362. */
  5363. function DisplayGrid(name) {
  5364. var _this = _super.call(this, name) || this;
  5365. _this.name = name;
  5366. _this._cellWidth = 20;
  5367. _this._cellHeight = 20;
  5368. _this._minorLineTickness = 1;
  5369. _this._minorLineColor = "DarkGray";
  5370. _this._majorLineTickness = 2;
  5371. _this._majorLineColor = "White";
  5372. _this._majorLineFrequency = 5;
  5373. _this._background = "Black";
  5374. _this._displayMajorLines = true;
  5375. _this._displayMinorLines = true;
  5376. return _this;
  5377. }
  5378. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5379. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5380. get: function () {
  5381. return this._displayMinorLines;
  5382. },
  5383. set: function (value) {
  5384. if (this._displayMinorLines === value) {
  5385. return;
  5386. }
  5387. this._displayMinorLines = value;
  5388. this._markAsDirty();
  5389. },
  5390. enumerable: true,
  5391. configurable: true
  5392. });
  5393. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5394. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5395. get: function () {
  5396. return this._displayMajorLines;
  5397. },
  5398. set: function (value) {
  5399. if (this._displayMajorLines === value) {
  5400. return;
  5401. }
  5402. this._displayMajorLines = value;
  5403. this._markAsDirty();
  5404. },
  5405. enumerable: true,
  5406. configurable: true
  5407. });
  5408. Object.defineProperty(DisplayGrid.prototype, "background", {
  5409. /** Gets or sets background color (Black by default) */
  5410. get: function () {
  5411. return this._background;
  5412. },
  5413. set: function (value) {
  5414. if (this._background === value) {
  5415. return;
  5416. }
  5417. this._background = value;
  5418. this._markAsDirty();
  5419. },
  5420. enumerable: true,
  5421. configurable: true
  5422. });
  5423. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5424. /** Gets or sets the width of each cell (20 by default) */
  5425. get: function () {
  5426. return this._cellWidth;
  5427. },
  5428. set: function (value) {
  5429. this._cellWidth = value;
  5430. this._markAsDirty();
  5431. },
  5432. enumerable: true,
  5433. configurable: true
  5434. });
  5435. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5436. /** Gets or sets the height of each cell (20 by default) */
  5437. get: function () {
  5438. return this._cellHeight;
  5439. },
  5440. set: function (value) {
  5441. this._cellHeight = value;
  5442. this._markAsDirty();
  5443. },
  5444. enumerable: true,
  5445. configurable: true
  5446. });
  5447. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5448. /** Gets or sets the tickness of minor lines (1 by default) */
  5449. get: function () {
  5450. return this._minorLineTickness;
  5451. },
  5452. set: function (value) {
  5453. this._minorLineTickness = value;
  5454. this._markAsDirty();
  5455. },
  5456. enumerable: true,
  5457. configurable: true
  5458. });
  5459. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5460. /** Gets or sets the color of minor lines (DarkGray by default) */
  5461. get: function () {
  5462. return this._minorLineColor;
  5463. },
  5464. set: function (value) {
  5465. this._minorLineColor = value;
  5466. this._markAsDirty();
  5467. },
  5468. enumerable: true,
  5469. configurable: true
  5470. });
  5471. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5472. /** Gets or sets the tickness of major lines (2 by default) */
  5473. get: function () {
  5474. return this._majorLineTickness;
  5475. },
  5476. set: function (value) {
  5477. this._majorLineTickness = value;
  5478. this._markAsDirty();
  5479. },
  5480. enumerable: true,
  5481. configurable: true
  5482. });
  5483. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5484. /** Gets or sets the color of major lines (White by default) */
  5485. get: function () {
  5486. return this._majorLineColor;
  5487. },
  5488. set: function (value) {
  5489. this._majorLineColor = value;
  5490. this._markAsDirty();
  5491. },
  5492. enumerable: true,
  5493. configurable: true
  5494. });
  5495. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5496. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5497. get: function () {
  5498. return this._majorLineFrequency;
  5499. },
  5500. set: function (value) {
  5501. this._majorLineFrequency = value;
  5502. this._markAsDirty();
  5503. },
  5504. enumerable: true,
  5505. configurable: true
  5506. });
  5507. DisplayGrid.prototype._draw = function (context) {
  5508. context.save();
  5509. this._applyStates(context);
  5510. if (this._isEnabled) {
  5511. if (this._background) {
  5512. context.fillStyle = this._background;
  5513. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5514. }
  5515. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5516. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5517. // Minor lines
  5518. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5519. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5520. if (this._displayMinorLines) {
  5521. context.strokeStyle = this._minorLineColor;
  5522. context.lineWidth = this._minorLineTickness;
  5523. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5524. var cellX = left + x * this.cellWidth;
  5525. context.beginPath();
  5526. context.moveTo(cellX, this._currentMeasure.top);
  5527. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5528. context.stroke();
  5529. }
  5530. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5531. var cellY = top_1 + y * this.cellHeight;
  5532. context.beginPath();
  5533. context.moveTo(this._currentMeasure.left, cellY);
  5534. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5535. context.stroke();
  5536. }
  5537. }
  5538. // Major lines
  5539. if (this._displayMajorLines) {
  5540. context.strokeStyle = this._majorLineColor;
  5541. context.lineWidth = this._majorLineTickness;
  5542. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5543. var cellX = left + x * this.cellWidth;
  5544. context.beginPath();
  5545. context.moveTo(cellX, this._currentMeasure.top);
  5546. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5547. context.stroke();
  5548. }
  5549. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5550. var cellY = top_1 + y * this.cellHeight;
  5551. context.moveTo(this._currentMeasure.left, cellY);
  5552. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5553. context.closePath();
  5554. context.stroke();
  5555. }
  5556. }
  5557. }
  5558. context.restore();
  5559. };
  5560. DisplayGrid.prototype._getTypeName = function () {
  5561. return "DisplayGrid";
  5562. };
  5563. return DisplayGrid;
  5564. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5565. /***/ }),
  5566. /***/ "./2D/controls/ellipse.ts":
  5567. /*!********************************!*\
  5568. !*** ./2D/controls/ellipse.ts ***!
  5569. \********************************/
  5570. /*! exports provided: Ellipse */
  5571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5572. "use strict";
  5573. __webpack_require__.r(__webpack_exports__);
  5574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5575. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5576. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5577. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5578. /** Class used to create 2D ellipse containers */
  5579. var Ellipse = /** @class */ (function (_super) {
  5580. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5581. /**
  5582. * Creates a new Ellipse
  5583. * @param name defines the control name
  5584. */
  5585. function Ellipse(name) {
  5586. var _this = _super.call(this, name) || this;
  5587. _this.name = name;
  5588. _this._thickness = 1;
  5589. return _this;
  5590. }
  5591. Object.defineProperty(Ellipse.prototype, "thickness", {
  5592. /** Gets or sets border thickness */
  5593. get: function () {
  5594. return this._thickness;
  5595. },
  5596. set: function (value) {
  5597. if (this._thickness === value) {
  5598. return;
  5599. }
  5600. this._thickness = value;
  5601. this._markAsDirty();
  5602. },
  5603. enumerable: true,
  5604. configurable: true
  5605. });
  5606. Ellipse.prototype._getTypeName = function () {
  5607. return "Ellipse";
  5608. };
  5609. Ellipse.prototype._localDraw = function (context) {
  5610. context.save();
  5611. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5612. context.shadowColor = this.shadowColor;
  5613. context.shadowBlur = this.shadowBlur;
  5614. context.shadowOffsetX = this.shadowOffsetX;
  5615. context.shadowOffsetY = this.shadowOffsetY;
  5616. }
  5617. _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);
  5618. if (this._background) {
  5619. context.fillStyle = this._background;
  5620. context.fill();
  5621. }
  5622. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5623. context.shadowBlur = 0;
  5624. context.shadowOffsetX = 0;
  5625. context.shadowOffsetY = 0;
  5626. }
  5627. if (this._thickness) {
  5628. if (this.color) {
  5629. context.strokeStyle = this.color;
  5630. }
  5631. context.lineWidth = this._thickness;
  5632. context.stroke();
  5633. }
  5634. context.restore();
  5635. };
  5636. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5637. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5638. this._measureForChildren.width -= 2 * this._thickness;
  5639. this._measureForChildren.height -= 2 * this._thickness;
  5640. this._measureForChildren.left += this._thickness;
  5641. this._measureForChildren.top += this._thickness;
  5642. };
  5643. Ellipse.prototype._clipForChildren = function (context) {
  5644. _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);
  5645. context.clip();
  5646. };
  5647. return Ellipse;
  5648. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5649. /***/ }),
  5650. /***/ "./2D/controls/grid.ts":
  5651. /*!*****************************!*\
  5652. !*** ./2D/controls/grid.ts ***!
  5653. \*****************************/
  5654. /*! exports provided: Grid */
  5655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5656. "use strict";
  5657. __webpack_require__.r(__webpack_exports__);
  5658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5659. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5660. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5661. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5662. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5663. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5664. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5665. /**
  5666. * Class used to create a 2D grid container
  5667. */
  5668. var Grid = /** @class */ (function (_super) {
  5669. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5670. /**
  5671. * Creates a new Grid
  5672. * @param name defines control name
  5673. */
  5674. function Grid(name) {
  5675. var _this = _super.call(this, name) || this;
  5676. _this.name = name;
  5677. _this._rowDefinitions = new Array();
  5678. _this._columnDefinitions = new Array();
  5679. _this._cells = {};
  5680. _this._childControls = new Array();
  5681. return _this;
  5682. }
  5683. Object.defineProperty(Grid.prototype, "columnCount", {
  5684. /**
  5685. * Gets the number of columns
  5686. */
  5687. get: function () {
  5688. return this._columnDefinitions.length;
  5689. },
  5690. enumerable: true,
  5691. configurable: true
  5692. });
  5693. Object.defineProperty(Grid.prototype, "rowCount", {
  5694. /**
  5695. * Gets the number of rows
  5696. */
  5697. get: function () {
  5698. return this._rowDefinitions.length;
  5699. },
  5700. enumerable: true,
  5701. configurable: true
  5702. });
  5703. Object.defineProperty(Grid.prototype, "children", {
  5704. /** Gets the list of children */
  5705. get: function () {
  5706. return this._childControls;
  5707. },
  5708. enumerable: true,
  5709. configurable: true
  5710. });
  5711. Object.defineProperty(Grid.prototype, "cells", {
  5712. /** Gets the list of cells (e.g. the containers) */
  5713. get: function () {
  5714. return this._cells;
  5715. },
  5716. enumerable: true,
  5717. configurable: true
  5718. });
  5719. /**
  5720. * Gets the definition of a specific row
  5721. * @param index defines the index of the row
  5722. * @returns the row definition
  5723. */
  5724. Grid.prototype.getRowDefinition = function (index) {
  5725. if (index < 0 || index >= this._rowDefinitions.length) {
  5726. return null;
  5727. }
  5728. return this._rowDefinitions[index];
  5729. };
  5730. /**
  5731. * Gets the definition of a specific column
  5732. * @param index defines the index of the column
  5733. * @returns the column definition
  5734. */
  5735. Grid.prototype.getColumnDefinition = function (index) {
  5736. if (index < 0 || index >= this._columnDefinitions.length) {
  5737. return null;
  5738. }
  5739. return this._columnDefinitions[index];
  5740. };
  5741. /**
  5742. * Adds a new row to the grid
  5743. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5744. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5745. * @returns the current grid
  5746. */
  5747. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5748. if (isPixel === void 0) { isPixel = false; }
  5749. 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));
  5750. this._markAsDirty();
  5751. return this;
  5752. };
  5753. /**
  5754. * Adds a new column to the grid
  5755. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5756. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5757. * @returns the current grid
  5758. */
  5759. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5760. if (isPixel === void 0) { isPixel = false; }
  5761. 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));
  5762. this._markAsDirty();
  5763. return this;
  5764. };
  5765. /**
  5766. * Update a row definition
  5767. * @param index defines the index of the row to update
  5768. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5769. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5770. * @returns the current grid
  5771. */
  5772. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5773. if (isPixel === void 0) { isPixel = false; }
  5774. if (index < 0 || index >= this._rowDefinitions.length) {
  5775. return this;
  5776. }
  5777. var current = this._rowDefinitions[index];
  5778. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5779. return this;
  5780. }
  5781. 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);
  5782. this._markAsDirty();
  5783. return this;
  5784. };
  5785. /**
  5786. * Update a column definition
  5787. * @param index defines the index of the column to update
  5788. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5789. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5790. * @returns the current grid
  5791. */
  5792. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5793. if (isPixel === void 0) { isPixel = false; }
  5794. if (index < 0 || index >= this._columnDefinitions.length) {
  5795. return this;
  5796. }
  5797. var current = this._columnDefinitions[index];
  5798. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5799. return this;
  5800. }
  5801. 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);
  5802. this._markAsDirty();
  5803. return this;
  5804. };
  5805. /**
  5806. * Gets the list of children stored in a specific cell
  5807. * @param row defines the row to check
  5808. * @param column defines the column to check
  5809. * @returns the list of controls
  5810. */
  5811. Grid.prototype.getChildrenAt = function (row, column) {
  5812. var cell = this._cells[row + ":" + column];
  5813. if (!cell) {
  5814. return null;
  5815. }
  5816. return cell.children;
  5817. };
  5818. /**
  5819. * Gets a string representing the child cell info (row x column)
  5820. * @param child defines the control to get info from
  5821. * @returns a string containing the child cell info (row x column)
  5822. */
  5823. Grid.prototype.getChildCellInfo = function (child) {
  5824. return child._tag;
  5825. };
  5826. Grid.prototype._removeCell = function (cell, key) {
  5827. if (!cell) {
  5828. return;
  5829. }
  5830. _super.prototype.removeControl.call(this, cell);
  5831. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5832. var control = _a[_i];
  5833. var childIndex = this._childControls.indexOf(control);
  5834. if (childIndex !== -1) {
  5835. this._childControls.splice(childIndex, 1);
  5836. }
  5837. }
  5838. delete this._cells[key];
  5839. };
  5840. Grid.prototype._offsetCell = function (previousKey, key) {
  5841. if (!this._cells[key]) {
  5842. return;
  5843. }
  5844. this._cells[previousKey] = this._cells[key];
  5845. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5846. var control = _a[_i];
  5847. control._tag = previousKey;
  5848. }
  5849. delete this._cells[key];
  5850. };
  5851. /**
  5852. * Remove a column definition at specified index
  5853. * @param index defines the index of the column to remove
  5854. * @returns the current grid
  5855. */
  5856. Grid.prototype.removeColumnDefinition = function (index) {
  5857. if (index < 0 || index >= this._columnDefinitions.length) {
  5858. return this;
  5859. }
  5860. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5861. var key = x + ":" + index;
  5862. var cell = this._cells[key];
  5863. this._removeCell(cell, key);
  5864. }
  5865. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5866. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5867. var previousKey = x + ":" + (y - 1);
  5868. var key = x + ":" + y;
  5869. this._offsetCell(previousKey, key);
  5870. }
  5871. }
  5872. this._columnDefinitions.splice(index, 1);
  5873. this._markAsDirty();
  5874. return this;
  5875. };
  5876. /**
  5877. * Remove a row definition at specified index
  5878. * @param index defines the index of the row to remove
  5879. * @returns the current grid
  5880. */
  5881. Grid.prototype.removeRowDefinition = function (index) {
  5882. if (index < 0 || index >= this._rowDefinitions.length) {
  5883. return this;
  5884. }
  5885. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5886. var key = index + ":" + y;
  5887. var cell = this._cells[key];
  5888. this._removeCell(cell, key);
  5889. }
  5890. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5891. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5892. var previousKey = x - 1 + ":" + y;
  5893. var key = x + ":" + y;
  5894. this._offsetCell(previousKey, key);
  5895. }
  5896. }
  5897. this._rowDefinitions.splice(index, 1);
  5898. this._markAsDirty();
  5899. return this;
  5900. };
  5901. /**
  5902. * Adds a new control to the current grid
  5903. * @param control defines the control to add
  5904. * @param row defines the row where to add the control (0 by default)
  5905. * @param column defines the column where to add the control (0 by default)
  5906. * @returns the current grid
  5907. */
  5908. Grid.prototype.addControl = function (control, row, column) {
  5909. if (row === void 0) { row = 0; }
  5910. if (column === void 0) { column = 0; }
  5911. if (this._rowDefinitions.length === 0) {
  5912. // Add default row definition
  5913. this.addRowDefinition(1, false);
  5914. }
  5915. if (this._columnDefinitions.length === 0) {
  5916. // Add default column definition
  5917. this.addColumnDefinition(1, false);
  5918. }
  5919. if (this._childControls.indexOf(control) !== -1) {
  5920. 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");
  5921. return this;
  5922. }
  5923. var x = Math.min(row, this._rowDefinitions.length - 1);
  5924. var y = Math.min(column, this._columnDefinitions.length - 1);
  5925. var key = x + ":" + y;
  5926. var goodContainer = this._cells[key];
  5927. if (!goodContainer) {
  5928. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5929. this._cells[key] = goodContainer;
  5930. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5931. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5932. _super.prototype.addControl.call(this, goodContainer);
  5933. }
  5934. goodContainer.addControl(control);
  5935. this._childControls.push(control);
  5936. control._tag = key;
  5937. control.parent = this;
  5938. this._markAsDirty();
  5939. return this;
  5940. };
  5941. /**
  5942. * Removes a control from the current container
  5943. * @param control defines the control to remove
  5944. * @returns the current container
  5945. */
  5946. Grid.prototype.removeControl = function (control) {
  5947. var index = this._childControls.indexOf(control);
  5948. if (index !== -1) {
  5949. this._childControls.splice(index, 1);
  5950. }
  5951. var cell = this._cells[control._tag];
  5952. if (cell) {
  5953. cell.removeControl(control);
  5954. control._tag = null;
  5955. }
  5956. this._markAsDirty();
  5957. return this;
  5958. };
  5959. Grid.prototype._getTypeName = function () {
  5960. return "Grid";
  5961. };
  5962. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5963. var widths = [];
  5964. var heights = [];
  5965. var lefts = [];
  5966. var tops = [];
  5967. var availableWidth = this._currentMeasure.width;
  5968. var globalWidthPercentage = 0;
  5969. var availableHeight = this._currentMeasure.height;
  5970. var globalHeightPercentage = 0;
  5971. // Heights
  5972. var index = 0;
  5973. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5974. var value = _a[_i];
  5975. if (value.isPixel) {
  5976. var height = value.getValue(this._host);
  5977. availableHeight -= height;
  5978. heights[index] = height;
  5979. }
  5980. else {
  5981. globalHeightPercentage += value.internalValue;
  5982. }
  5983. index++;
  5984. }
  5985. var top = 0;
  5986. index = 0;
  5987. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  5988. var value = _c[_b];
  5989. tops.push(top);
  5990. if (!value.isPixel) {
  5991. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  5992. top += height;
  5993. heights[index] = height;
  5994. }
  5995. else {
  5996. top += value.getValue(this._host);
  5997. }
  5998. index++;
  5999. }
  6000. // Widths
  6001. index = 0;
  6002. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6003. var value = _e[_d];
  6004. if (value.isPixel) {
  6005. var width = value.getValue(this._host);
  6006. availableWidth -= width;
  6007. widths[index] = width;
  6008. }
  6009. else {
  6010. globalWidthPercentage += value.internalValue;
  6011. }
  6012. index++;
  6013. }
  6014. var left = 0;
  6015. index = 0;
  6016. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6017. var value = _g[_f];
  6018. lefts.push(left);
  6019. if (!value.isPixel) {
  6020. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6021. left += width;
  6022. widths[index] = width;
  6023. }
  6024. else {
  6025. left += value.getValue(this._host);
  6026. }
  6027. index++;
  6028. }
  6029. definitionCallback(lefts, tops, widths, heights);
  6030. };
  6031. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6032. var _this = this;
  6033. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6034. // Setting child sizes
  6035. for (var key in _this._cells) {
  6036. if (!_this._cells.hasOwnProperty(key)) {
  6037. continue;
  6038. }
  6039. var split = key.split(":");
  6040. var x = parseInt(split[0]);
  6041. var y = parseInt(split[1]);
  6042. var cell = _this._cells[key];
  6043. cell.left = lefts[y] + "px";
  6044. cell.top = tops[x] + "px";
  6045. cell.width = widths[y] + "px";
  6046. cell.height = heights[x] + "px";
  6047. cell._left.ignoreAdaptiveScaling = true;
  6048. cell._top.ignoreAdaptiveScaling = true;
  6049. cell._width.ignoreAdaptiveScaling = true;
  6050. cell._height.ignoreAdaptiveScaling = true;
  6051. }
  6052. });
  6053. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6054. };
  6055. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6056. for (var key in this._cells) {
  6057. if (!this._cells.hasOwnProperty(key)) {
  6058. continue;
  6059. }
  6060. var child = this._cells[key];
  6061. child._markMatrixAsDirty();
  6062. }
  6063. };
  6064. Grid.prototype._renderHighlightSpecific = function (context) {
  6065. var _this = this;
  6066. _super.prototype._renderHighlightSpecific.call(this, context);
  6067. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6068. // Columns
  6069. for (var index = 0; index < lefts.length; index++) {
  6070. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6071. context.beginPath();
  6072. context.moveTo(left, _this._currentMeasure.top);
  6073. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6074. context.stroke();
  6075. }
  6076. // Rows
  6077. for (var index = 0; index < tops.length; index++) {
  6078. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6079. context.beginPath();
  6080. context.moveTo(_this._currentMeasure.left, top_1);
  6081. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6082. context.stroke();
  6083. }
  6084. });
  6085. context.restore();
  6086. };
  6087. /** Releases associated resources */
  6088. Grid.prototype.dispose = function () {
  6089. _super.prototype.dispose.call(this);
  6090. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6091. var control = _a[_i];
  6092. control.dispose();
  6093. }
  6094. this._childControls = [];
  6095. };
  6096. return Grid;
  6097. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6098. /***/ }),
  6099. /***/ "./2D/controls/image.ts":
  6100. /*!******************************!*\
  6101. !*** ./2D/controls/image.ts ***!
  6102. \******************************/
  6103. /*! exports provided: Image */
  6104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6105. "use strict";
  6106. __webpack_require__.r(__webpack_exports__);
  6107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6108. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6109. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6110. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6111. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6112. /**
  6113. * Class used to create 2D images
  6114. */
  6115. var Image = /** @class */ (function (_super) {
  6116. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6117. /**
  6118. * Creates a new Image
  6119. * @param name defines the control name
  6120. * @param url defines the image url
  6121. */
  6122. function Image(name, url) {
  6123. if (url === void 0) { url = null; }
  6124. var _this = _super.call(this, name) || this;
  6125. _this.name = name;
  6126. _this._loaded = false;
  6127. _this._stretch = Image.STRETCH_FILL;
  6128. _this._autoScale = false;
  6129. _this._sourceLeft = 0;
  6130. _this._sourceTop = 0;
  6131. _this._sourceWidth = 0;
  6132. _this._sourceHeight = 0;
  6133. _this._cellWidth = 0;
  6134. _this._cellHeight = 0;
  6135. _this._cellId = -1;
  6136. _this._populateNinePatchSlicesFromImage = false;
  6137. /**
  6138. * Observable notified when the content is loaded
  6139. */
  6140. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6141. _this.source = url;
  6142. return _this;
  6143. }
  6144. Object.defineProperty(Image.prototype, "isLoaded", {
  6145. /**
  6146. * Gets a boolean indicating that the content is loaded
  6147. */
  6148. get: function () {
  6149. return this._loaded;
  6150. },
  6151. enumerable: true,
  6152. configurable: true
  6153. });
  6154. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6155. /**
  6156. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6157. */
  6158. get: function () {
  6159. return this._populateNinePatchSlicesFromImage;
  6160. },
  6161. set: function (value) {
  6162. if (this._populateNinePatchSlicesFromImage === value) {
  6163. return;
  6164. }
  6165. this._populateNinePatchSlicesFromImage = value;
  6166. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6167. this._extractNinePatchSliceDataFromImage();
  6168. }
  6169. },
  6170. enumerable: true,
  6171. configurable: true
  6172. });
  6173. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6174. /**
  6175. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6176. * Beware using this as this will comsume more memory as the image has to be stored twice
  6177. */
  6178. get: function () {
  6179. return this._detectPointerOnOpaqueOnly;
  6180. },
  6181. set: function (value) {
  6182. if (this._detectPointerOnOpaqueOnly === value) {
  6183. return;
  6184. }
  6185. this._detectPointerOnOpaqueOnly = value;
  6186. },
  6187. enumerable: true,
  6188. configurable: true
  6189. });
  6190. Object.defineProperty(Image.prototype, "sliceLeft", {
  6191. /**
  6192. * Gets or sets the left value for slicing (9-patch)
  6193. */
  6194. get: function () {
  6195. return this._sliceLeft;
  6196. },
  6197. set: function (value) {
  6198. if (this._sliceLeft === value) {
  6199. return;
  6200. }
  6201. this._sliceLeft = value;
  6202. this._markAsDirty();
  6203. },
  6204. enumerable: true,
  6205. configurable: true
  6206. });
  6207. Object.defineProperty(Image.prototype, "sliceRight", {
  6208. /**
  6209. * Gets or sets the right value for slicing (9-patch)
  6210. */
  6211. get: function () {
  6212. return this._sliceRight;
  6213. },
  6214. set: function (value) {
  6215. if (this._sliceRight === value) {
  6216. return;
  6217. }
  6218. this._sliceRight = value;
  6219. this._markAsDirty();
  6220. },
  6221. enumerable: true,
  6222. configurable: true
  6223. });
  6224. Object.defineProperty(Image.prototype, "sliceTop", {
  6225. /**
  6226. * Gets or sets the top value for slicing (9-patch)
  6227. */
  6228. get: function () {
  6229. return this._sliceTop;
  6230. },
  6231. set: function (value) {
  6232. if (this._sliceTop === value) {
  6233. return;
  6234. }
  6235. this._sliceTop = value;
  6236. this._markAsDirty();
  6237. },
  6238. enumerable: true,
  6239. configurable: true
  6240. });
  6241. Object.defineProperty(Image.prototype, "sliceBottom", {
  6242. /**
  6243. * Gets or sets the bottom value for slicing (9-patch)
  6244. */
  6245. get: function () {
  6246. return this._sliceBottom;
  6247. },
  6248. set: function (value) {
  6249. if (this._sliceBottom === value) {
  6250. return;
  6251. }
  6252. this._sliceBottom = value;
  6253. this._markAsDirty();
  6254. },
  6255. enumerable: true,
  6256. configurable: true
  6257. });
  6258. Object.defineProperty(Image.prototype, "sourceLeft", {
  6259. /**
  6260. * Gets or sets the left coordinate in the source image
  6261. */
  6262. get: function () {
  6263. return this._sourceLeft;
  6264. },
  6265. set: function (value) {
  6266. if (this._sourceLeft === value) {
  6267. return;
  6268. }
  6269. this._sourceLeft = value;
  6270. this._markAsDirty();
  6271. },
  6272. enumerable: true,
  6273. configurable: true
  6274. });
  6275. Object.defineProperty(Image.prototype, "sourceTop", {
  6276. /**
  6277. * Gets or sets the top coordinate in the source image
  6278. */
  6279. get: function () {
  6280. return this._sourceTop;
  6281. },
  6282. set: function (value) {
  6283. if (this._sourceTop === value) {
  6284. return;
  6285. }
  6286. this._sourceTop = value;
  6287. this._markAsDirty();
  6288. },
  6289. enumerable: true,
  6290. configurable: true
  6291. });
  6292. Object.defineProperty(Image.prototype, "sourceWidth", {
  6293. /**
  6294. * Gets or sets the width to capture in the source image
  6295. */
  6296. get: function () {
  6297. return this._sourceWidth;
  6298. },
  6299. set: function (value) {
  6300. if (this._sourceWidth === value) {
  6301. return;
  6302. }
  6303. this._sourceWidth = value;
  6304. this._markAsDirty();
  6305. },
  6306. enumerable: true,
  6307. configurable: true
  6308. });
  6309. Object.defineProperty(Image.prototype, "sourceHeight", {
  6310. /**
  6311. * Gets or sets the height to capture in the source image
  6312. */
  6313. get: function () {
  6314. return this._sourceHeight;
  6315. },
  6316. set: function (value) {
  6317. if (this._sourceHeight === value) {
  6318. return;
  6319. }
  6320. this._sourceHeight = value;
  6321. this._markAsDirty();
  6322. },
  6323. enumerable: true,
  6324. configurable: true
  6325. });
  6326. Object.defineProperty(Image.prototype, "autoScale", {
  6327. /**
  6328. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6329. * @see http://doc.babylonjs.com/how_to/gui#image
  6330. */
  6331. get: function () {
  6332. return this._autoScale;
  6333. },
  6334. set: function (value) {
  6335. if (this._autoScale === value) {
  6336. return;
  6337. }
  6338. this._autoScale = value;
  6339. if (value && this._loaded) {
  6340. this.synchronizeSizeWithContent();
  6341. }
  6342. },
  6343. enumerable: true,
  6344. configurable: true
  6345. });
  6346. Object.defineProperty(Image.prototype, "stretch", {
  6347. /** Gets or sets the streching mode used by the image */
  6348. get: function () {
  6349. return this._stretch;
  6350. },
  6351. set: function (value) {
  6352. if (this._stretch === value) {
  6353. return;
  6354. }
  6355. this._stretch = value;
  6356. this._markAsDirty();
  6357. },
  6358. enumerable: true,
  6359. configurable: true
  6360. });
  6361. Object.defineProperty(Image.prototype, "domImage", {
  6362. get: function () {
  6363. return this._domImage;
  6364. },
  6365. /**
  6366. * Gets or sets the internal DOM image used to render the control
  6367. */
  6368. set: function (value) {
  6369. var _this = this;
  6370. this._domImage = value;
  6371. this._loaded = false;
  6372. if (this._domImage.width) {
  6373. this._onImageLoaded();
  6374. }
  6375. else {
  6376. this._domImage.onload = function () {
  6377. _this._onImageLoaded();
  6378. };
  6379. }
  6380. },
  6381. enumerable: true,
  6382. configurable: true
  6383. });
  6384. Image.prototype._onImageLoaded = function () {
  6385. this._imageWidth = this._domImage.width;
  6386. this._imageHeight = this._domImage.height;
  6387. this._loaded = true;
  6388. if (this._populateNinePatchSlicesFromImage) {
  6389. this._extractNinePatchSliceDataFromImage();
  6390. }
  6391. if (this._autoScale) {
  6392. this.synchronizeSizeWithContent();
  6393. }
  6394. this.onImageLoadedObservable.notifyObservers(this);
  6395. this._markAsDirty();
  6396. };
  6397. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6398. if (!Image._WorkingCanvas) {
  6399. Image._WorkingCanvas = document.createElement('canvas');
  6400. }
  6401. var canvas = Image._WorkingCanvas;
  6402. var context = canvas.getContext('2d');
  6403. var width = this._domImage.width;
  6404. var height = this._domImage.height;
  6405. canvas.width = width;
  6406. canvas.height = height;
  6407. context.drawImage(this._domImage, 0, 0, width, height);
  6408. var imageData = context.getImageData(0, 0, width, height);
  6409. // Left and right
  6410. this._sliceLeft = -1;
  6411. this._sliceRight = -1;
  6412. for (var x = 0; x < width; x++) {
  6413. var alpha = imageData.data[x * 4 + 3];
  6414. if (alpha > 127 && this._sliceLeft === -1) {
  6415. this._sliceLeft = x;
  6416. continue;
  6417. }
  6418. if (alpha < 127 && this._sliceLeft > -1) {
  6419. this._sliceRight = x;
  6420. break;
  6421. }
  6422. }
  6423. // top and bottom
  6424. this._sliceTop = -1;
  6425. this._sliceBottom = -1;
  6426. for (var y = 0; y < height; y++) {
  6427. var alpha = imageData.data[y * width * 4 + 3];
  6428. if (alpha > 127 && this._sliceTop === -1) {
  6429. this._sliceTop = y;
  6430. continue;
  6431. }
  6432. if (alpha < 127 && this._sliceTop > -1) {
  6433. this._sliceBottom = y;
  6434. break;
  6435. }
  6436. }
  6437. };
  6438. Object.defineProperty(Image.prototype, "source", {
  6439. /**
  6440. * Gets or sets image source url
  6441. */
  6442. set: function (value) {
  6443. var _this = this;
  6444. if (this._source === value) {
  6445. return;
  6446. }
  6447. this._loaded = false;
  6448. this._source = value;
  6449. this._domImage = document.createElement("img");
  6450. this._domImage.onload = function () {
  6451. _this._onImageLoaded();
  6452. };
  6453. if (value) {
  6454. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6455. this._domImage.src = value;
  6456. }
  6457. },
  6458. enumerable: true,
  6459. configurable: true
  6460. });
  6461. Object.defineProperty(Image.prototype, "cellWidth", {
  6462. /**
  6463. * Gets or sets the cell width to use when animation sheet is enabled
  6464. * @see http://doc.babylonjs.com/how_to/gui#image
  6465. */
  6466. get: function () {
  6467. return this._cellWidth;
  6468. },
  6469. set: function (value) {
  6470. if (this._cellWidth === value) {
  6471. return;
  6472. }
  6473. this._cellWidth = value;
  6474. this._markAsDirty();
  6475. },
  6476. enumerable: true,
  6477. configurable: true
  6478. });
  6479. Object.defineProperty(Image.prototype, "cellHeight", {
  6480. /**
  6481. * Gets or sets the cell height to use when animation sheet is enabled
  6482. * @see http://doc.babylonjs.com/how_to/gui#image
  6483. */
  6484. get: function () {
  6485. return this._cellHeight;
  6486. },
  6487. set: function (value) {
  6488. if (this._cellHeight === value) {
  6489. return;
  6490. }
  6491. this._cellHeight = value;
  6492. this._markAsDirty();
  6493. },
  6494. enumerable: true,
  6495. configurable: true
  6496. });
  6497. Object.defineProperty(Image.prototype, "cellId", {
  6498. /**
  6499. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6500. * @see http://doc.babylonjs.com/how_to/gui#image
  6501. */
  6502. get: function () {
  6503. return this._cellId;
  6504. },
  6505. set: function (value) {
  6506. if (this._cellId === value) {
  6507. return;
  6508. }
  6509. this._cellId = value;
  6510. this._markAsDirty();
  6511. },
  6512. enumerable: true,
  6513. configurable: true
  6514. });
  6515. /**
  6516. * Tests if a given coordinates belong to the current control
  6517. * @param x defines x coordinate to test
  6518. * @param y defines y coordinate to test
  6519. * @returns true if the coordinates are inside the control
  6520. */
  6521. Image.prototype.contains = function (x, y) {
  6522. if (!_super.prototype.contains.call(this, x, y)) {
  6523. return false;
  6524. }
  6525. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6526. return true;
  6527. }
  6528. var canvas = Image._WorkingCanvas;
  6529. var context = canvas.getContext("2d");
  6530. var width = this._currentMeasure.width | 0;
  6531. var height = this._currentMeasure.height | 0;
  6532. var imageData = context.getImageData(0, 0, width, height).data;
  6533. x = (x - this._currentMeasure.left) | 0;
  6534. y = (y - this._currentMeasure.top) | 0;
  6535. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6536. return pickedPixel > 0;
  6537. };
  6538. Image.prototype._getTypeName = function () {
  6539. return "Image";
  6540. };
  6541. /** Force the control to synchronize with its content */
  6542. Image.prototype.synchronizeSizeWithContent = function () {
  6543. if (!this._loaded) {
  6544. return;
  6545. }
  6546. this.width = this._domImage.width + "px";
  6547. this.height = this._domImage.height + "px";
  6548. };
  6549. Image.prototype._processMeasures = function (parentMeasure, context) {
  6550. if (this._loaded) {
  6551. switch (this._stretch) {
  6552. case Image.STRETCH_NONE:
  6553. break;
  6554. case Image.STRETCH_FILL:
  6555. break;
  6556. case Image.STRETCH_UNIFORM:
  6557. break;
  6558. case Image.STRETCH_NINE_PATCH:
  6559. break;
  6560. case Image.STRETCH_EXTEND:
  6561. if (this._autoScale) {
  6562. this.synchronizeSizeWithContent();
  6563. }
  6564. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6565. this.parent.adaptWidthToChildren = true;
  6566. this.parent.adaptHeightToChildren = true;
  6567. }
  6568. break;
  6569. }
  6570. }
  6571. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6572. };
  6573. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6574. if (!this._detectPointerOnOpaqueOnly) {
  6575. return;
  6576. }
  6577. if (!Image._WorkingCanvas) {
  6578. Image._WorkingCanvas = document.createElement('canvas');
  6579. }
  6580. var canvas = Image._WorkingCanvas;
  6581. var width = this._currentMeasure.width;
  6582. var height = this._currentMeasure.height;
  6583. var context = canvas.getContext("2d");
  6584. canvas.width = width;
  6585. canvas.height = height;
  6586. context.clearRect(0, 0, width, height);
  6587. };
  6588. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6589. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6590. if (!this._detectPointerOnOpaqueOnly) {
  6591. return;
  6592. }
  6593. var canvas = Image._WorkingCanvas;
  6594. context = canvas.getContext("2d");
  6595. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6596. };
  6597. Image.prototype._draw = function (context) {
  6598. context.save();
  6599. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6600. context.shadowColor = this.shadowColor;
  6601. context.shadowBlur = this.shadowBlur;
  6602. context.shadowOffsetX = this.shadowOffsetX;
  6603. context.shadowOffsetY = this.shadowOffsetY;
  6604. }
  6605. var x, y, width, height;
  6606. if (this.cellId == -1) {
  6607. x = this._sourceLeft;
  6608. y = this._sourceTop;
  6609. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6610. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6611. }
  6612. else {
  6613. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6614. var column = (this.cellId / rowCount) >> 0;
  6615. var row = this.cellId % rowCount;
  6616. x = this.cellWidth * row;
  6617. y = this.cellHeight * column;
  6618. width = this.cellWidth;
  6619. height = this.cellHeight;
  6620. }
  6621. this._prepareWorkingCanvasForOpaqueDetection();
  6622. this._applyStates(context);
  6623. if (this._loaded) {
  6624. switch (this._stretch) {
  6625. case Image.STRETCH_NONE:
  6626. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6627. break;
  6628. case Image.STRETCH_FILL:
  6629. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6630. break;
  6631. case Image.STRETCH_UNIFORM:
  6632. var hRatio = this._currentMeasure.width / width;
  6633. var vRatio = this._currentMeasure.height / height;
  6634. var ratio = Math.min(hRatio, vRatio);
  6635. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6636. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6637. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6638. break;
  6639. case Image.STRETCH_EXTEND:
  6640. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6641. break;
  6642. case Image.STRETCH_NINE_PATCH:
  6643. this._renderNinePatch(context);
  6644. break;
  6645. }
  6646. }
  6647. context.restore();
  6648. };
  6649. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6650. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6651. };
  6652. Image.prototype._renderNinePatch = function (context) {
  6653. var height = this._imageHeight;
  6654. var leftWidth = this._sliceLeft;
  6655. var topHeight = this._sliceTop;
  6656. var bottomHeight = this._imageHeight - this._sliceBottom;
  6657. var rightWidth = this._imageWidth - this._sliceRight;
  6658. var left = 0;
  6659. var top = 0;
  6660. if (this._populateNinePatchSlicesFromImage) {
  6661. left = 1;
  6662. top = 1;
  6663. height -= 2;
  6664. leftWidth -= 1;
  6665. topHeight -= 1;
  6666. bottomHeight -= 1;
  6667. rightWidth -= 1;
  6668. }
  6669. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6670. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6671. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6672. // Corners
  6673. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6674. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6675. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6676. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6677. // Center
  6678. 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);
  6679. // Borders
  6680. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6681. 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);
  6682. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6683. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6684. };
  6685. Image.prototype.dispose = function () {
  6686. _super.prototype.dispose.call(this);
  6687. this.onImageLoadedObservable.clear();
  6688. };
  6689. Image._WorkingCanvas = null;
  6690. // Static
  6691. /** STRETCH_NONE */
  6692. Image.STRETCH_NONE = 0;
  6693. /** STRETCH_FILL */
  6694. Image.STRETCH_FILL = 1;
  6695. /** STRETCH_UNIFORM */
  6696. Image.STRETCH_UNIFORM = 2;
  6697. /** STRETCH_EXTEND */
  6698. Image.STRETCH_EXTEND = 3;
  6699. /** NINE_PATCH */
  6700. Image.STRETCH_NINE_PATCH = 4;
  6701. return Image;
  6702. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6703. /***/ }),
  6704. /***/ "./2D/controls/index.ts":
  6705. /*!******************************!*\
  6706. !*** ./2D/controls/index.ts ***!
  6707. \******************************/
  6708. /*! 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 */
  6709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6710. "use strict";
  6711. __webpack_require__.r(__webpack_exports__);
  6712. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6714. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6716. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6718. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6720. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6722. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6724. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6726. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6728. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6730. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6732. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6734. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6736. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6738. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6740. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6746. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6748. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6751. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6754. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6756. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6758. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6760. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6762. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6764. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6766. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6768. /***/ }),
  6769. /***/ "./2D/controls/inputPassword.ts":
  6770. /*!**************************************!*\
  6771. !*** ./2D/controls/inputPassword.ts ***!
  6772. \**************************************/
  6773. /*! exports provided: InputPassword */
  6774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6775. "use strict";
  6776. __webpack_require__.r(__webpack_exports__);
  6777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6778. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6779. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6780. /**
  6781. * Class used to create a password control
  6782. */
  6783. var InputPassword = /** @class */ (function (_super) {
  6784. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6785. function InputPassword() {
  6786. return _super !== null && _super.apply(this, arguments) || this;
  6787. }
  6788. InputPassword.prototype._beforeRenderText = function (text) {
  6789. var txt = "";
  6790. for (var i = 0; i < text.length; i++) {
  6791. txt += "\u2022";
  6792. }
  6793. return txt;
  6794. };
  6795. return InputPassword;
  6796. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6797. /***/ }),
  6798. /***/ "./2D/controls/inputText.ts":
  6799. /*!**********************************!*\
  6800. !*** ./2D/controls/inputText.ts ***!
  6801. \**********************************/
  6802. /*! exports provided: InputText */
  6803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6804. "use strict";
  6805. __webpack_require__.r(__webpack_exports__);
  6806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6807. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6808. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6809. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6810. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6811. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6812. /**
  6813. * Class used to create input text control
  6814. */
  6815. var InputText = /** @class */ (function (_super) {
  6816. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6817. /**
  6818. * Creates a new InputText
  6819. * @param name defines the control name
  6820. * @param text defines the text of the control
  6821. */
  6822. function InputText(name, text) {
  6823. if (text === void 0) { text = ""; }
  6824. var _this = _super.call(this, name) || this;
  6825. _this.name = name;
  6826. _this._text = "";
  6827. _this._placeholderText = "";
  6828. _this._background = "#222222";
  6829. _this._focusedBackground = "#000000";
  6830. _this._focusedColor = "white";
  6831. _this._placeholderColor = "gray";
  6832. _this._thickness = 1;
  6833. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6834. _this._autoStretchWidth = true;
  6835. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6836. _this._isFocused = false;
  6837. _this._blinkIsEven = false;
  6838. _this._cursorOffset = 0;
  6839. _this._deadKey = false;
  6840. _this._addKey = true;
  6841. _this._currentKey = "";
  6842. _this._isTextHighlightOn = false;
  6843. _this._textHighlightColor = "#d5e0ff";
  6844. _this._highligherOpacity = 0.4;
  6845. _this._highlightedText = "";
  6846. _this._startHighlightIndex = 0;
  6847. _this._endHighlightIndex = 0;
  6848. _this._cursorIndex = -1;
  6849. _this._onFocusSelectAll = false;
  6850. _this._isPointerDown = false;
  6851. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6852. _this.promptMessage = "Please enter text:";
  6853. /** Force disable prompt on mobile device */
  6854. _this.disableMobilePrompt = false;
  6855. /** Observable raised when the text changes */
  6856. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6857. /** Observable raised just before an entered character is to be added */
  6858. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6859. /** Observable raised when the control gets the focus */
  6860. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6861. /** Observable raised when the control loses the focus */
  6862. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6863. /**Observable raised when the text is highlighted */
  6864. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6865. /**Observable raised when copy event is triggered */
  6866. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6867. /** Observable raised when cut event is triggered */
  6868. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6869. /** Observable raised when paste event is triggered */
  6870. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6871. /** Observable raised when a key event was processed */
  6872. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6873. _this.text = text;
  6874. _this.isPointerBlocker = true;
  6875. return _this;
  6876. }
  6877. Object.defineProperty(InputText.prototype, "maxWidth", {
  6878. /** Gets or sets the maximum width allowed by the control */
  6879. get: function () {
  6880. return this._maxWidth.toString(this._host);
  6881. },
  6882. set: function (value) {
  6883. if (this._maxWidth.toString(this._host) === value) {
  6884. return;
  6885. }
  6886. if (this._maxWidth.fromString(value)) {
  6887. this._markAsDirty();
  6888. }
  6889. },
  6890. enumerable: true,
  6891. configurable: true
  6892. });
  6893. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6894. /** Gets the maximum width allowed by the control in pixels */
  6895. get: function () {
  6896. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6897. },
  6898. enumerable: true,
  6899. configurable: true
  6900. });
  6901. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6902. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6903. get: function () {
  6904. return this._highligherOpacity;
  6905. },
  6906. set: function (value) {
  6907. if (this._highligherOpacity === value) {
  6908. return;
  6909. }
  6910. this._highligherOpacity = value;
  6911. this._markAsDirty();
  6912. },
  6913. enumerable: true,
  6914. configurable: true
  6915. });
  6916. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6917. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6918. get: function () {
  6919. return this._onFocusSelectAll;
  6920. },
  6921. set: function (value) {
  6922. if (this._onFocusSelectAll === value) {
  6923. return;
  6924. }
  6925. this._onFocusSelectAll = value;
  6926. this._markAsDirty();
  6927. },
  6928. enumerable: true,
  6929. configurable: true
  6930. });
  6931. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6932. /** Gets or sets the text hightlight color */
  6933. get: function () {
  6934. return this._textHighlightColor;
  6935. },
  6936. set: function (value) {
  6937. if (this._textHighlightColor === value) {
  6938. return;
  6939. }
  6940. this._textHighlightColor = value;
  6941. this._markAsDirty();
  6942. },
  6943. enumerable: true,
  6944. configurable: true
  6945. });
  6946. Object.defineProperty(InputText.prototype, "margin", {
  6947. /** Gets or sets control margin */
  6948. get: function () {
  6949. return this._margin.toString(this._host);
  6950. },
  6951. set: function (value) {
  6952. if (this._margin.toString(this._host) === value) {
  6953. return;
  6954. }
  6955. if (this._margin.fromString(value)) {
  6956. this._markAsDirty();
  6957. }
  6958. },
  6959. enumerable: true,
  6960. configurable: true
  6961. });
  6962. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6963. /** Gets control margin in pixels */
  6964. get: function () {
  6965. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6966. },
  6967. enumerable: true,
  6968. configurable: true
  6969. });
  6970. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6971. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6972. get: function () {
  6973. return this._autoStretchWidth;
  6974. },
  6975. set: function (value) {
  6976. if (this._autoStretchWidth === value) {
  6977. return;
  6978. }
  6979. this._autoStretchWidth = value;
  6980. this._markAsDirty();
  6981. },
  6982. enumerable: true,
  6983. configurable: true
  6984. });
  6985. Object.defineProperty(InputText.prototype, "thickness", {
  6986. /** Gets or sets border thickness */
  6987. get: function () {
  6988. return this._thickness;
  6989. },
  6990. set: function (value) {
  6991. if (this._thickness === value) {
  6992. return;
  6993. }
  6994. this._thickness = value;
  6995. this._markAsDirty();
  6996. },
  6997. enumerable: true,
  6998. configurable: true
  6999. });
  7000. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7001. /** Gets or sets the background color when focused */
  7002. get: function () {
  7003. return this._focusedBackground;
  7004. },
  7005. set: function (value) {
  7006. if (this._focusedBackground === value) {
  7007. return;
  7008. }
  7009. this._focusedBackground = value;
  7010. this._markAsDirty();
  7011. },
  7012. enumerable: true,
  7013. configurable: true
  7014. });
  7015. Object.defineProperty(InputText.prototype, "focusedColor", {
  7016. /** Gets or sets the background color when focused */
  7017. get: function () {
  7018. return this._focusedColor;
  7019. },
  7020. set: function (value) {
  7021. if (this._focusedColor === value) {
  7022. return;
  7023. }
  7024. this._focusedColor = value;
  7025. this._markAsDirty();
  7026. },
  7027. enumerable: true,
  7028. configurable: true
  7029. });
  7030. Object.defineProperty(InputText.prototype, "background", {
  7031. /** Gets or sets the background color */
  7032. get: function () {
  7033. return this._background;
  7034. },
  7035. set: function (value) {
  7036. if (this._background === value) {
  7037. return;
  7038. }
  7039. this._background = value;
  7040. this._markAsDirty();
  7041. },
  7042. enumerable: true,
  7043. configurable: true
  7044. });
  7045. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7046. /** Gets or sets the placeholder color */
  7047. get: function () {
  7048. return this._placeholderColor;
  7049. },
  7050. set: function (value) {
  7051. if (this._placeholderColor === value) {
  7052. return;
  7053. }
  7054. this._placeholderColor = value;
  7055. this._markAsDirty();
  7056. },
  7057. enumerable: true,
  7058. configurable: true
  7059. });
  7060. Object.defineProperty(InputText.prototype, "placeholderText", {
  7061. /** Gets or sets the text displayed when the control is empty */
  7062. get: function () {
  7063. return this._placeholderText;
  7064. },
  7065. set: function (value) {
  7066. if (this._placeholderText === value) {
  7067. return;
  7068. }
  7069. this._placeholderText = value;
  7070. this._markAsDirty();
  7071. },
  7072. enumerable: true,
  7073. configurable: true
  7074. });
  7075. Object.defineProperty(InputText.prototype, "deadKey", {
  7076. /** Gets or sets the dead key flag */
  7077. get: function () {
  7078. return this._deadKey;
  7079. },
  7080. set: function (flag) {
  7081. this._deadKey = flag;
  7082. },
  7083. enumerable: true,
  7084. configurable: true
  7085. });
  7086. Object.defineProperty(InputText.prototype, "highlightedText", {
  7087. /** Gets or sets the highlight text */
  7088. get: function () {
  7089. return this._highlightedText;
  7090. },
  7091. set: function (text) {
  7092. if (this._highlightedText === text) {
  7093. return;
  7094. }
  7095. this._highlightedText = text;
  7096. this._markAsDirty();
  7097. },
  7098. enumerable: true,
  7099. configurable: true
  7100. });
  7101. Object.defineProperty(InputText.prototype, "addKey", {
  7102. /** Gets or sets if the current key should be added */
  7103. get: function () {
  7104. return this._addKey;
  7105. },
  7106. set: function (flag) {
  7107. this._addKey = flag;
  7108. },
  7109. enumerable: true,
  7110. configurable: true
  7111. });
  7112. Object.defineProperty(InputText.prototype, "currentKey", {
  7113. /** Gets or sets the value of the current key being entered */
  7114. get: function () {
  7115. return this._currentKey;
  7116. },
  7117. set: function (key) {
  7118. this._currentKey = key;
  7119. },
  7120. enumerable: true,
  7121. configurable: true
  7122. });
  7123. Object.defineProperty(InputText.prototype, "text", {
  7124. /** Gets or sets the text displayed in the control */
  7125. get: function () {
  7126. return this._text;
  7127. },
  7128. set: function (value) {
  7129. var valueAsString = value.toString(); // Forcing convertion
  7130. if (this._text === valueAsString) {
  7131. return;
  7132. }
  7133. this._text = valueAsString;
  7134. this._markAsDirty();
  7135. this.onTextChangedObservable.notifyObservers(this);
  7136. },
  7137. enumerable: true,
  7138. configurable: true
  7139. });
  7140. Object.defineProperty(InputText.prototype, "width", {
  7141. /** Gets or sets control width */
  7142. get: function () {
  7143. return this._width.toString(this._host);
  7144. },
  7145. set: function (value) {
  7146. if (this._width.toString(this._host) === value) {
  7147. return;
  7148. }
  7149. if (this._width.fromString(value)) {
  7150. this._markAsDirty();
  7151. }
  7152. this.autoStretchWidth = false;
  7153. },
  7154. enumerable: true,
  7155. configurable: true
  7156. });
  7157. /** @hidden */
  7158. InputText.prototype.onBlur = function () {
  7159. this._isFocused = false;
  7160. this._scrollLeft = null;
  7161. this._cursorOffset = 0;
  7162. clearTimeout(this._blinkTimeout);
  7163. this._markAsDirty();
  7164. this.onBlurObservable.notifyObservers(this);
  7165. this._host.unRegisterClipboardEvents();
  7166. if (this._onClipboardObserver) {
  7167. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7168. }
  7169. var scene = this._host.getScene();
  7170. if (this._onPointerDblTapObserver && scene) {
  7171. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7172. }
  7173. };
  7174. /** @hidden */
  7175. InputText.prototype.onFocus = function () {
  7176. var _this = this;
  7177. if (!this._isEnabled) {
  7178. return;
  7179. }
  7180. this._scrollLeft = null;
  7181. this._isFocused = true;
  7182. this._blinkIsEven = false;
  7183. this._cursorOffset = 0;
  7184. this._markAsDirty();
  7185. this.onFocusObservable.notifyObservers(this);
  7186. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7187. var value = prompt(this.promptMessage);
  7188. if (value !== null) {
  7189. this.text = value;
  7190. }
  7191. this._host.focusedControl = null;
  7192. return;
  7193. }
  7194. this._host.registerClipboardEvents();
  7195. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7196. // process clipboard event, can be configured.
  7197. switch (clipboardInfo.type) {
  7198. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7199. _this._onCopyText(clipboardInfo.event);
  7200. _this.onTextCopyObservable.notifyObservers(_this);
  7201. break;
  7202. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7203. _this._onCutText(clipboardInfo.event);
  7204. _this.onTextCutObservable.notifyObservers(_this);
  7205. break;
  7206. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7207. _this._onPasteText(clipboardInfo.event);
  7208. _this.onTextPasteObservable.notifyObservers(_this);
  7209. break;
  7210. default: return;
  7211. }
  7212. });
  7213. var scene = this._host.getScene();
  7214. if (scene) {
  7215. //register the pointer double tap event
  7216. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7217. if (!_this._isFocused) {
  7218. return;
  7219. }
  7220. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7221. _this._processDblClick(pointerInfo);
  7222. }
  7223. });
  7224. }
  7225. if (this._onFocusSelectAll) {
  7226. this._selectAllText();
  7227. }
  7228. };
  7229. InputText.prototype._getTypeName = function () {
  7230. return "InputText";
  7231. };
  7232. /**
  7233. * Function called to get the list of controls that should not steal the focus from this control
  7234. * @returns an array of controls
  7235. */
  7236. InputText.prototype.keepsFocusWith = function () {
  7237. if (!this._connectedVirtualKeyboard) {
  7238. return null;
  7239. }
  7240. return [this._connectedVirtualKeyboard];
  7241. };
  7242. /** @hidden */
  7243. InputText.prototype.processKey = function (keyCode, key, evt) {
  7244. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7245. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7246. return;
  7247. }
  7248. //select all
  7249. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7250. this._selectAllText();
  7251. evt.preventDefault();
  7252. return;
  7253. }
  7254. // Specific cases
  7255. switch (keyCode) {
  7256. case 32: //SPACE
  7257. key = " "; //ie11 key for space is "Spacebar"
  7258. break;
  7259. case 191: //SLASH
  7260. if (evt) {
  7261. evt.preventDefault();
  7262. }
  7263. break;
  7264. case 8: // BACKSPACE
  7265. if (this._text && this._text.length > 0) {
  7266. //delete the highlighted text
  7267. if (this._isTextHighlightOn) {
  7268. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7269. this._isTextHighlightOn = false;
  7270. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7271. this._blinkIsEven = false;
  7272. if (evt) {
  7273. evt.preventDefault();
  7274. }
  7275. return;
  7276. }
  7277. //delete single character
  7278. if (this._cursorOffset === 0) {
  7279. this.text = this._text.substr(0, this._text.length - 1);
  7280. }
  7281. else {
  7282. var deletePosition = this._text.length - this._cursorOffset;
  7283. if (deletePosition > 0) {
  7284. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7285. }
  7286. }
  7287. }
  7288. if (evt) {
  7289. evt.preventDefault();
  7290. }
  7291. return;
  7292. case 46: // DELETE
  7293. if (this._isTextHighlightOn) {
  7294. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7295. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7296. while (decrementor > 0 && this._cursorOffset > 0) {
  7297. this._cursorOffset--;
  7298. }
  7299. this._isTextHighlightOn = false;
  7300. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7301. if (evt) {
  7302. evt.preventDefault();
  7303. }
  7304. return;
  7305. }
  7306. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7307. var deletePosition = this._text.length - this._cursorOffset;
  7308. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7309. this._cursorOffset--;
  7310. }
  7311. if (evt) {
  7312. evt.preventDefault();
  7313. }
  7314. return;
  7315. case 13: // RETURN
  7316. this._host.focusedControl = null;
  7317. this._isTextHighlightOn = false;
  7318. return;
  7319. case 35: // END
  7320. this._cursorOffset = 0;
  7321. this._blinkIsEven = false;
  7322. this._isTextHighlightOn = false;
  7323. this._markAsDirty();
  7324. return;
  7325. case 36: // HOME
  7326. this._cursorOffset = this._text.length;
  7327. this._blinkIsEven = false;
  7328. this._isTextHighlightOn = false;
  7329. this._markAsDirty();
  7330. return;
  7331. case 37: // LEFT
  7332. this._cursorOffset++;
  7333. if (this._cursorOffset > this._text.length) {
  7334. this._cursorOffset = this._text.length;
  7335. }
  7336. if (evt && evt.shiftKey) {
  7337. // update the cursor
  7338. this._blinkIsEven = false;
  7339. // shift + ctrl/cmd + <-
  7340. if (evt.ctrlKey || evt.metaKey) {
  7341. if (!this._isTextHighlightOn) {
  7342. if (this._text.length === this._cursorOffset) {
  7343. return;
  7344. }
  7345. else {
  7346. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7347. }
  7348. }
  7349. this._startHighlightIndex = 0;
  7350. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7351. this._cursorOffset = this._text.length;
  7352. this._isTextHighlightOn = true;
  7353. this._markAsDirty();
  7354. return;
  7355. }
  7356. //store the starting point
  7357. if (!this._isTextHighlightOn) {
  7358. this._isTextHighlightOn = true;
  7359. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7360. }
  7361. //if text is already highlighted
  7362. else if (this._cursorIndex === -1) {
  7363. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7364. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7365. }
  7366. //set the highlight indexes
  7367. if (this._cursorIndex < this._cursorOffset) {
  7368. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7369. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7370. }
  7371. else if (this._cursorIndex > this._cursorOffset) {
  7372. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7373. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7374. }
  7375. else {
  7376. this._isTextHighlightOn = false;
  7377. }
  7378. this._markAsDirty();
  7379. return;
  7380. }
  7381. if (this._isTextHighlightOn) {
  7382. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7383. this._isTextHighlightOn = false;
  7384. }
  7385. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7386. this._cursorOffset = this.text.length;
  7387. evt.preventDefault();
  7388. }
  7389. this._blinkIsEven = false;
  7390. this._isTextHighlightOn = false;
  7391. this._cursorIndex = -1;
  7392. this._markAsDirty();
  7393. return;
  7394. case 39: // RIGHT
  7395. this._cursorOffset--;
  7396. if (this._cursorOffset < 0) {
  7397. this._cursorOffset = 0;
  7398. }
  7399. if (evt && evt.shiftKey) {
  7400. //update the cursor
  7401. this._blinkIsEven = false;
  7402. //shift + ctrl/cmd + ->
  7403. if (evt.ctrlKey || evt.metaKey) {
  7404. if (!this._isTextHighlightOn) {
  7405. if (this._cursorOffset === 0) {
  7406. return;
  7407. }
  7408. else {
  7409. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7410. }
  7411. }
  7412. this._endHighlightIndex = this._text.length;
  7413. this._isTextHighlightOn = true;
  7414. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7415. this._cursorOffset = 0;
  7416. this._markAsDirty();
  7417. return;
  7418. }
  7419. if (!this._isTextHighlightOn) {
  7420. this._isTextHighlightOn = true;
  7421. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7422. }
  7423. //if text is already highlighted
  7424. else if (this._cursorIndex === -1) {
  7425. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7426. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7427. }
  7428. //set the highlight indexes
  7429. if (this._cursorIndex < this._cursorOffset) {
  7430. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7431. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7432. }
  7433. else if (this._cursorIndex > this._cursorOffset) {
  7434. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7435. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7436. }
  7437. else {
  7438. this._isTextHighlightOn = false;
  7439. }
  7440. this._markAsDirty();
  7441. return;
  7442. }
  7443. if (this._isTextHighlightOn) {
  7444. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7445. this._isTextHighlightOn = false;
  7446. }
  7447. //ctr + ->
  7448. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7449. this._cursorOffset = 0;
  7450. evt.preventDefault();
  7451. }
  7452. this._blinkIsEven = false;
  7453. this._isTextHighlightOn = false;
  7454. this._cursorIndex = -1;
  7455. this._markAsDirty();
  7456. return;
  7457. case 222: // Dead
  7458. if (evt) {
  7459. evt.preventDefault();
  7460. }
  7461. this._cursorIndex = -1;
  7462. this.deadKey = true;
  7463. break;
  7464. }
  7465. // Printable characters
  7466. if (key &&
  7467. ((keyCode === -1) || // Direct access
  7468. (keyCode === 32) || // Space
  7469. (keyCode > 47 && keyCode < 64) || // Numbers
  7470. (keyCode > 64 && keyCode < 91) || // Letters
  7471. (keyCode > 159 && keyCode < 193) || // Special characters
  7472. (keyCode > 218 && keyCode < 223) || // Special characters
  7473. (keyCode > 95 && keyCode < 112))) { // Numpad
  7474. this._currentKey = key;
  7475. this.onBeforeKeyAddObservable.notifyObservers(this);
  7476. key = this._currentKey;
  7477. if (this._addKey) {
  7478. if (this._isTextHighlightOn) {
  7479. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7480. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7481. this._isTextHighlightOn = false;
  7482. this._blinkIsEven = false;
  7483. this._markAsDirty();
  7484. }
  7485. else if (this._cursorOffset === 0) {
  7486. this.text += key;
  7487. }
  7488. else {
  7489. var insertPosition = this._text.length - this._cursorOffset;
  7490. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7491. }
  7492. }
  7493. }
  7494. };
  7495. /** @hidden */
  7496. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7497. //update the cursor
  7498. this._blinkIsEven = false;
  7499. if (this._cursorIndex === -1) {
  7500. this._cursorIndex = offset;
  7501. }
  7502. else {
  7503. if (this._cursorIndex < this._cursorOffset) {
  7504. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7505. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7506. }
  7507. else if (this._cursorIndex > this._cursorOffset) {
  7508. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7509. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7510. }
  7511. else {
  7512. this._isTextHighlightOn = false;
  7513. this._markAsDirty();
  7514. return;
  7515. }
  7516. }
  7517. this._isTextHighlightOn = true;
  7518. this._markAsDirty();
  7519. };
  7520. /** @hidden */
  7521. InputText.prototype._processDblClick = function (evt) {
  7522. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7523. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7524. this._endHighlightIndex = this._startHighlightIndex;
  7525. var rWord = /\w+/g, moveLeft, moveRight;
  7526. do {
  7527. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7528. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7529. } while (moveLeft || moveRight);
  7530. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7531. this.onTextHighlightObservable.notifyObservers(this);
  7532. this._isTextHighlightOn = true;
  7533. this._clickedCoordinate = null;
  7534. this._blinkIsEven = true;
  7535. this._cursorIndex = -1;
  7536. this._markAsDirty();
  7537. };
  7538. /** @hidden */
  7539. InputText.prototype._selectAllText = function () {
  7540. this._blinkIsEven = true;
  7541. this._isTextHighlightOn = true;
  7542. this._startHighlightIndex = 0;
  7543. this._endHighlightIndex = this._text.length;
  7544. this._cursorOffset = this._text.length;
  7545. this._cursorIndex = -1;
  7546. this._markAsDirty();
  7547. };
  7548. /**
  7549. * Handles the keyboard event
  7550. * @param evt Defines the KeyboardEvent
  7551. */
  7552. InputText.prototype.processKeyboard = function (evt) {
  7553. // process pressed key
  7554. this.processKey(evt.keyCode, evt.key, evt);
  7555. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7556. };
  7557. /** @hidden */
  7558. InputText.prototype._onCopyText = function (ev) {
  7559. this._isTextHighlightOn = false;
  7560. //when write permission to clipbaord data is denied
  7561. try {
  7562. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7563. }
  7564. catch (_a) { } //pass
  7565. this._host.clipboardData = this._highlightedText;
  7566. };
  7567. /** @hidden */
  7568. InputText.prototype._onCutText = function (ev) {
  7569. if (!this._highlightedText) {
  7570. return;
  7571. }
  7572. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7573. this._isTextHighlightOn = false;
  7574. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7575. //when write permission to clipbaord data is denied
  7576. try {
  7577. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7578. }
  7579. catch (_a) { } //pass
  7580. this._host.clipboardData = this._highlightedText;
  7581. this._highlightedText = "";
  7582. };
  7583. /** @hidden */
  7584. InputText.prototype._onPasteText = function (ev) {
  7585. var data = "";
  7586. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7587. data = ev.clipboardData.getData("text/plain");
  7588. }
  7589. else {
  7590. //get the cached data; returns blank string by default
  7591. data = this._host.clipboardData;
  7592. }
  7593. var insertPosition = this._text.length - this._cursorOffset;
  7594. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7595. };
  7596. InputText.prototype._draw = function (context) {
  7597. var _this = this;
  7598. context.save();
  7599. this._applyStates(context);
  7600. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7601. context.shadowColor = this.shadowColor;
  7602. context.shadowBlur = this.shadowBlur;
  7603. context.shadowOffsetX = this.shadowOffsetX;
  7604. context.shadowOffsetY = this.shadowOffsetY;
  7605. }
  7606. // Background
  7607. if (this._isFocused) {
  7608. if (this._focusedBackground) {
  7609. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7610. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7611. }
  7612. }
  7613. else if (this._background) {
  7614. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7615. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7616. }
  7617. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7618. context.shadowBlur = 0;
  7619. context.shadowOffsetX = 0;
  7620. context.shadowOffsetY = 0;
  7621. }
  7622. if (!this._fontOffset) {
  7623. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7624. }
  7625. // Text
  7626. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7627. if (this.color) {
  7628. context.fillStyle = this.color;
  7629. }
  7630. var text = this._beforeRenderText(this._text);
  7631. if (!this._isFocused && !this._text && this._placeholderText) {
  7632. text = this._placeholderText;
  7633. if (this._placeholderColor) {
  7634. context.fillStyle = this._placeholderColor;
  7635. }
  7636. }
  7637. this._textWidth = context.measureText(text).width;
  7638. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7639. if (this._autoStretchWidth) {
  7640. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7641. }
  7642. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7643. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7644. context.save();
  7645. context.beginPath();
  7646. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7647. context.clip();
  7648. if (this._isFocused && this._textWidth > availableWidth) {
  7649. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7650. if (!this._scrollLeft) {
  7651. this._scrollLeft = textLeft;
  7652. }
  7653. }
  7654. else {
  7655. this._scrollLeft = clipTextLeft;
  7656. }
  7657. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7658. // Cursor
  7659. if (this._isFocused) {
  7660. // Need to move cursor
  7661. if (this._clickedCoordinate) {
  7662. var rightPosition = this._scrollLeft + this._textWidth;
  7663. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7664. var currentSize = 0;
  7665. this._cursorOffset = 0;
  7666. var previousDist = 0;
  7667. do {
  7668. if (this._cursorOffset) {
  7669. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7670. }
  7671. this._cursorOffset++;
  7672. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7673. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7674. // Find closest move
  7675. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7676. this._cursorOffset--;
  7677. }
  7678. this._blinkIsEven = false;
  7679. this._clickedCoordinate = null;
  7680. }
  7681. // Render cursor
  7682. if (!this._blinkIsEven) {
  7683. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7684. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7685. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7686. if (cursorLeft < clipTextLeft) {
  7687. this._scrollLeft += (clipTextLeft - cursorLeft);
  7688. cursorLeft = clipTextLeft;
  7689. this._markAsDirty();
  7690. }
  7691. else if (cursorLeft > clipTextLeft + availableWidth) {
  7692. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7693. cursorLeft = clipTextLeft + availableWidth;
  7694. this._markAsDirty();
  7695. }
  7696. if (!this._isTextHighlightOn) {
  7697. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7698. }
  7699. }
  7700. clearTimeout(this._blinkTimeout);
  7701. this._blinkTimeout = setTimeout(function () {
  7702. _this._blinkIsEven = !_this._blinkIsEven;
  7703. _this._markAsDirty();
  7704. }, 500);
  7705. //show the highlighted text
  7706. if (this._isTextHighlightOn) {
  7707. clearTimeout(this._blinkTimeout);
  7708. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7709. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7710. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7711. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7712. if (highlightCursorLeft < clipTextLeft) {
  7713. width = width - (clipTextLeft - highlightCursorLeft);
  7714. if (!width) {
  7715. // when using left arrow on text.length > availableWidth;
  7716. // assigns the width of the first letter after clipTextLeft
  7717. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7718. }
  7719. highlightCursorLeft = clipTextLeft;
  7720. }
  7721. //for transparancy
  7722. context.globalAlpha = this._highligherOpacity;
  7723. context.fillStyle = this._textHighlightColor;
  7724. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7725. context.globalAlpha = 1.0;
  7726. }
  7727. }
  7728. context.restore();
  7729. // Border
  7730. if (this._thickness) {
  7731. if (this._isFocused) {
  7732. if (this.focusedColor) {
  7733. context.strokeStyle = this.focusedColor;
  7734. }
  7735. }
  7736. else {
  7737. if (this.color) {
  7738. context.strokeStyle = this.color;
  7739. }
  7740. }
  7741. context.lineWidth = this._thickness;
  7742. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7743. }
  7744. context.restore();
  7745. };
  7746. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7747. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7748. return false;
  7749. }
  7750. this._clickedCoordinate = coordinates.x;
  7751. this._isTextHighlightOn = false;
  7752. this._highlightedText = "";
  7753. this._cursorIndex = -1;
  7754. this._isPointerDown = true;
  7755. this._host._capturingControl[pointerId] = this;
  7756. if (this._host.focusedControl === this) {
  7757. // Move cursor
  7758. clearTimeout(this._blinkTimeout);
  7759. this._markAsDirty();
  7760. return true;
  7761. }
  7762. if (!this._isEnabled) {
  7763. return false;
  7764. }
  7765. this._host.focusedControl = this;
  7766. return true;
  7767. };
  7768. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7769. if (this._host.focusedControl === this && this._isPointerDown) {
  7770. this._clickedCoordinate = coordinates.x;
  7771. this._markAsDirty();
  7772. this._updateValueFromCursorIndex(this._cursorOffset);
  7773. }
  7774. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7775. };
  7776. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7777. this._isPointerDown = false;
  7778. delete this._host._capturingControl[pointerId];
  7779. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7780. };
  7781. InputText.prototype._beforeRenderText = function (text) {
  7782. return text;
  7783. };
  7784. InputText.prototype.dispose = function () {
  7785. _super.prototype.dispose.call(this);
  7786. this.onBlurObservable.clear();
  7787. this.onFocusObservable.clear();
  7788. this.onTextChangedObservable.clear();
  7789. this.onTextCopyObservable.clear();
  7790. this.onTextCutObservable.clear();
  7791. this.onTextPasteObservable.clear();
  7792. this.onTextHighlightObservable.clear();
  7793. this.onKeyboardEventProcessedObservable.clear();
  7794. };
  7795. return InputText;
  7796. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7797. /***/ }),
  7798. /***/ "./2D/controls/line.ts":
  7799. /*!*****************************!*\
  7800. !*** ./2D/controls/line.ts ***!
  7801. \*****************************/
  7802. /*! exports provided: Line */
  7803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7804. "use strict";
  7805. __webpack_require__.r(__webpack_exports__);
  7806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7807. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7808. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  7809. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7810. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7811. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7812. /** Class used to render 2D lines */
  7813. var Line = /** @class */ (function (_super) {
  7814. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7815. /**
  7816. * Creates a new Line
  7817. * @param name defines the control name
  7818. */
  7819. function Line(name) {
  7820. var _this = _super.call(this, name) || this;
  7821. _this.name = name;
  7822. _this._lineWidth = 1;
  7823. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7824. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7825. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7826. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7827. _this._dash = new Array();
  7828. _this.isHitTestVisible = false;
  7829. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7830. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7831. return _this;
  7832. }
  7833. Object.defineProperty(Line.prototype, "dash", {
  7834. /** Gets or sets the dash pattern */
  7835. get: function () {
  7836. return this._dash;
  7837. },
  7838. set: function (value) {
  7839. if (this._dash === value) {
  7840. return;
  7841. }
  7842. this._dash = value;
  7843. this._markAsDirty();
  7844. },
  7845. enumerable: true,
  7846. configurable: true
  7847. });
  7848. Object.defineProperty(Line.prototype, "connectedControl", {
  7849. /** Gets or sets the control connected with the line end */
  7850. get: function () {
  7851. return this._connectedControl;
  7852. },
  7853. set: function (value) {
  7854. var _this = this;
  7855. if (this._connectedControl === value) {
  7856. return;
  7857. }
  7858. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7859. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7860. this._connectedControlDirtyObserver = null;
  7861. }
  7862. if (value) {
  7863. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7864. }
  7865. this._connectedControl = value;
  7866. this._markAsDirty();
  7867. },
  7868. enumerable: true,
  7869. configurable: true
  7870. });
  7871. Object.defineProperty(Line.prototype, "x1", {
  7872. /** Gets or sets start coordinates on X axis */
  7873. get: function () {
  7874. return this._x1.toString(this._host);
  7875. },
  7876. set: function (value) {
  7877. if (this._x1.toString(this._host) === value) {
  7878. return;
  7879. }
  7880. if (this._x1.fromString(value)) {
  7881. this._markAsDirty();
  7882. }
  7883. },
  7884. enumerable: true,
  7885. configurable: true
  7886. });
  7887. Object.defineProperty(Line.prototype, "y1", {
  7888. /** Gets or sets start coordinates on Y axis */
  7889. get: function () {
  7890. return this._y1.toString(this._host);
  7891. },
  7892. set: function (value) {
  7893. if (this._y1.toString(this._host) === value) {
  7894. return;
  7895. }
  7896. if (this._y1.fromString(value)) {
  7897. this._markAsDirty();
  7898. }
  7899. },
  7900. enumerable: true,
  7901. configurable: true
  7902. });
  7903. Object.defineProperty(Line.prototype, "x2", {
  7904. /** Gets or sets end coordinates on X axis */
  7905. get: function () {
  7906. return this._x2.toString(this._host);
  7907. },
  7908. set: function (value) {
  7909. if (this._x2.toString(this._host) === value) {
  7910. return;
  7911. }
  7912. if (this._x2.fromString(value)) {
  7913. this._markAsDirty();
  7914. }
  7915. },
  7916. enumerable: true,
  7917. configurable: true
  7918. });
  7919. Object.defineProperty(Line.prototype, "y2", {
  7920. /** Gets or sets end coordinates on Y axis */
  7921. get: function () {
  7922. return this._y2.toString(this._host);
  7923. },
  7924. set: function (value) {
  7925. if (this._y2.toString(this._host) === value) {
  7926. return;
  7927. }
  7928. if (this._y2.fromString(value)) {
  7929. this._markAsDirty();
  7930. }
  7931. },
  7932. enumerable: true,
  7933. configurable: true
  7934. });
  7935. Object.defineProperty(Line.prototype, "lineWidth", {
  7936. /** Gets or sets line width */
  7937. get: function () {
  7938. return this._lineWidth;
  7939. },
  7940. set: function (value) {
  7941. if (this._lineWidth === value) {
  7942. return;
  7943. }
  7944. this._lineWidth = value;
  7945. this._markAsDirty();
  7946. },
  7947. enumerable: true,
  7948. configurable: true
  7949. });
  7950. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7951. /** Gets or sets horizontal alignment */
  7952. set: function (value) {
  7953. return;
  7954. },
  7955. enumerable: true,
  7956. configurable: true
  7957. });
  7958. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7959. /** Gets or sets vertical alignment */
  7960. set: function (value) {
  7961. return;
  7962. },
  7963. enumerable: true,
  7964. configurable: true
  7965. });
  7966. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7967. get: function () {
  7968. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7969. },
  7970. enumerable: true,
  7971. configurable: true
  7972. });
  7973. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7974. get: function () {
  7975. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7976. },
  7977. enumerable: true,
  7978. configurable: true
  7979. });
  7980. Line.prototype._getTypeName = function () {
  7981. return "Line";
  7982. };
  7983. Line.prototype._draw = function (context) {
  7984. context.save();
  7985. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7986. context.shadowColor = this.shadowColor;
  7987. context.shadowBlur = this.shadowBlur;
  7988. context.shadowOffsetX = this.shadowOffsetX;
  7989. context.shadowOffsetY = this.shadowOffsetY;
  7990. }
  7991. this._applyStates(context);
  7992. context.strokeStyle = this.color;
  7993. context.lineWidth = this._lineWidth;
  7994. context.setLineDash(this._dash);
  7995. context.beginPath();
  7996. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  7997. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  7998. context.stroke();
  7999. context.restore();
  8000. };
  8001. Line.prototype._measure = function () {
  8002. // Width / Height
  8003. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8004. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8005. };
  8006. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8007. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8008. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8009. };
  8010. /**
  8011. * Move one end of the line given 3D cartesian coordinates.
  8012. * @param position Targeted world position
  8013. * @param scene Scene
  8014. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8015. */
  8016. Line.prototype.moveToVector3 = function (position, scene, end) {
  8017. if (end === void 0) { end = false; }
  8018. if (!this._host || this.parent !== this._host._rootContainer) {
  8019. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8020. return;
  8021. }
  8022. var globalViewport = this._host._getGlobalViewport(scene);
  8023. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8024. this._moveToProjectedPosition(projectedPosition, end);
  8025. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8026. this.notRenderable = true;
  8027. return;
  8028. }
  8029. this.notRenderable = false;
  8030. };
  8031. /**
  8032. * Move one end of the line to a position in screen absolute space.
  8033. * @param projectedPosition Position in screen absolute space (X, Y)
  8034. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8035. */
  8036. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8037. if (end === void 0) { end = false; }
  8038. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8039. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8040. if (end) {
  8041. this.x2 = x;
  8042. this.y2 = y;
  8043. this._x2.ignoreAdaptiveScaling = true;
  8044. this._y2.ignoreAdaptiveScaling = true;
  8045. }
  8046. else {
  8047. this.x1 = x;
  8048. this.y1 = y;
  8049. this._x1.ignoreAdaptiveScaling = true;
  8050. this._y1.ignoreAdaptiveScaling = true;
  8051. }
  8052. };
  8053. return Line;
  8054. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8055. /***/ }),
  8056. /***/ "./2D/controls/multiLine.ts":
  8057. /*!**********************************!*\
  8058. !*** ./2D/controls/multiLine.ts ***!
  8059. \**********************************/
  8060. /*! exports provided: MultiLine */
  8061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8062. "use strict";
  8063. __webpack_require__.r(__webpack_exports__);
  8064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8065. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8066. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8067. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8068. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8069. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8070. /**
  8071. * Class used to create multi line control
  8072. */
  8073. var MultiLine = /** @class */ (function (_super) {
  8074. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8075. /**
  8076. * Creates a new MultiLine
  8077. * @param name defines the control name
  8078. */
  8079. function MultiLine(name) {
  8080. var _this = _super.call(this, name) || this;
  8081. _this.name = name;
  8082. _this._lineWidth = 1;
  8083. /** Function called when a point is updated */
  8084. _this.onPointUpdate = function () {
  8085. _this._markAsDirty();
  8086. };
  8087. _this.isHitTestVisible = false;
  8088. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8089. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8090. _this._dash = [];
  8091. _this._points = [];
  8092. return _this;
  8093. }
  8094. Object.defineProperty(MultiLine.prototype, "dash", {
  8095. /** Gets or sets dash pattern */
  8096. get: function () {
  8097. return this._dash;
  8098. },
  8099. set: function (value) {
  8100. if (this._dash === value) {
  8101. return;
  8102. }
  8103. this._dash = value;
  8104. this._markAsDirty();
  8105. },
  8106. enumerable: true,
  8107. configurable: true
  8108. });
  8109. /**
  8110. * Gets point stored at specified index
  8111. * @param index defines the index to look for
  8112. * @returns the requested point if found
  8113. */
  8114. MultiLine.prototype.getAt = function (index) {
  8115. if (!this._points[index]) {
  8116. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8117. }
  8118. return this._points[index];
  8119. };
  8120. /**
  8121. * Adds new points to the point collection
  8122. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8123. * @returns the list of created MultiLinePoint
  8124. */
  8125. MultiLine.prototype.add = function () {
  8126. var _this = this;
  8127. var items = [];
  8128. for (var _i = 0; _i < arguments.length; _i++) {
  8129. items[_i] = arguments[_i];
  8130. }
  8131. return items.map(function (item) { return _this.push(item); });
  8132. };
  8133. /**
  8134. * Adds a new point to the point collection
  8135. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8136. * @returns the created MultiLinePoint
  8137. */
  8138. MultiLine.prototype.push = function (item) {
  8139. var point = this.getAt(this._points.length);
  8140. if (item == null) {
  8141. return point;
  8142. }
  8143. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8144. point.mesh = item;
  8145. }
  8146. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8147. point.control = item;
  8148. }
  8149. else if (item.x != null && item.y != null) {
  8150. point.x = item.x;
  8151. point.y = item.y;
  8152. }
  8153. return point;
  8154. };
  8155. /**
  8156. * Remove a specific value or point from the active point collection
  8157. * @param value defines the value or point to remove
  8158. */
  8159. MultiLine.prototype.remove = function (value) {
  8160. var index;
  8161. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8162. index = this._points.indexOf(value);
  8163. if (index === -1) {
  8164. return;
  8165. }
  8166. }
  8167. else {
  8168. index = value;
  8169. }
  8170. var point = this._points[index];
  8171. if (!point) {
  8172. return;
  8173. }
  8174. point.dispose();
  8175. this._points.splice(index, 1);
  8176. };
  8177. /**
  8178. * Resets this object to initial state (no point)
  8179. */
  8180. MultiLine.prototype.reset = function () {
  8181. while (this._points.length > 0) {
  8182. this.remove(this._points.length - 1);
  8183. }
  8184. };
  8185. /**
  8186. * Resets all links
  8187. */
  8188. MultiLine.prototype.resetLinks = function () {
  8189. this._points.forEach(function (point) {
  8190. if (point != null) {
  8191. point.resetLinks();
  8192. }
  8193. });
  8194. };
  8195. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8196. /** Gets or sets line width */
  8197. get: function () {
  8198. return this._lineWidth;
  8199. },
  8200. set: function (value) {
  8201. if (this._lineWidth === value) {
  8202. return;
  8203. }
  8204. this._lineWidth = value;
  8205. this._markAsDirty();
  8206. },
  8207. enumerable: true,
  8208. configurable: true
  8209. });
  8210. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8211. set: function (value) {
  8212. return;
  8213. },
  8214. enumerable: true,
  8215. configurable: true
  8216. });
  8217. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8218. set: function (value) {
  8219. return;
  8220. },
  8221. enumerable: true,
  8222. configurable: true
  8223. });
  8224. MultiLine.prototype._getTypeName = function () {
  8225. return "MultiLine";
  8226. };
  8227. MultiLine.prototype._draw = function (context) {
  8228. context.save();
  8229. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8230. context.shadowColor = this.shadowColor;
  8231. context.shadowBlur = this.shadowBlur;
  8232. context.shadowOffsetX = this.shadowOffsetX;
  8233. context.shadowOffsetY = this.shadowOffsetY;
  8234. }
  8235. this._applyStates(context);
  8236. context.strokeStyle = this.color;
  8237. context.lineWidth = this._lineWidth;
  8238. context.setLineDash(this._dash);
  8239. context.beginPath();
  8240. var first = true; //first index is not necessarily 0
  8241. this._points.forEach(function (point) {
  8242. if (!point) {
  8243. return;
  8244. }
  8245. if (first) {
  8246. context.moveTo(point._point.x, point._point.y);
  8247. first = false;
  8248. }
  8249. else {
  8250. context.lineTo(point._point.x, point._point.y);
  8251. }
  8252. });
  8253. context.stroke();
  8254. context.restore();
  8255. };
  8256. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8257. var _this = this;
  8258. this._minX = null;
  8259. this._minY = null;
  8260. this._maxX = null;
  8261. this._maxY = null;
  8262. this._points.forEach(function (point, index) {
  8263. if (!point) {
  8264. return;
  8265. }
  8266. point.translate();
  8267. if (_this._minX == null || point._point.x < _this._minX) {
  8268. _this._minX = point._point.x;
  8269. }
  8270. if (_this._minY == null || point._point.y < _this._minY) {
  8271. _this._minY = point._point.y;
  8272. }
  8273. if (_this._maxX == null || point._point.x > _this._maxX) {
  8274. _this._maxX = point._point.x;
  8275. }
  8276. if (_this._maxY == null || point._point.y > _this._maxY) {
  8277. _this._maxY = point._point.y;
  8278. }
  8279. });
  8280. if (this._minX == null) {
  8281. this._minX = 0;
  8282. }
  8283. if (this._minY == null) {
  8284. this._minY = 0;
  8285. }
  8286. if (this._maxX == null) {
  8287. this._maxX = 0;
  8288. }
  8289. if (this._maxY == null) {
  8290. this._maxY = 0;
  8291. }
  8292. };
  8293. MultiLine.prototype._measure = function () {
  8294. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8295. return;
  8296. }
  8297. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8298. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8299. };
  8300. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8301. if (this._minX == null || this._minY == null) {
  8302. return;
  8303. }
  8304. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8305. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8306. };
  8307. MultiLine.prototype.dispose = function () {
  8308. this.reset();
  8309. _super.prototype.dispose.call(this);
  8310. };
  8311. return MultiLine;
  8312. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8313. /***/ }),
  8314. /***/ "./2D/controls/radioButton.ts":
  8315. /*!************************************!*\
  8316. !*** ./2D/controls/radioButton.ts ***!
  8317. \************************************/
  8318. /*! exports provided: RadioButton */
  8319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8320. "use strict";
  8321. __webpack_require__.r(__webpack_exports__);
  8322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8323. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8324. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8325. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8326. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8327. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8328. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8329. /**
  8330. * Class used to create radio button controls
  8331. */
  8332. var RadioButton = /** @class */ (function (_super) {
  8333. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8334. /**
  8335. * Creates a new RadioButton
  8336. * @param name defines the control name
  8337. */
  8338. function RadioButton(name) {
  8339. var _this = _super.call(this, name) || this;
  8340. _this.name = name;
  8341. _this._isChecked = false;
  8342. _this._background = "black";
  8343. _this._checkSizeRatio = 0.8;
  8344. _this._thickness = 1;
  8345. /** Gets or sets group name */
  8346. _this.group = "";
  8347. /** Observable raised when isChecked is changed */
  8348. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8349. _this.isPointerBlocker = true;
  8350. return _this;
  8351. }
  8352. Object.defineProperty(RadioButton.prototype, "thickness", {
  8353. /** Gets or sets border thickness */
  8354. get: function () {
  8355. return this._thickness;
  8356. },
  8357. set: function (value) {
  8358. if (this._thickness === value) {
  8359. return;
  8360. }
  8361. this._thickness = value;
  8362. this._markAsDirty();
  8363. },
  8364. enumerable: true,
  8365. configurable: true
  8366. });
  8367. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8368. /** Gets or sets a value indicating the ratio between overall size and check size */
  8369. get: function () {
  8370. return this._checkSizeRatio;
  8371. },
  8372. set: function (value) {
  8373. value = Math.max(Math.min(1, value), 0);
  8374. if (this._checkSizeRatio === value) {
  8375. return;
  8376. }
  8377. this._checkSizeRatio = value;
  8378. this._markAsDirty();
  8379. },
  8380. enumerable: true,
  8381. configurable: true
  8382. });
  8383. Object.defineProperty(RadioButton.prototype, "background", {
  8384. /** Gets or sets background color */
  8385. get: function () {
  8386. return this._background;
  8387. },
  8388. set: function (value) {
  8389. if (this._background === value) {
  8390. return;
  8391. }
  8392. this._background = value;
  8393. this._markAsDirty();
  8394. },
  8395. enumerable: true,
  8396. configurable: true
  8397. });
  8398. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8399. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8400. get: function () {
  8401. return this._isChecked;
  8402. },
  8403. set: function (value) {
  8404. var _this = this;
  8405. if (this._isChecked === value) {
  8406. return;
  8407. }
  8408. this._isChecked = value;
  8409. this._markAsDirty();
  8410. this.onIsCheckedChangedObservable.notifyObservers(value);
  8411. if (this._isChecked && this._host) {
  8412. // Update all controls from same group
  8413. this._host.executeOnAllControls(function (control) {
  8414. if (control === _this) {
  8415. return;
  8416. }
  8417. if (control.group === undefined) {
  8418. return;
  8419. }
  8420. var childRadio = control;
  8421. if (childRadio.group === _this.group) {
  8422. childRadio.isChecked = false;
  8423. }
  8424. });
  8425. }
  8426. },
  8427. enumerable: true,
  8428. configurable: true
  8429. });
  8430. RadioButton.prototype._getTypeName = function () {
  8431. return "RadioButton";
  8432. };
  8433. RadioButton.prototype._draw = function (context) {
  8434. context.save();
  8435. this._applyStates(context);
  8436. var actualWidth = this._currentMeasure.width - this._thickness;
  8437. var actualHeight = this._currentMeasure.height - this._thickness;
  8438. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8439. context.shadowColor = this.shadowColor;
  8440. context.shadowBlur = this.shadowBlur;
  8441. context.shadowOffsetX = this.shadowOffsetX;
  8442. context.shadowOffsetY = this.shadowOffsetY;
  8443. }
  8444. // Outer
  8445. _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);
  8446. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8447. context.fill();
  8448. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8449. context.shadowBlur = 0;
  8450. context.shadowOffsetX = 0;
  8451. context.shadowOffsetY = 0;
  8452. }
  8453. context.strokeStyle = this.color;
  8454. context.lineWidth = this._thickness;
  8455. context.stroke();
  8456. // Inner
  8457. if (this._isChecked) {
  8458. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8459. var offsetWidth = actualWidth * this._checkSizeRatio;
  8460. var offseHeight = actualHeight * this._checkSizeRatio;
  8461. _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);
  8462. context.fill();
  8463. }
  8464. context.restore();
  8465. };
  8466. // Events
  8467. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8468. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8469. return false;
  8470. }
  8471. if (!this.isChecked) {
  8472. this.isChecked = true;
  8473. }
  8474. return true;
  8475. };
  8476. /**
  8477. * Utility function to easily create a radio button with a header
  8478. * @param title defines the label to use for the header
  8479. * @param group defines the group to use for the radio button
  8480. * @param isChecked defines the initial state of the radio button
  8481. * @param onValueChanged defines the callback to call when value changes
  8482. * @returns a StackPanel containing the radio button and a textBlock
  8483. */
  8484. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8485. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8486. panel.isVertical = false;
  8487. panel.height = "30px";
  8488. var radio = new RadioButton();
  8489. radio.width = "20px";
  8490. radio.height = "20px";
  8491. radio.isChecked = isChecked;
  8492. radio.color = "green";
  8493. radio.group = group;
  8494. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8495. panel.addControl(radio);
  8496. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8497. header.text = title;
  8498. header.width = "180px";
  8499. header.paddingLeft = "5px";
  8500. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8501. header.color = "white";
  8502. panel.addControl(header);
  8503. return panel;
  8504. };
  8505. return RadioButton;
  8506. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8507. /***/ }),
  8508. /***/ "./2D/controls/rectangle.ts":
  8509. /*!**********************************!*\
  8510. !*** ./2D/controls/rectangle.ts ***!
  8511. \**********************************/
  8512. /*! exports provided: Rectangle */
  8513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8514. "use strict";
  8515. __webpack_require__.r(__webpack_exports__);
  8516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8517. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8518. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8519. /** Class used to create rectangle container */
  8520. var Rectangle = /** @class */ (function (_super) {
  8521. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8522. /**
  8523. * Creates a new Rectangle
  8524. * @param name defines the control name
  8525. */
  8526. function Rectangle(name) {
  8527. var _this = _super.call(this, name) || this;
  8528. _this.name = name;
  8529. _this._thickness = 1;
  8530. _this._cornerRadius = 0;
  8531. return _this;
  8532. }
  8533. Object.defineProperty(Rectangle.prototype, "thickness", {
  8534. /** Gets or sets border thickness */
  8535. get: function () {
  8536. return this._thickness;
  8537. },
  8538. set: function (value) {
  8539. if (this._thickness === value) {
  8540. return;
  8541. }
  8542. this._thickness = value;
  8543. this._markAsDirty();
  8544. },
  8545. enumerable: true,
  8546. configurable: true
  8547. });
  8548. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8549. /** Gets or sets the corner radius angle */
  8550. get: function () {
  8551. return this._cornerRadius;
  8552. },
  8553. set: function (value) {
  8554. if (value < 0) {
  8555. value = 0;
  8556. }
  8557. if (this._cornerRadius === value) {
  8558. return;
  8559. }
  8560. this._cornerRadius = value;
  8561. this._markAsDirty();
  8562. },
  8563. enumerable: true,
  8564. configurable: true
  8565. });
  8566. Rectangle.prototype._getTypeName = function () {
  8567. return "Rectangle";
  8568. };
  8569. Rectangle.prototype._localDraw = function (context) {
  8570. context.save();
  8571. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8572. context.shadowColor = this.shadowColor;
  8573. context.shadowBlur = this.shadowBlur;
  8574. context.shadowOffsetX = this.shadowOffsetX;
  8575. context.shadowOffsetY = this.shadowOffsetY;
  8576. }
  8577. if (this._background) {
  8578. context.fillStyle = this._background;
  8579. if (this._cornerRadius) {
  8580. this._drawRoundedRect(context, this._thickness / 2);
  8581. context.fill();
  8582. }
  8583. else {
  8584. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8585. }
  8586. }
  8587. if (this._thickness) {
  8588. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8589. context.shadowBlur = 0;
  8590. context.shadowOffsetX = 0;
  8591. context.shadowOffsetY = 0;
  8592. }
  8593. if (this.color) {
  8594. context.strokeStyle = this.color;
  8595. }
  8596. context.lineWidth = this._thickness;
  8597. if (this._cornerRadius) {
  8598. this._drawRoundedRect(context, this._thickness / 2);
  8599. context.stroke();
  8600. }
  8601. else {
  8602. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8603. }
  8604. }
  8605. context.restore();
  8606. };
  8607. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8608. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8609. this._measureForChildren.width -= 2 * this._thickness;
  8610. this._measureForChildren.height -= 2 * this._thickness;
  8611. this._measureForChildren.left += this._thickness;
  8612. this._measureForChildren.top += this._thickness;
  8613. };
  8614. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8615. if (offset === void 0) { offset = 0; }
  8616. var x = this._currentMeasure.left + offset;
  8617. var y = this._currentMeasure.top + offset;
  8618. var width = this._currentMeasure.width - offset * 2;
  8619. var height = this._currentMeasure.height - offset * 2;
  8620. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8621. context.beginPath();
  8622. context.moveTo(x + radius, y);
  8623. context.lineTo(x + width - radius, y);
  8624. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8625. context.lineTo(x + width, y + height - radius);
  8626. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8627. context.lineTo(x + radius, y + height);
  8628. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8629. context.lineTo(x, y + radius);
  8630. context.quadraticCurveTo(x, y, x + radius, y);
  8631. context.closePath();
  8632. };
  8633. Rectangle.prototype._clipForChildren = function (context) {
  8634. if (this._cornerRadius) {
  8635. this._drawRoundedRect(context, this._thickness);
  8636. context.clip();
  8637. }
  8638. };
  8639. return Rectangle;
  8640. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8641. /***/ }),
  8642. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8643. /*!***************************************************!*\
  8644. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8645. \***************************************************/
  8646. /*! exports provided: ScrollViewer */
  8647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8648. "use strict";
  8649. __webpack_require__.r(__webpack_exports__);
  8650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8651. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8652. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/perfCounter");
  8653. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8654. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8655. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8656. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8657. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8658. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8659. /**
  8660. * Class used to hold a viewer window and sliders in a grid
  8661. */
  8662. var ScrollViewer = /** @class */ (function (_super) {
  8663. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8664. /**
  8665. * Creates a new ScrollViewer
  8666. * @param name of ScrollViewer
  8667. */
  8668. function ScrollViewer(name) {
  8669. var _this = _super.call(this, name) || this;
  8670. _this._barSize = 20;
  8671. _this._pointerIsOver = false;
  8672. _this._wheelPrecision = 0.05;
  8673. _this.onDirtyObservable.add(function () {
  8674. _this._horizontalBarSpace.color = _this.color;
  8675. _this._verticalBarSpace.color = _this.color;
  8676. _this._dragSpace.color = _this.color;
  8677. });
  8678. _this.onPointerEnterObservable.add(function () {
  8679. _this._pointerIsOver = true;
  8680. });
  8681. _this.onPointerOutObservable.add(function () {
  8682. _this._pointerIsOver = false;
  8683. });
  8684. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8685. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8686. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8687. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8688. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8689. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8690. _this._grid.addColumnDefinition(1);
  8691. _this._grid.addColumnDefinition(0, true);
  8692. _this._grid.addRowDefinition(1);
  8693. _this._grid.addRowDefinition(0, true);
  8694. _super.prototype.addControl.call(_this, _this._grid);
  8695. _this._grid.addControl(_this._window, 0, 0);
  8696. _this._verticalBar.paddingLeft = 0;
  8697. _this._verticalBar.width = "100%";
  8698. _this._verticalBar.height = "100%";
  8699. _this._verticalBar.barOffset = 0;
  8700. _this._verticalBar.value = 0;
  8701. _this._verticalBar.maximum = 1;
  8702. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8703. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8704. _this._verticalBar.isVertical = true;
  8705. _this._verticalBar.rotation = Math.PI;
  8706. _this._verticalBar.isVisible = false;
  8707. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8708. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8709. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8710. _this._verticalBarSpace.thickness = 1;
  8711. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8712. _this._verticalBarSpace.addControl(_this._verticalBar);
  8713. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8714. _this._window.top = value * _this._endTop + "px";
  8715. });
  8716. _this._horizontalBar.paddingLeft = 0;
  8717. _this._horizontalBar.width = "100%";
  8718. _this._horizontalBar.height = "100%";
  8719. _this._horizontalBar.barOffset = 0;
  8720. _this._horizontalBar.value = 0;
  8721. _this._horizontalBar.maximum = 1;
  8722. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8723. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8724. _this._horizontalBar.isVisible = false;
  8725. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8726. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8727. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8728. _this._horizontalBarSpace.thickness = 1;
  8729. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8730. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8731. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8732. _this._window.left = value * _this._endLeft + "px";
  8733. });
  8734. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8735. _this._dragSpace.thickness = 1;
  8736. _this._grid.addControl(_this._dragSpace, 1, 1);
  8737. // Colors
  8738. _this.barColor = "grey";
  8739. _this.barBackground = "transparent";
  8740. return _this;
  8741. }
  8742. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8743. /**
  8744. * Gets the horizontal scrollbar
  8745. */
  8746. get: function () {
  8747. return this._horizontalBar;
  8748. },
  8749. enumerable: true,
  8750. configurable: true
  8751. });
  8752. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8753. /**
  8754. * Gets the vertical scrollbar
  8755. */
  8756. get: function () {
  8757. return this._verticalBar;
  8758. },
  8759. enumerable: true,
  8760. configurable: true
  8761. });
  8762. /**
  8763. * Adds a new control to the current container
  8764. * @param control defines the control to add
  8765. * @returns the current container
  8766. */
  8767. ScrollViewer.prototype.addControl = function (control) {
  8768. if (!control) {
  8769. return this;
  8770. }
  8771. this._window.addControl(control);
  8772. return this;
  8773. };
  8774. /**
  8775. * Removes a control from the current container
  8776. * @param control defines the control to remove
  8777. * @returns the current container
  8778. */
  8779. ScrollViewer.prototype.removeControl = function (control) {
  8780. this._window.removeControl(control);
  8781. return this;
  8782. };
  8783. Object.defineProperty(ScrollViewer.prototype, "children", {
  8784. /** Gets the list of children */
  8785. get: function () {
  8786. return this._window.children;
  8787. },
  8788. enumerable: true,
  8789. configurable: true
  8790. });
  8791. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8792. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8793. var child = _a[_i];
  8794. child._markMatrixAsDirty();
  8795. }
  8796. };
  8797. /** Reset the scroll viewer window to initial size */
  8798. ScrollViewer.prototype.resetWindow = function () {
  8799. this._window.width = "100%";
  8800. this._window.height = "100%";
  8801. };
  8802. ScrollViewer.prototype._getTypeName = function () {
  8803. return "ScrollViewer";
  8804. };
  8805. ScrollViewer.prototype._buildClientSizes = function () {
  8806. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8807. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8808. this._clientWidth = this._window.parentClientWidth;
  8809. this._clientHeight = this._window.parentClientHeight;
  8810. };
  8811. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8812. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8813. this._buildClientSizes();
  8814. };
  8815. ScrollViewer.prototype._postMeasure = function () {
  8816. _super.prototype._postMeasure.call(this);
  8817. this._updateScroller();
  8818. };
  8819. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8820. /**
  8821. * Gets or sets the mouse wheel precision
  8822. * from 0 to 1 with a default value of 0.05
  8823. * */
  8824. get: function () {
  8825. return this._wheelPrecision;
  8826. },
  8827. set: function (value) {
  8828. if (this._wheelPrecision === value) {
  8829. return;
  8830. }
  8831. if (value < 0) {
  8832. value = 0;
  8833. }
  8834. if (value > 1) {
  8835. value = 1;
  8836. }
  8837. this._wheelPrecision = value;
  8838. },
  8839. enumerable: true,
  8840. configurable: true
  8841. });
  8842. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8843. /** Gets or sets the bar color */
  8844. get: function () {
  8845. return this._barColor;
  8846. },
  8847. set: function (color) {
  8848. if (this._barColor === color) {
  8849. return;
  8850. }
  8851. this._barColor = color;
  8852. this._horizontalBar.color = color;
  8853. this._verticalBar.color = color;
  8854. },
  8855. enumerable: true,
  8856. configurable: true
  8857. });
  8858. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8859. /** Gets or sets the size of the bar */
  8860. get: function () {
  8861. return this._barSize;
  8862. },
  8863. set: function (value) {
  8864. if (this._barSize === value) {
  8865. return;
  8866. }
  8867. this._barSize = value;
  8868. this._markAsDirty();
  8869. if (this._horizontalBar.isVisible) {
  8870. this._grid.setRowDefinition(1, this._barSize, true);
  8871. }
  8872. if (this._verticalBar.isVisible) {
  8873. this._grid.setColumnDefinition(1, this._barSize, true);
  8874. }
  8875. },
  8876. enumerable: true,
  8877. configurable: true
  8878. });
  8879. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8880. /** Gets or sets the bar background */
  8881. get: function () {
  8882. return this._barBackground;
  8883. },
  8884. set: function (color) {
  8885. if (this._barBackground === color) {
  8886. return;
  8887. }
  8888. this._barBackground = color;
  8889. this._horizontalBar.background = color;
  8890. this._verticalBar.background = color;
  8891. this._dragSpace.background = color;
  8892. },
  8893. enumerable: true,
  8894. configurable: true
  8895. });
  8896. /** @hidden */
  8897. ScrollViewer.prototype._updateScroller = function () {
  8898. var windowContentsWidth = this._window._currentMeasure.width;
  8899. var windowContentsHeight = this._window._currentMeasure.height;
  8900. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8901. this._grid.setRowDefinition(1, 0, true);
  8902. this._horizontalBar.isVisible = false;
  8903. this._horizontalBar.value = 0;
  8904. this._rebuildLayout = true;
  8905. }
  8906. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8907. this._grid.setRowDefinition(1, this._barSize, true);
  8908. this._horizontalBar.isVisible = true;
  8909. this._rebuildLayout = true;
  8910. }
  8911. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8912. this._grid.setColumnDefinition(1, 0, true);
  8913. this._verticalBar.isVisible = false;
  8914. this._verticalBar.value = 0;
  8915. this._rebuildLayout = true;
  8916. }
  8917. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8918. this._grid.setColumnDefinition(1, this._barSize, true);
  8919. this._verticalBar.isVisible = true;
  8920. this._rebuildLayout = true;
  8921. }
  8922. this._buildClientSizes();
  8923. this._endLeft = this._clientWidth - windowContentsWidth;
  8924. this._endTop = this._clientHeight - windowContentsHeight;
  8925. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8926. var newTop = this._verticalBar.value * this._endTop + "px";
  8927. if (newLeft !== this._window.left) {
  8928. this._window.left = newLeft;
  8929. this._rebuildLayout = true;
  8930. }
  8931. if (newTop !== this._window.top) {
  8932. this._window.top = newTop;
  8933. this._rebuildLayout = true;
  8934. }
  8935. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8936. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8937. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8938. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8939. };
  8940. ScrollViewer.prototype._link = function (host) {
  8941. _super.prototype._link.call(this, host);
  8942. this._attachWheel();
  8943. };
  8944. /** @hidden */
  8945. ScrollViewer.prototype._attachWheel = function () {
  8946. var _this = this;
  8947. if (!this._host || this._onPointerObserver) {
  8948. return;
  8949. }
  8950. var scene = this._host.getScene();
  8951. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8952. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8953. return;
  8954. }
  8955. if (_this._verticalBar.isVisible == true) {
  8956. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8957. _this._verticalBar.value -= _this._wheelPrecision;
  8958. }
  8959. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8960. _this._verticalBar.value += _this._wheelPrecision;
  8961. }
  8962. }
  8963. if (_this._horizontalBar.isVisible == true) {
  8964. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8965. _this._horizontalBar.value += _this._wheelPrecision;
  8966. }
  8967. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8968. _this._horizontalBar.value -= _this._wheelPrecision;
  8969. }
  8970. }
  8971. });
  8972. };
  8973. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8974. if (!this.isHighlighted) {
  8975. return;
  8976. }
  8977. _super.prototype._renderHighlightSpecific.call(this, context);
  8978. this._grid._renderHighlightSpecific(context);
  8979. context.restore();
  8980. };
  8981. /** Releases associated resources */
  8982. ScrollViewer.prototype.dispose = function () {
  8983. var scene = this._host.getScene();
  8984. if (scene && this._onPointerObserver) {
  8985. scene.onPointerObservable.remove(this._onPointerObserver);
  8986. this._onPointerObserver = null;
  8987. }
  8988. _super.prototype.dispose.call(this);
  8989. };
  8990. return ScrollViewer;
  8991. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8992. /***/ }),
  8993. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8994. /*!*********************************************************!*\
  8995. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8996. \*********************************************************/
  8997. /*! exports provided: _ScrollViewerWindow */
  8998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8999. "use strict";
  9000. __webpack_require__.r(__webpack_exports__);
  9001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9002. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9003. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9004. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9005. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9006. /**
  9007. * Class used to hold a the container for ScrollViewer
  9008. * @hidden
  9009. */
  9010. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9011. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  9012. /**
  9013. * Creates a new ScrollViewerWindow
  9014. * @param name of ScrollViewerWindow
  9015. */
  9016. function _ScrollViewerWindow(name) {
  9017. return _super.call(this, name) || this;
  9018. }
  9019. _ScrollViewerWindow.prototype._getTypeName = function () {
  9020. return "ScrollViewerWindow";
  9021. };
  9022. /** @hidden */
  9023. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9024. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9025. this._measureForChildren.left = this._currentMeasure.left;
  9026. this._measureForChildren.top = this._currentMeasure.top;
  9027. this._measureForChildren.width = parentMeasure.width;
  9028. this._measureForChildren.height = parentMeasure.height;
  9029. };
  9030. _ScrollViewerWindow.prototype._postMeasure = function () {
  9031. var maxWidth = this.parentClientWidth;
  9032. var maxHeight = this.parentClientHeight;
  9033. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9034. var child = _a[_i];
  9035. if (!child.isVisible || child.notRenderable) {
  9036. continue;
  9037. }
  9038. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9039. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9040. }
  9041. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9042. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9043. }
  9044. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9045. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9046. }
  9047. if (this._currentMeasure.width !== maxWidth) {
  9048. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9049. this._currentMeasure.width = maxWidth;
  9050. this._rebuildLayout = true;
  9051. this._isDirty = true;
  9052. }
  9053. if (this._currentMeasure.height !== maxHeight) {
  9054. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9055. this._currentMeasure.height = maxHeight;
  9056. this._rebuildLayout = true;
  9057. this._isDirty = true;
  9058. }
  9059. _super.prototype._postMeasure.call(this);
  9060. };
  9061. return _ScrollViewerWindow;
  9062. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9063. /***/ }),
  9064. /***/ "./2D/controls/selector.ts":
  9065. /*!*********************************!*\
  9066. !*** ./2D/controls/selector.ts ***!
  9067. \*********************************/
  9068. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9070. "use strict";
  9071. __webpack_require__.r(__webpack_exports__);
  9072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9076. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9077. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9078. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9079. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9080. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9081. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9082. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9083. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9084. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9085. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9086. /** Class used to create a RadioGroup
  9087. * which contains groups of radio buttons
  9088. */
  9089. var SelectorGroup = /** @class */ (function () {
  9090. /**
  9091. * Creates a new SelectorGroup
  9092. * @param name of group, used as a group heading
  9093. */
  9094. function SelectorGroup(
  9095. /** name of SelectorGroup */
  9096. name) {
  9097. this.name = name;
  9098. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9099. this._selectors = new Array();
  9100. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9101. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9102. this._groupHeader = this._addGroupHeader(name);
  9103. }
  9104. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9105. /** Gets the groupPanel of the SelectorGroup */
  9106. get: function () {
  9107. return this._groupPanel;
  9108. },
  9109. enumerable: true,
  9110. configurable: true
  9111. });
  9112. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9113. /** Gets the selectors array */
  9114. get: function () {
  9115. return this._selectors;
  9116. },
  9117. enumerable: true,
  9118. configurable: true
  9119. });
  9120. Object.defineProperty(SelectorGroup.prototype, "header", {
  9121. /** Gets and sets the group header */
  9122. get: function () {
  9123. return this._groupHeader.text;
  9124. },
  9125. set: function (label) {
  9126. if (this._groupHeader.text === "label") {
  9127. return;
  9128. }
  9129. this._groupHeader.text = label;
  9130. },
  9131. enumerable: true,
  9132. configurable: true
  9133. });
  9134. /** @hidden */
  9135. SelectorGroup.prototype._addGroupHeader = function (text) {
  9136. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9137. groupHeading.width = 0.9;
  9138. groupHeading.height = "30px";
  9139. groupHeading.textWrapping = true;
  9140. groupHeading.color = "black";
  9141. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9142. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9143. groupHeading.left = "2px";
  9144. this._groupPanel.addControl(groupHeading);
  9145. return groupHeading;
  9146. };
  9147. /** @hidden*/
  9148. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9149. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9150. return;
  9151. }
  9152. return this._selectors[selectorNb];
  9153. };
  9154. /** Removes the selector at the given position
  9155. * @param selectorNb the position of the selector within the group
  9156. */
  9157. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9158. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9159. return;
  9160. }
  9161. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9162. this._selectors.splice(selectorNb, 1);
  9163. };
  9164. return SelectorGroup;
  9165. }());
  9166. /** Class used to create a CheckboxGroup
  9167. * which contains groups of checkbox buttons
  9168. */
  9169. var CheckboxGroup = /** @class */ (function (_super) {
  9170. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9171. function CheckboxGroup() {
  9172. return _super !== null && _super.apply(this, arguments) || this;
  9173. }
  9174. /** Adds a checkbox as a control
  9175. * @param text is the label for the selector
  9176. * @param func is the function called when the Selector is checked
  9177. * @param checked is true when Selector is checked
  9178. */
  9179. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9180. if (func === void 0) { func = function (s) { }; }
  9181. if (checked === void 0) { checked = false; }
  9182. var checked = checked || false;
  9183. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9184. button.width = "20px";
  9185. button.height = "20px";
  9186. button.color = "#364249";
  9187. button.background = "#CCCCCC";
  9188. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9189. button.onIsCheckedChangedObservable.add(function (state) {
  9190. func(state);
  9191. });
  9192. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9193. _selector.height = "30px";
  9194. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9195. _selector.left = "4px";
  9196. this.groupPanel.addControl(_selector);
  9197. this.selectors.push(_selector);
  9198. button.isChecked = checked;
  9199. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9200. button.color = this.groupPanel.parent.parent.buttonColor;
  9201. button.background = this.groupPanel.parent.parent.buttonBackground;
  9202. }
  9203. };
  9204. /** @hidden */
  9205. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9206. this.selectors[selectorNb].children[1].text = label;
  9207. };
  9208. /** @hidden */
  9209. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9210. this.selectors[selectorNb].children[1].color = color;
  9211. };
  9212. /** @hidden */
  9213. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9214. this.selectors[selectorNb].children[0].color = color;
  9215. };
  9216. /** @hidden */
  9217. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9218. this.selectors[selectorNb].children[0].background = color;
  9219. };
  9220. return CheckboxGroup;
  9221. }(SelectorGroup));
  9222. /** Class used to create a RadioGroup
  9223. * which contains groups of radio buttons
  9224. */
  9225. var RadioGroup = /** @class */ (function (_super) {
  9226. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9227. function RadioGroup() {
  9228. var _this = _super !== null && _super.apply(this, arguments) || this;
  9229. _this._selectNb = 0;
  9230. return _this;
  9231. }
  9232. /** Adds a radio button as a control
  9233. * @param label is the label for the selector
  9234. * @param func is the function called when the Selector is checked
  9235. * @param checked is true when Selector is checked
  9236. */
  9237. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9238. if (func === void 0) { func = function (n) { }; }
  9239. if (checked === void 0) { checked = false; }
  9240. var nb = this._selectNb++;
  9241. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9242. button.name = label;
  9243. button.width = "20px";
  9244. button.height = "20px";
  9245. button.color = "#364249";
  9246. button.background = "#CCCCCC";
  9247. button.group = this.name;
  9248. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9249. button.onIsCheckedChangedObservable.add(function (state) {
  9250. if (state) {
  9251. func(nb);
  9252. }
  9253. });
  9254. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9255. _selector.height = "30px";
  9256. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9257. _selector.left = "4px";
  9258. this.groupPanel.addControl(_selector);
  9259. this.selectors.push(_selector);
  9260. button.isChecked = checked;
  9261. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9262. button.color = this.groupPanel.parent.parent.buttonColor;
  9263. button.background = this.groupPanel.parent.parent.buttonBackground;
  9264. }
  9265. };
  9266. /** @hidden */
  9267. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9268. this.selectors[selectorNb].children[1].text = label;
  9269. };
  9270. /** @hidden */
  9271. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9272. this.selectors[selectorNb].children[1].color = color;
  9273. };
  9274. /** @hidden */
  9275. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9276. this.selectors[selectorNb].children[0].color = color;
  9277. };
  9278. /** @hidden */
  9279. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9280. this.selectors[selectorNb].children[0].background = color;
  9281. };
  9282. return RadioGroup;
  9283. }(SelectorGroup));
  9284. /** Class used to create a SliderGroup
  9285. * which contains groups of slider buttons
  9286. */
  9287. var SliderGroup = /** @class */ (function (_super) {
  9288. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9289. function SliderGroup() {
  9290. return _super !== null && _super.apply(this, arguments) || this;
  9291. }
  9292. /**
  9293. * Adds a slider to the SelectorGroup
  9294. * @param label is the label for the SliderBar
  9295. * @param func is the function called when the Slider moves
  9296. * @param unit is a string describing the units used, eg degrees or metres
  9297. * @param min is the minimum value for the Slider
  9298. * @param max is the maximum value for the Slider
  9299. * @param value is the start value for the Slider between min and max
  9300. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9301. */
  9302. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9303. if (func === void 0) { func = function (v) { }; }
  9304. if (unit === void 0) { unit = "Units"; }
  9305. if (min === void 0) { min = 0; }
  9306. if (max === void 0) { max = 0; }
  9307. if (value === void 0) { value = 0; }
  9308. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9309. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9310. button.name = unit;
  9311. button.value = value;
  9312. button.minimum = min;
  9313. button.maximum = max;
  9314. button.width = 0.9;
  9315. button.height = "20px";
  9316. button.color = "#364249";
  9317. button.background = "#CCCCCC";
  9318. button.borderColor = "black";
  9319. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9320. button.left = "4px";
  9321. button.paddingBottom = "4px";
  9322. button.onValueChangedObservable.add(function (value) {
  9323. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9324. func(value);
  9325. });
  9326. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9327. _selector.height = "60px";
  9328. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9329. _selector.left = "4px";
  9330. _selector.children[0].name = label;
  9331. this.groupPanel.addControl(_selector);
  9332. this.selectors.push(_selector);
  9333. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9334. button.color = this.groupPanel.parent.parent.buttonColor;
  9335. button.background = this.groupPanel.parent.parent.buttonBackground;
  9336. }
  9337. };
  9338. /** @hidden */
  9339. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9340. this.selectors[selectorNb].children[0].name = label;
  9341. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9342. };
  9343. /** @hidden */
  9344. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9345. this.selectors[selectorNb].children[0].color = color;
  9346. };
  9347. /** @hidden */
  9348. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9349. this.selectors[selectorNb].children[1].color = color;
  9350. };
  9351. /** @hidden */
  9352. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9353. this.selectors[selectorNb].children[1].background = color;
  9354. };
  9355. return SliderGroup;
  9356. }(SelectorGroup));
  9357. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9358. * @see http://doc.babylonjs.com/how_to/selector
  9359. */
  9360. var SelectionPanel = /** @class */ (function (_super) {
  9361. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9362. /**
  9363. * Creates a new SelectionPanel
  9364. * @param name of SelectionPanel
  9365. * @param groups is an array of SelectionGroups
  9366. */
  9367. function SelectionPanel(
  9368. /** name of SelectionPanel */
  9369. name,
  9370. /** an array of SelectionGroups */
  9371. groups) {
  9372. if (groups === void 0) { groups = []; }
  9373. var _this = _super.call(this, name) || this;
  9374. _this.name = name;
  9375. _this.groups = groups;
  9376. _this._buttonColor = "#364249";
  9377. _this._buttonBackground = "#CCCCCC";
  9378. _this._headerColor = "black";
  9379. _this._barColor = "white";
  9380. _this._barHeight = "2px";
  9381. _this._spacerHeight = "20px";
  9382. _this._bars = new Array();
  9383. _this._groups = groups;
  9384. _this.thickness = 2;
  9385. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9386. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9387. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9388. _this._panel.top = 5;
  9389. _this._panel.left = 5;
  9390. _this._panel.width = 0.95;
  9391. if (groups.length > 0) {
  9392. for (var i = 0; i < groups.length - 1; i++) {
  9393. _this._panel.addControl(groups[i].groupPanel);
  9394. _this._addSpacer();
  9395. }
  9396. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9397. }
  9398. _this.addControl(_this._panel);
  9399. return _this;
  9400. }
  9401. SelectionPanel.prototype._getTypeName = function () {
  9402. return "SelectionPanel";
  9403. };
  9404. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9405. /** Gets or sets the headerColor */
  9406. get: function () {
  9407. return this._headerColor;
  9408. },
  9409. set: function (color) {
  9410. if (this._headerColor === color) {
  9411. return;
  9412. }
  9413. this._headerColor = color;
  9414. this._setHeaderColor();
  9415. },
  9416. enumerable: true,
  9417. configurable: true
  9418. });
  9419. SelectionPanel.prototype._setHeaderColor = function () {
  9420. for (var i = 0; i < this._groups.length; i++) {
  9421. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9422. }
  9423. };
  9424. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9425. /** Gets or sets the button color */
  9426. get: function () {
  9427. return this._buttonColor;
  9428. },
  9429. set: function (color) {
  9430. if (this._buttonColor === color) {
  9431. return;
  9432. }
  9433. this._buttonColor = color;
  9434. this._setbuttonColor();
  9435. },
  9436. enumerable: true,
  9437. configurable: true
  9438. });
  9439. SelectionPanel.prototype._setbuttonColor = function () {
  9440. for (var i = 0; i < this._groups.length; i++) {
  9441. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9442. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9443. }
  9444. }
  9445. };
  9446. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9447. /** Gets or sets the label color */
  9448. get: function () {
  9449. return this._labelColor;
  9450. },
  9451. set: function (color) {
  9452. if (this._labelColor === color) {
  9453. return;
  9454. }
  9455. this._labelColor = color;
  9456. this._setLabelColor();
  9457. },
  9458. enumerable: true,
  9459. configurable: true
  9460. });
  9461. SelectionPanel.prototype._setLabelColor = function () {
  9462. for (var i = 0; i < this._groups.length; i++) {
  9463. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9464. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9465. }
  9466. }
  9467. };
  9468. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9469. /** Gets or sets the button background */
  9470. get: function () {
  9471. return this._buttonBackground;
  9472. },
  9473. set: function (color) {
  9474. if (this._buttonBackground === color) {
  9475. return;
  9476. }
  9477. this._buttonBackground = color;
  9478. this._setButtonBackground();
  9479. },
  9480. enumerable: true,
  9481. configurable: true
  9482. });
  9483. SelectionPanel.prototype._setButtonBackground = function () {
  9484. for (var i = 0; i < this._groups.length; i++) {
  9485. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9486. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9487. }
  9488. }
  9489. };
  9490. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9491. /** Gets or sets the color of separator bar */
  9492. get: function () {
  9493. return this._barColor;
  9494. },
  9495. set: function (color) {
  9496. if (this._barColor === color) {
  9497. return;
  9498. }
  9499. this._barColor = color;
  9500. this._setBarColor();
  9501. },
  9502. enumerable: true,
  9503. configurable: true
  9504. });
  9505. SelectionPanel.prototype._setBarColor = function () {
  9506. for (var i = 0; i < this._bars.length; i++) {
  9507. this._bars[i].children[0].background = this._barColor;
  9508. }
  9509. };
  9510. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9511. /** Gets or sets the height of separator bar */
  9512. get: function () {
  9513. return this._barHeight;
  9514. },
  9515. set: function (value) {
  9516. if (this._barHeight === value) {
  9517. return;
  9518. }
  9519. this._barHeight = value;
  9520. this._setBarHeight();
  9521. },
  9522. enumerable: true,
  9523. configurable: true
  9524. });
  9525. SelectionPanel.prototype._setBarHeight = function () {
  9526. for (var i = 0; i < this._bars.length; i++) {
  9527. this._bars[i].children[0].height = this._barHeight;
  9528. }
  9529. };
  9530. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9531. /** Gets or sets the height of spacers*/
  9532. get: function () {
  9533. return this._spacerHeight;
  9534. },
  9535. set: function (value) {
  9536. if (this._spacerHeight === value) {
  9537. return;
  9538. }
  9539. this._spacerHeight = value;
  9540. this._setSpacerHeight();
  9541. },
  9542. enumerable: true,
  9543. configurable: true
  9544. });
  9545. SelectionPanel.prototype._setSpacerHeight = function () {
  9546. for (var i = 0; i < this._bars.length; i++) {
  9547. this._bars[i].height = this._spacerHeight;
  9548. }
  9549. };
  9550. /** Adds a bar between groups */
  9551. SelectionPanel.prototype._addSpacer = function () {
  9552. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9553. separator.width = 1;
  9554. separator.height = this._spacerHeight;
  9555. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9556. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9557. bar.width = 1;
  9558. bar.height = this._barHeight;
  9559. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9560. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9561. bar.background = this._barColor;
  9562. bar.color = "transparent";
  9563. separator.addControl(bar);
  9564. this._panel.addControl(separator);
  9565. this._bars.push(separator);
  9566. };
  9567. /** Add a group to the selection panel
  9568. * @param group is the selector group to add
  9569. */
  9570. SelectionPanel.prototype.addGroup = function (group) {
  9571. if (this._groups.length > 0) {
  9572. this._addSpacer();
  9573. }
  9574. this._panel.addControl(group.groupPanel);
  9575. this._groups.push(group);
  9576. group.groupPanel.children[0].color = this._headerColor;
  9577. for (var j = 0; j < group.selectors.length; j++) {
  9578. group._setSelectorButtonColor(j, this._buttonColor);
  9579. group._setSelectorButtonBackground(j, this._buttonBackground);
  9580. }
  9581. };
  9582. /** Remove the group from the given position
  9583. * @param groupNb is the position of the group in the list
  9584. */
  9585. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9586. if (groupNb < 0 || groupNb >= this._groups.length) {
  9587. return;
  9588. }
  9589. var group = this._groups[groupNb];
  9590. this._panel.removeControl(group.groupPanel);
  9591. this._groups.splice(groupNb, 1);
  9592. if (groupNb < this._bars.length) {
  9593. this._panel.removeControl(this._bars[groupNb]);
  9594. this._bars.splice(groupNb, 1);
  9595. }
  9596. };
  9597. /** Change a group header label
  9598. * @param label is the new group header label
  9599. * @param groupNb is the number of the group to relabel
  9600. * */
  9601. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9602. if (groupNb < 0 || groupNb >= this._groups.length) {
  9603. return;
  9604. }
  9605. var group = this._groups[groupNb];
  9606. group.groupPanel.children[0].text = label;
  9607. };
  9608. /** Change selector label to the one given
  9609. * @param label is the new selector label
  9610. * @param groupNb is the number of the groupcontaining the selector
  9611. * @param selectorNb is the number of the selector within a group to relabel
  9612. * */
  9613. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9614. if (groupNb < 0 || groupNb >= this._groups.length) {
  9615. return;
  9616. }
  9617. var group = this._groups[groupNb];
  9618. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9619. return;
  9620. }
  9621. group._setSelectorLabel(selectorNb, label);
  9622. };
  9623. /** For a given group position remove the selector at the given position
  9624. * @param groupNb is the number of the group to remove the selector from
  9625. * @param selectorNb is the number of the selector within the group
  9626. */
  9627. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9628. if (groupNb < 0 || groupNb >= this._groups.length) {
  9629. return;
  9630. }
  9631. var group = this._groups[groupNb];
  9632. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9633. return;
  9634. }
  9635. group.removeSelector(selectorNb);
  9636. };
  9637. /** For a given group position of correct type add a checkbox button
  9638. * @param groupNb is the number of the group to remove the selector from
  9639. * @param label is the label for the selector
  9640. * @param func is the function called when the Selector is checked
  9641. * @param checked is true when Selector is checked
  9642. */
  9643. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9644. if (func === void 0) { func = function () { }; }
  9645. if (checked === void 0) { checked = false; }
  9646. if (groupNb < 0 || groupNb >= this._groups.length) {
  9647. return;
  9648. }
  9649. var group = this._groups[groupNb];
  9650. group.addCheckbox(label, func, checked);
  9651. };
  9652. /** For a given group position of correct type add a radio button
  9653. * @param groupNb is the number of the group to remove the selector from
  9654. * @param label is the label for the selector
  9655. * @param func is the function called when the Selector is checked
  9656. * @param checked is true when Selector is checked
  9657. */
  9658. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9659. if (func === void 0) { func = function () { }; }
  9660. if (checked === void 0) { checked = false; }
  9661. if (groupNb < 0 || groupNb >= this._groups.length) {
  9662. return;
  9663. }
  9664. var group = this._groups[groupNb];
  9665. group.addRadio(label, func, checked);
  9666. };
  9667. /**
  9668. * For a given slider group add a slider
  9669. * @param groupNb is the number of the group to add the slider to
  9670. * @param label is the label for the Slider
  9671. * @param func is the function called when the Slider moves
  9672. * @param unit is a string describing the units used, eg degrees or metres
  9673. * @param min is the minimum value for the Slider
  9674. * @param max is the maximum value for the Slider
  9675. * @param value is the start value for the Slider between min and max
  9676. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9677. */
  9678. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9679. if (func === void 0) { func = function () { }; }
  9680. if (unit === void 0) { unit = "Units"; }
  9681. if (min === void 0) { min = 0; }
  9682. if (max === void 0) { max = 0; }
  9683. if (value === void 0) { value = 0; }
  9684. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9685. if (groupNb < 0 || groupNb >= this._groups.length) {
  9686. return;
  9687. }
  9688. var group = this._groups[groupNb];
  9689. group.addSlider(label, func, unit, min, max, value, onVal);
  9690. };
  9691. return SelectionPanel;
  9692. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9693. /***/ }),
  9694. /***/ "./2D/controls/sliders/baseSlider.ts":
  9695. /*!*******************************************!*\
  9696. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9697. \*******************************************/
  9698. /*! exports provided: BaseSlider */
  9699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9700. "use strict";
  9701. __webpack_require__.r(__webpack_exports__);
  9702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9703. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9704. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  9705. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9706. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9707. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9708. /**
  9709. * Class used to create slider controls
  9710. */
  9711. var BaseSlider = /** @class */ (function (_super) {
  9712. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9713. /**
  9714. * Creates a new BaseSlider
  9715. * @param name defines the control name
  9716. */
  9717. function BaseSlider(name) {
  9718. var _this = _super.call(this, name) || this;
  9719. _this.name = name;
  9720. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9721. _this._minimum = 0;
  9722. _this._maximum = 100;
  9723. _this._value = 50;
  9724. _this._isVertical = false;
  9725. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9726. _this._isThumbClamped = false;
  9727. _this._displayThumb = true;
  9728. _this._step = 0;
  9729. _this._lastPointerDownID = -1;
  9730. // Shared rendering info
  9731. _this._effectiveBarOffset = 0;
  9732. /** Observable raised when the sldier value changes */
  9733. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9734. // Events
  9735. _this._pointerIsDown = false;
  9736. _this.isPointerBlocker = true;
  9737. return _this;
  9738. }
  9739. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9740. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9741. get: function () {
  9742. return this._displayThumb;
  9743. },
  9744. set: function (value) {
  9745. if (this._displayThumb === value) {
  9746. return;
  9747. }
  9748. this._displayThumb = value;
  9749. this._markAsDirty();
  9750. },
  9751. enumerable: true,
  9752. configurable: true
  9753. });
  9754. Object.defineProperty(BaseSlider.prototype, "step", {
  9755. /** Gets or sets a step to apply to values (0 by default) */
  9756. get: function () {
  9757. return this._step;
  9758. },
  9759. set: function (value) {
  9760. if (this._step === value) {
  9761. return;
  9762. }
  9763. this._step = value;
  9764. this._markAsDirty();
  9765. },
  9766. enumerable: true,
  9767. configurable: true
  9768. });
  9769. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9770. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9771. get: function () {
  9772. return this._barOffset.toString(this._host);
  9773. },
  9774. set: function (value) {
  9775. if (this._barOffset.toString(this._host) === value) {
  9776. return;
  9777. }
  9778. if (this._barOffset.fromString(value)) {
  9779. this._markAsDirty();
  9780. }
  9781. },
  9782. enumerable: true,
  9783. configurable: true
  9784. });
  9785. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9786. /** Gets main bar offset in pixels*/
  9787. get: function () {
  9788. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9789. },
  9790. enumerable: true,
  9791. configurable: true
  9792. });
  9793. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9794. /** Gets or sets thumb width */
  9795. get: function () {
  9796. return this._thumbWidth.toString(this._host);
  9797. },
  9798. set: function (value) {
  9799. if (this._thumbWidth.toString(this._host) === value) {
  9800. return;
  9801. }
  9802. if (this._thumbWidth.fromString(value)) {
  9803. this._markAsDirty();
  9804. }
  9805. },
  9806. enumerable: true,
  9807. configurable: true
  9808. });
  9809. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9810. /** Gets thumb width in pixels */
  9811. get: function () {
  9812. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9813. },
  9814. enumerable: true,
  9815. configurable: true
  9816. });
  9817. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9818. /** Gets or sets minimum value */
  9819. get: function () {
  9820. return this._minimum;
  9821. },
  9822. set: function (value) {
  9823. if (this._minimum === value) {
  9824. return;
  9825. }
  9826. this._minimum = value;
  9827. this._markAsDirty();
  9828. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9829. },
  9830. enumerable: true,
  9831. configurable: true
  9832. });
  9833. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9834. /** Gets or sets maximum value */
  9835. get: function () {
  9836. return this._maximum;
  9837. },
  9838. set: function (value) {
  9839. if (this._maximum === value) {
  9840. return;
  9841. }
  9842. this._maximum = value;
  9843. this._markAsDirty();
  9844. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9845. },
  9846. enumerable: true,
  9847. configurable: true
  9848. });
  9849. Object.defineProperty(BaseSlider.prototype, "value", {
  9850. /** Gets or sets current value */
  9851. get: function () {
  9852. return this._value;
  9853. },
  9854. set: function (value) {
  9855. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9856. if (this._value === value) {
  9857. return;
  9858. }
  9859. this._value = value;
  9860. this._markAsDirty();
  9861. this.onValueChangedObservable.notifyObservers(this._value);
  9862. },
  9863. enumerable: true,
  9864. configurable: true
  9865. });
  9866. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9867. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9868. get: function () {
  9869. return this._isVertical;
  9870. },
  9871. set: function (value) {
  9872. if (this._isVertical === value) {
  9873. return;
  9874. }
  9875. this._isVertical = value;
  9876. this._markAsDirty();
  9877. },
  9878. enumerable: true,
  9879. configurable: true
  9880. });
  9881. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9882. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9883. get: function () {
  9884. return this._isThumbClamped;
  9885. },
  9886. set: function (value) {
  9887. if (this._isThumbClamped === value) {
  9888. return;
  9889. }
  9890. this._isThumbClamped = value;
  9891. this._markAsDirty();
  9892. },
  9893. enumerable: true,
  9894. configurable: true
  9895. });
  9896. BaseSlider.prototype._getTypeName = function () {
  9897. return "BaseSlider";
  9898. };
  9899. BaseSlider.prototype._getThumbPosition = function () {
  9900. if (this.isVertical) {
  9901. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9902. }
  9903. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9904. };
  9905. BaseSlider.prototype._getThumbThickness = function (type) {
  9906. var thumbThickness = 0;
  9907. switch (type) {
  9908. case "circle":
  9909. if (this._thumbWidth.isPixel) {
  9910. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9911. }
  9912. else {
  9913. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9914. }
  9915. break;
  9916. case "rectangle":
  9917. if (this._thumbWidth.isPixel) {
  9918. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9919. }
  9920. else {
  9921. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9922. }
  9923. }
  9924. return thumbThickness;
  9925. };
  9926. BaseSlider.prototype._prepareRenderingData = function (type) {
  9927. // Main bar
  9928. this._effectiveBarOffset = 0;
  9929. this._renderLeft = this._currentMeasure.left;
  9930. this._renderTop = this._currentMeasure.top;
  9931. this._renderWidth = this._currentMeasure.width;
  9932. this._renderHeight = this._currentMeasure.height;
  9933. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9934. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9935. this._effectiveThumbThickness = this._getThumbThickness(type);
  9936. if (this.displayThumb) {
  9937. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9938. }
  9939. //throw error when height is less than width for vertical slider
  9940. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9941. console.error("Height should be greater than width");
  9942. return;
  9943. }
  9944. if (this._barOffset.isPixel) {
  9945. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9946. }
  9947. else {
  9948. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9949. }
  9950. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9951. if (this.isVertical) {
  9952. this._renderLeft += this._effectiveBarOffset;
  9953. if (!this.isThumbClamped && this.displayThumb) {
  9954. this._renderTop += (this._effectiveThumbThickness / 2);
  9955. }
  9956. this._renderHeight = this._backgroundBoxLength;
  9957. this._renderWidth = this._backgroundBoxThickness;
  9958. }
  9959. else {
  9960. this._renderTop += this._effectiveBarOffset;
  9961. if (!this.isThumbClamped && this.displayThumb) {
  9962. this._renderLeft += (this._effectiveThumbThickness / 2);
  9963. }
  9964. this._renderHeight = this._backgroundBoxThickness;
  9965. this._renderWidth = this._backgroundBoxLength;
  9966. }
  9967. };
  9968. /** @hidden */
  9969. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9970. if (this.rotation != 0) {
  9971. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9972. x = this._transformedPosition.x;
  9973. y = this._transformedPosition.y;
  9974. }
  9975. var value;
  9976. if (this._isVertical) {
  9977. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9978. }
  9979. else {
  9980. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9981. }
  9982. var mult = (1 / this._step) | 0;
  9983. this.value = this._step ? ((value * mult) | 0) / mult : value;
  9984. };
  9985. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9986. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9987. return false;
  9988. }
  9989. this._pointerIsDown = true;
  9990. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9991. this._host._capturingControl[pointerId] = this;
  9992. this._lastPointerDownID = pointerId;
  9993. return true;
  9994. };
  9995. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  9996. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  9997. if (pointerId != this._lastPointerDownID) {
  9998. return;
  9999. }
  10000. if (this._pointerIsDown) {
  10001. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10002. }
  10003. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10004. };
  10005. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10006. this._pointerIsDown = false;
  10007. delete this._host._capturingControl[pointerId];
  10008. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10009. };
  10010. return BaseSlider;
  10011. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10012. /***/ }),
  10013. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10014. /*!*************************************************!*\
  10015. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10016. \*************************************************/
  10017. /*! exports provided: ImageBasedSlider */
  10018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10019. "use strict";
  10020. __webpack_require__.r(__webpack_exports__);
  10021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10022. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10023. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10024. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10025. /**
  10026. * Class used to create slider controls based on images
  10027. */
  10028. var ImageBasedSlider = /** @class */ (function (_super) {
  10029. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  10030. /**
  10031. * Creates a new ImageBasedSlider
  10032. * @param name defines the control name
  10033. */
  10034. function ImageBasedSlider(name) {
  10035. var _this = _super.call(this, name) || this;
  10036. _this.name = name;
  10037. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10038. return _this;
  10039. }
  10040. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10041. get: function () {
  10042. return this._displayThumb && this.thumbImage != null;
  10043. },
  10044. set: function (value) {
  10045. if (this._displayThumb === value) {
  10046. return;
  10047. }
  10048. this._displayThumb = value;
  10049. this._markAsDirty();
  10050. },
  10051. enumerable: true,
  10052. configurable: true
  10053. });
  10054. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10055. /**
  10056. * Gets or sets the image used to render the background
  10057. */
  10058. get: function () {
  10059. return this._backgroundImage;
  10060. },
  10061. set: function (value) {
  10062. var _this = this;
  10063. if (this._backgroundImage === value) {
  10064. return;
  10065. }
  10066. this._backgroundImage = value;
  10067. if (value && !value.isLoaded) {
  10068. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10069. }
  10070. this._markAsDirty();
  10071. },
  10072. enumerable: true,
  10073. configurable: true
  10074. });
  10075. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10076. /**
  10077. * Gets or sets the image used to render the value bar
  10078. */
  10079. get: function () {
  10080. return this._valueBarImage;
  10081. },
  10082. set: function (value) {
  10083. var _this = this;
  10084. if (this._valueBarImage === value) {
  10085. return;
  10086. }
  10087. this._valueBarImage = value;
  10088. if (value && !value.isLoaded) {
  10089. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10090. }
  10091. this._markAsDirty();
  10092. },
  10093. enumerable: true,
  10094. configurable: true
  10095. });
  10096. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10097. /**
  10098. * Gets or sets the image used to render the thumb
  10099. */
  10100. get: function () {
  10101. return this._thumbImage;
  10102. },
  10103. set: function (value) {
  10104. var _this = this;
  10105. if (this._thumbImage === value) {
  10106. return;
  10107. }
  10108. this._thumbImage = value;
  10109. if (value && !value.isLoaded) {
  10110. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10111. }
  10112. this._markAsDirty();
  10113. },
  10114. enumerable: true,
  10115. configurable: true
  10116. });
  10117. ImageBasedSlider.prototype._getTypeName = function () {
  10118. return "ImageBasedSlider";
  10119. };
  10120. ImageBasedSlider.prototype._draw = function (context) {
  10121. context.save();
  10122. this._applyStates(context);
  10123. this._prepareRenderingData("rectangle");
  10124. var thumbPosition = this._getThumbPosition();
  10125. var left = this._renderLeft;
  10126. var top = this._renderTop;
  10127. var width = this._renderWidth;
  10128. var height = this._renderHeight;
  10129. // Background
  10130. if (this._backgroundImage) {
  10131. this._tempMeasure.copyFromFloats(left, top, width, height);
  10132. if (this.isThumbClamped && this.displayThumb) {
  10133. if (this.isVertical) {
  10134. this._tempMeasure.height += this._effectiveThumbThickness;
  10135. }
  10136. else {
  10137. this._tempMeasure.width += this._effectiveThumbThickness;
  10138. }
  10139. }
  10140. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10141. this._backgroundImage._draw(context);
  10142. }
  10143. // Bar
  10144. if (this._valueBarImage) {
  10145. if (this.isVertical) {
  10146. if (this.isThumbClamped && this.displayThumb) {
  10147. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10148. }
  10149. else {
  10150. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10151. }
  10152. }
  10153. else {
  10154. if (this.isThumbClamped && this.displayThumb) {
  10155. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10156. }
  10157. else {
  10158. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10159. }
  10160. }
  10161. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10162. this._valueBarImage._draw(context);
  10163. }
  10164. // Thumb
  10165. if (this.displayThumb) {
  10166. if (this.isVertical) {
  10167. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10168. }
  10169. else {
  10170. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10171. }
  10172. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10173. this._thumbImage._draw(context);
  10174. }
  10175. context.restore();
  10176. };
  10177. return ImageBasedSlider;
  10178. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10179. /***/ }),
  10180. /***/ "./2D/controls/sliders/scrollBar.ts":
  10181. /*!******************************************!*\
  10182. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10183. \******************************************/
  10184. /*! exports provided: ScrollBar */
  10185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10186. "use strict";
  10187. __webpack_require__.r(__webpack_exports__);
  10188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10189. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10190. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10191. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10192. /**
  10193. * Class used to create slider controls
  10194. */
  10195. var ScrollBar = /** @class */ (function (_super) {
  10196. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10197. /**
  10198. * Creates a new Slider
  10199. * @param name defines the control name
  10200. */
  10201. function ScrollBar(name) {
  10202. var _this = _super.call(this, name) || this;
  10203. _this.name = name;
  10204. _this._background = "black";
  10205. _this._borderColor = "white";
  10206. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10207. return _this;
  10208. }
  10209. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10210. /** Gets or sets border color */
  10211. get: function () {
  10212. return this._borderColor;
  10213. },
  10214. set: function (value) {
  10215. if (this._borderColor === value) {
  10216. return;
  10217. }
  10218. this._borderColor = value;
  10219. this._markAsDirty();
  10220. },
  10221. enumerable: true,
  10222. configurable: true
  10223. });
  10224. Object.defineProperty(ScrollBar.prototype, "background", {
  10225. /** Gets or sets background color */
  10226. get: function () {
  10227. return this._background;
  10228. },
  10229. set: function (value) {
  10230. if (this._background === value) {
  10231. return;
  10232. }
  10233. this._background = value;
  10234. this._markAsDirty();
  10235. },
  10236. enumerable: true,
  10237. configurable: true
  10238. });
  10239. ScrollBar.prototype._getTypeName = function () {
  10240. return "Scrollbar";
  10241. };
  10242. ScrollBar.prototype._getThumbThickness = function () {
  10243. var thumbThickness = 0;
  10244. if (this._thumbWidth.isPixel) {
  10245. thumbThickness = this._thumbWidth.getValue(this._host);
  10246. }
  10247. else {
  10248. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10249. }
  10250. return thumbThickness;
  10251. };
  10252. ScrollBar.prototype._draw = function (context) {
  10253. context.save();
  10254. this._applyStates(context);
  10255. this._prepareRenderingData("rectangle");
  10256. var left = this._renderLeft;
  10257. var thumbPosition = this._getThumbPosition();
  10258. context.fillStyle = this._background;
  10259. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10260. // Value bar
  10261. context.fillStyle = this.color;
  10262. // Thumb
  10263. if (this.isVertical) {
  10264. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10265. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10266. this._thumbMeasure.width = this._currentMeasure.width;
  10267. this._thumbMeasure.height = this._effectiveThumbThickness;
  10268. }
  10269. else {
  10270. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10271. this._thumbMeasure.top = this._currentMeasure.top;
  10272. this._thumbMeasure.width = this._effectiveThumbThickness;
  10273. this._thumbMeasure.height = this._currentMeasure.height;
  10274. }
  10275. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10276. context.restore();
  10277. };
  10278. /** @hidden */
  10279. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10280. if (this.rotation != 0) {
  10281. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10282. x = this._transformedPosition.x;
  10283. y = this._transformedPosition.y;
  10284. }
  10285. if (this._first) {
  10286. this._first = false;
  10287. this._originX = x;
  10288. this._originY = y;
  10289. // Check if move is required
  10290. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10291. if (this.isVertical) {
  10292. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10293. }
  10294. else {
  10295. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10296. }
  10297. }
  10298. }
  10299. // Delta mode
  10300. var delta = 0;
  10301. if (this.isVertical) {
  10302. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10303. }
  10304. else {
  10305. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10306. }
  10307. this.value += delta * (this.maximum - this.minimum);
  10308. this._originX = x;
  10309. this._originY = y;
  10310. };
  10311. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10312. this._first = true;
  10313. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10314. };
  10315. return ScrollBar;
  10316. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10317. /***/ }),
  10318. /***/ "./2D/controls/sliders/slider.ts":
  10319. /*!***************************************!*\
  10320. !*** ./2D/controls/sliders/slider.ts ***!
  10321. \***************************************/
  10322. /*! exports provided: Slider */
  10323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10324. "use strict";
  10325. __webpack_require__.r(__webpack_exports__);
  10326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10327. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10328. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10329. /**
  10330. * Class used to create slider controls
  10331. */
  10332. var Slider = /** @class */ (function (_super) {
  10333. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10334. /**
  10335. * Creates a new Slider
  10336. * @param name defines the control name
  10337. */
  10338. function Slider(name) {
  10339. var _this = _super.call(this, name) || this;
  10340. _this.name = name;
  10341. _this._background = "black";
  10342. _this._borderColor = "white";
  10343. _this._isThumbCircle = false;
  10344. _this._displayValueBar = true;
  10345. return _this;
  10346. }
  10347. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10348. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10349. get: function () {
  10350. return this._displayValueBar;
  10351. },
  10352. set: function (value) {
  10353. if (this._displayValueBar === value) {
  10354. return;
  10355. }
  10356. this._displayValueBar = value;
  10357. this._markAsDirty();
  10358. },
  10359. enumerable: true,
  10360. configurable: true
  10361. });
  10362. Object.defineProperty(Slider.prototype, "borderColor", {
  10363. /** Gets or sets border color */
  10364. get: function () {
  10365. return this._borderColor;
  10366. },
  10367. set: function (value) {
  10368. if (this._borderColor === value) {
  10369. return;
  10370. }
  10371. this._borderColor = value;
  10372. this._markAsDirty();
  10373. },
  10374. enumerable: true,
  10375. configurable: true
  10376. });
  10377. Object.defineProperty(Slider.prototype, "background", {
  10378. /** Gets or sets background color */
  10379. get: function () {
  10380. return this._background;
  10381. },
  10382. set: function (value) {
  10383. if (this._background === value) {
  10384. return;
  10385. }
  10386. this._background = value;
  10387. this._markAsDirty();
  10388. },
  10389. enumerable: true,
  10390. configurable: true
  10391. });
  10392. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10393. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10394. get: function () {
  10395. return this._isThumbCircle;
  10396. },
  10397. set: function (value) {
  10398. if (this._isThumbCircle === value) {
  10399. return;
  10400. }
  10401. this._isThumbCircle = value;
  10402. this._markAsDirty();
  10403. },
  10404. enumerable: true,
  10405. configurable: true
  10406. });
  10407. Slider.prototype._getTypeName = function () {
  10408. return "Slider";
  10409. };
  10410. Slider.prototype._draw = function (context) {
  10411. context.save();
  10412. this._applyStates(context);
  10413. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10414. var left = this._renderLeft;
  10415. var top = this._renderTop;
  10416. var width = this._renderWidth;
  10417. var height = this._renderHeight;
  10418. var radius = 0;
  10419. if (this.isThumbClamped && this.isThumbCircle) {
  10420. if (this.isVertical) {
  10421. top += (this._effectiveThumbThickness / 2);
  10422. }
  10423. else {
  10424. left += (this._effectiveThumbThickness / 2);
  10425. }
  10426. radius = this._backgroundBoxThickness / 2;
  10427. }
  10428. else {
  10429. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10430. }
  10431. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10432. context.shadowColor = this.shadowColor;
  10433. context.shadowBlur = this.shadowBlur;
  10434. context.shadowOffsetX = this.shadowOffsetX;
  10435. context.shadowOffsetY = this.shadowOffsetY;
  10436. }
  10437. var thumbPosition = this._getThumbPosition();
  10438. context.fillStyle = this._background;
  10439. if (this.isVertical) {
  10440. if (this.isThumbClamped) {
  10441. if (this.isThumbCircle) {
  10442. context.beginPath();
  10443. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10444. context.fill();
  10445. context.fillRect(left, top, width, height);
  10446. }
  10447. else {
  10448. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10449. }
  10450. }
  10451. else {
  10452. context.fillRect(left, top, width, height);
  10453. }
  10454. }
  10455. else {
  10456. if (this.isThumbClamped) {
  10457. if (this.isThumbCircle) {
  10458. context.beginPath();
  10459. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10460. context.fill();
  10461. context.fillRect(left, top, width, height);
  10462. }
  10463. else {
  10464. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10465. }
  10466. }
  10467. else {
  10468. context.fillRect(left, top, width, height);
  10469. }
  10470. }
  10471. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10472. context.shadowBlur = 0;
  10473. context.shadowOffsetX = 0;
  10474. context.shadowOffsetY = 0;
  10475. }
  10476. // Value bar
  10477. context.fillStyle = this.color;
  10478. if (this._displayValueBar) {
  10479. if (this.isVertical) {
  10480. if (this.isThumbClamped) {
  10481. if (this.isThumbCircle) {
  10482. context.beginPath();
  10483. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10484. context.fill();
  10485. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10486. }
  10487. else {
  10488. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10489. }
  10490. }
  10491. else {
  10492. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10493. }
  10494. }
  10495. else {
  10496. if (this.isThumbClamped) {
  10497. if (this.isThumbCircle) {
  10498. context.beginPath();
  10499. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10500. context.fill();
  10501. context.fillRect(left, top, thumbPosition, height);
  10502. }
  10503. else {
  10504. context.fillRect(left, top, thumbPosition, height);
  10505. }
  10506. }
  10507. else {
  10508. context.fillRect(left, top, thumbPosition, height);
  10509. }
  10510. }
  10511. }
  10512. // Thumb
  10513. if (this.displayThumb) {
  10514. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10515. context.shadowColor = this.shadowColor;
  10516. context.shadowBlur = this.shadowBlur;
  10517. context.shadowOffsetX = this.shadowOffsetX;
  10518. context.shadowOffsetY = this.shadowOffsetY;
  10519. }
  10520. if (this._isThumbCircle) {
  10521. context.beginPath();
  10522. if (this.isVertical) {
  10523. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10524. }
  10525. else {
  10526. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10527. }
  10528. context.fill();
  10529. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10530. context.shadowBlur = 0;
  10531. context.shadowOffsetX = 0;
  10532. context.shadowOffsetY = 0;
  10533. }
  10534. context.strokeStyle = this._borderColor;
  10535. context.stroke();
  10536. }
  10537. else {
  10538. if (this.isVertical) {
  10539. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10540. }
  10541. else {
  10542. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10543. }
  10544. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10545. context.shadowBlur = 0;
  10546. context.shadowOffsetX = 0;
  10547. context.shadowOffsetY = 0;
  10548. }
  10549. context.strokeStyle = this._borderColor;
  10550. if (this.isVertical) {
  10551. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10552. }
  10553. else {
  10554. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10555. }
  10556. }
  10557. }
  10558. context.restore();
  10559. };
  10560. return Slider;
  10561. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10562. /***/ }),
  10563. /***/ "./2D/controls/stackPanel.ts":
  10564. /*!***********************************!*\
  10565. !*** ./2D/controls/stackPanel.ts ***!
  10566. \***********************************/
  10567. /*! exports provided: StackPanel */
  10568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10569. "use strict";
  10570. __webpack_require__.r(__webpack_exports__);
  10571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10572. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10573. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  10574. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10575. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10576. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10577. /**
  10578. * Class used to create a 2D stack panel container
  10579. */
  10580. var StackPanel = /** @class */ (function (_super) {
  10581. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10582. /**
  10583. * Creates a new StackPanel
  10584. * @param name defines control name
  10585. */
  10586. function StackPanel(name) {
  10587. var _this = _super.call(this, name) || this;
  10588. _this.name = name;
  10589. _this._isVertical = true;
  10590. _this._manualWidth = false;
  10591. _this._manualHeight = false;
  10592. _this._doNotTrackManualChanges = false;
  10593. return _this;
  10594. }
  10595. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10596. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10597. get: function () {
  10598. return this._isVertical;
  10599. },
  10600. set: function (value) {
  10601. if (this._isVertical === value) {
  10602. return;
  10603. }
  10604. this._isVertical = value;
  10605. this._markAsDirty();
  10606. },
  10607. enumerable: true,
  10608. configurable: true
  10609. });
  10610. Object.defineProperty(StackPanel.prototype, "width", {
  10611. get: function () {
  10612. return this._width.toString(this._host);
  10613. },
  10614. /**
  10615. * Gets or sets panel width.
  10616. * This value should not be set when in horizontal mode as it will be computed automatically
  10617. */
  10618. set: function (value) {
  10619. if (!this._doNotTrackManualChanges) {
  10620. this._manualWidth = true;
  10621. }
  10622. if (this._width.toString(this._host) === value) {
  10623. return;
  10624. }
  10625. if (this._width.fromString(value)) {
  10626. this._markAsDirty();
  10627. }
  10628. },
  10629. enumerable: true,
  10630. configurable: true
  10631. });
  10632. Object.defineProperty(StackPanel.prototype, "height", {
  10633. get: function () {
  10634. return this._height.toString(this._host);
  10635. },
  10636. /**
  10637. * Gets or sets panel height.
  10638. * This value should not be set when in vertical mode as it will be computed automatically
  10639. */
  10640. set: function (value) {
  10641. if (!this._doNotTrackManualChanges) {
  10642. this._manualHeight = true;
  10643. }
  10644. if (this._height.toString(this._host) === value) {
  10645. return;
  10646. }
  10647. if (this._height.fromString(value)) {
  10648. this._markAsDirty();
  10649. }
  10650. },
  10651. enumerable: true,
  10652. configurable: true
  10653. });
  10654. StackPanel.prototype._getTypeName = function () {
  10655. return "StackPanel";
  10656. };
  10657. /** @hidden */
  10658. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10659. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10660. var child = _a[_i];
  10661. if (this._isVertical) {
  10662. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10663. }
  10664. else {
  10665. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10666. }
  10667. }
  10668. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10669. };
  10670. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10671. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10672. this._measureForChildren.copyFrom(parentMeasure);
  10673. this._measureForChildren.left = this._currentMeasure.left;
  10674. this._measureForChildren.top = this._currentMeasure.top;
  10675. if (!this.isVertical || this._manualWidth) {
  10676. this._measureForChildren.width = this._currentMeasure.width;
  10677. }
  10678. if (this.isVertical || this._manualHeight) {
  10679. this._measureForChildren.height = this._currentMeasure.height;
  10680. }
  10681. };
  10682. StackPanel.prototype._postMeasure = function () {
  10683. var stackWidth = 0;
  10684. var stackHeight = 0;
  10685. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10686. var child = _a[_i];
  10687. if (!child.isVisible || child.notRenderable) {
  10688. continue;
  10689. }
  10690. if (this._isVertical) {
  10691. if (child.top !== stackHeight + "px") {
  10692. child.top = stackHeight + "px";
  10693. this._rebuildLayout = true;
  10694. child._top.ignoreAdaptiveScaling = true;
  10695. }
  10696. if (child._height.isPercentage) {
  10697. 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");
  10698. }
  10699. else {
  10700. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10701. }
  10702. }
  10703. else {
  10704. if (child.left !== stackWidth + "px") {
  10705. child.left = stackWidth + "px";
  10706. this._rebuildLayout = true;
  10707. child._left.ignoreAdaptiveScaling = true;
  10708. }
  10709. if (child._width.isPercentage) {
  10710. 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");
  10711. }
  10712. else {
  10713. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10714. }
  10715. }
  10716. }
  10717. this._doNotTrackManualChanges = true;
  10718. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10719. // User can now define their own height and width for stack panel.
  10720. var panelWidthChanged = false;
  10721. var panelHeightChanged = false;
  10722. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10723. var previousHeight = this.height;
  10724. this.height = stackHeight + "px";
  10725. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10726. }
  10727. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10728. var previousWidth = this.width;
  10729. this.width = stackWidth + "px";
  10730. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10731. }
  10732. if (panelHeightChanged) {
  10733. this._height.ignoreAdaptiveScaling = true;
  10734. }
  10735. if (panelWidthChanged) {
  10736. this._width.ignoreAdaptiveScaling = true;
  10737. }
  10738. this._doNotTrackManualChanges = false;
  10739. if (panelWidthChanged || panelHeightChanged) {
  10740. this._rebuildLayout = true;
  10741. }
  10742. _super.prototype._postMeasure.call(this);
  10743. };
  10744. return StackPanel;
  10745. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10746. /***/ }),
  10747. /***/ "./2D/controls/statics.ts":
  10748. /*!********************************!*\
  10749. !*** ./2D/controls/statics.ts ***!
  10750. \********************************/
  10751. /*! exports provided: name */
  10752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10753. "use strict";
  10754. __webpack_require__.r(__webpack_exports__);
  10755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10756. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10757. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10758. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10759. /**
  10760. * Forcing an export so that this code will execute
  10761. * @hidden
  10762. */
  10763. var name = "Statics";
  10764. /**
  10765. * Creates a stack panel that can be used to render headers
  10766. * @param control defines the control to associate with the header
  10767. * @param text defines the text of the header
  10768. * @param size defines the size of the header
  10769. * @param options defines options used to configure the header
  10770. * @returns a new StackPanel
  10771. */
  10772. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10773. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10774. var isHorizontal = options ? options.isHorizontal : true;
  10775. var controlFirst = options ? options.controlFirst : true;
  10776. panel.isVertical = !isHorizontal;
  10777. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10778. header.text = text;
  10779. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10780. if (isHorizontal) {
  10781. header.width = size;
  10782. }
  10783. else {
  10784. header.height = size;
  10785. }
  10786. if (controlFirst) {
  10787. panel.addControl(control);
  10788. panel.addControl(header);
  10789. header.paddingLeft = "5px";
  10790. }
  10791. else {
  10792. panel.addControl(header);
  10793. panel.addControl(control);
  10794. header.paddingRight = "5px";
  10795. }
  10796. header.shadowBlur = control.shadowBlur;
  10797. header.shadowColor = control.shadowColor;
  10798. header.shadowOffsetX = control.shadowOffsetX;
  10799. header.shadowOffsetY = control.shadowOffsetY;
  10800. return panel;
  10801. };
  10802. /***/ }),
  10803. /***/ "./2D/controls/textBlock.ts":
  10804. /*!**********************************!*\
  10805. !*** ./2D/controls/textBlock.ts ***!
  10806. \**********************************/
  10807. /*! exports provided: TextWrapping, TextBlock */
  10808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10809. "use strict";
  10810. __webpack_require__.r(__webpack_exports__);
  10811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10813. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10814. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10815. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10816. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10817. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10818. /**
  10819. * Enum that determines the text-wrapping mode to use.
  10820. */
  10821. var TextWrapping;
  10822. (function (TextWrapping) {
  10823. /**
  10824. * Clip the text when it's larger than Control.width; this is the default mode.
  10825. */
  10826. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10827. /**
  10828. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10829. */
  10830. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10831. /**
  10832. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10833. */
  10834. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10835. })(TextWrapping || (TextWrapping = {}));
  10836. /**
  10837. * Class used to create text block control
  10838. */
  10839. var TextBlock = /** @class */ (function (_super) {
  10840. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10841. /**
  10842. * Creates a new TextBlock object
  10843. * @param name defines the name of the control
  10844. * @param text defines the text to display (emptry string by default)
  10845. */
  10846. function TextBlock(
  10847. /**
  10848. * Defines the name of the control
  10849. */
  10850. name, text) {
  10851. if (text === void 0) { text = ""; }
  10852. var _this = _super.call(this, name) || this;
  10853. _this.name = name;
  10854. _this._text = "";
  10855. _this._textWrapping = TextWrapping.Clip;
  10856. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10857. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10858. _this._resizeToFit = false;
  10859. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10860. _this._outlineWidth = 0;
  10861. _this._outlineColor = "white";
  10862. /**
  10863. * An event triggered after the text is changed
  10864. */
  10865. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10866. /**
  10867. * An event triggered after the text was broken up into lines
  10868. */
  10869. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10870. _this.text = text;
  10871. return _this;
  10872. }
  10873. Object.defineProperty(TextBlock.prototype, "lines", {
  10874. /**
  10875. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10876. */
  10877. get: function () {
  10878. return this._lines;
  10879. },
  10880. enumerable: true,
  10881. configurable: true
  10882. });
  10883. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10884. /**
  10885. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10886. */
  10887. get: function () {
  10888. return this._resizeToFit;
  10889. },
  10890. /**
  10891. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10892. */
  10893. set: function (value) {
  10894. if (this._resizeToFit === value) {
  10895. return;
  10896. }
  10897. this._resizeToFit = value;
  10898. if (this._resizeToFit) {
  10899. this._width.ignoreAdaptiveScaling = true;
  10900. this._height.ignoreAdaptiveScaling = true;
  10901. }
  10902. this._markAsDirty();
  10903. },
  10904. enumerable: true,
  10905. configurable: true
  10906. });
  10907. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10908. /**
  10909. * Gets or sets a boolean indicating if text must be wrapped
  10910. */
  10911. get: function () {
  10912. return this._textWrapping;
  10913. },
  10914. /**
  10915. * Gets or sets a boolean indicating if text must be wrapped
  10916. */
  10917. set: function (value) {
  10918. if (this._textWrapping === value) {
  10919. return;
  10920. }
  10921. this._textWrapping = +value;
  10922. this._markAsDirty();
  10923. },
  10924. enumerable: true,
  10925. configurable: true
  10926. });
  10927. Object.defineProperty(TextBlock.prototype, "text", {
  10928. /**
  10929. * Gets or sets text to display
  10930. */
  10931. get: function () {
  10932. return this._text;
  10933. },
  10934. /**
  10935. * Gets or sets text to display
  10936. */
  10937. set: function (value) {
  10938. if (this._text === value) {
  10939. return;
  10940. }
  10941. this._text = value;
  10942. this._markAsDirty();
  10943. this.onTextChangedObservable.notifyObservers(this);
  10944. },
  10945. enumerable: true,
  10946. configurable: true
  10947. });
  10948. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10949. /**
  10950. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10951. */
  10952. get: function () {
  10953. return this._textHorizontalAlignment;
  10954. },
  10955. /**
  10956. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10957. */
  10958. set: function (value) {
  10959. if (this._textHorizontalAlignment === value) {
  10960. return;
  10961. }
  10962. this._textHorizontalAlignment = value;
  10963. this._markAsDirty();
  10964. },
  10965. enumerable: true,
  10966. configurable: true
  10967. });
  10968. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10969. /**
  10970. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10971. */
  10972. get: function () {
  10973. return this._textVerticalAlignment;
  10974. },
  10975. /**
  10976. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10977. */
  10978. set: function (value) {
  10979. if (this._textVerticalAlignment === value) {
  10980. return;
  10981. }
  10982. this._textVerticalAlignment = value;
  10983. this._markAsDirty();
  10984. },
  10985. enumerable: true,
  10986. configurable: true
  10987. });
  10988. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10989. /**
  10990. * Gets or sets line spacing value
  10991. */
  10992. get: function () {
  10993. return this._lineSpacing.toString(this._host);
  10994. },
  10995. /**
  10996. * Gets or sets line spacing value
  10997. */
  10998. set: function (value) {
  10999. if (this._lineSpacing.fromString(value)) {
  11000. this._markAsDirty();
  11001. }
  11002. },
  11003. enumerable: true,
  11004. configurable: true
  11005. });
  11006. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11007. /**
  11008. * Gets or sets outlineWidth of the text to display
  11009. */
  11010. get: function () {
  11011. return this._outlineWidth;
  11012. },
  11013. /**
  11014. * Gets or sets outlineWidth of the text to display
  11015. */
  11016. set: function (value) {
  11017. if (this._outlineWidth === value) {
  11018. return;
  11019. }
  11020. this._outlineWidth = value;
  11021. this._markAsDirty();
  11022. },
  11023. enumerable: true,
  11024. configurable: true
  11025. });
  11026. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11027. /**
  11028. * Gets or sets outlineColor of the text to display
  11029. */
  11030. get: function () {
  11031. return this._outlineColor;
  11032. },
  11033. /**
  11034. * Gets or sets outlineColor of the text to display
  11035. */
  11036. set: function (value) {
  11037. if (this._outlineColor === value) {
  11038. return;
  11039. }
  11040. this._outlineColor = value;
  11041. this._markAsDirty();
  11042. },
  11043. enumerable: true,
  11044. configurable: true
  11045. });
  11046. TextBlock.prototype._getTypeName = function () {
  11047. return "TextBlock";
  11048. };
  11049. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11050. if (!this._fontOffset) {
  11051. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11052. }
  11053. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11054. // Prepare lines
  11055. this._lines = this._breakLines(this._currentMeasure.width, context);
  11056. this.onLinesReadyObservable.notifyObservers(this);
  11057. var maxLineWidth = 0;
  11058. for (var i = 0; i < this._lines.length; i++) {
  11059. var line = this._lines[i];
  11060. if (line.width > maxLineWidth) {
  11061. maxLineWidth = line.width;
  11062. }
  11063. }
  11064. if (this._resizeToFit) {
  11065. if (this._textWrapping === TextWrapping.Clip) {
  11066. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11067. if (newWidth !== this._width.internalValue) {
  11068. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11069. this._rebuildLayout = true;
  11070. }
  11071. }
  11072. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11073. if (newHeight !== this._height.internalValue) {
  11074. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11075. this._rebuildLayout = true;
  11076. }
  11077. }
  11078. };
  11079. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11080. var width = this._currentMeasure.width;
  11081. var x = 0;
  11082. switch (this._textHorizontalAlignment) {
  11083. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11084. x = 0;
  11085. break;
  11086. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11087. x = width - textWidth;
  11088. break;
  11089. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11090. x = (width - textWidth) / 2;
  11091. break;
  11092. }
  11093. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11094. context.shadowColor = this.shadowColor;
  11095. context.shadowBlur = this.shadowBlur;
  11096. context.shadowOffsetX = this.shadowOffsetX;
  11097. context.shadowOffsetY = this.shadowOffsetY;
  11098. }
  11099. if (this.outlineWidth) {
  11100. context.strokeText(text, this._currentMeasure.left + x, y);
  11101. }
  11102. context.fillText(text, this._currentMeasure.left + x, y);
  11103. };
  11104. /** @hidden */
  11105. TextBlock.prototype._draw = function (context) {
  11106. context.save();
  11107. this._applyStates(context);
  11108. // Render lines
  11109. this._renderLines(context);
  11110. context.restore();
  11111. };
  11112. TextBlock.prototype._applyStates = function (context) {
  11113. _super.prototype._applyStates.call(this, context);
  11114. if (this.outlineWidth) {
  11115. context.lineWidth = this.outlineWidth;
  11116. context.strokeStyle = this.outlineColor;
  11117. }
  11118. };
  11119. TextBlock.prototype._breakLines = function (refWidth, context) {
  11120. var lines = [];
  11121. var _lines = this.text.split("\n");
  11122. if (this._textWrapping === TextWrapping.Ellipsis) {
  11123. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11124. var _line = _lines_1[_i];
  11125. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11126. }
  11127. }
  11128. else if (this._textWrapping === TextWrapping.WordWrap) {
  11129. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11130. var _line = _lines_2[_a];
  11131. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11132. }
  11133. }
  11134. else {
  11135. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11136. var _line = _lines_3[_b];
  11137. lines.push(this._parseLine(_line, context));
  11138. }
  11139. }
  11140. return lines;
  11141. };
  11142. TextBlock.prototype._parseLine = function (line, context) {
  11143. if (line === void 0) { line = ''; }
  11144. return { text: line, width: context.measureText(line).width };
  11145. };
  11146. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11147. if (line === void 0) { line = ''; }
  11148. var lineWidth = context.measureText(line).width;
  11149. if (lineWidth > width) {
  11150. line += '…';
  11151. }
  11152. while (line.length > 2 && lineWidth > width) {
  11153. line = line.slice(0, -2) + '…';
  11154. lineWidth = context.measureText(line).width;
  11155. }
  11156. return { text: line, width: lineWidth };
  11157. };
  11158. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11159. if (line === void 0) { line = ''; }
  11160. var lines = [];
  11161. var words = line.split(' ');
  11162. var lineWidth = 0;
  11163. for (var n = 0; n < words.length; n++) {
  11164. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11165. var metrics = context.measureText(testLine);
  11166. var testWidth = metrics.width;
  11167. if (testWidth > width && n > 0) {
  11168. lines.push({ text: line, width: lineWidth });
  11169. line = words[n];
  11170. lineWidth = context.measureText(line).width;
  11171. }
  11172. else {
  11173. lineWidth = testWidth;
  11174. line = testLine;
  11175. }
  11176. }
  11177. lines.push({ text: line, width: lineWidth });
  11178. return lines;
  11179. };
  11180. TextBlock.prototype._renderLines = function (context) {
  11181. var height = this._currentMeasure.height;
  11182. var rootY = 0;
  11183. switch (this._textVerticalAlignment) {
  11184. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11185. rootY = this._fontOffset.ascent;
  11186. break;
  11187. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11188. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11189. break;
  11190. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11191. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11192. break;
  11193. }
  11194. rootY += this._currentMeasure.top;
  11195. for (var i = 0; i < this._lines.length; i++) {
  11196. var line = this._lines[i];
  11197. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11198. if (this._lineSpacing.isPixel) {
  11199. rootY += this._lineSpacing.getValue(this._host);
  11200. }
  11201. else {
  11202. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11203. }
  11204. }
  11205. this._drawText(line.text, line.width, rootY, context);
  11206. rootY += this._fontOffset.height;
  11207. }
  11208. };
  11209. /**
  11210. * Given a width constraint applied on the text block, find the expected height
  11211. * @returns expected height
  11212. */
  11213. TextBlock.prototype.computeExpectedHeight = function () {
  11214. if (this.text && this.widthInPixels) {
  11215. var context_1 = document.createElement('canvas').getContext('2d');
  11216. if (context_1) {
  11217. this._applyStates(context_1);
  11218. if (!this._fontOffset) {
  11219. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11220. }
  11221. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11222. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11223. }
  11224. }
  11225. return 0;
  11226. };
  11227. TextBlock.prototype.dispose = function () {
  11228. _super.prototype.dispose.call(this);
  11229. this.onTextChangedObservable.clear();
  11230. };
  11231. return TextBlock;
  11232. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11233. /***/ }),
  11234. /***/ "./2D/controls/virtualKeyboard.ts":
  11235. /*!****************************************!*\
  11236. !*** ./2D/controls/virtualKeyboard.ts ***!
  11237. \****************************************/
  11238. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11240. "use strict";
  11241. __webpack_require__.r(__webpack_exports__);
  11242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11244. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11245. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11246. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11247. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11248. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11249. /**
  11250. * Class used to store key control properties
  11251. */
  11252. var KeyPropertySet = /** @class */ (function () {
  11253. function KeyPropertySet() {
  11254. }
  11255. return KeyPropertySet;
  11256. }());
  11257. /**
  11258. * Class used to create virtual keyboard
  11259. */
  11260. var VirtualKeyboard = /** @class */ (function (_super) {
  11261. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11262. function VirtualKeyboard() {
  11263. var _this = _super !== null && _super.apply(this, arguments) || this;
  11264. /** Observable raised when a key is pressed */
  11265. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11266. /** Gets or sets default key button width */
  11267. _this.defaultButtonWidth = "40px";
  11268. /** Gets or sets default key button height */
  11269. _this.defaultButtonHeight = "40px";
  11270. /** Gets or sets default key button left padding */
  11271. _this.defaultButtonPaddingLeft = "2px";
  11272. /** Gets or sets default key button right padding */
  11273. _this.defaultButtonPaddingRight = "2px";
  11274. /** Gets or sets default key button top padding */
  11275. _this.defaultButtonPaddingTop = "2px";
  11276. /** Gets or sets default key button bottom padding */
  11277. _this.defaultButtonPaddingBottom = "2px";
  11278. /** Gets or sets default key button foreground color */
  11279. _this.defaultButtonColor = "#DDD";
  11280. /** Gets or sets default key button background color */
  11281. _this.defaultButtonBackground = "#070707";
  11282. /** Gets or sets shift button foreground color */
  11283. _this.shiftButtonColor = "#7799FF";
  11284. /** Gets or sets shift button thickness*/
  11285. _this.selectedShiftThickness = 1;
  11286. /** Gets shift key state */
  11287. _this.shiftState = 0;
  11288. _this._currentlyConnectedInputText = null;
  11289. _this._connectedInputTexts = [];
  11290. _this._onKeyPressObserver = null;
  11291. return _this;
  11292. }
  11293. VirtualKeyboard.prototype._getTypeName = function () {
  11294. return "VirtualKeyboard";
  11295. };
  11296. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11297. var _this = this;
  11298. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11299. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11300. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11301. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11302. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11303. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11304. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11305. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11306. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11307. button.thickness = 0;
  11308. button.isFocusInvisible = true;
  11309. button.shadowColor = this.shadowColor;
  11310. button.shadowBlur = this.shadowBlur;
  11311. button.shadowOffsetX = this.shadowOffsetX;
  11312. button.shadowOffsetY = this.shadowOffsetY;
  11313. button.onPointerUpObservable.add(function () {
  11314. _this.onKeyPressObservable.notifyObservers(key);
  11315. });
  11316. return button;
  11317. };
  11318. /**
  11319. * Adds a new row of keys
  11320. * @param keys defines the list of keys to add
  11321. * @param propertySets defines the associated property sets
  11322. */
  11323. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11324. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11325. panel.isVertical = false;
  11326. panel.isFocusInvisible = true;
  11327. var maxKey = null;
  11328. for (var i = 0; i < keys.length; i++) {
  11329. var properties = null;
  11330. if (propertySets && propertySets.length === keys.length) {
  11331. properties = propertySets[i];
  11332. }
  11333. var key = this._createKey(keys[i], properties);
  11334. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11335. maxKey = key;
  11336. }
  11337. panel.addControl(key);
  11338. }
  11339. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11340. this.addControl(panel);
  11341. };
  11342. /**
  11343. * Set the shift key to a specific state
  11344. * @param shiftState defines the new shift state
  11345. */
  11346. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11347. if (!this.children) {
  11348. return;
  11349. }
  11350. for (var i = 0; i < this.children.length; i++) {
  11351. var row = this.children[i];
  11352. if (!row || !row.children) {
  11353. continue;
  11354. }
  11355. var rowContainer = row;
  11356. for (var j = 0; j < rowContainer.children.length; j++) {
  11357. var button = rowContainer.children[j];
  11358. if (!button || !button.children[0]) {
  11359. continue;
  11360. }
  11361. var button_tblock = button.children[0];
  11362. if (button_tblock.text === "\u21E7") {
  11363. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11364. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11365. }
  11366. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11367. }
  11368. }
  11369. };
  11370. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11371. /** Gets the input text control currently attached to the keyboard */
  11372. get: function () {
  11373. return this._currentlyConnectedInputText;
  11374. },
  11375. enumerable: true,
  11376. configurable: true
  11377. });
  11378. /**
  11379. * Connects the keyboard with an input text control
  11380. *
  11381. * @param input defines the target control
  11382. */
  11383. VirtualKeyboard.prototype.connect = function (input) {
  11384. var _this = this;
  11385. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11386. if (inputTextAlreadyConnected) {
  11387. return;
  11388. }
  11389. if (this._onKeyPressObserver === null) {
  11390. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11391. if (!_this._currentlyConnectedInputText) {
  11392. return;
  11393. }
  11394. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11395. switch (key) {
  11396. case "\u21E7":
  11397. _this.shiftState++;
  11398. if (_this.shiftState > 2) {
  11399. _this.shiftState = 0;
  11400. }
  11401. _this.applyShiftState(_this.shiftState);
  11402. return;
  11403. case "\u2190":
  11404. _this._currentlyConnectedInputText.processKey(8);
  11405. return;
  11406. case "\u21B5":
  11407. _this._currentlyConnectedInputText.processKey(13);
  11408. return;
  11409. }
  11410. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11411. if (_this.shiftState === 1) {
  11412. _this.shiftState = 0;
  11413. _this.applyShiftState(_this.shiftState);
  11414. }
  11415. });
  11416. }
  11417. this.isVisible = false;
  11418. this._currentlyConnectedInputText = input;
  11419. input._connectedVirtualKeyboard = this;
  11420. // Events hooking
  11421. var onFocusObserver = input.onFocusObservable.add(function () {
  11422. _this._currentlyConnectedInputText = input;
  11423. input._connectedVirtualKeyboard = _this;
  11424. _this.isVisible = true;
  11425. });
  11426. var onBlurObserver = input.onBlurObservable.add(function () {
  11427. input._connectedVirtualKeyboard = null;
  11428. _this._currentlyConnectedInputText = null;
  11429. _this.isVisible = false;
  11430. });
  11431. this._connectedInputTexts.push({
  11432. input: input,
  11433. onBlurObserver: onBlurObserver,
  11434. onFocusObserver: onFocusObserver
  11435. });
  11436. };
  11437. /**
  11438. * Disconnects the keyboard from connected InputText controls
  11439. *
  11440. * @param input optionally defines a target control, otherwise all are disconnected
  11441. */
  11442. VirtualKeyboard.prototype.disconnect = function (input) {
  11443. var _this = this;
  11444. if (input) {
  11445. // .find not available on IE
  11446. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11447. if (filtered.length === 1) {
  11448. this._removeConnectedInputObservables(filtered[0]);
  11449. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11450. if (this._currentlyConnectedInputText === input) {
  11451. this._currentlyConnectedInputText = null;
  11452. }
  11453. }
  11454. }
  11455. else {
  11456. this._connectedInputTexts.forEach(function (connectedInputText) {
  11457. _this._removeConnectedInputObservables(connectedInputText);
  11458. });
  11459. this._connectedInputTexts = [];
  11460. }
  11461. if (this._connectedInputTexts.length === 0) {
  11462. this._currentlyConnectedInputText = null;
  11463. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11464. this._onKeyPressObserver = null;
  11465. }
  11466. };
  11467. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11468. connectedInputText.input._connectedVirtualKeyboard = null;
  11469. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11470. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11471. };
  11472. /**
  11473. * Release all resources
  11474. */
  11475. VirtualKeyboard.prototype.dispose = function () {
  11476. _super.prototype.dispose.call(this);
  11477. this.disconnect();
  11478. };
  11479. // Statics
  11480. /**
  11481. * Creates a new keyboard using a default layout
  11482. *
  11483. * @param name defines control name
  11484. * @returns a new VirtualKeyboard
  11485. */
  11486. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11487. var returnValue = new VirtualKeyboard(name);
  11488. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11489. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11490. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11491. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11492. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11493. return returnValue;
  11494. };
  11495. return VirtualKeyboard;
  11496. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11497. /***/ }),
  11498. /***/ "./2D/index.ts":
  11499. /*!*********************!*\
  11500. !*** ./2D/index.ts ***!
  11501. \*********************/
  11502. /*! 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 */
  11503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11504. "use strict";
  11505. __webpack_require__.r(__webpack_exports__);
  11506. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11538. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11540. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11542. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11545. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11547. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11549. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11551. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11553. /***/ }),
  11554. /***/ "./2D/math2D.ts":
  11555. /*!**********************!*\
  11556. !*** ./2D/math2D.ts ***!
  11557. \**********************/
  11558. /*! exports provided: Vector2WithInfo, Matrix2D */
  11559. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11560. "use strict";
  11561. __webpack_require__.r(__webpack_exports__);
  11562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11564. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11565. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11566. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11567. /**
  11568. * Class used to transport Vector2 information for pointer events
  11569. */
  11570. var Vector2WithInfo = /** @class */ (function (_super) {
  11571. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11572. /**
  11573. * Creates a new Vector2WithInfo
  11574. * @param source defines the vector2 data to transport
  11575. * @param buttonIndex defines the current mouse button index
  11576. */
  11577. function Vector2WithInfo(source,
  11578. /** defines the current mouse button index */
  11579. buttonIndex) {
  11580. if (buttonIndex === void 0) { buttonIndex = 0; }
  11581. var _this = _super.call(this, source.x, source.y) || this;
  11582. _this.buttonIndex = buttonIndex;
  11583. return _this;
  11584. }
  11585. return Vector2WithInfo;
  11586. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11587. /** Class used to provide 2D matrix features */
  11588. var Matrix2D = /** @class */ (function () {
  11589. /**
  11590. * Creates a new matrix
  11591. * @param m00 defines value for (0, 0)
  11592. * @param m01 defines value for (0, 1)
  11593. * @param m10 defines value for (1, 0)
  11594. * @param m11 defines value for (1, 1)
  11595. * @param m20 defines value for (2, 0)
  11596. * @param m21 defines value for (2, 1)
  11597. */
  11598. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11599. /** Gets the internal array of 6 floats used to store matrix data */
  11600. this.m = new Float32Array(6);
  11601. this.fromValues(m00, m01, m10, m11, m20, m21);
  11602. }
  11603. /**
  11604. * Fills the matrix from direct values
  11605. * @param m00 defines value for (0, 0)
  11606. * @param m01 defines value for (0, 1)
  11607. * @param m10 defines value for (1, 0)
  11608. * @param m11 defines value for (1, 1)
  11609. * @param m20 defines value for (2, 0)
  11610. * @param m21 defines value for (2, 1)
  11611. * @returns the current modified matrix
  11612. */
  11613. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11614. this.m[0] = m00;
  11615. this.m[1] = m01;
  11616. this.m[2] = m10;
  11617. this.m[3] = m11;
  11618. this.m[4] = m20;
  11619. this.m[5] = m21;
  11620. return this;
  11621. };
  11622. /**
  11623. * Gets matrix determinant
  11624. * @returns the determinant
  11625. */
  11626. Matrix2D.prototype.determinant = function () {
  11627. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11628. };
  11629. /**
  11630. * Inverses the matrix and stores it in a target matrix
  11631. * @param result defines the target matrix
  11632. * @returns the current matrix
  11633. */
  11634. Matrix2D.prototype.invertToRef = function (result) {
  11635. var l0 = this.m[0];
  11636. var l1 = this.m[1];
  11637. var l2 = this.m[2];
  11638. var l3 = this.m[3];
  11639. var l4 = this.m[4];
  11640. var l5 = this.m[5];
  11641. var det = this.determinant();
  11642. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11643. result.m[0] = 0;
  11644. result.m[1] = 0;
  11645. result.m[2] = 0;
  11646. result.m[3] = 0;
  11647. result.m[4] = 0;
  11648. result.m[5] = 0;
  11649. return this;
  11650. }
  11651. var detDiv = 1 / det;
  11652. var det4 = l2 * l5 - l3 * l4;
  11653. var det5 = l1 * l4 - l0 * l5;
  11654. result.m[0] = l3 * detDiv;
  11655. result.m[1] = -l1 * detDiv;
  11656. result.m[2] = -l2 * detDiv;
  11657. result.m[3] = l0 * detDiv;
  11658. result.m[4] = det4 * detDiv;
  11659. result.m[5] = det5 * detDiv;
  11660. return this;
  11661. };
  11662. /**
  11663. * Multiplies the current matrix with another one
  11664. * @param other defines the second operand
  11665. * @param result defines the target matrix
  11666. * @returns the current matrix
  11667. */
  11668. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11669. var l0 = this.m[0];
  11670. var l1 = this.m[1];
  11671. var l2 = this.m[2];
  11672. var l3 = this.m[3];
  11673. var l4 = this.m[4];
  11674. var l5 = this.m[5];
  11675. var r0 = other.m[0];
  11676. var r1 = other.m[1];
  11677. var r2 = other.m[2];
  11678. var r3 = other.m[3];
  11679. var r4 = other.m[4];
  11680. var r5 = other.m[5];
  11681. result.m[0] = l0 * r0 + l1 * r2;
  11682. result.m[1] = l0 * r1 + l1 * r3;
  11683. result.m[2] = l2 * r0 + l3 * r2;
  11684. result.m[3] = l2 * r1 + l3 * r3;
  11685. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11686. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11687. return this;
  11688. };
  11689. /**
  11690. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11691. * @param x defines the x coordinate to transform
  11692. * @param y defines the x coordinate to transform
  11693. * @param result defines the target vector2
  11694. * @returns the current matrix
  11695. */
  11696. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11697. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11698. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11699. return this;
  11700. };
  11701. // Statics
  11702. /**
  11703. * Creates an identity matrix
  11704. * @returns a new matrix
  11705. */
  11706. Matrix2D.Identity = function () {
  11707. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11708. };
  11709. /**
  11710. * Creates a translation matrix and stores it in a target matrix
  11711. * @param x defines the x coordinate of the translation
  11712. * @param y defines the y coordinate of the translation
  11713. * @param result defines the target matrix
  11714. */
  11715. Matrix2D.TranslationToRef = function (x, y, result) {
  11716. result.fromValues(1, 0, 0, 1, x, y);
  11717. };
  11718. /**
  11719. * Creates a scaling matrix and stores it in a target matrix
  11720. * @param x defines the x coordinate of the scaling
  11721. * @param y defines the y coordinate of the scaling
  11722. * @param result defines the target matrix
  11723. */
  11724. Matrix2D.ScalingToRef = function (x, y, result) {
  11725. result.fromValues(x, 0, 0, y, 0, 0);
  11726. };
  11727. /**
  11728. * Creates a rotation matrix and stores it in a target matrix
  11729. * @param angle defines the rotation angle
  11730. * @param result defines the target matrix
  11731. */
  11732. Matrix2D.RotationToRef = function (angle, result) {
  11733. var s = Math.sin(angle);
  11734. var c = Math.cos(angle);
  11735. result.fromValues(c, s, -s, c, 0, 0);
  11736. };
  11737. /**
  11738. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11739. * @param tx defines the x coordinate of the translation
  11740. * @param ty defines the y coordinate of the translation
  11741. * @param angle defines the rotation angle
  11742. * @param scaleX defines the x coordinate of the scaling
  11743. * @param scaleY defines the y coordinate of the scaling
  11744. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11745. * @param result defines the target matrix
  11746. */
  11747. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11748. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11749. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11750. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11751. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11752. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11753. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11754. if (parentMatrix) {
  11755. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11756. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11757. }
  11758. else {
  11759. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11760. }
  11761. };
  11762. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11763. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11764. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11765. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11766. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11767. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11768. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11769. return Matrix2D;
  11770. }());
  11771. /***/ }),
  11772. /***/ "./2D/measure.ts":
  11773. /*!***********************!*\
  11774. !*** ./2D/measure.ts ***!
  11775. \***********************/
  11776. /*! exports provided: Measure */
  11777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11778. "use strict";
  11779. __webpack_require__.r(__webpack_exports__);
  11780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11781. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11782. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11783. /**
  11784. * Class used to store 2D control sizes
  11785. */
  11786. var Measure = /** @class */ (function () {
  11787. /**
  11788. * Creates a new measure
  11789. * @param left defines left coordinate
  11790. * @param top defines top coordinate
  11791. * @param width defines width dimension
  11792. * @param height defines height dimension
  11793. */
  11794. function Measure(
  11795. /** defines left coordinate */
  11796. left,
  11797. /** defines top coordinate */
  11798. top,
  11799. /** defines width dimension */
  11800. width,
  11801. /** defines height dimension */
  11802. height) {
  11803. this.left = left;
  11804. this.top = top;
  11805. this.width = width;
  11806. this.height = height;
  11807. }
  11808. /**
  11809. * Copy from another measure
  11810. * @param other defines the other measure to copy from
  11811. */
  11812. Measure.prototype.copyFrom = function (other) {
  11813. this.left = other.left;
  11814. this.top = other.top;
  11815. this.width = other.width;
  11816. this.height = other.height;
  11817. };
  11818. /**
  11819. * Copy from a group of 4 floats
  11820. * @param left defines left coordinate
  11821. * @param top defines top coordinate
  11822. * @param width defines width dimension
  11823. * @param height defines height dimension
  11824. */
  11825. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11826. this.left = left;
  11827. this.top = top;
  11828. this.width = width;
  11829. this.height = height;
  11830. };
  11831. /**
  11832. * Computes the axis aligned bounding box measure for two given measures
  11833. * @param a Input measure
  11834. * @param b Input measure
  11835. * @param result the resulting bounding measure
  11836. */
  11837. Measure.CombineToRef = function (a, b, result) {
  11838. var left = Math.min(a.left, b.left);
  11839. var top = Math.min(a.top, b.top);
  11840. var right = Math.max(a.left + a.width, b.left + b.width);
  11841. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11842. result.left = left;
  11843. result.top = top;
  11844. result.width = right - left;
  11845. result.height = bottom - top;
  11846. };
  11847. /**
  11848. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11849. * @param transform the matrix to transform the measure before computing the AABB
  11850. * @param result the resulting AABB
  11851. */
  11852. Measure.prototype.transformToRef = function (transform, result) {
  11853. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11854. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11855. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11856. for (var i = 0; i < 4; i++) {
  11857. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11858. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11859. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11860. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11861. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11862. }
  11863. result.left = min.x;
  11864. result.top = min.y;
  11865. result.width = max.x - min.x;
  11866. result.height = max.y - min.y;
  11867. };
  11868. /**
  11869. * Check equality between this measure and another one
  11870. * @param other defines the other measures
  11871. * @returns true if both measures are equals
  11872. */
  11873. Measure.prototype.isEqualsTo = function (other) {
  11874. if (this.left !== other.left) {
  11875. return false;
  11876. }
  11877. if (this.top !== other.top) {
  11878. return false;
  11879. }
  11880. if (this.width !== other.width) {
  11881. return false;
  11882. }
  11883. if (this.height !== other.height) {
  11884. return false;
  11885. }
  11886. return true;
  11887. };
  11888. /**
  11889. * Creates an empty measure
  11890. * @returns a new measure
  11891. */
  11892. Measure.Empty = function () {
  11893. return new Measure(0, 0, 0, 0);
  11894. };
  11895. return Measure;
  11896. }());
  11897. /***/ }),
  11898. /***/ "./2D/multiLinePoint.ts":
  11899. /*!******************************!*\
  11900. !*** ./2D/multiLinePoint.ts ***!
  11901. \******************************/
  11902. /*! exports provided: MultiLinePoint */
  11903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11904. "use strict";
  11905. __webpack_require__.r(__webpack_exports__);
  11906. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11907. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11908. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11909. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11910. /**
  11911. * Class used to store a point for a MultiLine object.
  11912. * The point can be pure 2D coordinates, a mesh or a control
  11913. */
  11914. var MultiLinePoint = /** @class */ (function () {
  11915. /**
  11916. * Creates a new MultiLinePoint
  11917. * @param multiLine defines the source MultiLine object
  11918. */
  11919. function MultiLinePoint(multiLine) {
  11920. this._multiLine = multiLine;
  11921. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11922. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11923. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11924. }
  11925. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11926. /** Gets or sets x coordinate */
  11927. get: function () {
  11928. return this._x.toString(this._multiLine._host);
  11929. },
  11930. set: function (value) {
  11931. if (this._x.toString(this._multiLine._host) === value) {
  11932. return;
  11933. }
  11934. if (this._x.fromString(value)) {
  11935. this._multiLine._markAsDirty();
  11936. }
  11937. },
  11938. enumerable: true,
  11939. configurable: true
  11940. });
  11941. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11942. /** Gets or sets y coordinate */
  11943. get: function () {
  11944. return this._y.toString(this._multiLine._host);
  11945. },
  11946. set: function (value) {
  11947. if (this._y.toString(this._multiLine._host) === value) {
  11948. return;
  11949. }
  11950. if (this._y.fromString(value)) {
  11951. this._multiLine._markAsDirty();
  11952. }
  11953. },
  11954. enumerable: true,
  11955. configurable: true
  11956. });
  11957. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11958. /** Gets or sets the control associated with this point */
  11959. get: function () {
  11960. return this._control;
  11961. },
  11962. set: function (value) {
  11963. if (this._control === value) {
  11964. return;
  11965. }
  11966. if (this._control && this._controlObserver) {
  11967. this._control.onDirtyObservable.remove(this._controlObserver);
  11968. this._controlObserver = null;
  11969. }
  11970. this._control = value;
  11971. if (this._control) {
  11972. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11973. }
  11974. this._multiLine._markAsDirty();
  11975. },
  11976. enumerable: true,
  11977. configurable: true
  11978. });
  11979. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11980. /** Gets or sets the mesh associated with this point */
  11981. get: function () {
  11982. return this._mesh;
  11983. },
  11984. set: function (value) {
  11985. if (this._mesh === value) {
  11986. return;
  11987. }
  11988. if (this._mesh && this._meshObserver) {
  11989. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11990. }
  11991. this._mesh = value;
  11992. if (this._mesh) {
  11993. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11994. }
  11995. this._multiLine._markAsDirty();
  11996. },
  11997. enumerable: true,
  11998. configurable: true
  11999. });
  12000. /** Resets links */
  12001. MultiLinePoint.prototype.resetLinks = function () {
  12002. this.control = null;
  12003. this.mesh = null;
  12004. };
  12005. /**
  12006. * Gets a translation vector
  12007. * @returns the translation vector
  12008. */
  12009. MultiLinePoint.prototype.translate = function () {
  12010. this._point = this._translatePoint();
  12011. return this._point;
  12012. };
  12013. MultiLinePoint.prototype._translatePoint = function () {
  12014. if (this._mesh != null) {
  12015. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12016. }
  12017. else if (this._control != null) {
  12018. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12019. }
  12020. else {
  12021. var host = this._multiLine._host;
  12022. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12023. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12024. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12025. }
  12026. };
  12027. /** Release associated resources */
  12028. MultiLinePoint.prototype.dispose = function () {
  12029. this.resetLinks();
  12030. };
  12031. return MultiLinePoint;
  12032. }());
  12033. /***/ }),
  12034. /***/ "./2D/style.ts":
  12035. /*!*********************!*\
  12036. !*** ./2D/style.ts ***!
  12037. \*********************/
  12038. /*! exports provided: Style */
  12039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12040. "use strict";
  12041. __webpack_require__.r(__webpack_exports__);
  12042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12043. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12044. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12045. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12046. /**
  12047. * Define a style used by control to automatically setup properties based on a template.
  12048. * Only support font related properties so far
  12049. */
  12050. var Style = /** @class */ (function () {
  12051. /**
  12052. * Creates a new style object
  12053. * @param host defines the AdvancedDynamicTexture which hosts this style
  12054. */
  12055. function Style(host) {
  12056. this._fontFamily = "Arial";
  12057. this._fontStyle = "";
  12058. this._fontWeight = "";
  12059. /** @hidden */
  12060. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12061. /**
  12062. * Observable raised when the style values are changed
  12063. */
  12064. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12065. this._host = host;
  12066. }
  12067. Object.defineProperty(Style.prototype, "fontSize", {
  12068. /**
  12069. * Gets or sets the font size
  12070. */
  12071. get: function () {
  12072. return this._fontSize.toString(this._host);
  12073. },
  12074. set: function (value) {
  12075. if (this._fontSize.toString(this._host) === value) {
  12076. return;
  12077. }
  12078. if (this._fontSize.fromString(value)) {
  12079. this.onChangedObservable.notifyObservers(this);
  12080. }
  12081. },
  12082. enumerable: true,
  12083. configurable: true
  12084. });
  12085. Object.defineProperty(Style.prototype, "fontFamily", {
  12086. /**
  12087. * Gets or sets the font family
  12088. */
  12089. get: function () {
  12090. return this._fontFamily;
  12091. },
  12092. set: function (value) {
  12093. if (this._fontFamily === value) {
  12094. return;
  12095. }
  12096. this._fontFamily = value;
  12097. this.onChangedObservable.notifyObservers(this);
  12098. },
  12099. enumerable: true,
  12100. configurable: true
  12101. });
  12102. Object.defineProperty(Style.prototype, "fontStyle", {
  12103. /**
  12104. * Gets or sets the font style
  12105. */
  12106. get: function () {
  12107. return this._fontStyle;
  12108. },
  12109. set: function (value) {
  12110. if (this._fontStyle === value) {
  12111. return;
  12112. }
  12113. this._fontStyle = value;
  12114. this.onChangedObservable.notifyObservers(this);
  12115. },
  12116. enumerable: true,
  12117. configurable: true
  12118. });
  12119. Object.defineProperty(Style.prototype, "fontWeight", {
  12120. /** Gets or sets font weight */
  12121. get: function () {
  12122. return this._fontWeight;
  12123. },
  12124. set: function (value) {
  12125. if (this._fontWeight === value) {
  12126. return;
  12127. }
  12128. this._fontWeight = value;
  12129. this.onChangedObservable.notifyObservers(this);
  12130. },
  12131. enumerable: true,
  12132. configurable: true
  12133. });
  12134. /** Dispose all associated resources */
  12135. Style.prototype.dispose = function () {
  12136. this.onChangedObservable.clear();
  12137. };
  12138. return Style;
  12139. }());
  12140. /***/ }),
  12141. /***/ "./2D/valueAndUnit.ts":
  12142. /*!****************************!*\
  12143. !*** ./2D/valueAndUnit.ts ***!
  12144. \****************************/
  12145. /*! exports provided: ValueAndUnit */
  12146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12147. "use strict";
  12148. __webpack_require__.r(__webpack_exports__);
  12149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12150. /**
  12151. * Class used to specific a value and its associated unit
  12152. */
  12153. var ValueAndUnit = /** @class */ (function () {
  12154. /**
  12155. * Creates a new ValueAndUnit
  12156. * @param value defines the value to store
  12157. * @param unit defines the unit to store
  12158. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12159. */
  12160. function ValueAndUnit(value,
  12161. /** defines the unit to store */
  12162. unit,
  12163. /** defines a boolean indicating if the value can be negative */
  12164. negativeValueAllowed) {
  12165. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12166. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12167. this.unit = unit;
  12168. this.negativeValueAllowed = negativeValueAllowed;
  12169. this._value = 1;
  12170. /**
  12171. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12172. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12173. */
  12174. this.ignoreAdaptiveScaling = false;
  12175. this._value = value;
  12176. this._originalUnit = unit;
  12177. }
  12178. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12179. /** Gets a boolean indicating if the value is a percentage */
  12180. get: function () {
  12181. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12182. },
  12183. enumerable: true,
  12184. configurable: true
  12185. });
  12186. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12187. /** Gets a boolean indicating if the value is store as pixel */
  12188. get: function () {
  12189. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12190. },
  12191. enumerable: true,
  12192. configurable: true
  12193. });
  12194. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12195. /** Gets direct internal value */
  12196. get: function () {
  12197. return this._value;
  12198. },
  12199. enumerable: true,
  12200. configurable: true
  12201. });
  12202. /**
  12203. * Gets value as pixel
  12204. * @param host defines the root host
  12205. * @param refValue defines the reference value for percentages
  12206. * @returns the value as pixel
  12207. */
  12208. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12209. if (this.isPixel) {
  12210. return this.getValue(host);
  12211. }
  12212. return this.getValue(host) * refValue;
  12213. };
  12214. /**
  12215. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12216. * @param value defines the value to store
  12217. * @param unit defines the unit to store
  12218. * @returns the current ValueAndUnit
  12219. */
  12220. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12221. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12222. this._value = value;
  12223. this.unit = unit;
  12224. return this;
  12225. };
  12226. /**
  12227. * Gets the value accordingly to its unit
  12228. * @param host defines the root host
  12229. * @returns the value
  12230. */
  12231. ValueAndUnit.prototype.getValue = function (host) {
  12232. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12233. var width = 0;
  12234. var height = 0;
  12235. if (host.idealWidth) {
  12236. width = (this._value * host.getSize().width) / host.idealWidth;
  12237. }
  12238. if (host.idealHeight) {
  12239. height = (this._value * host.getSize().height) / host.idealHeight;
  12240. }
  12241. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12242. return window.innerWidth < window.innerHeight ? width : height;
  12243. }
  12244. if (host.idealWidth) { // horizontal
  12245. return width;
  12246. }
  12247. if (host.idealHeight) { // vertical
  12248. return height;
  12249. }
  12250. }
  12251. return this._value;
  12252. };
  12253. /**
  12254. * Gets a string representation of the value
  12255. * @param host defines the root host
  12256. * @param decimals defines an optional number of decimals to display
  12257. * @returns a string
  12258. */
  12259. ValueAndUnit.prototype.toString = function (host, decimals) {
  12260. switch (this.unit) {
  12261. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12262. var percentage = this.getValue(host) * 100;
  12263. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12264. case ValueAndUnit.UNITMODE_PIXEL:
  12265. var pixels = this.getValue(host);
  12266. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12267. }
  12268. return this.unit.toString();
  12269. };
  12270. /**
  12271. * Store a value parsed from a string
  12272. * @param source defines the source string
  12273. * @returns true if the value was successfully parsed
  12274. */
  12275. ValueAndUnit.prototype.fromString = function (source) {
  12276. var match = ValueAndUnit._Regex.exec(source.toString());
  12277. if (!match || match.length === 0) {
  12278. return false;
  12279. }
  12280. var sourceValue = parseFloat(match[1]);
  12281. var sourceUnit = this._originalUnit;
  12282. if (!this.negativeValueAllowed) {
  12283. if (sourceValue < 0) {
  12284. sourceValue = 0;
  12285. }
  12286. }
  12287. if (match.length === 4) {
  12288. switch (match[3]) {
  12289. case "px":
  12290. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12291. break;
  12292. case "%":
  12293. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12294. sourceValue /= 100.0;
  12295. break;
  12296. }
  12297. }
  12298. if (sourceValue === this._value && sourceUnit === this.unit) {
  12299. return false;
  12300. }
  12301. this._value = sourceValue;
  12302. this.unit = sourceUnit;
  12303. return true;
  12304. };
  12305. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12306. /** UNITMODE_PERCENTAGE */
  12307. get: function () {
  12308. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12309. },
  12310. enumerable: true,
  12311. configurable: true
  12312. });
  12313. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12314. /** UNITMODE_PIXEL */
  12315. get: function () {
  12316. return ValueAndUnit._UNITMODE_PIXEL;
  12317. },
  12318. enumerable: true,
  12319. configurable: true
  12320. });
  12321. // Static
  12322. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12323. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12324. ValueAndUnit._UNITMODE_PIXEL = 1;
  12325. return ValueAndUnit;
  12326. }());
  12327. /***/ }),
  12328. /***/ "./3D/controls/abstractButton3D.ts":
  12329. /*!*****************************************!*\
  12330. !*** ./3D/controls/abstractButton3D.ts ***!
  12331. \*****************************************/
  12332. /*! exports provided: AbstractButton3D */
  12333. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12334. "use strict";
  12335. __webpack_require__.r(__webpack_exports__);
  12336. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12337. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12338. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  12339. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12340. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12341. /**
  12342. * Class used as a root to all buttons
  12343. */
  12344. var AbstractButton3D = /** @class */ (function (_super) {
  12345. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12346. /**
  12347. * Creates a new button
  12348. * @param name defines the control name
  12349. */
  12350. function AbstractButton3D(name) {
  12351. return _super.call(this, name) || this;
  12352. }
  12353. AbstractButton3D.prototype._getTypeName = function () {
  12354. return "AbstractButton3D";
  12355. };
  12356. // Mesh association
  12357. AbstractButton3D.prototype._createNode = function (scene) {
  12358. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12359. };
  12360. return AbstractButton3D;
  12361. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12362. /***/ }),
  12363. /***/ "./3D/controls/button3D.ts":
  12364. /*!*********************************!*\
  12365. !*** ./3D/controls/button3D.ts ***!
  12366. \*********************************/
  12367. /*! exports provided: Button3D */
  12368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12369. "use strict";
  12370. __webpack_require__.r(__webpack_exports__);
  12371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12372. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12373. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12374. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12375. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12376. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12377. /**
  12378. * Class used to create a button in 3D
  12379. */
  12380. var Button3D = /** @class */ (function (_super) {
  12381. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12382. /**
  12383. * Creates a new button
  12384. * @param name defines the control name
  12385. */
  12386. function Button3D(name) {
  12387. var _this = _super.call(this, name) || this;
  12388. _this._contentResolution = 512;
  12389. _this._contentScaleRatio = 2;
  12390. // Default animations
  12391. _this.pointerEnterAnimation = function () {
  12392. if (!_this.mesh) {
  12393. return;
  12394. }
  12395. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12396. };
  12397. _this.pointerOutAnimation = function () {
  12398. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12399. };
  12400. _this.pointerDownAnimation = function () {
  12401. if (!_this.mesh) {
  12402. return;
  12403. }
  12404. _this.mesh.scaling.scaleInPlace(0.95);
  12405. };
  12406. _this.pointerUpAnimation = function () {
  12407. if (!_this.mesh) {
  12408. return;
  12409. }
  12410. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12411. };
  12412. return _this;
  12413. }
  12414. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12415. /**
  12416. * Gets or sets the texture resolution used to render content (512 by default)
  12417. */
  12418. get: function () {
  12419. return this._contentResolution;
  12420. },
  12421. set: function (value) {
  12422. if (this._contentResolution === value) {
  12423. return;
  12424. }
  12425. this._contentResolution = value;
  12426. this._resetContent();
  12427. },
  12428. enumerable: true,
  12429. configurable: true
  12430. });
  12431. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12432. /**
  12433. * Gets or sets the texture scale ratio used to render content (2 by default)
  12434. */
  12435. get: function () {
  12436. return this._contentScaleRatio;
  12437. },
  12438. set: function (value) {
  12439. if (this._contentScaleRatio === value) {
  12440. return;
  12441. }
  12442. this._contentScaleRatio = value;
  12443. this._resetContent();
  12444. },
  12445. enumerable: true,
  12446. configurable: true
  12447. });
  12448. Button3D.prototype._disposeFacadeTexture = function () {
  12449. if (this._facadeTexture) {
  12450. this._facadeTexture.dispose();
  12451. this._facadeTexture = null;
  12452. }
  12453. };
  12454. Button3D.prototype._resetContent = function () {
  12455. this._disposeFacadeTexture();
  12456. this.content = this._content;
  12457. };
  12458. Object.defineProperty(Button3D.prototype, "content", {
  12459. /**
  12460. * Gets or sets the GUI 2D content used to display the button's facade
  12461. */
  12462. get: function () {
  12463. return this._content;
  12464. },
  12465. set: function (value) {
  12466. this._content = value;
  12467. if (!this._host || !this._host.utilityLayer) {
  12468. return;
  12469. }
  12470. if (!this._facadeTexture) {
  12471. 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);
  12472. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12473. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12474. this._facadeTexture.premulAlpha = true;
  12475. }
  12476. this._facadeTexture.addControl(value);
  12477. this._applyFacade(this._facadeTexture);
  12478. },
  12479. enumerable: true,
  12480. configurable: true
  12481. });
  12482. /**
  12483. * Apply the facade texture (created from the content property).
  12484. * This function can be overloaded by child classes
  12485. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12486. */
  12487. Button3D.prototype._applyFacade = function (facadeTexture) {
  12488. this._currentMaterial.emissiveTexture = facadeTexture;
  12489. };
  12490. Button3D.prototype._getTypeName = function () {
  12491. return "Button3D";
  12492. };
  12493. // Mesh association
  12494. Button3D.prototype._createNode = function (scene) {
  12495. var faceUV = new Array(6);
  12496. for (var i = 0; i < 6; i++) {
  12497. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12498. }
  12499. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12500. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12501. width: 1.0,
  12502. height: 1.0,
  12503. depth: 0.08,
  12504. faceUV: faceUV
  12505. }, scene);
  12506. return mesh;
  12507. };
  12508. Button3D.prototype._affectMaterial = function (mesh) {
  12509. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12510. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12511. mesh.material = material;
  12512. this._currentMaterial = material;
  12513. this._resetContent();
  12514. };
  12515. /**
  12516. * Releases all associated resources
  12517. */
  12518. Button3D.prototype.dispose = function () {
  12519. _super.prototype.dispose.call(this);
  12520. this._disposeFacadeTexture();
  12521. if (this._currentMaterial) {
  12522. this._currentMaterial.dispose();
  12523. }
  12524. };
  12525. return Button3D;
  12526. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12527. /***/ }),
  12528. /***/ "./3D/controls/container3D.ts":
  12529. /*!************************************!*\
  12530. !*** ./3D/controls/container3D.ts ***!
  12531. \************************************/
  12532. /*! exports provided: Container3D */
  12533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12534. "use strict";
  12535. __webpack_require__.r(__webpack_exports__);
  12536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12537. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12538. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  12539. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12540. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12541. /**
  12542. * Class used to create containers for controls
  12543. */
  12544. var Container3D = /** @class */ (function (_super) {
  12545. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12546. /**
  12547. * Creates a new container
  12548. * @param name defines the container name
  12549. */
  12550. function Container3D(name) {
  12551. var _this = _super.call(this, name) || this;
  12552. _this._blockLayout = false;
  12553. /**
  12554. * Gets the list of child controls
  12555. */
  12556. _this._children = new Array();
  12557. return _this;
  12558. }
  12559. Object.defineProperty(Container3D.prototype, "children", {
  12560. /**
  12561. * Gets the list of child controls
  12562. */
  12563. get: function () {
  12564. return this._children;
  12565. },
  12566. enumerable: true,
  12567. configurable: true
  12568. });
  12569. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12570. /**
  12571. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12572. * This is helpful to optimize layout operation when adding multiple children in a row
  12573. */
  12574. get: function () {
  12575. return this._blockLayout;
  12576. },
  12577. set: function (value) {
  12578. if (this._blockLayout === value) {
  12579. return;
  12580. }
  12581. this._blockLayout = value;
  12582. if (!this._blockLayout) {
  12583. this._arrangeChildren();
  12584. }
  12585. },
  12586. enumerable: true,
  12587. configurable: true
  12588. });
  12589. /**
  12590. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12591. * @returns the current container
  12592. */
  12593. Container3D.prototype.updateLayout = function () {
  12594. this._arrangeChildren();
  12595. return this;
  12596. };
  12597. /**
  12598. * Gets a boolean indicating if the given control is in the children of this control
  12599. * @param control defines the control to check
  12600. * @returns true if the control is in the child list
  12601. */
  12602. Container3D.prototype.containsControl = function (control) {
  12603. return this._children.indexOf(control) !== -1;
  12604. };
  12605. /**
  12606. * Adds a control to the children of this control
  12607. * @param control defines the control to add
  12608. * @returns the current container
  12609. */
  12610. Container3D.prototype.addControl = function (control) {
  12611. var index = this._children.indexOf(control);
  12612. if (index !== -1) {
  12613. return this;
  12614. }
  12615. control.parent = this;
  12616. control._host = this._host;
  12617. this._children.push(control);
  12618. if (this._host.utilityLayer) {
  12619. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12620. if (control.node) {
  12621. control.node.parent = this.node;
  12622. }
  12623. if (!this.blockLayout) {
  12624. this._arrangeChildren();
  12625. }
  12626. }
  12627. return this;
  12628. };
  12629. /**
  12630. * This function will be called everytime a new control is added
  12631. */
  12632. Container3D.prototype._arrangeChildren = function () {
  12633. };
  12634. Container3D.prototype._createNode = function (scene) {
  12635. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12636. };
  12637. /**
  12638. * Removes a control from the children of this control
  12639. * @param control defines the control to remove
  12640. * @returns the current container
  12641. */
  12642. Container3D.prototype.removeControl = function (control) {
  12643. var index = this._children.indexOf(control);
  12644. if (index !== -1) {
  12645. this._children.splice(index, 1);
  12646. control.parent = null;
  12647. control._disposeNode();
  12648. }
  12649. return this;
  12650. };
  12651. Container3D.prototype._getTypeName = function () {
  12652. return "Container3D";
  12653. };
  12654. /**
  12655. * Releases all associated resources
  12656. */
  12657. Container3D.prototype.dispose = function () {
  12658. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12659. var control = _a[_i];
  12660. control.dispose();
  12661. }
  12662. this._children = [];
  12663. _super.prototype.dispose.call(this);
  12664. };
  12665. /** Control rotation will remain unchanged */
  12666. Container3D.UNSET_ORIENTATION = 0;
  12667. /** Control will rotate to make it look at sphere central axis */
  12668. Container3D.FACEORIGIN_ORIENTATION = 1;
  12669. /** Control will rotate to make it look back at sphere central axis */
  12670. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12671. /** Control will rotate to look at z axis (0, 0, 1) */
  12672. Container3D.FACEFORWARD_ORIENTATION = 3;
  12673. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12674. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12675. return Container3D;
  12676. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12677. /***/ }),
  12678. /***/ "./3D/controls/control3D.ts":
  12679. /*!**********************************!*\
  12680. !*** ./3D/controls/control3D.ts ***!
  12681. \**********************************/
  12682. /*! exports provided: Control3D */
  12683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12684. "use strict";
  12685. __webpack_require__.r(__webpack_exports__);
  12686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12687. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12688. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12689. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12690. /**
  12691. * Class used as base class for controls
  12692. */
  12693. var Control3D = /** @class */ (function () {
  12694. /**
  12695. * Creates a new control
  12696. * @param name defines the control name
  12697. */
  12698. function Control3D(
  12699. /** Defines the control name */
  12700. name) {
  12701. this.name = name;
  12702. this._downCount = 0;
  12703. this._enterCount = -1;
  12704. this._downPointerIds = {};
  12705. this._isVisible = true;
  12706. /**
  12707. * An event triggered when the pointer move over the control
  12708. */
  12709. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12710. /**
  12711. * An event triggered when the pointer move out of the control
  12712. */
  12713. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12714. /**
  12715. * An event triggered when the pointer taps the control
  12716. */
  12717. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12718. /**
  12719. * An event triggered when pointer is up
  12720. */
  12721. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12722. /**
  12723. * An event triggered when a control is clicked on (with a mouse)
  12724. */
  12725. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12726. /**
  12727. * An event triggered when pointer enters the control
  12728. */
  12729. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12730. // Behaviors
  12731. this._behaviors = new Array();
  12732. }
  12733. Object.defineProperty(Control3D.prototype, "position", {
  12734. /** Gets or sets the control position in world space */
  12735. get: function () {
  12736. if (!this._node) {
  12737. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12738. }
  12739. return this._node.position;
  12740. },
  12741. set: function (value) {
  12742. if (!this._node) {
  12743. return;
  12744. }
  12745. this._node.position = value;
  12746. },
  12747. enumerable: true,
  12748. configurable: true
  12749. });
  12750. Object.defineProperty(Control3D.prototype, "scaling", {
  12751. /** Gets or sets the control scaling in world space */
  12752. get: function () {
  12753. if (!this._node) {
  12754. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12755. }
  12756. return this._node.scaling;
  12757. },
  12758. set: function (value) {
  12759. if (!this._node) {
  12760. return;
  12761. }
  12762. this._node.scaling = value;
  12763. },
  12764. enumerable: true,
  12765. configurable: true
  12766. });
  12767. Object.defineProperty(Control3D.prototype, "behaviors", {
  12768. /**
  12769. * Gets the list of attached behaviors
  12770. * @see http://doc.babylonjs.com/features/behaviour
  12771. */
  12772. get: function () {
  12773. return this._behaviors;
  12774. },
  12775. enumerable: true,
  12776. configurable: true
  12777. });
  12778. /**
  12779. * Attach a behavior to the control
  12780. * @see http://doc.babylonjs.com/features/behaviour
  12781. * @param behavior defines the behavior to attach
  12782. * @returns the current control
  12783. */
  12784. Control3D.prototype.addBehavior = function (behavior) {
  12785. var _this = this;
  12786. var index = this._behaviors.indexOf(behavior);
  12787. if (index !== -1) {
  12788. return this;
  12789. }
  12790. behavior.init();
  12791. var scene = this._host.scene;
  12792. if (scene.isLoading) {
  12793. // We defer the attach when the scene will be loaded
  12794. scene.onDataLoadedObservable.addOnce(function () {
  12795. behavior.attach(_this);
  12796. });
  12797. }
  12798. else {
  12799. behavior.attach(this);
  12800. }
  12801. this._behaviors.push(behavior);
  12802. return this;
  12803. };
  12804. /**
  12805. * Remove an attached behavior
  12806. * @see http://doc.babylonjs.com/features/behaviour
  12807. * @param behavior defines the behavior to attach
  12808. * @returns the current control
  12809. */
  12810. Control3D.prototype.removeBehavior = function (behavior) {
  12811. var index = this._behaviors.indexOf(behavior);
  12812. if (index === -1) {
  12813. return this;
  12814. }
  12815. this._behaviors[index].detach();
  12816. this._behaviors.splice(index, 1);
  12817. return this;
  12818. };
  12819. /**
  12820. * Gets an attached behavior by name
  12821. * @param name defines the name of the behavior to look for
  12822. * @see http://doc.babylonjs.com/features/behaviour
  12823. * @returns null if behavior was not found else the requested behavior
  12824. */
  12825. Control3D.prototype.getBehaviorByName = function (name) {
  12826. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12827. var behavior = _a[_i];
  12828. if (behavior.name === name) {
  12829. return behavior;
  12830. }
  12831. }
  12832. return null;
  12833. };
  12834. Object.defineProperty(Control3D.prototype, "isVisible", {
  12835. /** Gets or sets a boolean indicating if the control is visible */
  12836. get: function () {
  12837. return this._isVisible;
  12838. },
  12839. set: function (value) {
  12840. if (this._isVisible === value) {
  12841. return;
  12842. }
  12843. this._isVisible = value;
  12844. var mesh = this.mesh;
  12845. if (mesh) {
  12846. mesh.setEnabled(value);
  12847. }
  12848. },
  12849. enumerable: true,
  12850. configurable: true
  12851. });
  12852. Object.defineProperty(Control3D.prototype, "typeName", {
  12853. /**
  12854. * Gets a string representing the class name
  12855. */
  12856. get: function () {
  12857. return this._getTypeName();
  12858. },
  12859. enumerable: true,
  12860. configurable: true
  12861. });
  12862. /**
  12863. * Get the current class name of the control.
  12864. * @returns current class name
  12865. */
  12866. Control3D.prototype.getClassName = function () {
  12867. return this._getTypeName();
  12868. };
  12869. Control3D.prototype._getTypeName = function () {
  12870. return "Control3D";
  12871. };
  12872. Object.defineProperty(Control3D.prototype, "node", {
  12873. /**
  12874. * Gets the transform node used by this control
  12875. */
  12876. get: function () {
  12877. return this._node;
  12878. },
  12879. enumerable: true,
  12880. configurable: true
  12881. });
  12882. Object.defineProperty(Control3D.prototype, "mesh", {
  12883. /**
  12884. * Gets the mesh used to render this control
  12885. */
  12886. get: function () {
  12887. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12888. return this._node;
  12889. }
  12890. return null;
  12891. },
  12892. enumerable: true,
  12893. configurable: true
  12894. });
  12895. /**
  12896. * Link the control as child of the given node
  12897. * @param node defines the node to link to. Use null to unlink the control
  12898. * @returns the current control
  12899. */
  12900. Control3D.prototype.linkToTransformNode = function (node) {
  12901. if (this._node) {
  12902. this._node.parent = node;
  12903. }
  12904. return this;
  12905. };
  12906. /** @hidden **/
  12907. Control3D.prototype._prepareNode = function (scene) {
  12908. if (!this._node) {
  12909. this._node = this._createNode(scene);
  12910. if (!this.node) {
  12911. return;
  12912. }
  12913. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12914. this._node.position = this.position;
  12915. this._node.scaling = this.scaling;
  12916. var mesh = this.mesh;
  12917. if (mesh) {
  12918. mesh.isPickable = true;
  12919. this._affectMaterial(mesh);
  12920. }
  12921. }
  12922. };
  12923. /**
  12924. * Node creation.
  12925. * Can be overriden by children
  12926. * @param scene defines the scene where the node must be attached
  12927. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12928. */
  12929. Control3D.prototype._createNode = function (scene) {
  12930. // Do nothing by default
  12931. return null;
  12932. };
  12933. /**
  12934. * Affect a material to the given mesh
  12935. * @param mesh defines the mesh which will represent the control
  12936. */
  12937. Control3D.prototype._affectMaterial = function (mesh) {
  12938. mesh.material = null;
  12939. };
  12940. // Pointers
  12941. /** @hidden */
  12942. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12943. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12944. };
  12945. /** @hidden */
  12946. Control3D.prototype._onPointerEnter = function (target) {
  12947. if (this._enterCount > 0) {
  12948. return false;
  12949. }
  12950. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12951. this._enterCount = 0;
  12952. }
  12953. this._enterCount++;
  12954. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12955. if (this.pointerEnterAnimation) {
  12956. this.pointerEnterAnimation();
  12957. }
  12958. return true;
  12959. };
  12960. /** @hidden */
  12961. Control3D.prototype._onPointerOut = function (target) {
  12962. this._enterCount = 0;
  12963. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12964. if (this.pointerOutAnimation) {
  12965. this.pointerOutAnimation();
  12966. }
  12967. };
  12968. /** @hidden */
  12969. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12970. if (this._downCount !== 0) {
  12971. this._downCount++;
  12972. return false;
  12973. }
  12974. this._downCount++;
  12975. this._downPointerIds[pointerId] = true;
  12976. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12977. if (this.pointerDownAnimation) {
  12978. this.pointerDownAnimation();
  12979. }
  12980. return true;
  12981. };
  12982. /** @hidden */
  12983. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12984. this._downCount--;
  12985. delete this._downPointerIds[pointerId];
  12986. if (this._downCount < 0) {
  12987. // Handle if forcePointerUp was called prior to this
  12988. this._downCount = 0;
  12989. return;
  12990. }
  12991. if (this._downCount == 0) {
  12992. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12993. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12994. }
  12995. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12996. if (this.pointerUpAnimation) {
  12997. this.pointerUpAnimation();
  12998. }
  12999. }
  13000. };
  13001. /** @hidden */
  13002. Control3D.prototype.forcePointerUp = function (pointerId) {
  13003. if (pointerId === void 0) { pointerId = null; }
  13004. if (pointerId !== null) {
  13005. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13006. }
  13007. else {
  13008. for (var key in this._downPointerIds) {
  13009. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13010. }
  13011. if (this._downCount > 0) {
  13012. this._downCount = 1;
  13013. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13014. }
  13015. }
  13016. };
  13017. /** @hidden */
  13018. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13019. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13020. this._onPointerMove(this, pickedPoint);
  13021. var previousControlOver = this._host._lastControlOver[pointerId];
  13022. if (previousControlOver && previousControlOver !== this) {
  13023. previousControlOver._onPointerOut(this);
  13024. }
  13025. if (previousControlOver !== this) {
  13026. this._onPointerEnter(this);
  13027. }
  13028. this._host._lastControlOver[pointerId] = this;
  13029. return true;
  13030. }
  13031. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13032. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13033. this._host._lastControlDown[pointerId] = this;
  13034. this._host._lastPickedControl = this;
  13035. return true;
  13036. }
  13037. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13038. if (this._host._lastControlDown[pointerId]) {
  13039. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13040. }
  13041. delete this._host._lastControlDown[pointerId];
  13042. return true;
  13043. }
  13044. return false;
  13045. };
  13046. /** @hidden */
  13047. Control3D.prototype._disposeNode = function () {
  13048. if (this._node) {
  13049. this._node.dispose();
  13050. this._node = null;
  13051. }
  13052. };
  13053. /**
  13054. * Releases all associated resources
  13055. */
  13056. Control3D.prototype.dispose = function () {
  13057. this.onPointerDownObservable.clear();
  13058. this.onPointerEnterObservable.clear();
  13059. this.onPointerMoveObservable.clear();
  13060. this.onPointerOutObservable.clear();
  13061. this.onPointerUpObservable.clear();
  13062. this.onPointerClickObservable.clear();
  13063. this._disposeNode();
  13064. // Behaviors
  13065. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13066. var behavior = _a[_i];
  13067. behavior.detach();
  13068. }
  13069. };
  13070. return Control3D;
  13071. }());
  13072. /***/ }),
  13073. /***/ "./3D/controls/cylinderPanel.ts":
  13074. /*!**************************************!*\
  13075. !*** ./3D/controls/cylinderPanel.ts ***!
  13076. \**************************************/
  13077. /*! exports provided: CylinderPanel */
  13078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13079. "use strict";
  13080. __webpack_require__.r(__webpack_exports__);
  13081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13082. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13083. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13084. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13085. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13086. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13087. /**
  13088. * Class used to create a container panel deployed on the surface of a cylinder
  13089. */
  13090. var CylinderPanel = /** @class */ (function (_super) {
  13091. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13092. function CylinderPanel() {
  13093. var _this = _super !== null && _super.apply(this, arguments) || this;
  13094. _this._radius = 5.0;
  13095. return _this;
  13096. }
  13097. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13098. /**
  13099. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13100. */
  13101. get: function () {
  13102. return this._radius;
  13103. },
  13104. set: function (value) {
  13105. var _this = this;
  13106. if (this._radius === value) {
  13107. return;
  13108. }
  13109. this._radius = value;
  13110. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13111. _this._arrangeChildren();
  13112. });
  13113. },
  13114. enumerable: true,
  13115. configurable: true
  13116. });
  13117. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13118. var mesh = control.mesh;
  13119. if (!mesh) {
  13120. return;
  13121. }
  13122. var newPos = this._cylindricalMapping(nodePosition);
  13123. control.position = newPos;
  13124. switch (this.orientation) {
  13125. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13126. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13127. break;
  13128. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13129. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13130. break;
  13131. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13132. break;
  13133. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13134. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13135. break;
  13136. }
  13137. };
  13138. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13139. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13140. var yAngle = (source.x / this._radius);
  13141. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13142. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13143. };
  13144. return CylinderPanel;
  13145. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13146. /***/ }),
  13147. /***/ "./3D/controls/holographicButton.ts":
  13148. /*!******************************************!*\
  13149. !*** ./3D/controls/holographicButton.ts ***!
  13150. \******************************************/
  13151. /*! exports provided: HolographicButton */
  13152. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13153. "use strict";
  13154. __webpack_require__.r(__webpack_exports__);
  13155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13156. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13157. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13158. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13159. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13160. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13161. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13162. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13163. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13164. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13165. /**
  13166. * Class used to create a holographic button in 3D
  13167. */
  13168. var HolographicButton = /** @class */ (function (_super) {
  13169. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13170. /**
  13171. * Creates a new button
  13172. * @param name defines the control name
  13173. */
  13174. function HolographicButton(name, shareMaterials) {
  13175. if (shareMaterials === void 0) { shareMaterials = true; }
  13176. var _this = _super.call(this, name) || this;
  13177. _this._shareMaterials = true;
  13178. _this._shareMaterials = shareMaterials;
  13179. // Default animations
  13180. _this.pointerEnterAnimation = function () {
  13181. if (!_this.mesh) {
  13182. return;
  13183. }
  13184. _this._frontPlate.setEnabled(true);
  13185. };
  13186. _this.pointerOutAnimation = function () {
  13187. if (!_this.mesh) {
  13188. return;
  13189. }
  13190. _this._frontPlate.setEnabled(false);
  13191. };
  13192. return _this;
  13193. }
  13194. HolographicButton.prototype._disposeTooltip = function () {
  13195. this._tooltipFade = null;
  13196. if (this._tooltipTextBlock) {
  13197. this._tooltipTextBlock.dispose();
  13198. }
  13199. if (this._tooltipTexture) {
  13200. this._tooltipTexture.dispose();
  13201. }
  13202. if (this._tooltipMesh) {
  13203. this._tooltipMesh.dispose();
  13204. }
  13205. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13206. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13207. };
  13208. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13209. get: function () {
  13210. if (this._tooltipTextBlock) {
  13211. return this._tooltipTextBlock.text;
  13212. }
  13213. return null;
  13214. },
  13215. /**
  13216. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13217. */
  13218. set: function (text) {
  13219. var _this = this;
  13220. if (!text) {
  13221. this._disposeTooltip();
  13222. return;
  13223. }
  13224. if (!this._tooltipFade) {
  13225. // Create tooltip with mesh and text
  13226. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13227. 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);
  13228. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13229. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13230. tooltipBackground.material = mat;
  13231. tooltipBackground.isPickable = false;
  13232. this._tooltipMesh.addChild(tooltipBackground);
  13233. tooltipBackground.position.z = 0.05;
  13234. this._tooltipMesh.scaling.y = 1 / 3;
  13235. this._tooltipMesh.position.y = 0.7;
  13236. this._tooltipMesh.position.z = -0.15;
  13237. this._tooltipMesh.isPickable = false;
  13238. this._tooltipMesh.parent = this._backPlate;
  13239. // Create text texture for the tooltip
  13240. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13241. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13242. this._tooltipTextBlock.scaleY = 3;
  13243. this._tooltipTextBlock.color = "white";
  13244. this._tooltipTextBlock.fontSize = 130;
  13245. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13246. // Add hover action to tooltip
  13247. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13248. this._tooltipFade.delay = 500;
  13249. this._tooltipMesh.addBehavior(this._tooltipFade);
  13250. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13251. if (_this._tooltipFade) {
  13252. _this._tooltipFade.fadeIn(true);
  13253. }
  13254. });
  13255. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13256. if (_this._tooltipFade) {
  13257. _this._tooltipFade.fadeIn(false);
  13258. }
  13259. });
  13260. }
  13261. if (this._tooltipTextBlock) {
  13262. this._tooltipTextBlock.text = text;
  13263. }
  13264. },
  13265. enumerable: true,
  13266. configurable: true
  13267. });
  13268. Object.defineProperty(HolographicButton.prototype, "text", {
  13269. /**
  13270. * Gets or sets text for the button
  13271. */
  13272. get: function () {
  13273. return this._text;
  13274. },
  13275. set: function (value) {
  13276. if (this._text === value) {
  13277. return;
  13278. }
  13279. this._text = value;
  13280. this._rebuildContent();
  13281. },
  13282. enumerable: true,
  13283. configurable: true
  13284. });
  13285. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13286. /**
  13287. * Gets or sets the image url for the button
  13288. */
  13289. get: function () {
  13290. return this._imageUrl;
  13291. },
  13292. set: function (value) {
  13293. if (this._imageUrl === value) {
  13294. return;
  13295. }
  13296. this._imageUrl = value;
  13297. this._rebuildContent();
  13298. },
  13299. enumerable: true,
  13300. configurable: true
  13301. });
  13302. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13303. /**
  13304. * Gets the back material used by this button
  13305. */
  13306. get: function () {
  13307. return this._backMaterial;
  13308. },
  13309. enumerable: true,
  13310. configurable: true
  13311. });
  13312. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13313. /**
  13314. * Gets the front material used by this button
  13315. */
  13316. get: function () {
  13317. return this._frontMaterial;
  13318. },
  13319. enumerable: true,
  13320. configurable: true
  13321. });
  13322. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13323. /**
  13324. * Gets the plate material used by this button
  13325. */
  13326. get: function () {
  13327. return this._plateMaterial;
  13328. },
  13329. enumerable: true,
  13330. configurable: true
  13331. });
  13332. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13333. /**
  13334. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13335. */
  13336. get: function () {
  13337. return this._shareMaterials;
  13338. },
  13339. enumerable: true,
  13340. configurable: true
  13341. });
  13342. HolographicButton.prototype._getTypeName = function () {
  13343. return "HolographicButton";
  13344. };
  13345. HolographicButton.prototype._rebuildContent = function () {
  13346. this._disposeFacadeTexture();
  13347. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13348. panel.isVertical = true;
  13349. if (this._imageUrl) {
  13350. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13351. image.source = this._imageUrl;
  13352. image.paddingTop = "40px";
  13353. image.height = "180px";
  13354. image.width = "100px";
  13355. image.paddingBottom = "40px";
  13356. panel.addControl(image);
  13357. }
  13358. if (this._text) {
  13359. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13360. text.text = this._text;
  13361. text.color = "white";
  13362. text.height = "30px";
  13363. text.fontSize = 24;
  13364. panel.addControl(text);
  13365. }
  13366. if (this._frontPlate) {
  13367. this.content = panel;
  13368. }
  13369. };
  13370. // Mesh association
  13371. HolographicButton.prototype._createNode = function (scene) {
  13372. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13373. width: 1.0,
  13374. height: 1.0,
  13375. depth: 0.08
  13376. }, scene);
  13377. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13378. width: 1.0,
  13379. height: 1.0,
  13380. depth: 0.08
  13381. }, scene);
  13382. this._frontPlate.parent = this._backPlate;
  13383. this._frontPlate.position.z = -0.08;
  13384. this._frontPlate.isPickable = false;
  13385. this._frontPlate.setEnabled(false);
  13386. this._textPlate = _super.prototype._createNode.call(this, scene);
  13387. this._textPlate.parent = this._backPlate;
  13388. this._textPlate.position.z = -0.08;
  13389. this._textPlate.isPickable = false;
  13390. return this._backPlate;
  13391. };
  13392. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13393. this._plateMaterial.emissiveTexture = facadeTexture;
  13394. this._plateMaterial.opacityTexture = facadeTexture;
  13395. };
  13396. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13397. var _this = this;
  13398. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13399. this._backMaterial.renderHoverLight = true;
  13400. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13401. if (pickedPoint) {
  13402. _this._backMaterial.hoverPosition = pickedPoint;
  13403. _this._backMaterial.hoverColor.a = 1.0;
  13404. }
  13405. else {
  13406. _this._backMaterial.hoverColor.a = 0;
  13407. }
  13408. });
  13409. };
  13410. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13411. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13412. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13413. this._frontMaterial.alpha = 0.5; // Additive
  13414. this._frontMaterial.renderBorders = true;
  13415. };
  13416. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13417. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13418. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13419. };
  13420. HolographicButton.prototype._affectMaterial = function (mesh) {
  13421. // Back
  13422. if (this._shareMaterials) {
  13423. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13424. this._createBackMaterial(mesh);
  13425. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13426. }
  13427. else {
  13428. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13429. }
  13430. // Front
  13431. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13432. this._createFrontMaterial(mesh);
  13433. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13434. }
  13435. else {
  13436. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13437. }
  13438. }
  13439. else {
  13440. this._createBackMaterial(mesh);
  13441. this._createFrontMaterial(mesh);
  13442. }
  13443. this._createPlateMaterial(mesh);
  13444. this._backPlate.material = this._backMaterial;
  13445. this._frontPlate.material = this._frontMaterial;
  13446. this._textPlate.material = this._plateMaterial;
  13447. this._rebuildContent();
  13448. };
  13449. /**
  13450. * Releases all associated resources
  13451. */
  13452. HolographicButton.prototype.dispose = function () {
  13453. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13454. this._disposeTooltip();
  13455. if (!this.shareMaterials) {
  13456. this._backMaterial.dispose();
  13457. this._frontMaterial.dispose();
  13458. this._plateMaterial.dispose();
  13459. if (this._pickedPointObserver) {
  13460. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13461. this._pickedPointObserver = null;
  13462. }
  13463. }
  13464. };
  13465. return HolographicButton;
  13466. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13467. /***/ }),
  13468. /***/ "./3D/controls/index.ts":
  13469. /*!******************************!*\
  13470. !*** ./3D/controls/index.ts ***!
  13471. \******************************/
  13472. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13474. "use strict";
  13475. __webpack_require__.r(__webpack_exports__);
  13476. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13478. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13480. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13482. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13484. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13486. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13488. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13490. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13492. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13494. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13496. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13498. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13500. /***/ }),
  13501. /***/ "./3D/controls/meshButton3D.ts":
  13502. /*!*************************************!*\
  13503. !*** ./3D/controls/meshButton3D.ts ***!
  13504. \*************************************/
  13505. /*! exports provided: MeshButton3D */
  13506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13507. "use strict";
  13508. __webpack_require__.r(__webpack_exports__);
  13509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13510. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13511. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13512. /**
  13513. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13514. */
  13515. var MeshButton3D = /** @class */ (function (_super) {
  13516. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13517. /**
  13518. * Creates a new 3D button based on a mesh
  13519. * @param mesh mesh to become a 3D button
  13520. * @param name defines the control name
  13521. */
  13522. function MeshButton3D(mesh, name) {
  13523. var _this = _super.call(this, name) || this;
  13524. _this._currentMesh = mesh;
  13525. /**
  13526. * Provides a default behavior on hover/out & up/down
  13527. * Override those function to create your own desired behavior specific to your mesh
  13528. */
  13529. _this.pointerEnterAnimation = function () {
  13530. if (!_this.mesh) {
  13531. return;
  13532. }
  13533. _this.mesh.scaling.scaleInPlace(1.1);
  13534. };
  13535. _this.pointerOutAnimation = function () {
  13536. if (!_this.mesh) {
  13537. return;
  13538. }
  13539. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13540. };
  13541. _this.pointerDownAnimation = function () {
  13542. if (!_this.mesh) {
  13543. return;
  13544. }
  13545. _this.mesh.scaling.scaleInPlace(0.95);
  13546. };
  13547. _this.pointerUpAnimation = function () {
  13548. if (!_this.mesh) {
  13549. return;
  13550. }
  13551. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13552. };
  13553. return _this;
  13554. }
  13555. MeshButton3D.prototype._getTypeName = function () {
  13556. return "MeshButton3D";
  13557. };
  13558. // Mesh association
  13559. MeshButton3D.prototype._createNode = function (scene) {
  13560. var _this = this;
  13561. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13562. mesh.metadata = _this;
  13563. });
  13564. return this._currentMesh;
  13565. };
  13566. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13567. };
  13568. return MeshButton3D;
  13569. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13570. /***/ }),
  13571. /***/ "./3D/controls/planePanel.ts":
  13572. /*!***********************************!*\
  13573. !*** ./3D/controls/planePanel.ts ***!
  13574. \***********************************/
  13575. /*! exports provided: PlanePanel */
  13576. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13577. "use strict";
  13578. __webpack_require__.r(__webpack_exports__);
  13579. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13580. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13581. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13582. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13583. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13584. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13585. /**
  13586. * Class used to create a container panel deployed on the surface of a plane
  13587. */
  13588. var PlanePanel = /** @class */ (function (_super) {
  13589. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13590. function PlanePanel() {
  13591. return _super !== null && _super.apply(this, arguments) || this;
  13592. }
  13593. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13594. var mesh = control.mesh;
  13595. if (!mesh) {
  13596. return;
  13597. }
  13598. control.position = nodePosition.clone();
  13599. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13600. target.copyFrom(nodePosition);
  13601. switch (this.orientation) {
  13602. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13603. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13604. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13605. mesh.lookAt(target);
  13606. break;
  13607. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13608. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13609. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13610. mesh.lookAt(target);
  13611. break;
  13612. }
  13613. };
  13614. return PlanePanel;
  13615. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13616. /***/ }),
  13617. /***/ "./3D/controls/scatterPanel.ts":
  13618. /*!*************************************!*\
  13619. !*** ./3D/controls/scatterPanel.ts ***!
  13620. \*************************************/
  13621. /*! exports provided: ScatterPanel */
  13622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13623. "use strict";
  13624. __webpack_require__.r(__webpack_exports__);
  13625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13626. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13627. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13628. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13629. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13630. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13631. /**
  13632. * Class used to create a container panel where items get randomized planar mapping
  13633. */
  13634. var ScatterPanel = /** @class */ (function (_super) {
  13635. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13636. function ScatterPanel() {
  13637. var _this = _super !== null && _super.apply(this, arguments) || this;
  13638. _this._iteration = 100.0;
  13639. return _this;
  13640. }
  13641. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13642. /**
  13643. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13644. */
  13645. get: function () {
  13646. return this._iteration;
  13647. },
  13648. set: function (value) {
  13649. var _this = this;
  13650. if (this._iteration === value) {
  13651. return;
  13652. }
  13653. this._iteration = value;
  13654. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13655. _this._arrangeChildren();
  13656. });
  13657. },
  13658. enumerable: true,
  13659. configurable: true
  13660. });
  13661. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13662. var mesh = control.mesh;
  13663. var newPos = this._scatterMapping(nodePosition);
  13664. if (!mesh) {
  13665. return;
  13666. }
  13667. switch (this.orientation) {
  13668. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13669. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13670. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13671. break;
  13672. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13673. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13674. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13675. break;
  13676. }
  13677. control.position = newPos;
  13678. };
  13679. ScatterPanel.prototype._scatterMapping = function (source) {
  13680. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13681. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13682. return source;
  13683. };
  13684. ScatterPanel.prototype._finalProcessing = function () {
  13685. var meshes = [];
  13686. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13687. var child = _a[_i];
  13688. if (!child.mesh) {
  13689. continue;
  13690. }
  13691. meshes.push(child.mesh);
  13692. }
  13693. for (var count = 0; count < this._iteration; count++) {
  13694. meshes.sort(function (a, b) {
  13695. var distance1 = a.position.lengthSquared();
  13696. var distance2 = b.position.lengthSquared();
  13697. if (distance1 < distance2) {
  13698. return 1;
  13699. }
  13700. else if (distance1 > distance2) {
  13701. return -1;
  13702. }
  13703. return 0;
  13704. });
  13705. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13706. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13707. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  13708. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13709. for (var i = 0; i < meshes.length - 1; i++) {
  13710. for (var j = i + 1; j < meshes.length; j++) {
  13711. if (i != j) {
  13712. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13713. // Ignore Z axis
  13714. difference2D.x = difference.x;
  13715. difference2D.y = difference.y;
  13716. var combinedRadius = cellSize;
  13717. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13718. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13719. distance -= minSeparation;
  13720. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13721. difference2D.normalize();
  13722. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13723. meshes[j].position.addInPlace(difference);
  13724. meshes[i].position.subtractInPlace(difference);
  13725. }
  13726. }
  13727. }
  13728. }
  13729. }
  13730. };
  13731. return ScatterPanel;
  13732. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13733. /***/ }),
  13734. /***/ "./3D/controls/spherePanel.ts":
  13735. /*!************************************!*\
  13736. !*** ./3D/controls/spherePanel.ts ***!
  13737. \************************************/
  13738. /*! exports provided: SpherePanel */
  13739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13740. "use strict";
  13741. __webpack_require__.r(__webpack_exports__);
  13742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13743. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13744. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13745. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13746. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13747. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13748. /**
  13749. * Class used to create a container panel deployed on the surface of a sphere
  13750. */
  13751. var SpherePanel = /** @class */ (function (_super) {
  13752. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13753. function SpherePanel() {
  13754. var _this = _super !== null && _super.apply(this, arguments) || this;
  13755. _this._radius = 5.0;
  13756. return _this;
  13757. }
  13758. Object.defineProperty(SpherePanel.prototype, "radius", {
  13759. /**
  13760. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13761. */
  13762. get: function () {
  13763. return this._radius;
  13764. },
  13765. set: function (value) {
  13766. var _this = this;
  13767. if (this._radius === value) {
  13768. return;
  13769. }
  13770. this._radius = value;
  13771. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13772. _this._arrangeChildren();
  13773. });
  13774. },
  13775. enumerable: true,
  13776. configurable: true
  13777. });
  13778. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13779. var mesh = control.mesh;
  13780. if (!mesh) {
  13781. return;
  13782. }
  13783. var newPos = this._sphericalMapping(nodePosition);
  13784. control.position = newPos;
  13785. switch (this.orientation) {
  13786. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13787. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13788. break;
  13789. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13790. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13791. break;
  13792. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13793. break;
  13794. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13795. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13796. break;
  13797. }
  13798. };
  13799. SpherePanel.prototype._sphericalMapping = function (source) {
  13800. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13801. var xAngle = (source.y / this._radius);
  13802. var yAngle = -(source.x / this._radius);
  13803. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13804. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13805. };
  13806. return SpherePanel;
  13807. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13808. /***/ }),
  13809. /***/ "./3D/controls/stackPanel3D.ts":
  13810. /*!*************************************!*\
  13811. !*** ./3D/controls/stackPanel3D.ts ***!
  13812. \*************************************/
  13813. /*! exports provided: StackPanel3D */
  13814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13815. "use strict";
  13816. __webpack_require__.r(__webpack_exports__);
  13817. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13818. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13819. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13820. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13821. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13822. /**
  13823. * Class used to create a stack panel in 3D on XY plane
  13824. */
  13825. var StackPanel3D = /** @class */ (function (_super) {
  13826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13827. /**
  13828. * Creates new StackPanel
  13829. * @param isVertical
  13830. */
  13831. function StackPanel3D(isVertical) {
  13832. if (isVertical === void 0) { isVertical = false; }
  13833. var _this = _super.call(this) || this;
  13834. _this._isVertical = false;
  13835. /**
  13836. * Gets or sets the distance between elements
  13837. */
  13838. _this.margin = 0.1;
  13839. _this._isVertical = isVertical;
  13840. return _this;
  13841. }
  13842. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13843. /**
  13844. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13845. */
  13846. get: function () {
  13847. return this._isVertical;
  13848. },
  13849. set: function (value) {
  13850. var _this = this;
  13851. if (this._isVertical === value) {
  13852. return;
  13853. }
  13854. this._isVertical = value;
  13855. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13856. _this._arrangeChildren();
  13857. });
  13858. },
  13859. enumerable: true,
  13860. configurable: true
  13861. });
  13862. StackPanel3D.prototype._arrangeChildren = function () {
  13863. var width = 0;
  13864. var height = 0;
  13865. var controlCount = 0;
  13866. var extendSizes = [];
  13867. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13868. // Measure
  13869. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13870. var child = _a[_i];
  13871. if (!child.mesh) {
  13872. continue;
  13873. }
  13874. controlCount++;
  13875. child.mesh.computeWorldMatrix(true);
  13876. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13877. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13878. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13879. extendSizes.push(extendSize);
  13880. if (this._isVertical) {
  13881. height += extendSize.y;
  13882. }
  13883. else {
  13884. width += extendSize.x;
  13885. }
  13886. }
  13887. if (this._isVertical) {
  13888. height += (controlCount - 1) * this.margin / 2;
  13889. }
  13890. else {
  13891. width += (controlCount - 1) * this.margin / 2;
  13892. }
  13893. // Arrange
  13894. var offset;
  13895. if (this._isVertical) {
  13896. offset = -height;
  13897. }
  13898. else {
  13899. offset = -width;
  13900. }
  13901. var index = 0;
  13902. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13903. var child = _c[_b];
  13904. if (!child.mesh) {
  13905. continue;
  13906. }
  13907. controlCount--;
  13908. var extendSize = extendSizes[index++];
  13909. if (this._isVertical) {
  13910. child.position.y = offset + extendSize.y;
  13911. child.position.x = 0;
  13912. offset += extendSize.y * 2;
  13913. }
  13914. else {
  13915. child.position.x = offset + extendSize.x;
  13916. child.position.y = 0;
  13917. offset += extendSize.x * 2;
  13918. }
  13919. offset += (controlCount > 0 ? this.margin : 0);
  13920. }
  13921. };
  13922. return StackPanel3D;
  13923. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13924. /***/ }),
  13925. /***/ "./3D/controls/volumeBasedPanel.ts":
  13926. /*!*****************************************!*\
  13927. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13928. \*****************************************/
  13929. /*! exports provided: VolumeBasedPanel */
  13930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13931. "use strict";
  13932. __webpack_require__.r(__webpack_exports__);
  13933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13935. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13936. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13937. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13938. /**
  13939. * Abstract class used to create a container panel deployed on the surface of a volume
  13940. */
  13941. var VolumeBasedPanel = /** @class */ (function (_super) {
  13942. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13943. /**
  13944. * Creates new VolumeBasedPanel
  13945. */
  13946. function VolumeBasedPanel() {
  13947. var _this = _super.call(this) || this;
  13948. _this._columns = 10;
  13949. _this._rows = 0;
  13950. _this._rowThenColum = true;
  13951. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13952. /**
  13953. * Gets or sets the distance between elements
  13954. */
  13955. _this.margin = 0;
  13956. return _this;
  13957. }
  13958. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13959. /**
  13960. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13961. * | Value | Type | Description |
  13962. * | ----- | ----------------------------------- | ----------- |
  13963. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13964. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13965. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13966. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13967. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13968. */
  13969. get: function () {
  13970. return this._orientation;
  13971. },
  13972. set: function (value) {
  13973. var _this = this;
  13974. if (this._orientation === value) {
  13975. return;
  13976. }
  13977. this._orientation = value;
  13978. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13979. _this._arrangeChildren();
  13980. });
  13981. },
  13982. enumerable: true,
  13983. configurable: true
  13984. });
  13985. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13986. /**
  13987. * Gets or sets the number of columns requested (10 by default).
  13988. * The panel will automatically compute the number of rows based on number of child controls.
  13989. */
  13990. get: function () {
  13991. return this._columns;
  13992. },
  13993. set: function (value) {
  13994. var _this = this;
  13995. if (this._columns === value) {
  13996. return;
  13997. }
  13998. this._columns = value;
  13999. this._rowThenColum = true;
  14000. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14001. _this._arrangeChildren();
  14002. });
  14003. },
  14004. enumerable: true,
  14005. configurable: true
  14006. });
  14007. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14008. /**
  14009. * Gets or sets a the number of rows requested.
  14010. * The panel will automatically compute the number of columns based on number of child controls.
  14011. */
  14012. get: function () {
  14013. return this._rows;
  14014. },
  14015. set: function (value) {
  14016. var _this = this;
  14017. if (this._rows === value) {
  14018. return;
  14019. }
  14020. this._rows = value;
  14021. this._rowThenColum = false;
  14022. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14023. _this._arrangeChildren();
  14024. });
  14025. },
  14026. enumerable: true,
  14027. configurable: true
  14028. });
  14029. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14030. this._cellWidth = 0;
  14031. this._cellHeight = 0;
  14032. var rows = 0;
  14033. var columns = 0;
  14034. var controlCount = 0;
  14035. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14036. // Measure
  14037. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14038. var child = _a[_i];
  14039. if (!child.mesh) {
  14040. continue;
  14041. }
  14042. controlCount++;
  14043. child.mesh.computeWorldMatrix(true);
  14044. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14045. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14046. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14047. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14048. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14049. diff.scaleInPlace(0.5);
  14050. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14051. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14052. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14053. }
  14054. this._cellWidth += this.margin * 2;
  14055. this._cellHeight += this.margin * 2;
  14056. // Arrange
  14057. if (this._rowThenColum) {
  14058. columns = this._columns;
  14059. rows = Math.ceil(controlCount / this._columns);
  14060. }
  14061. else {
  14062. rows = this._rows;
  14063. columns = Math.ceil(controlCount / this._rows);
  14064. }
  14065. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14066. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14067. var nodeGrid = [];
  14068. var cellCounter = 0;
  14069. if (this._rowThenColum) {
  14070. for (var r = 0; r < rows; r++) {
  14071. for (var c = 0; c < columns; c++) {
  14072. 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));
  14073. cellCounter++;
  14074. if (cellCounter > controlCount) {
  14075. break;
  14076. }
  14077. }
  14078. }
  14079. }
  14080. else {
  14081. for (var c = 0; c < columns; c++) {
  14082. for (var r = 0; r < rows; r++) {
  14083. 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));
  14084. cellCounter++;
  14085. if (cellCounter > controlCount) {
  14086. break;
  14087. }
  14088. }
  14089. }
  14090. }
  14091. cellCounter = 0;
  14092. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14093. var child = _c[_b];
  14094. if (!child.mesh) {
  14095. continue;
  14096. }
  14097. this._mapGridNode(child, nodeGrid[cellCounter]);
  14098. cellCounter++;
  14099. }
  14100. this._finalProcessing();
  14101. };
  14102. /** Child classes can implement this function to provide additional processing */
  14103. VolumeBasedPanel.prototype._finalProcessing = function () {
  14104. };
  14105. return VolumeBasedPanel;
  14106. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14107. /***/ }),
  14108. /***/ "./3D/gui3DManager.ts":
  14109. /*!****************************!*\
  14110. !*** ./3D/gui3DManager.ts ***!
  14111. \****************************/
  14112. /*! exports provided: GUI3DManager */
  14113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14114. "use strict";
  14115. __webpack_require__.r(__webpack_exports__);
  14116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14117. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14118. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14119. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14120. /**
  14121. * Class used to manage 3D user interface
  14122. * @see http://doc.babylonjs.com/how_to/gui3d
  14123. */
  14124. var GUI3DManager = /** @class */ (function () {
  14125. /**
  14126. * Creates a new GUI3DManager
  14127. * @param scene
  14128. */
  14129. function GUI3DManager(scene) {
  14130. var _this = this;
  14131. /** @hidden */
  14132. this._lastControlOver = {};
  14133. /** @hidden */
  14134. this._lastControlDown = {};
  14135. /**
  14136. * Observable raised when the point picked by the pointer events changed
  14137. */
  14138. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14139. // Shared resources
  14140. /** @hidden */
  14141. this._sharedMaterials = {};
  14142. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14143. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14144. _this._sceneDisposeObserver = null;
  14145. _this._utilityLayer = null;
  14146. _this.dispose();
  14147. });
  14148. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14149. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14150. this._utilityLayer.pickUtilitySceneFirst = false;
  14151. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14152. return mesh && mesh.metadata && mesh.metadata._node;
  14153. };
  14154. // Root
  14155. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14156. this._rootContainer._host = this;
  14157. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14158. // Events
  14159. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14160. _this._handlePointerOut(pointerId, true);
  14161. });
  14162. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14163. _this._doPicking(pi);
  14164. });
  14165. // Scene
  14166. this._utilityLayer.utilityLayerScene.autoClear = false;
  14167. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14168. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14169. }
  14170. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14171. /** Gets the hosting scene */
  14172. get: function () {
  14173. return this._scene;
  14174. },
  14175. enumerable: true,
  14176. configurable: true
  14177. });
  14178. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14179. /** Gets associated utility layer */
  14180. get: function () {
  14181. return this._utilityLayer;
  14182. },
  14183. enumerable: true,
  14184. configurable: true
  14185. });
  14186. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14187. var previousControlOver = this._lastControlOver[pointerId];
  14188. if (previousControlOver) {
  14189. previousControlOver._onPointerOut(previousControlOver);
  14190. delete this._lastControlOver[pointerId];
  14191. }
  14192. if (isPointerUp) {
  14193. if (this._lastControlDown[pointerId]) {
  14194. this._lastControlDown[pointerId].forcePointerUp();
  14195. delete this._lastControlDown[pointerId];
  14196. }
  14197. }
  14198. this.onPickedPointChangedObservable.notifyObservers(null);
  14199. };
  14200. GUI3DManager.prototype._doPicking = function (pi) {
  14201. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14202. return false;
  14203. }
  14204. var pointerEvent = (pi.event);
  14205. var pointerId = pointerEvent.pointerId || 0;
  14206. var buttonIndex = pointerEvent.button;
  14207. var pickingInfo = pi.pickInfo;
  14208. if (!pickingInfo || !pickingInfo.hit) {
  14209. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14210. return false;
  14211. }
  14212. var control = (pickingInfo.pickedMesh.metadata);
  14213. if (pickingInfo.pickedPoint) {
  14214. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14215. }
  14216. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14217. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14218. if (this._lastControlOver[pointerId]) {
  14219. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14220. }
  14221. delete this._lastControlOver[pointerId];
  14222. }
  14223. }
  14224. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14225. if (this._lastControlDown[pointerEvent.pointerId]) {
  14226. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14227. delete this._lastControlDown[pointerEvent.pointerId];
  14228. }
  14229. if (pointerEvent.pointerType === "touch") {
  14230. this._handlePointerOut(pointerId, false);
  14231. }
  14232. }
  14233. return true;
  14234. };
  14235. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14236. /**
  14237. * Gets the root container
  14238. */
  14239. get: function () {
  14240. return this._rootContainer;
  14241. },
  14242. enumerable: true,
  14243. configurable: true
  14244. });
  14245. /**
  14246. * Gets a boolean indicating if the given control is in the root child list
  14247. * @param control defines the control to check
  14248. * @returns true if the control is in the root child list
  14249. */
  14250. GUI3DManager.prototype.containsControl = function (control) {
  14251. return this._rootContainer.containsControl(control);
  14252. };
  14253. /**
  14254. * Adds a control to the root child list
  14255. * @param control defines the control to add
  14256. * @returns the current manager
  14257. */
  14258. GUI3DManager.prototype.addControl = function (control) {
  14259. this._rootContainer.addControl(control);
  14260. return this;
  14261. };
  14262. /**
  14263. * Removes a control from the root child list
  14264. * @param control defines the control to remove
  14265. * @returns the current container
  14266. */
  14267. GUI3DManager.prototype.removeControl = function (control) {
  14268. this._rootContainer.removeControl(control);
  14269. return this;
  14270. };
  14271. /**
  14272. * Releases all associated resources
  14273. */
  14274. GUI3DManager.prototype.dispose = function () {
  14275. this._rootContainer.dispose();
  14276. for (var materialName in this._sharedMaterials) {
  14277. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14278. continue;
  14279. }
  14280. this._sharedMaterials[materialName].dispose();
  14281. }
  14282. this._sharedMaterials = {};
  14283. if (this._pointerOutObserver && this._utilityLayer) {
  14284. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14285. this._pointerOutObserver = null;
  14286. }
  14287. this.onPickedPointChangedObservable.clear();
  14288. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14289. if (utilityLayerScene) {
  14290. if (this._pointerObserver) {
  14291. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14292. this._pointerObserver = null;
  14293. }
  14294. }
  14295. if (this._scene) {
  14296. if (this._sceneDisposeObserver) {
  14297. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14298. this._sceneDisposeObserver = null;
  14299. }
  14300. }
  14301. if (this._utilityLayer) {
  14302. this._utilityLayer.dispose();
  14303. }
  14304. };
  14305. return GUI3DManager;
  14306. }());
  14307. /***/ }),
  14308. /***/ "./3D/index.ts":
  14309. /*!*********************!*\
  14310. !*** ./3D/index.ts ***!
  14311. \*********************/
  14312. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14314. "use strict";
  14315. __webpack_require__.r(__webpack_exports__);
  14316. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14329. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14332. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14334. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14336. /***/ }),
  14337. /***/ "./3D/materials/fluentMaterial.ts":
  14338. /*!****************************************!*\
  14339. !*** ./3D/materials/fluentMaterial.ts ***!
  14340. \****************************************/
  14341. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14343. "use strict";
  14344. __webpack_require__.r(__webpack_exports__);
  14345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14347. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14348. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  14349. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14350. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14351. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14352. /** @hidden */
  14353. var FluentMaterialDefines = /** @class */ (function (_super) {
  14354. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14355. function FluentMaterialDefines() {
  14356. var _this = _super.call(this) || this;
  14357. _this.INNERGLOW = false;
  14358. _this.BORDER = false;
  14359. _this.HOVERLIGHT = false;
  14360. _this.TEXTURE = false;
  14361. _this.rebuild();
  14362. return _this;
  14363. }
  14364. return FluentMaterialDefines;
  14365. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14366. /**
  14367. * Class used to render controls with fluent desgin
  14368. */
  14369. var FluentMaterial = /** @class */ (function (_super) {
  14370. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14371. /**
  14372. * Creates a new Fluent material
  14373. * @param name defines the name of the material
  14374. * @param scene defines the hosting scene
  14375. */
  14376. function FluentMaterial(name, scene) {
  14377. var _this = _super.call(this, name, scene) || this;
  14378. /**
  14379. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14380. */
  14381. _this.innerGlowColorIntensity = 0.5;
  14382. /**
  14383. * Gets or sets the inner glow color (white by default)
  14384. */
  14385. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14386. /**
  14387. * Gets or sets alpha value (default is 1.0)
  14388. */
  14389. _this.alpha = 1.0;
  14390. /**
  14391. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14392. */
  14393. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14394. /**
  14395. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14396. */
  14397. _this.renderBorders = false;
  14398. /**
  14399. * Gets or sets border width (default is 0.5)
  14400. */
  14401. _this.borderWidth = 0.5;
  14402. /**
  14403. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14404. */
  14405. _this.edgeSmoothingValue = 0.02;
  14406. /**
  14407. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14408. */
  14409. _this.borderMinValue = 0.1;
  14410. /**
  14411. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14412. */
  14413. _this.renderHoverLight = false;
  14414. /**
  14415. * Gets or sets the radius used to render the hover light (default is 1.0)
  14416. */
  14417. _this.hoverRadius = 1.0;
  14418. /**
  14419. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14420. */
  14421. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14422. /**
  14423. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14424. */
  14425. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14426. return _this;
  14427. }
  14428. FluentMaterial.prototype.needAlphaBlending = function () {
  14429. return this.alpha !== 1.0;
  14430. };
  14431. FluentMaterial.prototype.needAlphaTesting = function () {
  14432. return false;
  14433. };
  14434. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14435. return null;
  14436. };
  14437. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14438. if (this.isFrozen) {
  14439. if (this._wasPreviouslyReady && subMesh.effect) {
  14440. return true;
  14441. }
  14442. }
  14443. if (!subMesh._materialDefines) {
  14444. subMesh._materialDefines = new FluentMaterialDefines();
  14445. }
  14446. var scene = this.getScene();
  14447. var defines = subMesh._materialDefines;
  14448. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14449. if (defines._renderId === scene.getRenderId()) {
  14450. return true;
  14451. }
  14452. }
  14453. if (defines._areTexturesDirty) {
  14454. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14455. defines.BORDER = this.renderBorders;
  14456. defines.HOVERLIGHT = this.renderHoverLight;
  14457. if (this._albedoTexture) {
  14458. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14459. return false;
  14460. }
  14461. else {
  14462. defines.TEXTURE = true;
  14463. }
  14464. }
  14465. else {
  14466. defines.TEXTURE = false;
  14467. }
  14468. }
  14469. var engine = scene.getEngine();
  14470. // Get correct effect
  14471. if (defines.isDirty) {
  14472. defines.markAsProcessed();
  14473. scene.resetCachedMaterial();
  14474. //Attributes
  14475. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14476. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14477. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14478. var shaderName = "fluent";
  14479. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14480. "hoverColor", "hoverPosition", "hoverRadius"
  14481. ];
  14482. var samplers = ["albedoSampler"];
  14483. var uniformBuffers = new Array();
  14484. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14485. uniformsNames: uniforms,
  14486. uniformBuffersNames: uniformBuffers,
  14487. samplers: samplers,
  14488. defines: defines,
  14489. maxSimultaneousLights: 4
  14490. });
  14491. var join = defines.toString();
  14492. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14493. attributes: attribs,
  14494. uniformsNames: uniforms,
  14495. uniformBuffersNames: uniformBuffers,
  14496. samplers: samplers,
  14497. defines: join,
  14498. fallbacks: null,
  14499. onCompiled: this.onCompiled,
  14500. onError: this.onError,
  14501. indexParameters: { maxSimultaneousLights: 4 }
  14502. }, engine));
  14503. }
  14504. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14505. return false;
  14506. }
  14507. defines._renderId = scene.getRenderId();
  14508. this._wasPreviouslyReady = true;
  14509. return true;
  14510. };
  14511. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14512. var scene = this.getScene();
  14513. var defines = subMesh._materialDefines;
  14514. if (!defines) {
  14515. return;
  14516. }
  14517. var effect = subMesh.effect;
  14518. if (!effect) {
  14519. return;
  14520. }
  14521. this._activeEffect = effect;
  14522. // Matrices
  14523. this.bindOnlyWorldMatrix(world);
  14524. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14525. if (this._mustRebind(scene, effect)) {
  14526. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14527. if (defines.INNERGLOW) {
  14528. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14529. }
  14530. if (defines.BORDER) {
  14531. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14532. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14533. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14534. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14535. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14536. }
  14537. if (defines.HOVERLIGHT) {
  14538. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14539. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14540. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14541. }
  14542. if (defines.TEXTURE) {
  14543. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14544. }
  14545. }
  14546. this._afterBind(mesh, this._activeEffect);
  14547. };
  14548. FluentMaterial.prototype.getActiveTextures = function () {
  14549. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14550. return activeTextures;
  14551. };
  14552. FluentMaterial.prototype.hasTexture = function (texture) {
  14553. if (_super.prototype.hasTexture.call(this, texture)) {
  14554. return true;
  14555. }
  14556. return false;
  14557. };
  14558. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14559. _super.prototype.dispose.call(this, forceDisposeEffect);
  14560. };
  14561. FluentMaterial.prototype.clone = function (name) {
  14562. var _this = this;
  14563. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14564. };
  14565. FluentMaterial.prototype.serialize = function () {
  14566. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14567. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14568. return serializationObject;
  14569. };
  14570. FluentMaterial.prototype.getClassName = function () {
  14571. return "FluentMaterial";
  14572. };
  14573. // Statics
  14574. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14575. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14576. };
  14577. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14578. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14579. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14580. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14582. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14583. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14585. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14586. ], FluentMaterial.prototype, "alpha", void 0);
  14587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14588. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14589. ], FluentMaterial.prototype, "albedoColor", void 0);
  14590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14591. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14592. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14593. ], FluentMaterial.prototype, "renderBorders", void 0);
  14594. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14595. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14596. ], FluentMaterial.prototype, "borderWidth", void 0);
  14597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14598. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14599. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14600. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14601. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14602. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14603. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14604. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14605. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14606. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14608. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14609. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14611. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14612. ], FluentMaterial.prototype, "hoverColor", void 0);
  14613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14614. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14615. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14617. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14618. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14620. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14621. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14622. return FluentMaterial;
  14623. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14624. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14625. /***/ }),
  14626. /***/ "./3D/materials/index.ts":
  14627. /*!*******************************!*\
  14628. !*** ./3D/materials/index.ts ***!
  14629. \*******************************/
  14630. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14632. "use strict";
  14633. __webpack_require__.r(__webpack_exports__);
  14634. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14637. /***/ }),
  14638. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14639. /*!*************************************************!*\
  14640. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14641. \*************************************************/
  14642. /*! exports provided: fluentPixelShader */
  14643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14644. "use strict";
  14645. __webpack_require__.r(__webpack_exports__);
  14646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14647. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  14648. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14649. var name = 'fluentPixelShader';
  14650. 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}";
  14651. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14652. /** @hidden */
  14653. var fluentPixelShader = { name: name, shader: shader };
  14654. /***/ }),
  14655. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14656. /*!***********************************************!*\
  14657. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14658. \***********************************************/
  14659. /*! exports provided: fluentVertexShader */
  14660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14661. "use strict";
  14662. __webpack_require__.r(__webpack_exports__);
  14663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14664. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  14665. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14666. var name = 'fluentVertexShader';
  14667. 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";
  14668. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14669. /** @hidden */
  14670. var fluentVertexShader = { name: name, shader: shader };
  14671. /***/ }),
  14672. /***/ "./3D/vector3WithInfo.ts":
  14673. /*!*******************************!*\
  14674. !*** ./3D/vector3WithInfo.ts ***!
  14675. \*******************************/
  14676. /*! exports provided: Vector3WithInfo */
  14677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14678. "use strict";
  14679. __webpack_require__.r(__webpack_exports__);
  14680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14682. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14683. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14684. /**
  14685. * Class used to transport Vector3 information for pointer events
  14686. */
  14687. var Vector3WithInfo = /** @class */ (function (_super) {
  14688. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14689. /**
  14690. * Creates a new Vector3WithInfo
  14691. * @param source defines the vector3 data to transport
  14692. * @param buttonIndex defines the current mouse button index
  14693. */
  14694. function Vector3WithInfo(source,
  14695. /** defines the current mouse button index */
  14696. buttonIndex) {
  14697. if (buttonIndex === void 0) { buttonIndex = 0; }
  14698. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14699. _this.buttonIndex = buttonIndex;
  14700. return _this;
  14701. }
  14702. return Vector3WithInfo;
  14703. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14704. /***/ }),
  14705. /***/ "./index.ts":
  14706. /*!******************!*\
  14707. !*** ./index.ts ***!
  14708. \******************/
  14709. /*! 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 */
  14710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14711. "use strict";
  14712. __webpack_require__.r(__webpack_exports__);
  14713. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14753. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14770. /***/ }),
  14771. /***/ "./legacy/legacy.ts":
  14772. /*!**************************!*\
  14773. !*** ./legacy/legacy.ts ***!
  14774. \**************************/
  14775. /*! 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 */
  14776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14777. "use strict";
  14778. __webpack_require__.r(__webpack_exports__);
  14779. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14835. /**
  14836. * Legacy support, defining window.BABYLON.GUI (global variable).
  14837. *
  14838. * This is the entry point for the UMD module.
  14839. * The entry point for a future ESM package should be index.ts
  14840. */
  14841. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14842. if (typeof globalObject !== "undefined") {
  14843. globalObject.BABYLON = globalObject.BABYLON || {};
  14844. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14845. }
  14846. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14847. /***/ }),
  14848. /***/ "babylonjs/Misc/perfCounter":
  14849. /*!****************************************************************************************************!*\
  14850. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14851. \****************************************************************************************************/
  14852. /*! no static exports found */
  14853. /***/ (function(module, exports) {
  14854. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  14855. /***/ })
  14856. /******/ });
  14857. });
  14858. //# sourceMappingURL=babylon.gui.js.map