babylon.gui.js 675 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601
  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_tools__) {
  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. !*** D:/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, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../../node_modules/webpack/buildin/global.js":
  291. /*!***********************************!*\
  292. !*** (webpack)/buildin/global.js ***!
  293. \***********************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./2D/adtInstrumentation.ts":
  314. /*!**********************************!*\
  315. !*** ./2D/adtInstrumentation.ts ***!
  316. \**********************************/
  317. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  322. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  323. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  324. /**
  325. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  326. */
  327. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  328. /**
  329. * Instantiates a new advanced dynamic texture instrumentation.
  330. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  331. * @param texture Defines the AdvancedDynamicTexture to instrument
  332. */
  333. function AdvancedDynamicTextureInstrumentation(
  334. /**
  335. * Define the instrumented AdvancedDynamicTexture.
  336. */
  337. texture) {
  338. this.texture = texture;
  339. this._captureRenderTime = false;
  340. this._renderTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  341. this._captureLayoutTime = false;
  342. this._layoutTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  343. // Observers
  344. this._onBeginRenderObserver = null;
  345. this._onEndRenderObserver = null;
  346. this._onBeginLayoutObserver = null;
  347. this._onEndLayoutObserver = null;
  348. }
  349. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  350. // Properties
  351. /**
  352. * Gets the perf counter used to capture render time
  353. */
  354. get: function () {
  355. return this._renderTime;
  356. },
  357. enumerable: true,
  358. configurable: true
  359. });
  360. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  361. /**
  362. * Gets the perf counter used to capture layout time
  363. */
  364. get: function () {
  365. return this._layoutTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  371. /**
  372. * Enable or disable the render time capture
  373. */
  374. get: function () {
  375. return this._captureRenderTime;
  376. },
  377. set: function (value) {
  378. var _this = this;
  379. if (value === this._captureRenderTime) {
  380. return;
  381. }
  382. this._captureRenderTime = value;
  383. if (value) {
  384. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  385. _this._renderTime.beginMonitoring();
  386. });
  387. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  388. _this._renderTime.endMonitoring(true);
  389. });
  390. }
  391. else {
  392. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  393. this._onBeginRenderObserver = null;
  394. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  395. this._onEndRenderObserver = null;
  396. }
  397. },
  398. enumerable: true,
  399. configurable: true
  400. });
  401. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  402. /**
  403. * Enable or disable the layout time capture
  404. */
  405. get: function () {
  406. return this._captureLayoutTime;
  407. },
  408. set: function (value) {
  409. var _this = this;
  410. if (value === this._captureLayoutTime) {
  411. return;
  412. }
  413. this._captureLayoutTime = value;
  414. if (value) {
  415. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  416. _this._layoutTime.beginMonitoring();
  417. });
  418. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  419. _this._layoutTime.endMonitoring(true);
  420. });
  421. }
  422. else {
  423. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  424. this._onBeginLayoutObserver = null;
  425. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  426. this._onEndLayoutObserver = null;
  427. }
  428. },
  429. enumerable: true,
  430. configurable: true
  431. });
  432. /**
  433. * Dispose and release associated resources.
  434. */
  435. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  436. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  437. this._onBeginRenderObserver = null;
  438. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  439. this._onEndRenderObserver = null;
  440. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  441. this._onBeginLayoutObserver = null;
  442. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  443. this._onEndLayoutObserver = null;
  444. this.texture = null;
  445. };
  446. return AdvancedDynamicTextureInstrumentation;
  447. }());
  448. /***/ }),
  449. /***/ "./2D/advancedDynamicTexture.ts":
  450. /*!**************************************!*\
  451. !*** ./2D/advancedDynamicTexture.ts ***!
  452. \**************************************/
  453. /*! exports provided: AdvancedDynamicTexture */
  454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  455. "use strict";
  456. __webpack_require__.r(__webpack_exports__);
  457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  459. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  460. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  461. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  462. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  463. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  464. /**
  465. * Class used to create texture to support 2D GUI elements
  466. * @see http://doc.babylonjs.com/how_to/gui
  467. */
  468. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  470. /**
  471. * Creates a new AdvancedDynamicTexture
  472. * @param name defines the name of the texture
  473. * @param width defines the width of the texture
  474. * @param height defines the height of the texture
  475. * @param scene defines the hosting scene
  476. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  477. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  478. */
  479. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  480. if (width === void 0) { width = 0; }
  481. if (height === void 0) { height = 0; }
  482. if (generateMipMaps === void 0) { generateMipMaps = false; }
  483. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  484. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  485. _this._isDirty = false;
  486. /** @hidden */
  487. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  488. /** @hidden */
  489. _this._lastControlOver = {};
  490. /** @hidden */
  491. _this._lastControlDown = {};
  492. /** @hidden */
  493. _this._capturingControl = {};
  494. /** @hidden */
  495. _this._linkedControls = new Array();
  496. _this._isFullscreen = false;
  497. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  498. _this._idealWidth = 0;
  499. _this._idealHeight = 0;
  500. _this._useSmallestIdeal = false;
  501. _this._renderAtIdealSize = false;
  502. _this._blockNextFocusCheck = false;
  503. _this._renderScale = 1;
  504. _this._cursorChanged = false;
  505. /**
  506. * Define type to string to ensure compatibility across browsers
  507. * Safari doesn't support DataTransfer constructor
  508. */
  509. _this._clipboardData = "";
  510. /**
  511. * Observable event triggered each time an clipboard event is received from the rendering canvas
  512. */
  513. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  514. /**
  515. * Observable event triggered each time a pointer down is intercepted by a control
  516. */
  517. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  518. /**
  519. * Observable event triggered before layout is evaluated
  520. */
  521. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  522. /**
  523. * Observable event triggered after the layout was evaluated
  524. */
  525. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  526. /**
  527. * Observable event triggered before the texture is rendered
  528. */
  529. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  530. /**
  531. * Observable event triggered after the texture was rendered
  532. */
  533. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  534. /**
  535. * Gets or sets a boolean defining if alpha is stored as premultiplied
  536. */
  537. _this.premulAlpha = false;
  538. _this._useInvalidateRectOptimization = true;
  539. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  540. _this._invalidatedRectangle = null;
  541. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  542. /** @hidden */
  543. _this.onClipboardCopy = function (rawEvt) {
  544. var evt = rawEvt;
  545. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  546. _this.onClipboardObservable.notifyObservers(ev);
  547. evt.preventDefault();
  548. };
  549. /** @hidden */
  550. _this.onClipboardCut = function (rawEvt) {
  551. var evt = rawEvt;
  552. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  553. _this.onClipboardObservable.notifyObservers(ev);
  554. evt.preventDefault();
  555. };
  556. /** @hidden */
  557. _this.onClipboardPaste = function (rawEvt) {
  558. var evt = rawEvt;
  559. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  560. _this.onClipboardObservable.notifyObservers(ev);
  561. evt.preventDefault();
  562. };
  563. scene = _this.getScene();
  564. if (!scene || !_this._texture) {
  565. return _this;
  566. }
  567. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  568. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  569. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  570. if (!_this._focusedControl) {
  571. return;
  572. }
  573. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  574. _this._focusedControl.processKeyboard(info.event);
  575. }
  576. info.skipOnPointerObservable = true;
  577. });
  578. _this._rootContainer._link(_this);
  579. _this.hasAlpha = true;
  580. if (!width || !height) {
  581. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  582. _this._onResize();
  583. }
  584. _this._texture.isReady = true;
  585. return _this;
  586. }
  587. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  588. /**
  589. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  590. * Useful when you want more antialiasing
  591. */
  592. get: function () {
  593. return this._renderScale;
  594. },
  595. set: function (value) {
  596. if (value === this._renderScale) {
  597. return;
  598. }
  599. this._renderScale = value;
  600. this._onResize();
  601. },
  602. enumerable: true,
  603. configurable: true
  604. });
  605. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  606. /** Gets or sets the background color */
  607. get: function () {
  608. return this._background;
  609. },
  610. set: function (value) {
  611. if (this._background === value) {
  612. return;
  613. }
  614. this._background = value;
  615. this.markAsDirty();
  616. },
  617. enumerable: true,
  618. configurable: true
  619. });
  620. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  621. /**
  622. * Gets or sets the ideal width used to design controls.
  623. * The GUI will then rescale everything accordingly
  624. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  625. */
  626. get: function () {
  627. return this._idealWidth;
  628. },
  629. set: function (value) {
  630. if (this._idealWidth === value) {
  631. return;
  632. }
  633. this._idealWidth = value;
  634. this.markAsDirty();
  635. this._rootContainer._markAllAsDirty();
  636. },
  637. enumerable: true,
  638. configurable: true
  639. });
  640. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  641. /**
  642. * Gets or sets the ideal height used to design controls.
  643. * The GUI will then rescale everything accordingly
  644. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  645. */
  646. get: function () {
  647. return this._idealHeight;
  648. },
  649. set: function (value) {
  650. if (this._idealHeight === value) {
  651. return;
  652. }
  653. this._idealHeight = value;
  654. this.markAsDirty();
  655. this._rootContainer._markAllAsDirty();
  656. },
  657. enumerable: true,
  658. configurable: true
  659. });
  660. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  661. /**
  662. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  663. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  664. */
  665. get: function () {
  666. return this._useSmallestIdeal;
  667. },
  668. set: function (value) {
  669. if (this._useSmallestIdeal === value) {
  670. return;
  671. }
  672. this._useSmallestIdeal = value;
  673. this.markAsDirty();
  674. this._rootContainer._markAllAsDirty();
  675. },
  676. enumerable: true,
  677. configurable: true
  678. });
  679. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  680. /**
  681. * Gets or sets a boolean indicating if adaptive scaling must be used
  682. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  683. */
  684. get: function () {
  685. return this._renderAtIdealSize;
  686. },
  687. set: function (value) {
  688. if (this._renderAtIdealSize === value) {
  689. return;
  690. }
  691. this._renderAtIdealSize = value;
  692. this._onResize();
  693. },
  694. enumerable: true,
  695. configurable: true
  696. });
  697. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  698. /**
  699. * Gets the underlying layer used to render the texture when in fullscreen mode
  700. */
  701. get: function () {
  702. return this._layerToDispose;
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  708. /**
  709. * Gets the root container control
  710. */
  711. get: function () {
  712. return this._rootContainer;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. /**
  718. * Returns an array containing the root container.
  719. * This is mostly used to let the Inspector introspects the ADT
  720. * @returns an array containing the rootContainer
  721. */
  722. AdvancedDynamicTexture.prototype.getChildren = function () {
  723. return [this._rootContainer];
  724. };
  725. /**
  726. * Will return all controls that are inside this texture
  727. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  728. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  729. * @return all child controls
  730. */
  731. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  732. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  733. };
  734. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  735. /**
  736. * Gets or sets the current focused control
  737. */
  738. get: function () {
  739. return this._focusedControl;
  740. },
  741. set: function (control) {
  742. if (this._focusedControl == control) {
  743. return;
  744. }
  745. if (this._focusedControl) {
  746. this._focusedControl.onBlur();
  747. }
  748. if (control) {
  749. control.onFocus();
  750. }
  751. this._focusedControl = control;
  752. },
  753. enumerable: true,
  754. configurable: true
  755. });
  756. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  757. /**
  758. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  759. */
  760. get: function () {
  761. if (!this.layer) {
  762. return true;
  763. }
  764. return (!this.layer.isBackground);
  765. },
  766. set: function (value) {
  767. if (!this.layer) {
  768. return;
  769. }
  770. if (this.layer.isBackground === !value) {
  771. return;
  772. }
  773. this.layer.isBackground = !value;
  774. },
  775. enumerable: true,
  776. configurable: true
  777. });
  778. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  779. /**
  780. * Gets or set information about clipboardData
  781. */
  782. get: function () {
  783. return this._clipboardData;
  784. },
  785. set: function (value) {
  786. this._clipboardData = value;
  787. },
  788. enumerable: true,
  789. configurable: true
  790. });
  791. /**
  792. * Get the current class name of the texture useful for serialization or dynamic coding.
  793. * @returns "AdvancedDynamicTexture"
  794. */
  795. AdvancedDynamicTexture.prototype.getClassName = function () {
  796. return "AdvancedDynamicTexture";
  797. };
  798. /**
  799. * Function used to execute a function on all controls
  800. * @param func defines the function to execute
  801. * @param container defines the container where controls belong. If null the root container will be used
  802. */
  803. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  804. if (!container) {
  805. container = this._rootContainer;
  806. }
  807. func(container);
  808. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  809. var child = _a[_i];
  810. if (child.children) {
  811. this.executeOnAllControls(func, child);
  812. continue;
  813. }
  814. func(child);
  815. }
  816. };
  817. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  818. /**
  819. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  820. */
  821. get: function () {
  822. return this._useInvalidateRectOptimization;
  823. },
  824. set: function (value) {
  825. this._useInvalidateRectOptimization = value;
  826. },
  827. enumerable: true,
  828. configurable: true
  829. });
  830. /**
  831. * Invalidates a rectangle area on the gui texture
  832. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  833. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  834. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  835. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  836. */
  837. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  838. if (!this._useInvalidateRectOptimization) {
  839. return;
  840. }
  841. if (!this._invalidatedRectangle) {
  842. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  843. }
  844. else {
  845. // Compute intersection
  846. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  847. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  848. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  849. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  850. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  851. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  852. }
  853. };
  854. /**
  855. * Marks the texture as dirty forcing a complete update
  856. */
  857. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  858. this._isDirty = true;
  859. };
  860. /**
  861. * Helper function used to create a new style
  862. * @returns a new style
  863. * @see http://doc.babylonjs.com/how_to/gui#styles
  864. */
  865. AdvancedDynamicTexture.prototype.createStyle = function () {
  866. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  867. };
  868. /**
  869. * Adds a new control to the root container
  870. * @param control defines the control to add
  871. * @returns the current texture
  872. */
  873. AdvancedDynamicTexture.prototype.addControl = function (control) {
  874. this._rootContainer.addControl(control);
  875. return this;
  876. };
  877. /**
  878. * Removes a control from the root container
  879. * @param control defines the control to remove
  880. * @returns the current texture
  881. */
  882. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  883. this._rootContainer.removeControl(control);
  884. return this;
  885. };
  886. /**
  887. * Release all resources
  888. */
  889. AdvancedDynamicTexture.prototype.dispose = function () {
  890. var scene = this.getScene();
  891. if (!scene) {
  892. return;
  893. }
  894. this._rootCanvas = null;
  895. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  896. if (this._resizeObserver) {
  897. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  898. }
  899. if (this._pointerMoveObserver) {
  900. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  901. }
  902. if (this._pointerObserver) {
  903. scene.onPointerObservable.remove(this._pointerObserver);
  904. }
  905. if (this._preKeyboardObserver) {
  906. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  907. }
  908. if (this._canvasPointerOutObserver) {
  909. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  910. }
  911. if (this._layerToDispose) {
  912. this._layerToDispose.texture = null;
  913. this._layerToDispose.dispose();
  914. this._layerToDispose = null;
  915. }
  916. this._rootContainer.dispose();
  917. this.onClipboardObservable.clear();
  918. this.onControlPickedObservable.clear();
  919. this.onBeginRenderObservable.clear();
  920. this.onEndRenderObservable.clear();
  921. this.onBeginLayoutObservable.clear();
  922. this.onEndLayoutObservable.clear();
  923. _super.prototype.dispose.call(this);
  924. };
  925. AdvancedDynamicTexture.prototype._onResize = function () {
  926. var scene = this.getScene();
  927. if (!scene) {
  928. return;
  929. }
  930. // Check size
  931. var engine = scene.getEngine();
  932. var textureSize = this.getSize();
  933. var renderWidth = engine.getRenderWidth() * this._renderScale;
  934. var renderHeight = engine.getRenderHeight() * this._renderScale;
  935. if (this._renderAtIdealSize) {
  936. if (this._idealWidth) {
  937. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  938. renderWidth = this._idealWidth;
  939. }
  940. else if (this._idealHeight) {
  941. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  942. renderHeight = this._idealHeight;
  943. }
  944. }
  945. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  946. this.scaleTo(renderWidth, renderHeight);
  947. this.markAsDirty();
  948. if (this._idealWidth || this._idealHeight) {
  949. this._rootContainer._markAllAsDirty();
  950. }
  951. }
  952. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  953. };
  954. /** @hidden */
  955. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  956. var engine = scene.getEngine();
  957. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  958. };
  959. /**
  960. * Get screen coordinates for a vector3
  961. * @param position defines the position to project
  962. * @param worldMatrix defines the world matrix to use
  963. * @returns the projected position
  964. */
  965. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  966. var scene = this.getScene();
  967. if (!scene) {
  968. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  969. }
  970. var globalViewport = this._getGlobalViewport(scene);
  971. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  972. projectedPosition.scaleInPlace(this.renderScale);
  973. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  974. };
  975. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  976. if (this._layerToDispose) {
  977. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  978. return;
  979. }
  980. }
  981. if (this._isFullscreen && this._linkedControls.length) {
  982. var scene = this.getScene();
  983. if (!scene) {
  984. return;
  985. }
  986. var globalViewport = this._getGlobalViewport(scene);
  987. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  988. var control = _a[_i];
  989. if (!control.isVisible) {
  990. continue;
  991. }
  992. var mesh = control._linkedMesh;
  993. if (!mesh || mesh.isDisposed()) {
  994. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  995. control.linkWithMesh(null);
  996. });
  997. continue;
  998. }
  999. var position = mesh.getBoundingInfo().boundingSphere.center;
  1000. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1001. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1002. control.notRenderable = true;
  1003. continue;
  1004. }
  1005. control.notRenderable = false;
  1006. // Account for RenderScale.
  1007. projectedPosition.scaleInPlace(this.renderScale);
  1008. control._moveToProjectedPosition(projectedPosition);
  1009. }
  1010. }
  1011. if (!this._isDirty && !this._rootContainer.isDirty) {
  1012. return;
  1013. }
  1014. this._isDirty = false;
  1015. this._render();
  1016. this.update(true, this.premulAlpha);
  1017. };
  1018. AdvancedDynamicTexture.prototype._render = function () {
  1019. var textureSize = this.getSize();
  1020. var renderWidth = textureSize.width;
  1021. var renderHeight = textureSize.height;
  1022. var context = this.getContext();
  1023. context.font = "18px Arial";
  1024. context.strokeStyle = "white";
  1025. // Layout
  1026. this.onBeginLayoutObservable.notifyObservers(this);
  1027. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1028. this._rootContainer._layout(measure, context);
  1029. this.onEndLayoutObservable.notifyObservers(this);
  1030. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1031. // Clear
  1032. if (this._invalidatedRectangle) {
  1033. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1034. }
  1035. else {
  1036. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1037. }
  1038. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1039. if (this._background) {
  1040. context.save();
  1041. context.fillStyle = this._background;
  1042. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1043. context.restore();
  1044. }
  1045. // Render
  1046. this.onBeginRenderObservable.notifyObservers(this);
  1047. this._rootContainer._render(context, this._invalidatedRectangle);
  1048. this.onEndRenderObservable.notifyObservers(this);
  1049. this._invalidatedRectangle = null;
  1050. };
  1051. /** @hidden */
  1052. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1053. if (this._rootCanvas) {
  1054. this._rootCanvas.style.cursor = cursor;
  1055. this._cursorChanged = true;
  1056. }
  1057. };
  1058. /** @hidden */
  1059. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1060. this._lastControlDown[pointerId] = control;
  1061. this.onControlPickedObservable.notifyObservers(control);
  1062. };
  1063. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1064. var scene = this.getScene();
  1065. if (!scene) {
  1066. return;
  1067. }
  1068. var engine = scene.getEngine();
  1069. var textureSize = this.getSize();
  1070. if (this._isFullscreen) {
  1071. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1072. var viewport = camera.viewport;
  1073. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1074. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1075. }
  1076. if (this._capturingControl[pointerId]) {
  1077. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1078. return;
  1079. }
  1080. this._cursorChanged = false;
  1081. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1082. this._changeCursor("");
  1083. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1084. if (this._lastControlOver[pointerId]) {
  1085. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1086. delete this._lastControlOver[pointerId];
  1087. }
  1088. }
  1089. }
  1090. if (!this._cursorChanged) {
  1091. this._changeCursor("");
  1092. }
  1093. this._manageFocus();
  1094. };
  1095. /** @hidden */
  1096. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1097. for (var pointerId in list) {
  1098. if (!list.hasOwnProperty(pointerId)) {
  1099. continue;
  1100. }
  1101. var lastControlOver = list[pointerId];
  1102. if (lastControlOver === control) {
  1103. delete list[pointerId];
  1104. }
  1105. }
  1106. };
  1107. /** @hidden */
  1108. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1109. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1110. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1111. };
  1112. /** Attach to all scene events required to support pointer events */
  1113. AdvancedDynamicTexture.prototype.attach = function () {
  1114. var _this = this;
  1115. var scene = this.getScene();
  1116. if (!scene) {
  1117. return;
  1118. }
  1119. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1120. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1121. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1122. return;
  1123. }
  1124. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1125. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1126. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1127. return;
  1128. }
  1129. if (!scene) {
  1130. return;
  1131. }
  1132. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1133. var engine = scene.getEngine();
  1134. if (!camera) {
  1135. tempViewport.x = 0;
  1136. tempViewport.y = 0;
  1137. tempViewport.width = engine.getRenderWidth();
  1138. tempViewport.height = engine.getRenderHeight();
  1139. }
  1140. else {
  1141. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1142. }
  1143. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1144. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1145. _this._shouldBlockPointer = false;
  1146. // Do picking modifies _shouldBlockPointer
  1147. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1148. // Avoid overwriting a true skipOnPointerObservable to false
  1149. if (_this._shouldBlockPointer) {
  1150. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1151. }
  1152. });
  1153. this._attachToOnPointerOut(scene);
  1154. };
  1155. /**
  1156. * Register the clipboard Events onto the canvas
  1157. */
  1158. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1159. self.addEventListener("copy", this.onClipboardCopy, false);
  1160. self.addEventListener("cut", this.onClipboardCut, false);
  1161. self.addEventListener("paste", this.onClipboardPaste, false);
  1162. };
  1163. /**
  1164. * Unregister the clipboard Events from the canvas
  1165. */
  1166. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1167. self.removeEventListener("copy", this.onClipboardCopy);
  1168. self.removeEventListener("cut", this.onClipboardCut);
  1169. self.removeEventListener("paste", this.onClipboardPaste);
  1170. };
  1171. /**
  1172. * Connect the texture to a hosting mesh to enable interactions
  1173. * @param mesh defines the mesh to attach to
  1174. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1175. */
  1176. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1177. var _this = this;
  1178. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1179. var scene = this.getScene();
  1180. if (!scene) {
  1181. return;
  1182. }
  1183. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1184. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1185. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1186. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1187. return;
  1188. }
  1189. var pointerId = pi.event.pointerId || 0;
  1190. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1191. var uv = pi.pickInfo.getTextureCoordinates();
  1192. if (uv) {
  1193. var size = _this.getSize();
  1194. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1195. }
  1196. }
  1197. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1198. if (_this._lastControlDown[pointerId]) {
  1199. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1200. }
  1201. delete _this._lastControlDown[pointerId];
  1202. if (_this.focusedControl) {
  1203. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1204. var canMoveFocus = true;
  1205. if (friendlyControls) {
  1206. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1207. var control = friendlyControls_1[_i];
  1208. // Same host, no need to keep the focus
  1209. if (_this === control._host) {
  1210. continue;
  1211. }
  1212. // Different hosts
  1213. var otherHost = control._host;
  1214. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1215. canMoveFocus = false;
  1216. break;
  1217. }
  1218. }
  1219. }
  1220. if (canMoveFocus) {
  1221. _this.focusedControl = null;
  1222. }
  1223. }
  1224. }
  1225. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1226. if (_this._lastControlOver[pointerId]) {
  1227. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1228. }
  1229. delete _this._lastControlOver[pointerId];
  1230. }
  1231. });
  1232. mesh.enablePointerMoveEvents = supportPointerMove;
  1233. this._attachToOnPointerOut(scene);
  1234. };
  1235. /**
  1236. * Move the focus to a specific control
  1237. * @param control defines the control which will receive the focus
  1238. */
  1239. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1240. this.focusedControl = control;
  1241. this._lastPickedControl = control;
  1242. this._blockNextFocusCheck = true;
  1243. };
  1244. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1245. if (this._blockNextFocusCheck) {
  1246. this._blockNextFocusCheck = false;
  1247. this._lastPickedControl = this._focusedControl;
  1248. return;
  1249. }
  1250. // Focus management
  1251. if (this._focusedControl) {
  1252. if (this._focusedControl !== this._lastPickedControl) {
  1253. if (this._lastPickedControl.isFocusInvisible) {
  1254. return;
  1255. }
  1256. this.focusedControl = null;
  1257. }
  1258. }
  1259. };
  1260. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1261. var _this = this;
  1262. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1263. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1264. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1265. }
  1266. delete _this._lastControlOver[pointerEvent.pointerId];
  1267. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1268. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1269. delete _this._lastControlDown[pointerEvent.pointerId];
  1270. }
  1271. });
  1272. };
  1273. // Statics
  1274. /**
  1275. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1276. * @param mesh defines the mesh which will receive the texture
  1277. * @param width defines the texture width (1024 by default)
  1278. * @param height defines the texture height (1024 by default)
  1279. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1280. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1281. * @returns a new AdvancedDynamicTexture
  1282. */
  1283. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1284. if (width === void 0) { width = 1024; }
  1285. if (height === void 0) { height = 1024; }
  1286. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1287. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1288. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1289. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1290. material.backFaceCulling = false;
  1291. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1292. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1293. if (onlyAlphaTesting) {
  1294. material.diffuseTexture = result;
  1295. material.emissiveTexture = result;
  1296. result.hasAlpha = true;
  1297. }
  1298. else {
  1299. material.emissiveTexture = result;
  1300. material.opacityTexture = result;
  1301. }
  1302. mesh.material = material;
  1303. result.attachToMesh(mesh, supportPointerMove);
  1304. return result;
  1305. };
  1306. /**
  1307. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1308. * In this mode the texture will rely on a layer for its rendering.
  1309. * This allows it to be treated like any other layer.
  1310. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1311. * LayerMask is set through advancedTexture.layer.layerMask
  1312. * @param name defines name for the texture
  1313. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1314. * @param scene defines the hsoting scene
  1315. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1316. * @returns a new AdvancedDynamicTexture
  1317. */
  1318. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1319. if (foreground === void 0) { foreground = true; }
  1320. if (scene === void 0) { scene = null; }
  1321. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1322. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1323. // Display
  1324. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1325. layer.texture = result;
  1326. result._layerToDispose = layer;
  1327. result._isFullscreen = true;
  1328. // Attach
  1329. result.attach();
  1330. return result;
  1331. };
  1332. return AdvancedDynamicTexture;
  1333. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1334. /***/ }),
  1335. /***/ "./2D/controls/button.ts":
  1336. /*!*******************************!*\
  1337. !*** ./2D/controls/button.ts ***!
  1338. \*******************************/
  1339. /*! exports provided: Button */
  1340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1341. "use strict";
  1342. __webpack_require__.r(__webpack_exports__);
  1343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1344. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1345. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1346. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1347. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1348. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1349. /**
  1350. * Class used to create 2D buttons
  1351. */
  1352. var Button = /** @class */ (function (_super) {
  1353. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1354. /**
  1355. * Creates a new Button
  1356. * @param name defines the name of the button
  1357. */
  1358. function Button(name) {
  1359. var _this = _super.call(this, name) || this;
  1360. _this.name = name;
  1361. _this.thickness = 1;
  1362. _this.isPointerBlocker = true;
  1363. var alphaStore = null;
  1364. _this.pointerEnterAnimation = function () {
  1365. alphaStore = _this.alpha;
  1366. _this.alpha -= 0.1;
  1367. };
  1368. _this.pointerOutAnimation = function () {
  1369. if (alphaStore !== null) {
  1370. _this.alpha = alphaStore;
  1371. }
  1372. };
  1373. _this.pointerDownAnimation = function () {
  1374. _this.scaleX -= 0.05;
  1375. _this.scaleY -= 0.05;
  1376. };
  1377. _this.pointerUpAnimation = function () {
  1378. _this.scaleX += 0.05;
  1379. _this.scaleY += 0.05;
  1380. };
  1381. return _this;
  1382. }
  1383. Object.defineProperty(Button.prototype, "image", {
  1384. /**
  1385. * Returns the image part of the button (if any)
  1386. */
  1387. get: function () {
  1388. return this._image;
  1389. },
  1390. enumerable: true,
  1391. configurable: true
  1392. });
  1393. Object.defineProperty(Button.prototype, "textBlock", {
  1394. /**
  1395. * Returns the image part of the button (if any)
  1396. */
  1397. get: function () {
  1398. return this._textBlock;
  1399. },
  1400. enumerable: true,
  1401. configurable: true
  1402. });
  1403. Button.prototype._getTypeName = function () {
  1404. return "Button";
  1405. };
  1406. // While being a container, the button behaves like a control.
  1407. /** @hidden */
  1408. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1409. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1410. return false;
  1411. }
  1412. if (!_super.prototype.contains.call(this, x, y)) {
  1413. return false;
  1414. }
  1415. this._processObservables(type, x, y, pointerId, buttonIndex);
  1416. return true;
  1417. };
  1418. /** @hidden */
  1419. Button.prototype._onPointerEnter = function (target) {
  1420. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1421. return false;
  1422. }
  1423. if (this.pointerEnterAnimation) {
  1424. this.pointerEnterAnimation();
  1425. }
  1426. return true;
  1427. };
  1428. /** @hidden */
  1429. Button.prototype._onPointerOut = function (target, force) {
  1430. if (force === void 0) { force = false; }
  1431. if (this.pointerOutAnimation) {
  1432. this.pointerOutAnimation();
  1433. }
  1434. _super.prototype._onPointerOut.call(this, target, force);
  1435. };
  1436. /** @hidden */
  1437. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1438. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1439. return false;
  1440. }
  1441. if (this.pointerDownAnimation) {
  1442. this.pointerDownAnimation();
  1443. }
  1444. return true;
  1445. };
  1446. /** @hidden */
  1447. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1448. if (this.pointerUpAnimation) {
  1449. this.pointerUpAnimation();
  1450. }
  1451. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1452. };
  1453. // Statics
  1454. /**
  1455. * Creates a new button made with an image and a text
  1456. * @param name defines the name of the button
  1457. * @param text defines the text of the button
  1458. * @param imageUrl defines the url of the image
  1459. * @returns a new Button
  1460. */
  1461. Button.CreateImageButton = function (name, text, imageUrl) {
  1462. var result = new Button(name);
  1463. // Adding text
  1464. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1465. textBlock.textWrapping = true;
  1466. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1467. textBlock.paddingLeft = "20%";
  1468. result.addControl(textBlock);
  1469. // Adding image
  1470. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1471. iconImage.width = "20%";
  1472. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1473. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1474. result.addControl(iconImage);
  1475. // Store
  1476. result._image = iconImage;
  1477. result._textBlock = textBlock;
  1478. return result;
  1479. };
  1480. /**
  1481. * Creates a new button made with an image
  1482. * @param name defines the name of the button
  1483. * @param imageUrl defines the url of the image
  1484. * @returns a new Button
  1485. */
  1486. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1487. var result = new Button(name);
  1488. // Adding image
  1489. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1490. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1491. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1492. result.addControl(iconImage);
  1493. // Store
  1494. result._image = iconImage;
  1495. return result;
  1496. };
  1497. /**
  1498. * Creates a new button made with a text
  1499. * @param name defines the name of the button
  1500. * @param text defines the text of the button
  1501. * @returns a new Button
  1502. */
  1503. Button.CreateSimpleButton = function (name, text) {
  1504. var result = new Button(name);
  1505. // Adding text
  1506. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1507. textBlock.textWrapping = true;
  1508. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1509. result.addControl(textBlock);
  1510. // Store
  1511. result._textBlock = textBlock;
  1512. return result;
  1513. };
  1514. /**
  1515. * Creates a new button made with an image and a centered text
  1516. * @param name defines the name of the button
  1517. * @param text defines the text of the button
  1518. * @param imageUrl defines the url of the image
  1519. * @returns a new Button
  1520. */
  1521. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1522. var result = new Button(name);
  1523. // Adding image
  1524. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1525. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1526. result.addControl(iconImage);
  1527. // Adding text
  1528. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1529. textBlock.textWrapping = true;
  1530. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1531. result.addControl(textBlock);
  1532. // Store
  1533. result._image = iconImage;
  1534. result._textBlock = textBlock;
  1535. return result;
  1536. };
  1537. return Button;
  1538. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1539. /***/ }),
  1540. /***/ "./2D/controls/checkbox.ts":
  1541. /*!*********************************!*\
  1542. !*** ./2D/controls/checkbox.ts ***!
  1543. \*********************************/
  1544. /*! exports provided: Checkbox */
  1545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1546. "use strict";
  1547. __webpack_require__.r(__webpack_exports__);
  1548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1550. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  1551. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1552. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1553. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1554. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1555. /**
  1556. * Class used to represent a 2D checkbox
  1557. */
  1558. var Checkbox = /** @class */ (function (_super) {
  1559. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1560. /**
  1561. * Creates a new CheckBox
  1562. * @param name defines the control name
  1563. */
  1564. function Checkbox(name) {
  1565. var _this = _super.call(this, name) || this;
  1566. _this.name = name;
  1567. _this._isChecked = false;
  1568. _this._background = "black";
  1569. _this._checkSizeRatio = 0.8;
  1570. _this._thickness = 1;
  1571. /**
  1572. * Observable raised when isChecked property changes
  1573. */
  1574. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1575. _this.isPointerBlocker = true;
  1576. return _this;
  1577. }
  1578. Object.defineProperty(Checkbox.prototype, "thickness", {
  1579. /** Gets or sets border thickness */
  1580. get: function () {
  1581. return this._thickness;
  1582. },
  1583. set: function (value) {
  1584. if (this._thickness === value) {
  1585. return;
  1586. }
  1587. this._thickness = value;
  1588. this._markAsDirty();
  1589. },
  1590. enumerable: true,
  1591. configurable: true
  1592. });
  1593. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1594. /** Gets or sets a value indicating the ratio between overall size and check size */
  1595. get: function () {
  1596. return this._checkSizeRatio;
  1597. },
  1598. set: function (value) {
  1599. value = Math.max(Math.min(1, value), 0);
  1600. if (this._checkSizeRatio === value) {
  1601. return;
  1602. }
  1603. this._checkSizeRatio = value;
  1604. this._markAsDirty();
  1605. },
  1606. enumerable: true,
  1607. configurable: true
  1608. });
  1609. Object.defineProperty(Checkbox.prototype, "background", {
  1610. /** Gets or sets background color */
  1611. get: function () {
  1612. return this._background;
  1613. },
  1614. set: function (value) {
  1615. if (this._background === value) {
  1616. return;
  1617. }
  1618. this._background = value;
  1619. this._markAsDirty();
  1620. },
  1621. enumerable: true,
  1622. configurable: true
  1623. });
  1624. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1625. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1626. get: function () {
  1627. return this._isChecked;
  1628. },
  1629. set: function (value) {
  1630. if (this._isChecked === value) {
  1631. return;
  1632. }
  1633. this._isChecked = value;
  1634. this._markAsDirty();
  1635. this.onIsCheckedChangedObservable.notifyObservers(value);
  1636. },
  1637. enumerable: true,
  1638. configurable: true
  1639. });
  1640. Checkbox.prototype._getTypeName = function () {
  1641. return "Checkbox";
  1642. };
  1643. /** @hidden */
  1644. Checkbox.prototype._draw = function (context) {
  1645. context.save();
  1646. this._applyStates(context);
  1647. var actualWidth = this._currentMeasure.width - this._thickness;
  1648. var actualHeight = this._currentMeasure.height - this._thickness;
  1649. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1650. context.shadowColor = this.shadowColor;
  1651. context.shadowBlur = this.shadowBlur;
  1652. context.shadowOffsetX = this.shadowOffsetX;
  1653. context.shadowOffsetY = this.shadowOffsetY;
  1654. }
  1655. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1656. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1657. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1658. context.shadowBlur = 0;
  1659. context.shadowOffsetX = 0;
  1660. context.shadowOffsetY = 0;
  1661. }
  1662. if (this._isChecked) {
  1663. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1664. var offsetWidth = actualWidth * this._checkSizeRatio;
  1665. var offseHeight = actualHeight * this._checkSizeRatio;
  1666. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1667. }
  1668. context.strokeStyle = this.color;
  1669. context.lineWidth = this._thickness;
  1670. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1671. context.restore();
  1672. };
  1673. // Events
  1674. /** @hidden */
  1675. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1676. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1677. return false;
  1678. }
  1679. this.isChecked = !this.isChecked;
  1680. return true;
  1681. };
  1682. /**
  1683. * Utility function to easily create a checkbox with a header
  1684. * @param title defines the label to use for the header
  1685. * @param onValueChanged defines the callback to call when value changes
  1686. * @returns a StackPanel containing the checkbox and a textBlock
  1687. */
  1688. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1689. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1690. panel.isVertical = false;
  1691. panel.height = "30px";
  1692. var checkbox = new Checkbox();
  1693. checkbox.width = "20px";
  1694. checkbox.height = "20px";
  1695. checkbox.isChecked = true;
  1696. checkbox.color = "green";
  1697. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1698. panel.addControl(checkbox);
  1699. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1700. header.text = title;
  1701. header.width = "180px";
  1702. header.paddingLeft = "5px";
  1703. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1704. header.color = "white";
  1705. panel.addControl(header);
  1706. return panel;
  1707. };
  1708. return Checkbox;
  1709. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1710. /***/ }),
  1711. /***/ "./2D/controls/colorpicker.ts":
  1712. /*!************************************!*\
  1713. !*** ./2D/controls/colorpicker.ts ***!
  1714. \************************************/
  1715. /*! exports provided: ColorPicker */
  1716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1717. "use strict";
  1718. __webpack_require__.r(__webpack_exports__);
  1719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1720. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1721. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  1722. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1723. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1724. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1725. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1726. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1727. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1728. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1729. /** Class used to create color pickers */
  1730. var ColorPicker = /** @class */ (function (_super) {
  1731. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1732. /**
  1733. * Creates a new ColorPicker
  1734. * @param name defines the control name
  1735. */
  1736. function ColorPicker(name) {
  1737. var _this = _super.call(this, name) || this;
  1738. _this.name = name;
  1739. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1740. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1741. _this._pointerStartedOnSquare = false;
  1742. _this._pointerStartedOnWheel = false;
  1743. _this._squareLeft = 0;
  1744. _this._squareTop = 0;
  1745. _this._squareSize = 0;
  1746. _this._h = 360;
  1747. _this._s = 1;
  1748. _this._v = 1;
  1749. /**
  1750. * Observable raised when the value changes
  1751. */
  1752. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1753. // Events
  1754. _this._pointerIsDown = false;
  1755. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1756. _this.size = "200px";
  1757. _this.isPointerBlocker = true;
  1758. return _this;
  1759. }
  1760. Object.defineProperty(ColorPicker.prototype, "value", {
  1761. /** Gets or sets the color of the color picker */
  1762. get: function () {
  1763. return this._value;
  1764. },
  1765. set: function (value) {
  1766. if (this._value.equals(value)) {
  1767. return;
  1768. }
  1769. this._value.copyFrom(value);
  1770. this._RGBtoHSV(this._value, this._tmpColor);
  1771. this._h = this._tmpColor.r;
  1772. this._s = Math.max(this._tmpColor.g, 0.00001);
  1773. this._v = Math.max(this._tmpColor.b, 0.00001);
  1774. this._markAsDirty();
  1775. if (this._value.r <= ColorPicker._Epsilon) {
  1776. this._value.r = 0;
  1777. }
  1778. if (this._value.g <= ColorPicker._Epsilon) {
  1779. this._value.g = 0;
  1780. }
  1781. if (this._value.b <= ColorPicker._Epsilon) {
  1782. this._value.b = 0;
  1783. }
  1784. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1785. this._value.r = 1.0;
  1786. }
  1787. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1788. this._value.g = 1.0;
  1789. }
  1790. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1791. this._value.b = 1.0;
  1792. }
  1793. this.onValueChangedObservable.notifyObservers(this._value);
  1794. },
  1795. enumerable: true,
  1796. configurable: true
  1797. });
  1798. Object.defineProperty(ColorPicker.prototype, "width", {
  1799. /**
  1800. * Gets or sets control width
  1801. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1802. */
  1803. get: function () {
  1804. return this._width.toString(this._host);
  1805. },
  1806. set: function (value) {
  1807. if (this._width.toString(this._host) === value) {
  1808. return;
  1809. }
  1810. if (this._width.fromString(value)) {
  1811. this._height.fromString(value);
  1812. this._markAsDirty();
  1813. }
  1814. },
  1815. enumerable: true,
  1816. configurable: true
  1817. });
  1818. Object.defineProperty(ColorPicker.prototype, "height", {
  1819. /**
  1820. * Gets or sets control height
  1821. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1822. */
  1823. get: function () {
  1824. return this._height.toString(this._host);
  1825. },
  1826. /** Gets or sets control height */
  1827. set: function (value) {
  1828. if (this._height.toString(this._host) === value) {
  1829. return;
  1830. }
  1831. if (this._height.fromString(value)) {
  1832. this._width.fromString(value);
  1833. this._markAsDirty();
  1834. }
  1835. },
  1836. enumerable: true,
  1837. configurable: true
  1838. });
  1839. Object.defineProperty(ColorPicker.prototype, "size", {
  1840. /** Gets or sets control size */
  1841. get: function () {
  1842. return this.width;
  1843. },
  1844. set: function (value) {
  1845. this.width = value;
  1846. },
  1847. enumerable: true,
  1848. configurable: true
  1849. });
  1850. ColorPicker.prototype._getTypeName = function () {
  1851. return "ColorPicker";
  1852. };
  1853. /** @hidden */
  1854. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1855. if (parentMeasure.width < parentMeasure.height) {
  1856. this._currentMeasure.height = parentMeasure.width;
  1857. }
  1858. else {
  1859. this._currentMeasure.width = parentMeasure.height;
  1860. }
  1861. };
  1862. ColorPicker.prototype._updateSquareProps = function () {
  1863. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1864. var wheelThickness = radius * .2;
  1865. var innerDiameter = (radius - wheelThickness) * 2;
  1866. var squareSize = innerDiameter / (Math.sqrt(2));
  1867. var offset = radius - squareSize * .5;
  1868. this._squareLeft = this._currentMeasure.left + offset;
  1869. this._squareTop = this._currentMeasure.top + offset;
  1870. this._squareSize = squareSize;
  1871. };
  1872. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1873. var lgh = context.createLinearGradient(left, top, width + left, top);
  1874. lgh.addColorStop(0, '#fff');
  1875. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1876. context.fillStyle = lgh;
  1877. context.fillRect(left, top, width, height);
  1878. var lgv = context.createLinearGradient(left, top, left, height + top);
  1879. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1880. lgv.addColorStop(1, '#000');
  1881. context.fillStyle = lgv;
  1882. context.fillRect(left, top, width, height);
  1883. };
  1884. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1885. context.beginPath();
  1886. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1887. context.lineWidth = 3;
  1888. context.strokeStyle = '#333333';
  1889. context.stroke();
  1890. context.beginPath();
  1891. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1892. context.lineWidth = 3;
  1893. context.strokeStyle = '#ffffff';
  1894. context.stroke();
  1895. };
  1896. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1897. var canvas = document.createElement("canvas");
  1898. canvas.width = radius * 2;
  1899. canvas.height = radius * 2;
  1900. var context = canvas.getContext("2d");
  1901. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1902. var data = image.data;
  1903. var color = this._tmpColor;
  1904. var maxDistSq = radius * radius;
  1905. var innerRadius = radius - thickness;
  1906. var minDistSq = innerRadius * innerRadius;
  1907. for (var x = -radius; x < radius; x++) {
  1908. for (var y = -radius; y < radius; y++) {
  1909. var distSq = x * x + y * y;
  1910. if (distSq > maxDistSq || distSq < minDistSq) {
  1911. continue;
  1912. }
  1913. var dist = Math.sqrt(distSq);
  1914. var ang = Math.atan2(y, x);
  1915. this._HSVtoRGB(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1916. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1917. data[index] = color.r * 255;
  1918. data[index + 1] = color.g * 255;
  1919. data[index + 2] = color.b * 255;
  1920. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1921. //apply less alpha to bigger color pickers
  1922. var alphaAmount = .2;
  1923. var maxAlpha = .2;
  1924. var minAlpha = .04;
  1925. var lowerRadius = 50;
  1926. var upperRadius = 150;
  1927. if (radius < lowerRadius) {
  1928. alphaAmount = maxAlpha;
  1929. }
  1930. else if (radius > upperRadius) {
  1931. alphaAmount = minAlpha;
  1932. }
  1933. else {
  1934. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1935. }
  1936. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1937. if (alphaRatio < alphaAmount) {
  1938. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1939. }
  1940. else if (alphaRatio > 1 - alphaAmount) {
  1941. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1942. }
  1943. else {
  1944. data[index + 3] = 255;
  1945. }
  1946. }
  1947. }
  1948. context.putImageData(image, 0, 0);
  1949. return canvas;
  1950. };
  1951. ColorPicker.prototype._RGBtoHSV = function (color, result) {
  1952. var r = color.r;
  1953. var g = color.g;
  1954. var b = color.b;
  1955. var max = Math.max(r, g, b);
  1956. var min = Math.min(r, g, b);
  1957. var h = 0;
  1958. var s = 0;
  1959. var v = max;
  1960. var dm = max - min;
  1961. if (max !== 0) {
  1962. s = dm / max;
  1963. }
  1964. if (max != min) {
  1965. if (max == r) {
  1966. h = (g - b) / dm;
  1967. if (g < b) {
  1968. h += 6;
  1969. }
  1970. }
  1971. else if (max == g) {
  1972. h = (b - r) / dm + 2;
  1973. }
  1974. else if (max == b) {
  1975. h = (r - g) / dm + 4;
  1976. }
  1977. h *= 60;
  1978. }
  1979. result.r = h;
  1980. result.g = s;
  1981. result.b = v;
  1982. };
  1983. ColorPicker.prototype._HSVtoRGB = function (hue, saturation, value, result) {
  1984. var chroma = value * saturation;
  1985. var h = hue / 60;
  1986. var x = chroma * (1 - Math.abs((h % 2) - 1));
  1987. var r = 0;
  1988. var g = 0;
  1989. var b = 0;
  1990. if (h >= 0 && h <= 1) {
  1991. r = chroma;
  1992. g = x;
  1993. }
  1994. else if (h >= 1 && h <= 2) {
  1995. r = x;
  1996. g = chroma;
  1997. }
  1998. else if (h >= 2 && h <= 3) {
  1999. g = chroma;
  2000. b = x;
  2001. }
  2002. else if (h >= 3 && h <= 4) {
  2003. g = x;
  2004. b = chroma;
  2005. }
  2006. else if (h >= 4 && h <= 5) {
  2007. r = x;
  2008. b = chroma;
  2009. }
  2010. else if (h >= 5 && h <= 6) {
  2011. r = chroma;
  2012. b = x;
  2013. }
  2014. var m = value - chroma;
  2015. result.set((r + m), (g + m), (b + m));
  2016. };
  2017. /** @hidden */
  2018. ColorPicker.prototype._draw = function (context) {
  2019. context.save();
  2020. this._applyStates(context);
  2021. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2022. var wheelThickness = radius * .2;
  2023. var left = this._currentMeasure.left;
  2024. var top = this._currentMeasure.top;
  2025. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2026. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2027. }
  2028. this._updateSquareProps();
  2029. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2030. context.shadowColor = this.shadowColor;
  2031. context.shadowBlur = this.shadowBlur;
  2032. context.shadowOffsetX = this.shadowOffsetX;
  2033. context.shadowOffsetY = this.shadowOffsetY;
  2034. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2035. }
  2036. context.drawImage(this._colorWheelCanvas, left, top);
  2037. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2038. context.shadowBlur = 0;
  2039. context.shadowOffsetX = 0;
  2040. context.shadowOffsetY = 0;
  2041. }
  2042. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2043. var cx = this._squareLeft + this._squareSize * this._s;
  2044. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2045. this._drawCircle(cx, cy, radius * .04, context);
  2046. var dist = radius - wheelThickness * .5;
  2047. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2048. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2049. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2050. context.restore();
  2051. };
  2052. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2053. if (this._pointerStartedOnWheel) {
  2054. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2055. var centerX = radius + this._currentMeasure.left;
  2056. var centerY = radius + this._currentMeasure.top;
  2057. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2058. }
  2059. else if (this._pointerStartedOnSquare) {
  2060. this._updateSquareProps();
  2061. this._s = (x - this._squareLeft) / this._squareSize;
  2062. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2063. this._s = Math.min(this._s, 1);
  2064. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2065. this._v = Math.min(this._v, 1);
  2066. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2067. }
  2068. this._HSVtoRGB(this._h, this._s, this._v, this._tmpColor);
  2069. this.value = this._tmpColor;
  2070. };
  2071. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2072. this._updateSquareProps();
  2073. var left = this._squareLeft;
  2074. var top = this._squareTop;
  2075. var size = this._squareSize;
  2076. if (x >= left && x <= left + size &&
  2077. y >= top && y <= top + size) {
  2078. return true;
  2079. }
  2080. return false;
  2081. };
  2082. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2083. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2084. var centerX = radius + this._currentMeasure.left;
  2085. var centerY = radius + this._currentMeasure.top;
  2086. var wheelThickness = radius * .2;
  2087. var innerRadius = radius - wheelThickness;
  2088. var radiusSq = radius * radius;
  2089. var innerRadiusSq = innerRadius * innerRadius;
  2090. var dx = x - centerX;
  2091. var dy = y - centerY;
  2092. var distSq = dx * dx + dy * dy;
  2093. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2094. return true;
  2095. }
  2096. return false;
  2097. };
  2098. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2099. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2100. return false;
  2101. }
  2102. this._pointerIsDown = true;
  2103. this._pointerStartedOnSquare = false;
  2104. this._pointerStartedOnWheel = false;
  2105. // Invert transform
  2106. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2107. var x = this._transformedPosition.x;
  2108. var y = this._transformedPosition.y;
  2109. if (this._isPointOnSquare(x, y)) {
  2110. this._pointerStartedOnSquare = true;
  2111. }
  2112. else if (this._isPointOnWheel(x, y)) {
  2113. this._pointerStartedOnWheel = true;
  2114. }
  2115. this._updateValueFromPointer(x, y);
  2116. this._host._capturingControl[pointerId] = this;
  2117. return true;
  2118. };
  2119. ColorPicker.prototype._onPointerMove = function (target, coordinates) {
  2120. // Invert transform
  2121. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2122. var x = this._transformedPosition.x;
  2123. var y = this._transformedPosition.y;
  2124. if (this._pointerIsDown) {
  2125. this._updateValueFromPointer(x, y);
  2126. }
  2127. _super.prototype._onPointerMove.call(this, target, coordinates);
  2128. };
  2129. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2130. this._pointerIsDown = false;
  2131. delete this._host._capturingControl[pointerId];
  2132. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2133. };
  2134. /**
  2135. * This function expands the color picker by creating a color picker dialog with manual
  2136. * color value input and the ability to save colors into an array to be used later in
  2137. * subsequent launches of the dialogue.
  2138. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2139. * @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.
  2140. * @returns picked color as a hex string and the saved colors array as hex strings.
  2141. */
  2142. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2143. return new Promise(function (resolve, reject) {
  2144. // Default options
  2145. options.pickerWidth = options.pickerWidth || "640px";
  2146. options.pickerHeight = options.pickerHeight || "400px";
  2147. options.headerHeight = options.headerHeight || "35px";
  2148. options.lastColor = options.lastColor || "#000000";
  2149. options.swatchLimit = options.swatchLimit || 20;
  2150. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2151. // Window size settings
  2152. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2153. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2154. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2155. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2156. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2157. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2158. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2159. // Button Colors
  2160. var buttonColor = "#c0c0c0";
  2161. var buttonBackgroundColor = "#535353";
  2162. var buttonBackgroundHoverColor = "#414141";
  2163. var buttonBackgroundClickColor = "515151";
  2164. var buttonDisabledColor = "#555555";
  2165. var buttonDisabledBackgroundColor = "#454545";
  2166. var currentSwatchesOutlineColor = "#404040";
  2167. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2168. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2169. var iconColorDark = "#aaaaaa";
  2170. var iconColorLight = "#ffffff";
  2171. var closeIconColor;
  2172. // Button settings
  2173. var buttonFontSize;
  2174. var butEdit;
  2175. var buttonWidth;
  2176. var buttonHeight;
  2177. // Input Text Colors
  2178. var inputFieldLabels = ["R", "G", "B"];
  2179. var inputTextBackgroundColor = "#454545";
  2180. var inputTextColor = "#f0f0f0";
  2181. // This is the current color as set by either the picker or by entering a value
  2182. var currentColor;
  2183. // This int is used for naming swatches and serves as the index for calling them from the list
  2184. var swatchNumber;
  2185. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2186. var swatchDrawer;
  2187. var editSwatchMode = false;
  2188. // Color InputText fields that will be updated upon value change
  2189. var picker;
  2190. var rValInt;
  2191. var gValInt;
  2192. var bValInt;
  2193. var rValDec;
  2194. var gValDec;
  2195. var bValDec;
  2196. var hexVal;
  2197. var newSwatch;
  2198. var lastVal;
  2199. var activeField;
  2200. /**
  2201. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2202. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2203. * are will receive no update. This is to prevent the input from the user being overwritten.
  2204. */
  2205. function updateValues(value, inputField) {
  2206. activeField = inputField;
  2207. var pickedColor = value.toHexString();
  2208. newSwatch.background = pickedColor;
  2209. if (rValInt.name != activeField) {
  2210. rValInt.text = Math.floor(value.r * 255).toString();
  2211. }
  2212. if (gValInt.name != activeField) {
  2213. gValInt.text = Math.floor(value.g * 255).toString();
  2214. }
  2215. if (bValInt.name != activeField) {
  2216. bValInt.text = Math.floor(value.b * 255).toString();
  2217. }
  2218. if (rValDec.name != activeField) {
  2219. rValDec.text = value.r.toString();
  2220. }
  2221. if (gValDec.name != activeField) {
  2222. gValDec.text = value.g.toString();
  2223. }
  2224. if (bValDec.name != activeField) {
  2225. bValDec.text = value.b.toString();
  2226. }
  2227. if (hexVal.name != activeField) {
  2228. var minusPound = pickedColor.split("#");
  2229. hexVal.text = minusPound[1];
  2230. }
  2231. if (picker.name != activeField) {
  2232. picker.value = value;
  2233. }
  2234. }
  2235. // 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.
  2236. function updateInt(field, channel) {
  2237. var newValue = field.text;
  2238. var checkVal = /[^0-9]/g.test(newValue);
  2239. if (checkVal) {
  2240. field.text = lastVal;
  2241. return;
  2242. }
  2243. else {
  2244. if (newValue != "") {
  2245. if (Math.floor(parseInt(newValue)) < 0) {
  2246. newValue = "0";
  2247. }
  2248. else if (Math.floor(parseInt(newValue)) > 255) {
  2249. newValue = "255";
  2250. }
  2251. else if (isNaN(parseInt(newValue))) {
  2252. newValue = "0";
  2253. }
  2254. }
  2255. if (activeField == field.name) {
  2256. lastVal = newValue;
  2257. }
  2258. }
  2259. if (newValue != "") {
  2260. newValue = parseInt(newValue).toString();
  2261. field.text = newValue;
  2262. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2263. if (activeField == field.name) {
  2264. if (channel == "r") {
  2265. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2266. }
  2267. else if (channel == "g") {
  2268. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2269. }
  2270. else {
  2271. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2272. }
  2273. }
  2274. }
  2275. }
  2276. // 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.
  2277. function updateFloat(field, channel) {
  2278. var newValue = field.text;
  2279. var checkVal = /[^0-9\.]/g.test(newValue);
  2280. if (checkVal) {
  2281. field.text = lastVal;
  2282. return;
  2283. }
  2284. else {
  2285. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2286. if (parseFloat(newValue) < 0.0) {
  2287. newValue = "0.0";
  2288. }
  2289. else if (parseFloat(newValue) > 1.0) {
  2290. newValue = "1.0";
  2291. }
  2292. else if (isNaN(parseFloat(newValue))) {
  2293. newValue = "0.0";
  2294. }
  2295. }
  2296. if (activeField == field.name) {
  2297. lastVal = newValue;
  2298. }
  2299. }
  2300. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2301. newValue = parseFloat(newValue).toString();
  2302. field.text = newValue;
  2303. }
  2304. else {
  2305. newValue = "0.0";
  2306. }
  2307. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2308. if (activeField == field.name) {
  2309. if (channel == "r") {
  2310. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2311. }
  2312. else if (channel == "g") {
  2313. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2314. }
  2315. else {
  2316. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2317. }
  2318. }
  2319. }
  2320. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2321. function deleteSwatch(index) {
  2322. if (options.savedColors) {
  2323. options.savedColors.splice(index, 1);
  2324. }
  2325. if (options.savedColors && options.savedColors.length == 0) {
  2326. setEditButtonVisibility(false);
  2327. editSwatchMode = false;
  2328. }
  2329. }
  2330. // Creates and styles an individual swatch when updateSwatches is called.
  2331. function createSwatch() {
  2332. if (options.savedColors && options.savedColors[swatchNumber]) {
  2333. if (editSwatchMode) {
  2334. var icon = "b";
  2335. }
  2336. else {
  2337. var icon = "";
  2338. }
  2339. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2340. swatch.fontFamily = "BabylonJSglyphs";
  2341. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2342. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2343. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2344. if (swatchLuminence > luminanceLimit) {
  2345. swatch.color = iconColorDark;
  2346. }
  2347. else {
  2348. swatch.color = iconColorLight;
  2349. }
  2350. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2351. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2352. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2353. swatch.background = options.savedColors[swatchNumber];
  2354. swatch.thickness = 2;
  2355. var metadata_1 = swatchNumber;
  2356. swatch.pointerDownAnimation = function () {
  2357. swatch.thickness = 4;
  2358. };
  2359. swatch.pointerUpAnimation = function () {
  2360. swatch.thickness = 3;
  2361. };
  2362. swatch.pointerEnterAnimation = function () {
  2363. swatch.thickness = 3;
  2364. };
  2365. swatch.pointerOutAnimation = function () {
  2366. swatch.thickness = 2;
  2367. };
  2368. swatch.onPointerClickObservable.add(function () {
  2369. if (!editSwatchMode) {
  2370. if (options.savedColors) {
  2371. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2372. }
  2373. }
  2374. else {
  2375. deleteSwatch(metadata_1);
  2376. updateSwatches("", butSave);
  2377. }
  2378. });
  2379. return swatch;
  2380. }
  2381. else {
  2382. return null;
  2383. }
  2384. }
  2385. // Mode switch to render button text and close symbols on swatch controls
  2386. function editSwatches(mode) {
  2387. if (mode !== undefined) {
  2388. editSwatchMode = mode;
  2389. }
  2390. if (editSwatchMode) {
  2391. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2392. var thisButton = swatchDrawer.children[i];
  2393. thisButton.textBlock.text = "b";
  2394. }
  2395. if (butEdit !== undefined) {
  2396. butEdit.textBlock.text = "Done";
  2397. }
  2398. }
  2399. else {
  2400. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2401. var thisButton = swatchDrawer.children[i];
  2402. thisButton.textBlock.text = "";
  2403. }
  2404. if (butEdit !== undefined) {
  2405. butEdit.textBlock.text = "Edit";
  2406. }
  2407. }
  2408. }
  2409. /**
  2410. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2411. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2412. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2413. * saved colors there are and how many can be stored per row.
  2414. */
  2415. function updateSwatches(color, button) {
  2416. if (options.savedColors) {
  2417. if (color != "") {
  2418. options.savedColors.push(color);
  2419. }
  2420. swatchNumber = 0;
  2421. swatchDrawer.clearControls();
  2422. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2423. if (rowCount == 0) {
  2424. var gutterCount = 0;
  2425. }
  2426. else {
  2427. var gutterCount = rowCount + 1;
  2428. }
  2429. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2430. var currentRows = swatchDrawer.rowCount;
  2431. for (var i = 0; i < currentRows; i++) {
  2432. swatchDrawer.removeRowDefinition(0);
  2433. }
  2434. for (var i = 0; i < rowCount + gutterCount; i++) {
  2435. if (i % 2) {
  2436. swatchDrawer.addRowDefinition(swatchSize, true);
  2437. }
  2438. else {
  2439. swatchDrawer.addRowDefinition(gutterSize, true);
  2440. }
  2441. }
  2442. }
  2443. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2444. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2445. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2446. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2447. var totalButtonsThisRow = options.numSwatchesPerLine;
  2448. }
  2449. else {
  2450. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2451. }
  2452. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2453. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2454. if (x > options.numSwatchesPerLine) {
  2455. continue;
  2456. }
  2457. var swatch = createSwatch();
  2458. if (swatch != null) {
  2459. swatchDrawer.addControl(swatch, y, w);
  2460. w += 2;
  2461. swatchNumber++;
  2462. }
  2463. else {
  2464. continue;
  2465. }
  2466. }
  2467. }
  2468. if (options.savedColors.length >= options.swatchLimit) {
  2469. disableButton(button, true);
  2470. }
  2471. else {
  2472. disableButton(button, false);
  2473. }
  2474. }
  2475. }
  2476. // Shows or hides edit swatches button depending on if there are saved swatches
  2477. function setEditButtonVisibility(enableButton) {
  2478. if (enableButton) {
  2479. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2480. butEdit.width = buttonWidth;
  2481. butEdit.height = buttonHeight;
  2482. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2483. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2484. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2485. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2486. butEdit.thickness = 2;
  2487. butEdit.color = buttonColor;
  2488. butEdit.fontSize = buttonFontSize;
  2489. butEdit.background = buttonBackgroundColor;
  2490. butEdit.onPointerEnterObservable.add(function () {
  2491. butEdit.background = buttonBackgroundHoverColor;
  2492. });
  2493. butEdit.onPointerOutObservable.add(function () {
  2494. butEdit.background = buttonBackgroundColor;
  2495. });
  2496. butEdit.pointerDownAnimation = function () {
  2497. butEdit.background = buttonBackgroundClickColor;
  2498. };
  2499. butEdit.pointerUpAnimation = function () {
  2500. butEdit.background = buttonBackgroundHoverColor;
  2501. };
  2502. butEdit.onPointerClickObservable.add(function () {
  2503. if (editSwatchMode) {
  2504. editSwatchMode = false;
  2505. }
  2506. else {
  2507. editSwatchMode = true;
  2508. }
  2509. editSwatches();
  2510. });
  2511. pickerGrid.addControl(butEdit, 1, 0);
  2512. }
  2513. else {
  2514. pickerGrid.removeControl(butEdit);
  2515. }
  2516. }
  2517. // Called when the user hits the limit of saved colors in the drawer.
  2518. function disableButton(button, disabled) {
  2519. if (disabled) {
  2520. button.color = buttonDisabledColor;
  2521. button.background = buttonDisabledBackgroundColor;
  2522. }
  2523. else {
  2524. button.color = buttonColor;
  2525. button.background = buttonBackgroundColor;
  2526. }
  2527. }
  2528. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2529. function closePicker(color) {
  2530. if (options.savedColors && options.savedColors.length > 0) {
  2531. resolve({
  2532. savedColors: options.savedColors,
  2533. pickedColor: color
  2534. });
  2535. }
  2536. else {
  2537. resolve({
  2538. pickedColor: color
  2539. });
  2540. }
  2541. advancedTexture.removeControl(dialogContainer);
  2542. }
  2543. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2544. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2545. dialogContainer.name = "Dialog Container";
  2546. dialogContainer.width = options.pickerWidth;
  2547. if (options.savedColors) {
  2548. dialogContainer.height = containerSize;
  2549. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2550. dialogContainer.addRowDefinition(topRow, false);
  2551. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2552. }
  2553. else {
  2554. dialogContainer.height = options.pickerHeight;
  2555. dialogContainer.addRowDefinition(1.0, false);
  2556. }
  2557. advancedTexture.addControl(dialogContainer);
  2558. // Swatch drawer which contains all saved color buttons
  2559. if (options.savedColors) {
  2560. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2561. swatchDrawer.name = "Swatch Drawer";
  2562. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2563. swatchDrawer.background = buttonBackgroundColor;
  2564. swatchDrawer.width = options.pickerWidth;
  2565. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2566. if (initialRows == 0) {
  2567. var gutterCount = 0;
  2568. }
  2569. else {
  2570. var gutterCount = initialRows + 1;
  2571. }
  2572. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2573. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2574. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2575. if (i % 2 != 0) {
  2576. swatchDrawer.addRowDefinition(swatchSize, true);
  2577. }
  2578. else {
  2579. swatchDrawer.addRowDefinition(gutterSize, true);
  2580. }
  2581. }
  2582. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2583. if (i % 2 != 0) {
  2584. swatchDrawer.addColumnDefinition(swatchSize, true);
  2585. }
  2586. else {
  2587. swatchDrawer.addColumnDefinition(gutterSize, true);
  2588. }
  2589. }
  2590. dialogContainer.addControl(swatchDrawer, 1, 0);
  2591. }
  2592. // Picker container
  2593. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2594. pickerPanel.name = "Picker Panel";
  2595. pickerPanel.height = options.pickerHeight;
  2596. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2597. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2598. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2599. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2600. dialogContainer.addControl(pickerPanel, 0, 0);
  2601. // Picker container header
  2602. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2603. header.name = "Dialogue Header Bar";
  2604. header.background = "#cccccc";
  2605. header.thickness = 0;
  2606. pickerPanel.addControl(header, 0, 0);
  2607. // Header close button
  2608. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2609. closeButton.fontFamily = "BabylonJSglyphs";
  2610. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2611. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2612. closeButton.color = closeIconColor.toHexString();
  2613. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2614. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2615. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2616. closeButton.height = closeButton.width = options.headerHeight;
  2617. closeButton.background = header.background;
  2618. closeButton.thickness = 0;
  2619. closeButton.pointerDownAnimation = function () {
  2620. };
  2621. closeButton.pointerUpAnimation = function () {
  2622. closeButton.background = header.background;
  2623. };
  2624. closeButton.pointerEnterAnimation = function () {
  2625. closeButton.color = header.background;
  2626. closeButton.background = "red";
  2627. };
  2628. closeButton.pointerOutAnimation = function () {
  2629. closeButton.color = closeIconColor.toHexString();
  2630. closeButton.background = header.background;
  2631. };
  2632. closeButton.onPointerClickObservable.add(function () {
  2633. closePicker(currentSwatch.background);
  2634. });
  2635. pickerPanel.addControl(closeButton, 0, 0);
  2636. // Dialog container body
  2637. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2638. dialogBody.name = "Dialogue Body";
  2639. dialogBody.background = buttonBackgroundColor;
  2640. var dialogBodyCols = [0.4375, 0.5625];
  2641. dialogBody.addRowDefinition(1.0, false);
  2642. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2643. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2644. pickerPanel.addControl(dialogBody, 1, 0);
  2645. // Picker grid
  2646. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2647. pickerGrid.name = "Picker Grid";
  2648. pickerGrid.addRowDefinition(0.85, false);
  2649. pickerGrid.addRowDefinition(0.15, false);
  2650. dialogBody.addControl(pickerGrid, 0, 0);
  2651. // Picker control
  2652. picker = new ColorPicker();
  2653. picker.name = "GUI Color Picker";
  2654. if (options.pickerHeight < options.pickerWidth) {
  2655. picker.width = 0.89;
  2656. }
  2657. else {
  2658. picker.height = 0.89;
  2659. }
  2660. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2661. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2662. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2663. picker.onPointerDownObservable.add(function () {
  2664. activeField = picker.name;
  2665. lastVal = "";
  2666. editSwatches(false);
  2667. });
  2668. picker.onValueChangedObservable.add(function (value) {
  2669. if (activeField == picker.name) {
  2670. updateValues(value, picker.name);
  2671. }
  2672. });
  2673. pickerGrid.addControl(picker, 0, 0);
  2674. // Picker body right quarant
  2675. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2676. pickerBodyRight.name = "Dialogue Right Half";
  2677. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2678. var pickerBodyRightRows = [0.514, 0.486];
  2679. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2680. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2681. dialogBody.addControl(pickerBodyRight, 1, 1);
  2682. // Picker container swatches and buttons
  2683. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2684. pickerSwatchesButtons.name = "Swatches and Buttons";
  2685. var pickerButtonsCol = [0.417, 0.583];
  2686. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2687. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2688. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2689. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2690. // Picker Swatches quadrant
  2691. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2692. pickerSwatches.name = "New and Current Swatches";
  2693. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2694. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2695. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2696. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2697. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2698. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2699. // Active swatches
  2700. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2701. activeSwatches.name = "Active Swatches";
  2702. activeSwatches.width = 0.67;
  2703. activeSwatches.addRowDefinition(0.5, false);
  2704. activeSwatches.addRowDefinition(0.5, false);
  2705. pickerSwatches.addControl(activeSwatches, 2, 0);
  2706. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2707. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2708. if (options.pickerWidth > options.pickerHeight) {
  2709. var labelTextSize = labelHeight;
  2710. }
  2711. else {
  2712. var labelTextSize = labelWidth;
  2713. }
  2714. // New color swatch and previous color button
  2715. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2716. newText.text = "new";
  2717. newText.name = "New Color Label";
  2718. newText.color = buttonColor;
  2719. newText.fontSize = labelTextSize;
  2720. pickerSwatches.addControl(newText, 1, 0);
  2721. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2722. newSwatch.name = "New Color Swatch";
  2723. newSwatch.background = options.lastColor;
  2724. newSwatch.thickness = 0;
  2725. activeSwatches.addControl(newSwatch, 0, 0);
  2726. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2727. currentSwatch.background = options.lastColor;
  2728. currentSwatch.thickness = 0;
  2729. currentSwatch.onPointerClickObservable.add(function () {
  2730. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2731. updateValues(revertColor, currentSwatch.name);
  2732. editSwatches(false);
  2733. });
  2734. currentSwatch.pointerDownAnimation = function () { };
  2735. currentSwatch.pointerUpAnimation = function () { };
  2736. currentSwatch.pointerEnterAnimation = function () { };
  2737. currentSwatch.pointerOutAnimation = function () { };
  2738. activeSwatches.addControl(currentSwatch, 1, 0);
  2739. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2740. swatchOutline.name = "Swatch Outline";
  2741. swatchOutline.width = 0.67;
  2742. swatchOutline.thickness = 2;
  2743. swatchOutline.color = currentSwatchesOutlineColor;
  2744. swatchOutline.isHitTestVisible = false;
  2745. pickerSwatches.addControl(swatchOutline, 2, 0);
  2746. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2747. currentText.name = "Current Color Label";
  2748. currentText.text = "current";
  2749. currentText.color = buttonColor;
  2750. currentText.fontSize = labelTextSize;
  2751. pickerSwatches.addControl(currentText, 3, 0);
  2752. // Buttons grid
  2753. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2754. buttonGrid.name = "Button Grid";
  2755. buttonGrid.height = 0.8;
  2756. var buttonGridRows = 1 / 3;
  2757. buttonGrid.addRowDefinition(buttonGridRows, false);
  2758. buttonGrid.addRowDefinition(buttonGridRows, false);
  2759. buttonGrid.addRowDefinition(buttonGridRows, false);
  2760. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2761. // Determine pixel width and height for all buttons from overall panel dimensions
  2762. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2763. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2764. // Determine button type size
  2765. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2766. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2767. }
  2768. else {
  2769. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2770. }
  2771. // Panel Buttons
  2772. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2773. butOK.width = buttonWidth;
  2774. butOK.height = buttonHeight;
  2775. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2776. butOK.thickness = 2;
  2777. butOK.color = buttonColor;
  2778. butOK.fontSize = buttonFontSize;
  2779. butOK.background = buttonBackgroundColor;
  2780. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2781. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2782. butOK.pointerDownAnimation = function () {
  2783. butOK.background = buttonBackgroundClickColor;
  2784. };
  2785. butOK.pointerUpAnimation = function () {
  2786. butOK.background = buttonBackgroundHoverColor;
  2787. };
  2788. butOK.onPointerClickObservable.add(function () {
  2789. editSwatches(false);
  2790. closePicker(newSwatch.background);
  2791. });
  2792. buttonGrid.addControl(butOK, 0, 0);
  2793. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2794. butCancel.width = buttonWidth;
  2795. butCancel.height = buttonHeight;
  2796. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2797. butCancel.thickness = 2;
  2798. butCancel.color = buttonColor;
  2799. butCancel.fontSize = buttonFontSize;
  2800. butCancel.background = buttonBackgroundColor;
  2801. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2802. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2803. butCancel.pointerDownAnimation = function () {
  2804. butCancel.background = buttonBackgroundClickColor;
  2805. };
  2806. butCancel.pointerUpAnimation = function () {
  2807. butCancel.background = buttonBackgroundHoverColor;
  2808. };
  2809. butCancel.onPointerClickObservable.add(function () {
  2810. editSwatches(false);
  2811. closePicker(currentSwatch.background);
  2812. });
  2813. buttonGrid.addControl(butCancel, 1, 0);
  2814. if (options.savedColors) {
  2815. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2816. butSave.width = buttonWidth;
  2817. butSave.height = buttonHeight;
  2818. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2819. butSave.thickness = 2;
  2820. butSave.fontSize = buttonFontSize;
  2821. if (options.savedColors.length < options.swatchLimit) {
  2822. butSave.color = buttonColor;
  2823. butSave.background = buttonBackgroundColor;
  2824. }
  2825. else {
  2826. disableButton(butSave, true);
  2827. }
  2828. butSave.onPointerEnterObservable.add(function () {
  2829. if (options.savedColors) {
  2830. if (options.savedColors.length < options.swatchLimit) {
  2831. butSave.background = buttonBackgroundHoverColor;
  2832. }
  2833. }
  2834. });
  2835. butSave.onPointerOutObservable.add(function () {
  2836. if (options.savedColors) {
  2837. if (options.savedColors.length < options.swatchLimit) {
  2838. butSave.background = buttonBackgroundColor;
  2839. }
  2840. }
  2841. });
  2842. butSave.pointerDownAnimation = function () {
  2843. if (options.savedColors) {
  2844. if (options.savedColors.length < options.swatchLimit) {
  2845. butSave.background = buttonBackgroundClickColor;
  2846. }
  2847. }
  2848. };
  2849. butSave.pointerUpAnimation = function () {
  2850. if (options.savedColors) {
  2851. if (options.savedColors.length < options.swatchLimit) {
  2852. butSave.background = buttonBackgroundHoverColor;
  2853. }
  2854. }
  2855. };
  2856. butSave.onPointerClickObservable.add(function () {
  2857. if (options.savedColors) {
  2858. if (options.savedColors.length == 0) {
  2859. setEditButtonVisibility(true);
  2860. }
  2861. if (options.savedColors.length < options.swatchLimit) {
  2862. updateSwatches(newSwatch.background, butSave);
  2863. }
  2864. editSwatches(false);
  2865. }
  2866. });
  2867. if (options.savedColors.length > 0) {
  2868. setEditButtonVisibility(true);
  2869. }
  2870. buttonGrid.addControl(butSave, 2, 0);
  2871. }
  2872. // Picker color values input
  2873. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2874. pickerColorValues.name = "Dialog Lower Right";
  2875. pickerColorValues.addRowDefinition(0.02, false);
  2876. pickerColorValues.addRowDefinition(0.63, false);
  2877. pickerColorValues.addRowDefinition(0.21, false);
  2878. pickerColorValues.addRowDefinition(0.14, false);
  2879. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2880. // RGB values text boxes
  2881. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2882. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2883. rgbValuesQuadrant.name = "RGB Values";
  2884. rgbValuesQuadrant.width = 0.82;
  2885. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2886. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2887. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2888. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2889. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2890. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2891. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2892. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2893. for (var i = 0; i < inputFieldLabels.length; i++) {
  2894. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2895. labelText.text = inputFieldLabels[i];
  2896. labelText.color = buttonColor;
  2897. labelText.fontSize = buttonFontSize;
  2898. rgbValuesQuadrant.addControl(labelText, i, 0);
  2899. }
  2900. // Input fields for RGB values
  2901. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2902. rValInt.width = 0.83;
  2903. rValInt.height = 0.72;
  2904. rValInt.name = "rIntField";
  2905. rValInt.fontSize = buttonFontSize;
  2906. rValInt.text = (currentColor.r * 255).toString();
  2907. rValInt.color = inputTextColor;
  2908. rValInt.background = inputTextBackgroundColor;
  2909. rValInt.onFocusObservable.add(function () {
  2910. activeField = rValInt.name;
  2911. lastVal = rValInt.text;
  2912. editSwatches(false);
  2913. });
  2914. rValInt.onBlurObservable.add(function () {
  2915. if (rValInt.text == "") {
  2916. rValInt.text = "0";
  2917. }
  2918. updateInt(rValInt, "r");
  2919. if (activeField == rValInt.name) {
  2920. activeField = "";
  2921. }
  2922. });
  2923. rValInt.onTextChangedObservable.add(function () {
  2924. if (activeField == rValInt.name) {
  2925. updateInt(rValInt, "r");
  2926. }
  2927. });
  2928. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2929. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2930. gValInt.width = 0.83;
  2931. gValInt.height = 0.72;
  2932. gValInt.name = "gIntField";
  2933. gValInt.fontSize = buttonFontSize;
  2934. gValInt.text = (currentColor.g * 255).toString();
  2935. gValInt.color = inputTextColor;
  2936. gValInt.background = inputTextBackgroundColor;
  2937. gValInt.onFocusObservable.add(function () {
  2938. activeField = gValInt.name;
  2939. lastVal = gValInt.text;
  2940. editSwatches(false);
  2941. });
  2942. gValInt.onBlurObservable.add(function () {
  2943. if (gValInt.text == "") {
  2944. gValInt.text = "0";
  2945. }
  2946. updateInt(gValInt, "g");
  2947. if (activeField == gValInt.name) {
  2948. activeField = "";
  2949. }
  2950. });
  2951. gValInt.onTextChangedObservable.add(function () {
  2952. if (activeField == gValInt.name) {
  2953. updateInt(gValInt, "g");
  2954. }
  2955. });
  2956. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2957. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2958. bValInt.width = 0.83;
  2959. bValInt.height = 0.72;
  2960. bValInt.name = "bIntField";
  2961. bValInt.fontSize = buttonFontSize;
  2962. bValInt.text = (currentColor.b * 255).toString();
  2963. bValInt.color = inputTextColor;
  2964. bValInt.background = inputTextBackgroundColor;
  2965. bValInt.onFocusObservable.add(function () {
  2966. activeField = bValInt.name;
  2967. lastVal = bValInt.text;
  2968. editSwatches(false);
  2969. });
  2970. bValInt.onBlurObservable.add(function () {
  2971. if (bValInt.text == "") {
  2972. bValInt.text = "0";
  2973. }
  2974. updateInt(bValInt, "b");
  2975. if (activeField == bValInt.name) {
  2976. activeField = "";
  2977. }
  2978. });
  2979. bValInt.onTextChangedObservable.add(function () {
  2980. if (activeField == bValInt.name) {
  2981. updateInt(bValInt, "b");
  2982. }
  2983. });
  2984. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2985. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2986. rValDec.width = 0.95;
  2987. rValDec.height = 0.72;
  2988. rValDec.name = "rDecField";
  2989. rValDec.fontSize = buttonFontSize;
  2990. rValDec.text = currentColor.r.toString();
  2991. rValDec.color = inputTextColor;
  2992. rValDec.background = inputTextBackgroundColor;
  2993. rValDec.onFocusObservable.add(function () {
  2994. activeField = rValDec.name;
  2995. lastVal = rValDec.text;
  2996. editSwatches(false);
  2997. });
  2998. rValDec.onBlurObservable.add(function () {
  2999. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3000. rValDec.text = "0";
  3001. updateFloat(rValDec, "r");
  3002. }
  3003. if (activeField == rValDec.name) {
  3004. activeField = "";
  3005. }
  3006. });
  3007. rValDec.onTextChangedObservable.add(function () {
  3008. if (activeField == rValDec.name) {
  3009. updateFloat(rValDec, "r");
  3010. }
  3011. });
  3012. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3013. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3014. gValDec.width = 0.95;
  3015. gValDec.height = 0.72;
  3016. gValDec.name = "gDecField";
  3017. gValDec.fontSize = buttonFontSize;
  3018. gValDec.text = currentColor.g.toString();
  3019. gValDec.color = inputTextColor;
  3020. gValDec.background = inputTextBackgroundColor;
  3021. gValDec.onFocusObservable.add(function () {
  3022. activeField = gValDec.name;
  3023. lastVal = gValDec.text;
  3024. editSwatches(false);
  3025. });
  3026. gValDec.onBlurObservable.add(function () {
  3027. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3028. gValDec.text = "0";
  3029. updateFloat(gValDec, "g");
  3030. }
  3031. if (activeField == gValDec.name) {
  3032. activeField = "";
  3033. }
  3034. });
  3035. gValDec.onTextChangedObservable.add(function () {
  3036. if (activeField == gValDec.name) {
  3037. updateFloat(gValDec, "g");
  3038. }
  3039. });
  3040. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3041. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3042. bValDec.width = 0.95;
  3043. bValDec.height = 0.72;
  3044. bValDec.name = "bDecField";
  3045. bValDec.fontSize = buttonFontSize;
  3046. bValDec.text = currentColor.b.toString();
  3047. bValDec.color = inputTextColor;
  3048. bValDec.background = inputTextBackgroundColor;
  3049. bValDec.onFocusObservable.add(function () {
  3050. activeField = bValDec.name;
  3051. lastVal = bValDec.text;
  3052. editSwatches(false);
  3053. });
  3054. bValDec.onBlurObservable.add(function () {
  3055. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3056. bValDec.text = "0";
  3057. updateFloat(bValDec, "b");
  3058. }
  3059. if (activeField == bValDec.name) {
  3060. activeField = "";
  3061. }
  3062. });
  3063. bValDec.onTextChangedObservable.add(function () {
  3064. if (activeField == bValDec.name) {
  3065. updateFloat(bValDec, "b");
  3066. }
  3067. });
  3068. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3069. // Hex value input
  3070. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3071. hexValueQuadrant.name = "Hex Value";
  3072. hexValueQuadrant.width = 0.82;
  3073. hexValueQuadrant.addRowDefinition(1.0, false);
  3074. hexValueQuadrant.addColumnDefinition(0.1, false);
  3075. hexValueQuadrant.addColumnDefinition(0.9, false);
  3076. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3077. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3078. labelText.text = "#";
  3079. labelText.color = buttonColor;
  3080. labelText.fontSize = buttonFontSize;
  3081. hexValueQuadrant.addControl(labelText, 0, 0);
  3082. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3083. hexVal.width = 0.96;
  3084. hexVal.height = 0.72;
  3085. hexVal.name = "hexField";
  3086. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3087. hexVal.fontSize = buttonFontSize;
  3088. var minusPound = options.lastColor.split("#");
  3089. hexVal.text = minusPound[1];
  3090. hexVal.color = inputTextColor;
  3091. hexVal.background = inputTextBackgroundColor;
  3092. hexVal.onFocusObservable.add(function () {
  3093. activeField = hexVal.name;
  3094. lastVal = hexVal.text;
  3095. editSwatches(false);
  3096. });
  3097. hexVal.onBlurObservable.add(function () {
  3098. if (hexVal.text.length == 3) {
  3099. var val = hexVal.text.split("");
  3100. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3101. }
  3102. if (hexVal.text == "") {
  3103. hexVal.text = "000000";
  3104. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3105. }
  3106. if (activeField == hexVal.name) {
  3107. activeField = "";
  3108. }
  3109. });
  3110. hexVal.onTextChangedObservable.add(function () {
  3111. var newHexValue = hexVal.text;
  3112. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3113. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3114. hexVal.text = lastVal;
  3115. }
  3116. else {
  3117. if (hexVal.text.length < 6) {
  3118. var leadingZero = 6 - hexVal.text.length;
  3119. for (var i = 0; i < leadingZero; i++) {
  3120. newHexValue = "0" + newHexValue;
  3121. }
  3122. }
  3123. if (hexVal.text.length == 3) {
  3124. var val = hexVal.text.split("");
  3125. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3126. }
  3127. newHexValue = "#" + newHexValue;
  3128. if (activeField == hexVal.name) {
  3129. lastVal = hexVal.text;
  3130. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3131. }
  3132. }
  3133. });
  3134. hexValueQuadrant.addControl(hexVal, 0, 1);
  3135. if (options.savedColors && options.savedColors.length > 0) {
  3136. updateSwatches("", butSave);
  3137. }
  3138. });
  3139. };
  3140. ColorPicker._Epsilon = 0.000001;
  3141. return ColorPicker;
  3142. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3143. /***/ }),
  3144. /***/ "./2D/controls/container.ts":
  3145. /*!**********************************!*\
  3146. !*** ./2D/controls/container.ts ***!
  3147. \**********************************/
  3148. /*! exports provided: Container */
  3149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3150. "use strict";
  3151. __webpack_require__.r(__webpack_exports__);
  3152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3153. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3154. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/tools");
  3155. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3156. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3157. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3158. /**
  3159. * Root class for 2D containers
  3160. * @see http://doc.babylonjs.com/how_to/gui#containers
  3161. */
  3162. var Container = /** @class */ (function (_super) {
  3163. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3164. /**
  3165. * Creates a new Container
  3166. * @param name defines the name of the container
  3167. */
  3168. function Container(name) {
  3169. var _this = _super.call(this, name) || this;
  3170. _this.name = name;
  3171. /** @hidden */
  3172. _this._children = new Array();
  3173. /** @hidden */
  3174. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3175. /** @hidden */
  3176. _this._background = "";
  3177. /** @hidden */
  3178. _this._adaptWidthToChildren = false;
  3179. /** @hidden */
  3180. _this._adaptHeightToChildren = false;
  3181. return _this;
  3182. }
  3183. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3184. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3185. get: function () {
  3186. return this._adaptHeightToChildren;
  3187. },
  3188. set: function (value) {
  3189. if (this._adaptHeightToChildren === value) {
  3190. return;
  3191. }
  3192. this._adaptHeightToChildren = value;
  3193. if (value) {
  3194. this.height = "100%";
  3195. }
  3196. this._markAsDirty();
  3197. },
  3198. enumerable: true,
  3199. configurable: true
  3200. });
  3201. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3202. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3203. get: function () {
  3204. return this._adaptWidthToChildren;
  3205. },
  3206. set: function (value) {
  3207. if (this._adaptWidthToChildren === value) {
  3208. return;
  3209. }
  3210. this._adaptWidthToChildren = value;
  3211. if (value) {
  3212. this.width = "100%";
  3213. }
  3214. this._markAsDirty();
  3215. },
  3216. enumerable: true,
  3217. configurable: true
  3218. });
  3219. Object.defineProperty(Container.prototype, "background", {
  3220. /** Gets or sets background color */
  3221. get: function () {
  3222. return this._background;
  3223. },
  3224. set: function (value) {
  3225. if (this._background === value) {
  3226. return;
  3227. }
  3228. this._background = value;
  3229. this._markAsDirty();
  3230. },
  3231. enumerable: true,
  3232. configurable: true
  3233. });
  3234. Object.defineProperty(Container.prototype, "children", {
  3235. /** Gets the list of children */
  3236. get: function () {
  3237. return this._children;
  3238. },
  3239. enumerable: true,
  3240. configurable: true
  3241. });
  3242. Container.prototype._getTypeName = function () {
  3243. return "Container";
  3244. };
  3245. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3246. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3247. var child = _a[_i];
  3248. child._markMatrixAsDirty();
  3249. }
  3250. };
  3251. /**
  3252. * Gets a child using its name
  3253. * @param name defines the child name to look for
  3254. * @returns the child control if found
  3255. */
  3256. Container.prototype.getChildByName = function (name) {
  3257. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3258. var child = _a[_i];
  3259. if (child.name === name) {
  3260. return child;
  3261. }
  3262. }
  3263. return null;
  3264. };
  3265. /**
  3266. * Gets a child using its type and its name
  3267. * @param name defines the child name to look for
  3268. * @param type defines the child type to look for
  3269. * @returns the child control if found
  3270. */
  3271. Container.prototype.getChildByType = function (name, type) {
  3272. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3273. var child = _a[_i];
  3274. if (child.typeName === type) {
  3275. return child;
  3276. }
  3277. }
  3278. return null;
  3279. };
  3280. /**
  3281. * Search for a specific control in children
  3282. * @param control defines the control to look for
  3283. * @returns true if the control is in child list
  3284. */
  3285. Container.prototype.containsControl = function (control) {
  3286. return this.children.indexOf(control) !== -1;
  3287. };
  3288. /**
  3289. * Adds a new control to the current container
  3290. * @param control defines the control to add
  3291. * @returns the current container
  3292. */
  3293. Container.prototype.addControl = function (control) {
  3294. if (!control) {
  3295. return this;
  3296. }
  3297. var index = this._children.indexOf(control);
  3298. if (index !== -1) {
  3299. return this;
  3300. }
  3301. control._link(this._host);
  3302. control._markAllAsDirty();
  3303. this._reOrderControl(control);
  3304. this._markAsDirty();
  3305. return this;
  3306. };
  3307. /**
  3308. * Removes all controls from the current container
  3309. * @returns the current container
  3310. */
  3311. Container.prototype.clearControls = function () {
  3312. var children = this.children.slice();
  3313. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3314. var child = children_1[_i];
  3315. this.removeControl(child);
  3316. }
  3317. return this;
  3318. };
  3319. /**
  3320. * Removes a control from the current container
  3321. * @param control defines the control to remove
  3322. * @returns the current container
  3323. */
  3324. Container.prototype.removeControl = function (control) {
  3325. var index = this._children.indexOf(control);
  3326. if (index !== -1) {
  3327. this._children.splice(index, 1);
  3328. control.parent = null;
  3329. }
  3330. control.linkWithMesh(null);
  3331. if (this._host) {
  3332. this._host._cleanControlAfterRemoval(control);
  3333. }
  3334. this._markAsDirty();
  3335. return this;
  3336. };
  3337. /** @hidden */
  3338. Container.prototype._reOrderControl = function (control) {
  3339. this.removeControl(control);
  3340. var wasAdded = false;
  3341. for (var index = 0; index < this._children.length; index++) {
  3342. if (this._children[index].zIndex > control.zIndex) {
  3343. this._children.splice(index, 0, control);
  3344. wasAdded = true;
  3345. break;
  3346. }
  3347. }
  3348. if (!wasAdded) {
  3349. this._children.push(control);
  3350. }
  3351. control.parent = this;
  3352. this._markAsDirty();
  3353. };
  3354. /** @hidden */
  3355. Container.prototype._offsetLeft = function (offset) {
  3356. _super.prototype._offsetLeft.call(this, offset);
  3357. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3358. var child = _a[_i];
  3359. child._offsetLeft(offset);
  3360. }
  3361. };
  3362. /** @hidden */
  3363. Container.prototype._offsetTop = function (offset) {
  3364. _super.prototype._offsetTop.call(this, offset);
  3365. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3366. var child = _a[_i];
  3367. child._offsetTop(offset);
  3368. }
  3369. };
  3370. /** @hidden */
  3371. Container.prototype._markAllAsDirty = function () {
  3372. _super.prototype._markAllAsDirty.call(this);
  3373. for (var index = 0; index < this._children.length; index++) {
  3374. this._children[index]._markAllAsDirty();
  3375. }
  3376. };
  3377. /** @hidden */
  3378. Container.prototype._localDraw = function (context) {
  3379. if (this._background) {
  3380. context.save();
  3381. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3382. context.shadowColor = this.shadowColor;
  3383. context.shadowBlur = this.shadowBlur;
  3384. context.shadowOffsetX = this.shadowOffsetX;
  3385. context.shadowOffsetY = this.shadowOffsetY;
  3386. }
  3387. context.fillStyle = this._background;
  3388. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3389. context.restore();
  3390. }
  3391. };
  3392. /** @hidden */
  3393. Container.prototype._link = function (host) {
  3394. _super.prototype._link.call(this, host);
  3395. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3396. var child = _a[_i];
  3397. child._link(host);
  3398. }
  3399. };
  3400. /** @hidden */
  3401. Container.prototype._beforeLayout = function () {
  3402. // Do nothing
  3403. };
  3404. /** @hidden */
  3405. Container.prototype._processMeasures = function (parentMeasure, context) {
  3406. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3407. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3408. this._evaluateClippingState(parentMeasure);
  3409. }
  3410. };
  3411. /** @hidden */
  3412. Container.prototype._layout = function (parentMeasure, context) {
  3413. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3414. return false;
  3415. }
  3416. if (this._isDirty) {
  3417. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3418. }
  3419. var rebuildCount = 0;
  3420. context.save();
  3421. this._applyStates(context);
  3422. this._beforeLayout();
  3423. do {
  3424. var computedWidth = -1;
  3425. var computedHeight = -1;
  3426. this._rebuildLayout = false;
  3427. this._processMeasures(parentMeasure, context);
  3428. if (!this._isClipped) {
  3429. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3430. var child = _a[_i];
  3431. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3432. if (child._layout(this._measureForChildren, context)) {
  3433. if (this.adaptWidthToChildren && child._width.isPixel) {
  3434. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3435. }
  3436. if (this.adaptHeightToChildren && child._height.isPixel) {
  3437. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3438. }
  3439. }
  3440. }
  3441. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3442. if (this.width !== computedWidth + "px") {
  3443. this.width = computedWidth + "px";
  3444. this._rebuildLayout = true;
  3445. }
  3446. }
  3447. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3448. if (this.height !== computedHeight + "px") {
  3449. this.height = computedHeight + "px";
  3450. this._rebuildLayout = true;
  3451. }
  3452. }
  3453. this._postMeasure();
  3454. }
  3455. rebuildCount++;
  3456. } while (this._rebuildLayout && rebuildCount < 3);
  3457. if (rebuildCount >= 3) {
  3458. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3459. }
  3460. context.restore();
  3461. if (this._isDirty) {
  3462. this.invalidateRect();
  3463. this._isDirty = false;
  3464. }
  3465. return true;
  3466. };
  3467. Container.prototype._postMeasure = function () {
  3468. // Do nothing by default
  3469. };
  3470. /** @hidden */
  3471. Container.prototype._draw = function (context, invalidatedRectangle) {
  3472. this._localDraw(context);
  3473. if (this.clipChildren) {
  3474. this._clipForChildren(context);
  3475. }
  3476. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3477. var child = _a[_i];
  3478. // Only redraw parts of the screen that are invalidated
  3479. if (invalidatedRectangle) {
  3480. if (!child._intersectsRect(invalidatedRectangle)) {
  3481. continue;
  3482. }
  3483. }
  3484. child._render(context, invalidatedRectangle);
  3485. }
  3486. };
  3487. /** @hidden */
  3488. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3489. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3490. if (!this.children) {
  3491. return;
  3492. }
  3493. for (var index = 0; index < this.children.length; index++) {
  3494. var item = this.children[index];
  3495. if (!predicate || predicate(item)) {
  3496. results.push(item);
  3497. }
  3498. if (!directDescendantsOnly) {
  3499. item._getDescendants(results, false, predicate);
  3500. }
  3501. }
  3502. };
  3503. /** @hidden */
  3504. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3505. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3506. return false;
  3507. }
  3508. if (!_super.prototype.contains.call(this, x, y)) {
  3509. return false;
  3510. }
  3511. // Checking backwards to pick closest first
  3512. for (var index = this._children.length - 1; index >= 0; index--) {
  3513. var child = this._children[index];
  3514. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3515. if (child.hoverCursor) {
  3516. this._host._changeCursor(child.hoverCursor);
  3517. }
  3518. return true;
  3519. }
  3520. }
  3521. if (!this.isHitTestVisible) {
  3522. return false;
  3523. }
  3524. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3525. };
  3526. /** @hidden */
  3527. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3528. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3529. this._measureForChildren.copyFrom(this._currentMeasure);
  3530. };
  3531. /** Releases associated resources */
  3532. Container.prototype.dispose = function () {
  3533. _super.prototype.dispose.call(this);
  3534. for (var index = this.children.length - 1; index >= 0; index--) {
  3535. this.children[index].dispose();
  3536. }
  3537. };
  3538. return Container;
  3539. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3540. /***/ }),
  3541. /***/ "./2D/controls/control.ts":
  3542. /*!********************************!*\
  3543. !*** ./2D/controls/control.ts ***!
  3544. \********************************/
  3545. /*! exports provided: Control */
  3546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3547. "use strict";
  3548. __webpack_require__.r(__webpack_exports__);
  3549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3550. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  3551. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3552. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3553. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3554. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3555. /**
  3556. * Root class used for all 2D controls
  3557. * @see http://doc.babylonjs.com/how_to/gui#controls
  3558. */
  3559. var Control = /** @class */ (function () {
  3560. // Functions
  3561. /**
  3562. * Creates a new control
  3563. * @param name defines the name of the control
  3564. */
  3565. function Control(
  3566. /** defines the name of the control */
  3567. name) {
  3568. this.name = name;
  3569. this._alpha = 1;
  3570. this._alphaSet = false;
  3571. this._zIndex = 0;
  3572. /** @hidden */
  3573. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3574. this._fontFamily = "Arial";
  3575. this._fontStyle = "";
  3576. this._fontWeight = "";
  3577. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3578. /** @hidden */
  3579. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3580. /** @hidden */
  3581. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3582. this._color = "";
  3583. this._style = null;
  3584. /** @hidden */
  3585. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3586. /** @hidden */
  3587. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3588. /** @hidden */
  3589. this._isDirty = true;
  3590. /** @hidden */
  3591. this._wasDirty = false;
  3592. /** @hidden */
  3593. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3594. /** @hidden */
  3595. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3596. /** @hidden */
  3597. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3598. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3599. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3600. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3601. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3602. /** @hidden */
  3603. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3604. /** @hidden */
  3605. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3606. this._scaleX = 1.0;
  3607. this._scaleY = 1.0;
  3608. this._rotation = 0;
  3609. this._transformCenterX = 0.5;
  3610. this._transformCenterY = 0.5;
  3611. /** @hidden */
  3612. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3613. /** @hidden */
  3614. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3615. /** @hidden */
  3616. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3617. this._isMatrixDirty = true;
  3618. this._isVisible = true;
  3619. this._isHighlighted = false;
  3620. this._fontSet = false;
  3621. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3622. this._downCount = 0;
  3623. this._enterCount = -1;
  3624. this._doNotRender = false;
  3625. this._downPointerIds = {};
  3626. this._isEnabled = true;
  3627. this._disabledColor = "#9a9a9a";
  3628. /** @hidden */
  3629. this._rebuildLayout = false;
  3630. /** @hidden */
  3631. this._isClipped = false;
  3632. /**
  3633. * Gets or sets an object used to store user defined information for the node
  3634. */
  3635. this.metadata = null;
  3636. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3637. this.isHitTestVisible = true;
  3638. /** Gets or sets a boolean indicating if the control can block pointer events */
  3639. this.isPointerBlocker = false;
  3640. /** Gets or sets a boolean indicating if the control can be focusable */
  3641. this.isFocusInvisible = false;
  3642. /**
  3643. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3644. * 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
  3645. */
  3646. this.clipChildren = true;
  3647. /**
  3648. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3649. */
  3650. this.useBitmapCache = false;
  3651. this._shadowOffsetX = 0;
  3652. this._shadowOffsetY = 0;
  3653. this._shadowBlur = 0;
  3654. this._shadowColor = 'black';
  3655. /** Gets or sets the cursor to use when the control is hovered */
  3656. this.hoverCursor = "";
  3657. /** @hidden */
  3658. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3659. /** @hidden */
  3660. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3661. /**
  3662. * An event triggered when the pointer move over the control.
  3663. */
  3664. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3665. /**
  3666. * An event triggered when the pointer move out of the control.
  3667. */
  3668. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3669. /**
  3670. * An event triggered when the pointer taps the control
  3671. */
  3672. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3673. /**
  3674. * An event triggered when pointer up
  3675. */
  3676. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3677. /**
  3678. * An event triggered when a control is clicked on
  3679. */
  3680. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3681. /**
  3682. * An event triggered when pointer enters the control
  3683. */
  3684. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3685. /**
  3686. * An event triggered when the control is marked as dirty
  3687. */
  3688. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3689. /**
  3690. * An event triggered before drawing the control
  3691. */
  3692. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3693. /**
  3694. * An event triggered after the control was drawn
  3695. */
  3696. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3697. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3698. }
  3699. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3700. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3701. get: function () {
  3702. return this._shadowOffsetX;
  3703. },
  3704. set: function (value) {
  3705. if (this._shadowOffsetX === value) {
  3706. return;
  3707. }
  3708. this._shadowOffsetX = value;
  3709. this._markAsDirty();
  3710. },
  3711. enumerable: true,
  3712. configurable: true
  3713. });
  3714. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3715. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3716. get: function () {
  3717. return this._shadowOffsetY;
  3718. },
  3719. set: function (value) {
  3720. if (this._shadowOffsetY === value) {
  3721. return;
  3722. }
  3723. this._shadowOffsetY = value;
  3724. this._markAsDirty();
  3725. },
  3726. enumerable: true,
  3727. configurable: true
  3728. });
  3729. Object.defineProperty(Control.prototype, "shadowBlur", {
  3730. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3731. get: function () {
  3732. return this._shadowBlur;
  3733. },
  3734. set: function (value) {
  3735. if (this._shadowBlur === value) {
  3736. return;
  3737. }
  3738. this._shadowBlur = value;
  3739. this._markAsDirty();
  3740. },
  3741. enumerable: true,
  3742. configurable: true
  3743. });
  3744. Object.defineProperty(Control.prototype, "shadowColor", {
  3745. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3746. get: function () {
  3747. return this._shadowColor;
  3748. },
  3749. set: function (value) {
  3750. if (this._shadowColor === value) {
  3751. return;
  3752. }
  3753. this._shadowColor = value;
  3754. this._markAsDirty();
  3755. },
  3756. enumerable: true,
  3757. configurable: true
  3758. });
  3759. Object.defineProperty(Control.prototype, "typeName", {
  3760. // Properties
  3761. /** Gets the control type name */
  3762. get: function () {
  3763. return this._getTypeName();
  3764. },
  3765. enumerable: true,
  3766. configurable: true
  3767. });
  3768. /**
  3769. * Get the current class name of the control.
  3770. * @returns current class name
  3771. */
  3772. Control.prototype.getClassName = function () {
  3773. return this._getTypeName();
  3774. };
  3775. Object.defineProperty(Control.prototype, "host", {
  3776. /**
  3777. * Get the hosting AdvancedDynamicTexture
  3778. */
  3779. get: function () {
  3780. return this._host;
  3781. },
  3782. enumerable: true,
  3783. configurable: true
  3784. });
  3785. Object.defineProperty(Control.prototype, "fontOffset", {
  3786. /** Gets or set information about font offsets (used to render and align text) */
  3787. get: function () {
  3788. return this._fontOffset;
  3789. },
  3790. set: function (offset) {
  3791. this._fontOffset = offset;
  3792. },
  3793. enumerable: true,
  3794. configurable: true
  3795. });
  3796. Object.defineProperty(Control.prototype, "alpha", {
  3797. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3798. get: function () {
  3799. return this._alpha;
  3800. },
  3801. set: function (value) {
  3802. if (this._alpha === value) {
  3803. return;
  3804. }
  3805. this._alphaSet = true;
  3806. this._alpha = value;
  3807. this._markAsDirty();
  3808. },
  3809. enumerable: true,
  3810. configurable: true
  3811. });
  3812. Object.defineProperty(Control.prototype, "isHighlighted", {
  3813. /**
  3814. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3815. */
  3816. get: function () {
  3817. return this._isHighlighted;
  3818. },
  3819. set: function (value) {
  3820. if (this._isHighlighted === value) {
  3821. return;
  3822. }
  3823. this._isHighlighted = value;
  3824. this._markAsDirty();
  3825. },
  3826. enumerable: true,
  3827. configurable: true
  3828. });
  3829. Object.defineProperty(Control.prototype, "scaleX", {
  3830. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3831. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3832. */
  3833. get: function () {
  3834. return this._scaleX;
  3835. },
  3836. set: function (value) {
  3837. if (this._scaleX === value) {
  3838. return;
  3839. }
  3840. this._scaleX = value;
  3841. this._markAsDirty();
  3842. this._markMatrixAsDirty();
  3843. },
  3844. enumerable: true,
  3845. configurable: true
  3846. });
  3847. Object.defineProperty(Control.prototype, "scaleY", {
  3848. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3849. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3850. */
  3851. get: function () {
  3852. return this._scaleY;
  3853. },
  3854. set: function (value) {
  3855. if (this._scaleY === value) {
  3856. return;
  3857. }
  3858. this._scaleY = value;
  3859. this._markAsDirty();
  3860. this._markMatrixAsDirty();
  3861. },
  3862. enumerable: true,
  3863. configurable: true
  3864. });
  3865. Object.defineProperty(Control.prototype, "rotation", {
  3866. /** Gets or sets the rotation angle (0 by default)
  3867. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3868. */
  3869. get: function () {
  3870. return this._rotation;
  3871. },
  3872. set: function (value) {
  3873. if (this._rotation === value) {
  3874. return;
  3875. }
  3876. this._rotation = value;
  3877. this._markAsDirty();
  3878. this._markMatrixAsDirty();
  3879. },
  3880. enumerable: true,
  3881. configurable: true
  3882. });
  3883. Object.defineProperty(Control.prototype, "transformCenterY", {
  3884. /** Gets or sets the transformation center on Y axis (0 by default)
  3885. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3886. */
  3887. get: function () {
  3888. return this._transformCenterY;
  3889. },
  3890. set: function (value) {
  3891. if (this._transformCenterY === value) {
  3892. return;
  3893. }
  3894. this._transformCenterY = value;
  3895. this._markAsDirty();
  3896. this._markMatrixAsDirty();
  3897. },
  3898. enumerable: true,
  3899. configurable: true
  3900. });
  3901. Object.defineProperty(Control.prototype, "transformCenterX", {
  3902. /** Gets or sets the transformation center on X axis (0 by default)
  3903. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3904. */
  3905. get: function () {
  3906. return this._transformCenterX;
  3907. },
  3908. set: function (value) {
  3909. if (this._transformCenterX === value) {
  3910. return;
  3911. }
  3912. this._transformCenterX = value;
  3913. this._markAsDirty();
  3914. this._markMatrixAsDirty();
  3915. },
  3916. enumerable: true,
  3917. configurable: true
  3918. });
  3919. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3920. /**
  3921. * Gets or sets the horizontal alignment
  3922. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3923. */
  3924. get: function () {
  3925. return this._horizontalAlignment;
  3926. },
  3927. set: function (value) {
  3928. if (this._horizontalAlignment === value) {
  3929. return;
  3930. }
  3931. this._horizontalAlignment = value;
  3932. this._markAsDirty();
  3933. },
  3934. enumerable: true,
  3935. configurable: true
  3936. });
  3937. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3938. /**
  3939. * Gets or sets the vertical alignment
  3940. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3941. */
  3942. get: function () {
  3943. return this._verticalAlignment;
  3944. },
  3945. set: function (value) {
  3946. if (this._verticalAlignment === value) {
  3947. return;
  3948. }
  3949. this._verticalAlignment = value;
  3950. this._markAsDirty();
  3951. },
  3952. enumerable: true,
  3953. configurable: true
  3954. });
  3955. Object.defineProperty(Control.prototype, "width", {
  3956. /**
  3957. * Gets or sets control width
  3958. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3959. */
  3960. get: function () {
  3961. return this._width.toString(this._host);
  3962. },
  3963. set: function (value) {
  3964. if (this._width.toString(this._host) === value) {
  3965. return;
  3966. }
  3967. if (this._width.fromString(value)) {
  3968. this._markAsDirty();
  3969. }
  3970. },
  3971. enumerable: true,
  3972. configurable: true
  3973. });
  3974. Object.defineProperty(Control.prototype, "widthInPixels", {
  3975. /**
  3976. * Gets control width in pixel
  3977. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3978. */
  3979. get: function () {
  3980. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3981. },
  3982. enumerable: true,
  3983. configurable: true
  3984. });
  3985. Object.defineProperty(Control.prototype, "height", {
  3986. /**
  3987. * Gets or sets control height
  3988. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3989. */
  3990. get: function () {
  3991. return this._height.toString(this._host);
  3992. },
  3993. set: function (value) {
  3994. if (this._height.toString(this._host) === value) {
  3995. return;
  3996. }
  3997. if (this._height.fromString(value)) {
  3998. this._markAsDirty();
  3999. }
  4000. },
  4001. enumerable: true,
  4002. configurable: true
  4003. });
  4004. Object.defineProperty(Control.prototype, "heightInPixels", {
  4005. /**
  4006. * Gets control height in pixel
  4007. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4008. */
  4009. get: function () {
  4010. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4011. },
  4012. enumerable: true,
  4013. configurable: true
  4014. });
  4015. Object.defineProperty(Control.prototype, "fontFamily", {
  4016. /** Gets or set font family */
  4017. get: function () {
  4018. if (!this._fontSet) {
  4019. return "";
  4020. }
  4021. return this._fontFamily;
  4022. },
  4023. set: function (value) {
  4024. if (this._fontFamily === value) {
  4025. return;
  4026. }
  4027. this._fontFamily = value;
  4028. this._resetFontCache();
  4029. },
  4030. enumerable: true,
  4031. configurable: true
  4032. });
  4033. Object.defineProperty(Control.prototype, "fontStyle", {
  4034. /** Gets or sets font style */
  4035. get: function () {
  4036. return this._fontStyle;
  4037. },
  4038. set: function (value) {
  4039. if (this._fontStyle === value) {
  4040. return;
  4041. }
  4042. this._fontStyle = value;
  4043. this._resetFontCache();
  4044. },
  4045. enumerable: true,
  4046. configurable: true
  4047. });
  4048. Object.defineProperty(Control.prototype, "fontWeight", {
  4049. /** Gets or sets font weight */
  4050. get: function () {
  4051. return this._fontWeight;
  4052. },
  4053. set: function (value) {
  4054. if (this._fontWeight === value) {
  4055. return;
  4056. }
  4057. this._fontWeight = value;
  4058. this._resetFontCache();
  4059. },
  4060. enumerable: true,
  4061. configurable: true
  4062. });
  4063. Object.defineProperty(Control.prototype, "style", {
  4064. /**
  4065. * Gets or sets style
  4066. * @see http://doc.babylonjs.com/how_to/gui#styles
  4067. */
  4068. get: function () {
  4069. return this._style;
  4070. },
  4071. set: function (value) {
  4072. var _this = this;
  4073. if (this._style) {
  4074. this._style.onChangedObservable.remove(this._styleObserver);
  4075. this._styleObserver = null;
  4076. }
  4077. this._style = value;
  4078. if (this._style) {
  4079. this._styleObserver = this._style.onChangedObservable.add(function () {
  4080. _this._markAsDirty();
  4081. _this._resetFontCache();
  4082. });
  4083. }
  4084. this._markAsDirty();
  4085. this._resetFontCache();
  4086. },
  4087. enumerable: true,
  4088. configurable: true
  4089. });
  4090. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4091. /** @hidden */
  4092. get: function () {
  4093. return this._fontSize.isPercentage;
  4094. },
  4095. enumerable: true,
  4096. configurable: true
  4097. });
  4098. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4099. /** Gets font size in pixels */
  4100. get: function () {
  4101. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4102. if (fontSizeToUse.isPixel) {
  4103. return fontSizeToUse.getValue(this._host);
  4104. }
  4105. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4106. },
  4107. enumerable: true,
  4108. configurable: true
  4109. });
  4110. Object.defineProperty(Control.prototype, "fontSize", {
  4111. /** Gets or sets font size */
  4112. get: function () {
  4113. return this._fontSize.toString(this._host);
  4114. },
  4115. set: function (value) {
  4116. if (this._fontSize.toString(this._host) === value) {
  4117. return;
  4118. }
  4119. if (this._fontSize.fromString(value)) {
  4120. this._markAsDirty();
  4121. this._resetFontCache();
  4122. }
  4123. },
  4124. enumerable: true,
  4125. configurable: true
  4126. });
  4127. Object.defineProperty(Control.prototype, "color", {
  4128. /** Gets or sets foreground color */
  4129. get: function () {
  4130. return this._color;
  4131. },
  4132. set: function (value) {
  4133. if (this._color === value) {
  4134. return;
  4135. }
  4136. this._color = value;
  4137. this._markAsDirty();
  4138. },
  4139. enumerable: true,
  4140. configurable: true
  4141. });
  4142. Object.defineProperty(Control.prototype, "zIndex", {
  4143. /** Gets or sets z index which is used to reorder controls on the z axis */
  4144. get: function () {
  4145. return this._zIndex;
  4146. },
  4147. set: function (value) {
  4148. if (this.zIndex === value) {
  4149. return;
  4150. }
  4151. this._zIndex = value;
  4152. if (this.parent) {
  4153. this.parent._reOrderControl(this);
  4154. }
  4155. },
  4156. enumerable: true,
  4157. configurable: true
  4158. });
  4159. Object.defineProperty(Control.prototype, "notRenderable", {
  4160. /** Gets or sets a boolean indicating if the control can be rendered */
  4161. get: function () {
  4162. return this._doNotRender;
  4163. },
  4164. set: function (value) {
  4165. if (this._doNotRender === value) {
  4166. return;
  4167. }
  4168. this._doNotRender = value;
  4169. this._markAsDirty();
  4170. },
  4171. enumerable: true,
  4172. configurable: true
  4173. });
  4174. Object.defineProperty(Control.prototype, "isVisible", {
  4175. /** Gets or sets a boolean indicating if the control is visible */
  4176. get: function () {
  4177. return this._isVisible;
  4178. },
  4179. set: function (value) {
  4180. if (this._isVisible === value) {
  4181. return;
  4182. }
  4183. this._isVisible = value;
  4184. this._markAsDirty(true);
  4185. },
  4186. enumerable: true,
  4187. configurable: true
  4188. });
  4189. Object.defineProperty(Control.prototype, "isDirty", {
  4190. /** Gets a boolean indicating that the control needs to update its rendering */
  4191. get: function () {
  4192. return this._isDirty;
  4193. },
  4194. enumerable: true,
  4195. configurable: true
  4196. });
  4197. Object.defineProperty(Control.prototype, "linkedMesh", {
  4198. /**
  4199. * Gets the current linked mesh (or null if none)
  4200. */
  4201. get: function () {
  4202. return this._linkedMesh;
  4203. },
  4204. enumerable: true,
  4205. configurable: true
  4206. });
  4207. Object.defineProperty(Control.prototype, "paddingLeft", {
  4208. /**
  4209. * Gets or sets a value indicating the padding to use on the left of the control
  4210. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4211. */
  4212. get: function () {
  4213. return this._paddingLeft.toString(this._host);
  4214. },
  4215. set: function (value) {
  4216. if (this._paddingLeft.fromString(value)) {
  4217. this._markAsDirty();
  4218. }
  4219. },
  4220. enumerable: true,
  4221. configurable: true
  4222. });
  4223. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4224. /**
  4225. * Gets a value indicating the padding in pixels to use on the left of the control
  4226. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4227. */
  4228. get: function () {
  4229. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4230. },
  4231. enumerable: true,
  4232. configurable: true
  4233. });
  4234. Object.defineProperty(Control.prototype, "paddingRight", {
  4235. /**
  4236. * Gets or sets a value indicating the padding to use on the right of the control
  4237. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4238. */
  4239. get: function () {
  4240. return this._paddingRight.toString(this._host);
  4241. },
  4242. set: function (value) {
  4243. if (this._paddingRight.fromString(value)) {
  4244. this._markAsDirty();
  4245. }
  4246. },
  4247. enumerable: true,
  4248. configurable: true
  4249. });
  4250. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4251. /**
  4252. * Gets a value indicating the padding in pixels to use on the right of the control
  4253. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4254. */
  4255. get: function () {
  4256. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4257. },
  4258. enumerable: true,
  4259. configurable: true
  4260. });
  4261. Object.defineProperty(Control.prototype, "paddingTop", {
  4262. /**
  4263. * Gets or sets a value indicating the padding to use on the top of the control
  4264. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4265. */
  4266. get: function () {
  4267. return this._paddingTop.toString(this._host);
  4268. },
  4269. set: function (value) {
  4270. if (this._paddingTop.fromString(value)) {
  4271. this._markAsDirty();
  4272. }
  4273. },
  4274. enumerable: true,
  4275. configurable: true
  4276. });
  4277. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4278. /**
  4279. * Gets a value indicating the padding in pixels to use on the top of the control
  4280. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4281. */
  4282. get: function () {
  4283. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4284. },
  4285. enumerable: true,
  4286. configurable: true
  4287. });
  4288. Object.defineProperty(Control.prototype, "paddingBottom", {
  4289. /**
  4290. * Gets or sets a value indicating the padding to use on the bottom of the control
  4291. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4292. */
  4293. get: function () {
  4294. return this._paddingBottom.toString(this._host);
  4295. },
  4296. set: function (value) {
  4297. if (this._paddingBottom.fromString(value)) {
  4298. this._markAsDirty();
  4299. }
  4300. },
  4301. enumerable: true,
  4302. configurable: true
  4303. });
  4304. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4305. /**
  4306. * Gets a value indicating the padding in pixels to use on the bottom of the control
  4307. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4308. */
  4309. get: function () {
  4310. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4311. },
  4312. enumerable: true,
  4313. configurable: true
  4314. });
  4315. Object.defineProperty(Control.prototype, "left", {
  4316. /**
  4317. * Gets or sets a value indicating the left coordinate of the control
  4318. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4319. */
  4320. get: function () {
  4321. return this._left.toString(this._host);
  4322. },
  4323. set: function (value) {
  4324. if (this._left.fromString(value)) {
  4325. this._markAsDirty();
  4326. }
  4327. },
  4328. enumerable: true,
  4329. configurable: true
  4330. });
  4331. Object.defineProperty(Control.prototype, "leftInPixels", {
  4332. /**
  4333. * Gets a value indicating the left coordinate in pixels of the control
  4334. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4335. */
  4336. get: function () {
  4337. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4338. },
  4339. enumerable: true,
  4340. configurable: true
  4341. });
  4342. Object.defineProperty(Control.prototype, "top", {
  4343. /**
  4344. * Gets or sets a value indicating the top coordinate of the control
  4345. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4346. */
  4347. get: function () {
  4348. return this._top.toString(this._host);
  4349. },
  4350. set: function (value) {
  4351. if (this._top.fromString(value)) {
  4352. this._markAsDirty();
  4353. }
  4354. },
  4355. enumerable: true,
  4356. configurable: true
  4357. });
  4358. Object.defineProperty(Control.prototype, "topInPixels", {
  4359. /**
  4360. * Gets a value indicating the top coordinate in pixels of the control
  4361. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4362. */
  4363. get: function () {
  4364. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4365. },
  4366. enumerable: true,
  4367. configurable: true
  4368. });
  4369. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4370. /**
  4371. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4372. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4373. */
  4374. get: function () {
  4375. return this._linkOffsetX.toString(this._host);
  4376. },
  4377. set: function (value) {
  4378. if (this._linkOffsetX.fromString(value)) {
  4379. this._markAsDirty();
  4380. }
  4381. },
  4382. enumerable: true,
  4383. configurable: true
  4384. });
  4385. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4386. /**
  4387. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  4388. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4389. */
  4390. get: function () {
  4391. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4392. },
  4393. enumerable: true,
  4394. configurable: true
  4395. });
  4396. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4397. /**
  4398. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4399. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4400. */
  4401. get: function () {
  4402. return this._linkOffsetY.toString(this._host);
  4403. },
  4404. set: function (value) {
  4405. if (this._linkOffsetY.fromString(value)) {
  4406. this._markAsDirty();
  4407. }
  4408. },
  4409. enumerable: true,
  4410. configurable: true
  4411. });
  4412. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4413. /**
  4414. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  4415. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4416. */
  4417. get: function () {
  4418. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4419. },
  4420. enumerable: true,
  4421. configurable: true
  4422. });
  4423. Object.defineProperty(Control.prototype, "centerX", {
  4424. /** Gets the center coordinate on X axis */
  4425. get: function () {
  4426. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4427. },
  4428. enumerable: true,
  4429. configurable: true
  4430. });
  4431. Object.defineProperty(Control.prototype, "centerY", {
  4432. /** Gets the center coordinate on Y axis */
  4433. get: function () {
  4434. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4435. },
  4436. enumerable: true,
  4437. configurable: true
  4438. });
  4439. Object.defineProperty(Control.prototype, "isEnabled", {
  4440. /** Gets or sets if control is Enabled*/
  4441. get: function () {
  4442. return this._isEnabled;
  4443. },
  4444. set: function (value) {
  4445. if (this._isEnabled === value) {
  4446. return;
  4447. }
  4448. this._isEnabled = value;
  4449. this._markAsDirty();
  4450. },
  4451. enumerable: true,
  4452. configurable: true
  4453. });
  4454. Object.defineProperty(Control.prototype, "disabledColor", {
  4455. /** Gets or sets background color of control if it's disabled*/
  4456. get: function () {
  4457. return this._disabledColor;
  4458. },
  4459. set: function (value) {
  4460. if (this._disabledColor === value) {
  4461. return;
  4462. }
  4463. this._disabledColor = value;
  4464. this._markAsDirty();
  4465. },
  4466. enumerable: true,
  4467. configurable: true
  4468. });
  4469. /** @hidden */
  4470. Control.prototype._getTypeName = function () {
  4471. return "Control";
  4472. };
  4473. /**
  4474. * Gets the first ascendant in the hierarchy of the given type
  4475. * @param className defines the required type
  4476. * @returns the ascendant or null if not found
  4477. */
  4478. Control.prototype.getAscendantOfClass = function (className) {
  4479. if (!this.parent) {
  4480. return null;
  4481. }
  4482. if (this.parent.getClassName() === className) {
  4483. return this.parent;
  4484. }
  4485. return this.parent.getAscendantOfClass(className);
  4486. };
  4487. /** @hidden */
  4488. Control.prototype._resetFontCache = function () {
  4489. this._fontSet = true;
  4490. this._markAsDirty();
  4491. };
  4492. /**
  4493. * Determines if a container is an ascendant of the current control
  4494. * @param container defines the container to look for
  4495. * @returns true if the container is one of the ascendant of the control
  4496. */
  4497. Control.prototype.isAscendant = function (container) {
  4498. if (!this.parent) {
  4499. return false;
  4500. }
  4501. if (this.parent === container) {
  4502. return true;
  4503. }
  4504. return this.parent.isAscendant(container);
  4505. };
  4506. /**
  4507. * Gets coordinates in local control space
  4508. * @param globalCoordinates defines the coordinates to transform
  4509. * @returns the new coordinates in local space
  4510. */
  4511. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4512. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4513. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4514. return result;
  4515. };
  4516. /**
  4517. * Gets coordinates in local control space
  4518. * @param globalCoordinates defines the coordinates to transform
  4519. * @param result defines the target vector2 where to store the result
  4520. * @returns the current control
  4521. */
  4522. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4523. result.x = globalCoordinates.x - this._currentMeasure.left;
  4524. result.y = globalCoordinates.y - this._currentMeasure.top;
  4525. return this;
  4526. };
  4527. /**
  4528. * Gets coordinates in parent local control space
  4529. * @param globalCoordinates defines the coordinates to transform
  4530. * @returns the new coordinates in parent local space
  4531. */
  4532. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4533. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4534. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4535. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4536. return result;
  4537. };
  4538. /**
  4539. * Move the current control to a vector3 position projected onto the screen.
  4540. * @param position defines the target position
  4541. * @param scene defines the hosting scene
  4542. */
  4543. Control.prototype.moveToVector3 = function (position, scene) {
  4544. if (!this._host || this.parent !== this._host._rootContainer) {
  4545. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4546. return;
  4547. }
  4548. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4549. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4550. var globalViewport = this._host._getGlobalViewport(scene);
  4551. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4552. this._moveToProjectedPosition(projectedPosition);
  4553. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4554. this.notRenderable = true;
  4555. return;
  4556. }
  4557. this.notRenderable = false;
  4558. };
  4559. /** @hidden */
  4560. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4561. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4562. // Do nothing by default
  4563. };
  4564. /**
  4565. * Will return all controls that have this control as ascendant
  4566. * @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
  4567. * @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
  4568. * @return all child controls
  4569. */
  4570. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4571. var results = new Array();
  4572. this._getDescendants(results, directDescendantsOnly, predicate);
  4573. return results;
  4574. };
  4575. /**
  4576. * Link current control with a target mesh
  4577. * @param mesh defines the mesh to link with
  4578. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4579. */
  4580. Control.prototype.linkWithMesh = function (mesh) {
  4581. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4582. if (mesh) {
  4583. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4584. }
  4585. return;
  4586. }
  4587. var index = this._host._linkedControls.indexOf(this);
  4588. if (index !== -1) {
  4589. this._linkedMesh = mesh;
  4590. if (!mesh) {
  4591. this._host._linkedControls.splice(index, 1);
  4592. }
  4593. return;
  4594. }
  4595. else if (!mesh) {
  4596. return;
  4597. }
  4598. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4599. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4600. this._linkedMesh = mesh;
  4601. this._host._linkedControls.push(this);
  4602. };
  4603. /** @hidden */
  4604. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4605. var oldLeft = this._left.getValue(this._host);
  4606. var oldTop = this._top.getValue(this._host);
  4607. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4608. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4609. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4610. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4611. newLeft = oldLeft;
  4612. }
  4613. if (Math.abs(newTop - oldTop) < 0.5) {
  4614. newTop = oldTop;
  4615. }
  4616. }
  4617. this.left = newLeft + "px";
  4618. this.top = newTop + "px";
  4619. this._left.ignoreAdaptiveScaling = true;
  4620. this._top.ignoreAdaptiveScaling = true;
  4621. this._markAsDirty();
  4622. };
  4623. /** @hidden */
  4624. Control.prototype._offsetLeft = function (offset) {
  4625. this._isDirty = true;
  4626. this._currentMeasure.left += offset;
  4627. };
  4628. /** @hidden */
  4629. Control.prototype._offsetTop = function (offset) {
  4630. this._isDirty = true;
  4631. this._currentMeasure.top += offset;
  4632. };
  4633. /** @hidden */
  4634. Control.prototype._markMatrixAsDirty = function () {
  4635. this._isMatrixDirty = true;
  4636. this._flagDescendantsAsMatrixDirty();
  4637. };
  4638. /** @hidden */
  4639. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4640. // No child
  4641. };
  4642. /** @hidden */
  4643. Control.prototype._intersectsRect = function (rect) {
  4644. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4645. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4646. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4647. return false;
  4648. }
  4649. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4650. return false;
  4651. }
  4652. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4653. return false;
  4654. }
  4655. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4656. return false;
  4657. }
  4658. return true;
  4659. };
  4660. /** @hidden */
  4661. Control.prototype.invalidateRect = function () {
  4662. this._transform();
  4663. if (this.host && this.host.useInvalidateRectOptimization) {
  4664. // Rotate by transform to get the measure transformed to global space
  4665. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4666. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4667. // the previous measure is used to properly clear a control that is scaled down
  4668. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4669. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4670. // Expand rect based on shadows
  4671. var shadowOffsetX = this.shadowOffsetX;
  4672. var shadowOffsetY = this.shadowOffsetY;
  4673. var shadowBlur = this.shadowBlur;
  4674. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4675. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4676. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4677. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4678. 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));
  4679. }
  4680. else {
  4681. 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));
  4682. }
  4683. }
  4684. };
  4685. /** @hidden */
  4686. Control.prototype._markAsDirty = function (force) {
  4687. if (force === void 0) { force = false; }
  4688. if (!this._isVisible && !force) {
  4689. return;
  4690. }
  4691. this._isDirty = true;
  4692. // Redraw only this rectangle
  4693. if (this._host) {
  4694. this._host.markAsDirty();
  4695. }
  4696. };
  4697. /** @hidden */
  4698. Control.prototype._markAllAsDirty = function () {
  4699. this._markAsDirty();
  4700. if (this._font) {
  4701. this._prepareFont();
  4702. }
  4703. };
  4704. /** @hidden */
  4705. Control.prototype._link = function (host) {
  4706. this._host = host;
  4707. if (this._host) {
  4708. this.uniqueId = this._host.getScene().getUniqueId();
  4709. }
  4710. };
  4711. /** @hidden */
  4712. Control.prototype._transform = function (context) {
  4713. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4714. return;
  4715. }
  4716. // postTranslate
  4717. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4718. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4719. if (context) {
  4720. context.translate(offsetX, offsetY);
  4721. // rotate
  4722. context.rotate(this._rotation);
  4723. // scale
  4724. context.scale(this._scaleX, this._scaleY);
  4725. // preTranslate
  4726. context.translate(-offsetX, -offsetY);
  4727. }
  4728. // Need to update matrices?
  4729. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4730. this._cachedOffsetX = offsetX;
  4731. this._cachedOffsetY = offsetY;
  4732. this._isMatrixDirty = false;
  4733. this._flagDescendantsAsMatrixDirty();
  4734. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4735. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4736. }
  4737. };
  4738. /** @hidden */
  4739. Control.prototype._renderHighlight = function (context) {
  4740. if (!this.isHighlighted) {
  4741. return;
  4742. }
  4743. context.save();
  4744. context.strokeStyle = "#4affff";
  4745. context.lineWidth = 2;
  4746. this._renderHighlightSpecific(context);
  4747. context.restore();
  4748. };
  4749. /** @hidden */
  4750. Control.prototype._renderHighlightSpecific = function (context) {
  4751. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4752. };
  4753. /** @hidden */
  4754. Control.prototype._applyStates = function (context) {
  4755. if (this._isFontSizeInPercentage) {
  4756. this._fontSet = true;
  4757. }
  4758. if (this._fontSet) {
  4759. this._prepareFont();
  4760. this._fontSet = false;
  4761. }
  4762. if (this._font) {
  4763. context.font = this._font;
  4764. }
  4765. if (this._color) {
  4766. context.fillStyle = this._color;
  4767. }
  4768. if (Control.AllowAlphaInheritance) {
  4769. context.globalAlpha *= this._alpha;
  4770. }
  4771. else if (this._alphaSet) {
  4772. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4773. }
  4774. };
  4775. /** @hidden */
  4776. Control.prototype._layout = function (parentMeasure, context) {
  4777. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4778. return false;
  4779. }
  4780. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4781. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4782. context.save();
  4783. this._applyStates(context);
  4784. var rebuildCount = 0;
  4785. do {
  4786. this._rebuildLayout = false;
  4787. this._processMeasures(parentMeasure, context);
  4788. rebuildCount++;
  4789. } while (this._rebuildLayout && rebuildCount < 3);
  4790. if (rebuildCount >= 3) {
  4791. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4792. }
  4793. context.restore();
  4794. this.invalidateRect();
  4795. this._evaluateClippingState(parentMeasure);
  4796. }
  4797. this._wasDirty = this._isDirty;
  4798. this._isDirty = false;
  4799. return true;
  4800. };
  4801. /** @hidden */
  4802. Control.prototype._processMeasures = function (parentMeasure, context) {
  4803. this._currentMeasure.copyFrom(parentMeasure);
  4804. // Let children take some pre-measurement actions
  4805. this._preMeasure(parentMeasure, context);
  4806. this._measure();
  4807. this._computeAlignment(parentMeasure, context);
  4808. // Convert to int values
  4809. this._currentMeasure.left = this._currentMeasure.left | 0;
  4810. this._currentMeasure.top = this._currentMeasure.top | 0;
  4811. this._currentMeasure.width = this._currentMeasure.width | 0;
  4812. this._currentMeasure.height = this._currentMeasure.height | 0;
  4813. // Let children add more features
  4814. this._additionalProcessing(parentMeasure, context);
  4815. this._cachedParentMeasure.copyFrom(parentMeasure);
  4816. if (this.onDirtyObservable.hasObservers()) {
  4817. this.onDirtyObservable.notifyObservers(this);
  4818. }
  4819. };
  4820. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4821. if (this.parent && this.parent.clipChildren) {
  4822. // Early clip
  4823. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4824. this._isClipped = true;
  4825. return;
  4826. }
  4827. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4828. this._isClipped = true;
  4829. return;
  4830. }
  4831. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4832. this._isClipped = true;
  4833. return;
  4834. }
  4835. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4836. this._isClipped = true;
  4837. return;
  4838. }
  4839. }
  4840. this._isClipped = false;
  4841. };
  4842. /** @hidden */
  4843. Control.prototype._measure = function () {
  4844. // Width / Height
  4845. if (this._width.isPixel) {
  4846. this._currentMeasure.width = this._width.getValue(this._host);
  4847. }
  4848. else {
  4849. this._currentMeasure.width *= this._width.getValue(this._host);
  4850. }
  4851. if (this._height.isPixel) {
  4852. this._currentMeasure.height = this._height.getValue(this._host);
  4853. }
  4854. else {
  4855. this._currentMeasure.height *= this._height.getValue(this._host);
  4856. }
  4857. };
  4858. /** @hidden */
  4859. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4860. var width = this._currentMeasure.width;
  4861. var height = this._currentMeasure.height;
  4862. var parentWidth = parentMeasure.width;
  4863. var parentHeight = parentMeasure.height;
  4864. // Left / top
  4865. var x = 0;
  4866. var y = 0;
  4867. switch (this.horizontalAlignment) {
  4868. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4869. x = 0;
  4870. break;
  4871. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4872. x = parentWidth - width;
  4873. break;
  4874. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4875. x = (parentWidth - width) / 2;
  4876. break;
  4877. }
  4878. switch (this.verticalAlignment) {
  4879. case Control.VERTICAL_ALIGNMENT_TOP:
  4880. y = 0;
  4881. break;
  4882. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4883. y = parentHeight - height;
  4884. break;
  4885. case Control.VERTICAL_ALIGNMENT_CENTER:
  4886. y = (parentHeight - height) / 2;
  4887. break;
  4888. }
  4889. if (this._paddingLeft.isPixel) {
  4890. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4891. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4892. }
  4893. else {
  4894. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4895. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4896. }
  4897. if (this._paddingRight.isPixel) {
  4898. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4899. }
  4900. else {
  4901. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4902. }
  4903. if (this._paddingTop.isPixel) {
  4904. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4905. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4906. }
  4907. else {
  4908. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4909. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4910. }
  4911. if (this._paddingBottom.isPixel) {
  4912. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4913. }
  4914. else {
  4915. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4916. }
  4917. if (this._left.isPixel) {
  4918. this._currentMeasure.left += this._left.getValue(this._host);
  4919. }
  4920. else {
  4921. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4922. }
  4923. if (this._top.isPixel) {
  4924. this._currentMeasure.top += this._top.getValue(this._host);
  4925. }
  4926. else {
  4927. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4928. }
  4929. this._currentMeasure.left += x;
  4930. this._currentMeasure.top += y;
  4931. };
  4932. /** @hidden */
  4933. Control.prototype._preMeasure = function (parentMeasure, context) {
  4934. // Do nothing
  4935. };
  4936. /** @hidden */
  4937. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4938. // Do nothing
  4939. };
  4940. /** @hidden */
  4941. Control.prototype._clipForChildren = function (context) {
  4942. // DO nothing
  4943. };
  4944. Control.prototype._clip = function (context, invalidatedRectangle) {
  4945. context.beginPath();
  4946. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4947. if (invalidatedRectangle) {
  4948. // Rotate the invalidated rect into the control's space
  4949. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4950. // Get the intersection of the rect in context space and the current context
  4951. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4952. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4953. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4954. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4955. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4956. Control._ClipMeasure.copyFrom(intersection);
  4957. }
  4958. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4959. var shadowOffsetX = this.shadowOffsetX;
  4960. var shadowOffsetY = this.shadowOffsetY;
  4961. var shadowBlur = this.shadowBlur;
  4962. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4963. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4964. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4965. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4966. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  4967. }
  4968. else {
  4969. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  4970. }
  4971. context.clip();
  4972. };
  4973. /** @hidden */
  4974. Control.prototype._render = function (context, invalidatedRectangle) {
  4975. if (!this.isVisible || this.notRenderable || this._isClipped) {
  4976. this._isDirty = false;
  4977. return false;
  4978. }
  4979. context.save();
  4980. this._applyStates(context);
  4981. // Transform
  4982. this._transform(context);
  4983. // Clip
  4984. // if (this.clipChildren) {
  4985. this._clip(context, invalidatedRectangle);
  4986. // }
  4987. if (this.onBeforeDrawObservable.hasObservers()) {
  4988. this.onBeforeDrawObservable.notifyObservers(this);
  4989. }
  4990. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  4991. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  4992. }
  4993. else {
  4994. this._draw(context, invalidatedRectangle);
  4995. }
  4996. if (this.useBitmapCache && this._wasDirty) {
  4997. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4998. }
  4999. this._renderHighlight(context);
  5000. if (this.onAfterDrawObservable.hasObservers()) {
  5001. this.onAfterDrawObservable.notifyObservers(this);
  5002. }
  5003. context.restore();
  5004. return true;
  5005. };
  5006. /** @hidden */
  5007. Control.prototype._draw = function (context, invalidatedRectangle) {
  5008. // Do nothing
  5009. };
  5010. /**
  5011. * Tests if a given coordinates belong to the current control
  5012. * @param x defines x coordinate to test
  5013. * @param y defines y coordinate to test
  5014. * @returns true if the coordinates are inside the control
  5015. */
  5016. Control.prototype.contains = function (x, y) {
  5017. // Invert transform
  5018. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5019. x = this._transformedPosition.x;
  5020. y = this._transformedPosition.y;
  5021. // Check
  5022. if (x < this._currentMeasure.left) {
  5023. return false;
  5024. }
  5025. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5026. return false;
  5027. }
  5028. if (y < this._currentMeasure.top) {
  5029. return false;
  5030. }
  5031. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5032. return false;
  5033. }
  5034. if (this.isPointerBlocker) {
  5035. this._host._shouldBlockPointer = true;
  5036. }
  5037. return true;
  5038. };
  5039. /** @hidden */
  5040. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5041. if (!this._isEnabled) {
  5042. return false;
  5043. }
  5044. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5045. return false;
  5046. }
  5047. if (!this.contains(x, y)) {
  5048. return false;
  5049. }
  5050. this._processObservables(type, x, y, pointerId, buttonIndex);
  5051. return true;
  5052. };
  5053. /** @hidden */
  5054. Control.prototype._onPointerMove = function (target, coordinates) {
  5055. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5056. if (canNotify && this.parent != null) {
  5057. this.parent._onPointerMove(target, coordinates);
  5058. }
  5059. };
  5060. /** @hidden */
  5061. Control.prototype._onPointerEnter = function (target) {
  5062. if (!this._isEnabled) {
  5063. return false;
  5064. }
  5065. if (this._enterCount > 0) {
  5066. return false;
  5067. }
  5068. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5069. this._enterCount = 0;
  5070. }
  5071. this._enterCount++;
  5072. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5073. if (canNotify && this.parent != null) {
  5074. this.parent._onPointerEnter(target);
  5075. }
  5076. return true;
  5077. };
  5078. /** @hidden */
  5079. Control.prototype._onPointerOut = function (target, force) {
  5080. if (force === void 0) { force = false; }
  5081. if (!force && (!this._isEnabled || target === this)) {
  5082. return;
  5083. }
  5084. this._enterCount = 0;
  5085. var canNotify = true;
  5086. if (!target.isAscendant(this)) {
  5087. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5088. }
  5089. if (canNotify && this.parent != null) {
  5090. this.parent._onPointerOut(target, force);
  5091. }
  5092. };
  5093. /** @hidden */
  5094. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5095. // Prevent pointerout to lose control context.
  5096. // Event redundancy is checked inside the function.
  5097. this._onPointerEnter(this);
  5098. if (this._downCount !== 0) {
  5099. return false;
  5100. }
  5101. this._downCount++;
  5102. this._downPointerIds[pointerId] = true;
  5103. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5104. if (canNotify && this.parent != null) {
  5105. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5106. }
  5107. return true;
  5108. };
  5109. /** @hidden */
  5110. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5111. if (!this._isEnabled) {
  5112. return;
  5113. }
  5114. this._downCount = 0;
  5115. delete this._downPointerIds[pointerId];
  5116. var canNotifyClick = notifyClick;
  5117. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5118. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5119. }
  5120. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5121. if (canNotify && this.parent != null) {
  5122. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5123. }
  5124. };
  5125. /** @hidden */
  5126. Control.prototype._forcePointerUp = function (pointerId) {
  5127. if (pointerId === void 0) { pointerId = null; }
  5128. if (pointerId !== null) {
  5129. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5130. }
  5131. else {
  5132. for (var key in this._downPointerIds) {
  5133. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5134. }
  5135. }
  5136. };
  5137. /** @hidden */
  5138. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5139. if (!this._isEnabled) {
  5140. return false;
  5141. }
  5142. this._dummyVector2.copyFromFloats(x, y);
  5143. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5144. this._onPointerMove(this, this._dummyVector2);
  5145. var previousControlOver = this._host._lastControlOver[pointerId];
  5146. if (previousControlOver && previousControlOver !== this) {
  5147. previousControlOver._onPointerOut(this);
  5148. }
  5149. if (previousControlOver !== this) {
  5150. this._onPointerEnter(this);
  5151. }
  5152. this._host._lastControlOver[pointerId] = this;
  5153. return true;
  5154. }
  5155. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5156. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5157. this._host._registerLastControlDown(this, pointerId);
  5158. this._host._lastPickedControl = this;
  5159. return true;
  5160. }
  5161. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5162. if (this._host._lastControlDown[pointerId]) {
  5163. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5164. }
  5165. delete this._host._lastControlDown[pointerId];
  5166. return true;
  5167. }
  5168. return false;
  5169. };
  5170. Control.prototype._prepareFont = function () {
  5171. if (!this._font && !this._fontSet) {
  5172. return;
  5173. }
  5174. if (this._style) {
  5175. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5176. }
  5177. else {
  5178. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5179. }
  5180. this._fontOffset = Control._GetFontOffset(this._font);
  5181. };
  5182. /** Releases associated resources */
  5183. Control.prototype.dispose = function () {
  5184. this.onDirtyObservable.clear();
  5185. this.onBeforeDrawObservable.clear();
  5186. this.onAfterDrawObservable.clear();
  5187. this.onPointerDownObservable.clear();
  5188. this.onPointerEnterObservable.clear();
  5189. this.onPointerMoveObservable.clear();
  5190. this.onPointerOutObservable.clear();
  5191. this.onPointerUpObservable.clear();
  5192. this.onPointerClickObservable.clear();
  5193. if (this._styleObserver && this._style) {
  5194. this._style.onChangedObservable.remove(this._styleObserver);
  5195. this._styleObserver = null;
  5196. }
  5197. if (this.parent) {
  5198. this.parent.removeControl(this);
  5199. this.parent = null;
  5200. }
  5201. if (this._host) {
  5202. var index = this._host._linkedControls.indexOf(this);
  5203. if (index > -1) {
  5204. this.linkWithMesh(null);
  5205. }
  5206. }
  5207. };
  5208. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5209. /** HORIZONTAL_ALIGNMENT_LEFT */
  5210. get: function () {
  5211. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5212. },
  5213. enumerable: true,
  5214. configurable: true
  5215. });
  5216. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5217. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5218. get: function () {
  5219. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5220. },
  5221. enumerable: true,
  5222. configurable: true
  5223. });
  5224. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5225. /** HORIZONTAL_ALIGNMENT_CENTER */
  5226. get: function () {
  5227. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5228. },
  5229. enumerable: true,
  5230. configurable: true
  5231. });
  5232. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5233. /** VERTICAL_ALIGNMENT_TOP */
  5234. get: function () {
  5235. return Control._VERTICAL_ALIGNMENT_TOP;
  5236. },
  5237. enumerable: true,
  5238. configurable: true
  5239. });
  5240. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5241. /** VERTICAL_ALIGNMENT_BOTTOM */
  5242. get: function () {
  5243. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5244. },
  5245. enumerable: true,
  5246. configurable: true
  5247. });
  5248. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5249. /** VERTICAL_ALIGNMENT_CENTER */
  5250. get: function () {
  5251. return Control._VERTICAL_ALIGNMENT_CENTER;
  5252. },
  5253. enumerable: true,
  5254. configurable: true
  5255. });
  5256. /** @hidden */
  5257. Control._GetFontOffset = function (font) {
  5258. if (Control._FontHeightSizes[font]) {
  5259. return Control._FontHeightSizes[font];
  5260. }
  5261. var text = document.createElement("span");
  5262. text.innerHTML = "Hg";
  5263. text.style.font = font;
  5264. var block = document.createElement("div");
  5265. block.style.display = "inline-block";
  5266. block.style.width = "1px";
  5267. block.style.height = "0px";
  5268. block.style.verticalAlign = "bottom";
  5269. var div = document.createElement("div");
  5270. div.appendChild(text);
  5271. div.appendChild(block);
  5272. document.body.appendChild(div);
  5273. var fontAscent = 0;
  5274. var fontHeight = 0;
  5275. try {
  5276. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5277. block.style.verticalAlign = "baseline";
  5278. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5279. }
  5280. finally {
  5281. document.body.removeChild(div);
  5282. }
  5283. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5284. Control._FontHeightSizes[font] = result;
  5285. return result;
  5286. };
  5287. /** @hidden */
  5288. Control.drawEllipse = function (x, y, width, height, context) {
  5289. context.translate(x, y);
  5290. context.scale(width, height);
  5291. context.beginPath();
  5292. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5293. context.closePath();
  5294. context.scale(1 / width, 1 / height);
  5295. context.translate(-x, -y);
  5296. };
  5297. /**
  5298. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5299. */
  5300. Control.AllowAlphaInheritance = false;
  5301. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5302. // Statics
  5303. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5304. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5305. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5306. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5307. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5308. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5309. Control._FontHeightSizes = {};
  5310. /**
  5311. * Creates a stack panel that can be used to render headers
  5312. * @param control defines the control to associate with the header
  5313. * @param text defines the text of the header
  5314. * @param size defines the size of the header
  5315. * @param options defines options used to configure the header
  5316. * @returns a new StackPanel
  5317. * @ignore
  5318. * @hidden
  5319. */
  5320. Control.AddHeader = function () { };
  5321. return Control;
  5322. }());
  5323. /***/ }),
  5324. /***/ "./2D/controls/displayGrid.ts":
  5325. /*!************************************!*\
  5326. !*** ./2D/controls/displayGrid.ts ***!
  5327. \************************************/
  5328. /*! exports provided: DisplayGrid */
  5329. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5330. "use strict";
  5331. __webpack_require__.r(__webpack_exports__);
  5332. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5333. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5334. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5335. /** Class used to render a grid */
  5336. var DisplayGrid = /** @class */ (function (_super) {
  5337. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5338. /**
  5339. * Creates a new GridDisplayRectangle
  5340. * @param name defines the control name
  5341. */
  5342. function DisplayGrid(name) {
  5343. var _this = _super.call(this, name) || this;
  5344. _this.name = name;
  5345. _this._cellWidth = 20;
  5346. _this._cellHeight = 20;
  5347. _this._minorLineTickness = 1;
  5348. _this._minorLineColor = "DarkGray";
  5349. _this._majorLineTickness = 2;
  5350. _this._majorLineColor = "White";
  5351. _this._majorLineFrequency = 5;
  5352. _this._background = "Black";
  5353. _this._displayMajorLines = true;
  5354. _this._displayMinorLines = true;
  5355. return _this;
  5356. }
  5357. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5358. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5359. get: function () {
  5360. return this._displayMinorLines;
  5361. },
  5362. set: function (value) {
  5363. if (this._displayMinorLines === value) {
  5364. return;
  5365. }
  5366. this._displayMinorLines = value;
  5367. this._markAsDirty();
  5368. },
  5369. enumerable: true,
  5370. configurable: true
  5371. });
  5372. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5373. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5374. get: function () {
  5375. return this._displayMajorLines;
  5376. },
  5377. set: function (value) {
  5378. if (this._displayMajorLines === value) {
  5379. return;
  5380. }
  5381. this._displayMajorLines = value;
  5382. this._markAsDirty();
  5383. },
  5384. enumerable: true,
  5385. configurable: true
  5386. });
  5387. Object.defineProperty(DisplayGrid.prototype, "background", {
  5388. /** Gets or sets background color (Black by default) */
  5389. get: function () {
  5390. return this._background;
  5391. },
  5392. set: function (value) {
  5393. if (this._background === value) {
  5394. return;
  5395. }
  5396. this._background = value;
  5397. this._markAsDirty();
  5398. },
  5399. enumerable: true,
  5400. configurable: true
  5401. });
  5402. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5403. /** Gets or sets the width of each cell (20 by default) */
  5404. get: function () {
  5405. return this._cellWidth;
  5406. },
  5407. set: function (value) {
  5408. this._cellWidth = value;
  5409. this._markAsDirty();
  5410. },
  5411. enumerable: true,
  5412. configurable: true
  5413. });
  5414. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5415. /** Gets or sets the height of each cell (20 by default) */
  5416. get: function () {
  5417. return this._cellHeight;
  5418. },
  5419. set: function (value) {
  5420. this._cellHeight = value;
  5421. this._markAsDirty();
  5422. },
  5423. enumerable: true,
  5424. configurable: true
  5425. });
  5426. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5427. /** Gets or sets the tickness of minor lines (1 by default) */
  5428. get: function () {
  5429. return this._minorLineTickness;
  5430. },
  5431. set: function (value) {
  5432. this._minorLineTickness = value;
  5433. this._markAsDirty();
  5434. },
  5435. enumerable: true,
  5436. configurable: true
  5437. });
  5438. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5439. /** Gets or sets the color of minor lines (DarkGray by default) */
  5440. get: function () {
  5441. return this._minorLineColor;
  5442. },
  5443. set: function (value) {
  5444. this._minorLineColor = value;
  5445. this._markAsDirty();
  5446. },
  5447. enumerable: true,
  5448. configurable: true
  5449. });
  5450. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5451. /** Gets or sets the tickness of major lines (2 by default) */
  5452. get: function () {
  5453. return this._majorLineTickness;
  5454. },
  5455. set: function (value) {
  5456. this._majorLineTickness = value;
  5457. this._markAsDirty();
  5458. },
  5459. enumerable: true,
  5460. configurable: true
  5461. });
  5462. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5463. /** Gets or sets the color of major lines (White by default) */
  5464. get: function () {
  5465. return this._majorLineColor;
  5466. },
  5467. set: function (value) {
  5468. this._majorLineColor = value;
  5469. this._markAsDirty();
  5470. },
  5471. enumerable: true,
  5472. configurable: true
  5473. });
  5474. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5475. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5476. get: function () {
  5477. return this._majorLineFrequency;
  5478. },
  5479. set: function (value) {
  5480. this._majorLineFrequency = value;
  5481. this._markAsDirty();
  5482. },
  5483. enumerable: true,
  5484. configurable: true
  5485. });
  5486. DisplayGrid.prototype._draw = function (context) {
  5487. context.save();
  5488. this._applyStates(context);
  5489. if (this._isEnabled) {
  5490. if (this._background) {
  5491. context.fillStyle = this._background;
  5492. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5493. }
  5494. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5495. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5496. // Minor lines
  5497. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5498. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5499. if (this._displayMinorLines) {
  5500. context.strokeStyle = this._minorLineColor;
  5501. context.lineWidth = this._minorLineTickness;
  5502. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5503. var cellX = left + x * this.cellWidth;
  5504. context.beginPath();
  5505. context.moveTo(cellX, this._currentMeasure.top);
  5506. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5507. context.stroke();
  5508. }
  5509. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5510. var cellY = top_1 + y * this.cellHeight;
  5511. context.beginPath();
  5512. context.moveTo(this._currentMeasure.left, cellY);
  5513. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5514. context.stroke();
  5515. }
  5516. }
  5517. // Major lines
  5518. if (this._displayMajorLines) {
  5519. context.strokeStyle = this._majorLineColor;
  5520. context.lineWidth = this._majorLineTickness;
  5521. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5522. var cellX = left + x * this.cellWidth;
  5523. context.beginPath();
  5524. context.moveTo(cellX, this._currentMeasure.top);
  5525. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5526. context.stroke();
  5527. }
  5528. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5529. var cellY = top_1 + y * this.cellHeight;
  5530. context.moveTo(this._currentMeasure.left, cellY);
  5531. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5532. context.closePath();
  5533. context.stroke();
  5534. }
  5535. }
  5536. }
  5537. context.restore();
  5538. };
  5539. DisplayGrid.prototype._getTypeName = function () {
  5540. return "DisplayGrid";
  5541. };
  5542. return DisplayGrid;
  5543. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5544. /***/ }),
  5545. /***/ "./2D/controls/ellipse.ts":
  5546. /*!********************************!*\
  5547. !*** ./2D/controls/ellipse.ts ***!
  5548. \********************************/
  5549. /*! exports provided: Ellipse */
  5550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5551. "use strict";
  5552. __webpack_require__.r(__webpack_exports__);
  5553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5554. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5555. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5556. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5557. /** Class used to create 2D ellipse containers */
  5558. var Ellipse = /** @class */ (function (_super) {
  5559. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5560. /**
  5561. * Creates a new Ellipse
  5562. * @param name defines the control name
  5563. */
  5564. function Ellipse(name) {
  5565. var _this = _super.call(this, name) || this;
  5566. _this.name = name;
  5567. _this._thickness = 1;
  5568. return _this;
  5569. }
  5570. Object.defineProperty(Ellipse.prototype, "thickness", {
  5571. /** Gets or sets border thickness */
  5572. get: function () {
  5573. return this._thickness;
  5574. },
  5575. set: function (value) {
  5576. if (this._thickness === value) {
  5577. return;
  5578. }
  5579. this._thickness = value;
  5580. this._markAsDirty();
  5581. },
  5582. enumerable: true,
  5583. configurable: true
  5584. });
  5585. Ellipse.prototype._getTypeName = function () {
  5586. return "Ellipse";
  5587. };
  5588. Ellipse.prototype._localDraw = function (context) {
  5589. context.save();
  5590. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5591. context.shadowColor = this.shadowColor;
  5592. context.shadowBlur = this.shadowBlur;
  5593. context.shadowOffsetX = this.shadowOffsetX;
  5594. context.shadowOffsetY = this.shadowOffsetY;
  5595. }
  5596. _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);
  5597. if (this._background) {
  5598. context.fillStyle = this._background;
  5599. context.fill();
  5600. }
  5601. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5602. context.shadowBlur = 0;
  5603. context.shadowOffsetX = 0;
  5604. context.shadowOffsetY = 0;
  5605. }
  5606. if (this._thickness) {
  5607. if (this.color) {
  5608. context.strokeStyle = this.color;
  5609. }
  5610. context.lineWidth = this._thickness;
  5611. context.stroke();
  5612. }
  5613. context.restore();
  5614. };
  5615. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5616. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5617. this._measureForChildren.width -= 2 * this._thickness;
  5618. this._measureForChildren.height -= 2 * this._thickness;
  5619. this._measureForChildren.left += this._thickness;
  5620. this._measureForChildren.top += this._thickness;
  5621. };
  5622. Ellipse.prototype._clipForChildren = function (context) {
  5623. _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);
  5624. context.clip();
  5625. };
  5626. return Ellipse;
  5627. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5628. /***/ }),
  5629. /***/ "./2D/controls/grid.ts":
  5630. /*!*****************************!*\
  5631. !*** ./2D/controls/grid.ts ***!
  5632. \*****************************/
  5633. /*! exports provided: Grid */
  5634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5635. "use strict";
  5636. __webpack_require__.r(__webpack_exports__);
  5637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5638. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5639. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5640. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5641. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5642. /**
  5643. * Class used to create a 2D grid container
  5644. */
  5645. var Grid = /** @class */ (function (_super) {
  5646. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5647. /**
  5648. * Creates a new Grid
  5649. * @param name defines control name
  5650. */
  5651. function Grid(name) {
  5652. var _this = _super.call(this, name) || this;
  5653. _this.name = name;
  5654. _this._rowDefinitions = new Array();
  5655. _this._columnDefinitions = new Array();
  5656. _this._cells = {};
  5657. _this._childControls = new Array();
  5658. return _this;
  5659. }
  5660. Object.defineProperty(Grid.prototype, "columnCount", {
  5661. /**
  5662. * Gets the number of columns
  5663. */
  5664. get: function () {
  5665. return this._columnDefinitions.length;
  5666. },
  5667. enumerable: true,
  5668. configurable: true
  5669. });
  5670. Object.defineProperty(Grid.prototype, "rowCount", {
  5671. /**
  5672. * Gets the number of rows
  5673. */
  5674. get: function () {
  5675. return this._rowDefinitions.length;
  5676. },
  5677. enumerable: true,
  5678. configurable: true
  5679. });
  5680. Object.defineProperty(Grid.prototype, "children", {
  5681. /** Gets the list of children */
  5682. get: function () {
  5683. return this._childControls;
  5684. },
  5685. enumerable: true,
  5686. configurable: true
  5687. });
  5688. /**
  5689. * Gets the definition of a specific row
  5690. * @param index defines the index of the row
  5691. * @returns the row definition
  5692. */
  5693. Grid.prototype.getRowDefinition = function (index) {
  5694. if (index < 0 || index >= this._rowDefinitions.length) {
  5695. return null;
  5696. }
  5697. return this._rowDefinitions[index];
  5698. };
  5699. /**
  5700. * Gets the definition of a specific column
  5701. * @param index defines the index of the column
  5702. * @returns the column definition
  5703. */
  5704. Grid.prototype.getColumnDefinition = function (index) {
  5705. if (index < 0 || index >= this._columnDefinitions.length) {
  5706. return null;
  5707. }
  5708. return this._columnDefinitions[index];
  5709. };
  5710. /**
  5711. * Adds a new row to the grid
  5712. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5713. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5714. * @returns the current grid
  5715. */
  5716. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5717. if (isPixel === void 0) { isPixel = false; }
  5718. 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));
  5719. this._markAsDirty();
  5720. return this;
  5721. };
  5722. /**
  5723. * Adds a new column to the grid
  5724. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5725. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5726. * @returns the current grid
  5727. */
  5728. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5729. if (isPixel === void 0) { isPixel = false; }
  5730. 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));
  5731. this._markAsDirty();
  5732. return this;
  5733. };
  5734. /**
  5735. * Update a row definition
  5736. * @param index defines the index of the row to update
  5737. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5738. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5739. * @returns the current grid
  5740. */
  5741. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5742. if (isPixel === void 0) { isPixel = false; }
  5743. if (index < 0 || index >= this._rowDefinitions.length) {
  5744. return this;
  5745. }
  5746. var current = this._rowDefinitions[index];
  5747. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5748. return this;
  5749. }
  5750. 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);
  5751. this._markAsDirty();
  5752. return this;
  5753. };
  5754. /**
  5755. * Update a column definition
  5756. * @param index defines the index of the column to update
  5757. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5758. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5759. * @returns the current grid
  5760. */
  5761. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5762. if (isPixel === void 0) { isPixel = false; }
  5763. if (index < 0 || index >= this._columnDefinitions.length) {
  5764. return this;
  5765. }
  5766. var current = this._columnDefinitions[index];
  5767. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5768. return this;
  5769. }
  5770. 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);
  5771. this._markAsDirty();
  5772. return this;
  5773. };
  5774. /**
  5775. * Gets the list of children stored in a specific cell
  5776. * @param row defines the row to check
  5777. * @param column defines the column to check
  5778. * @returns the list of controls
  5779. */
  5780. Grid.prototype.getChildrenAt = function (row, column) {
  5781. var cell = this._cells[row + ":" + column];
  5782. if (!cell) {
  5783. return null;
  5784. }
  5785. return cell.children;
  5786. };
  5787. /**
  5788. * Gets a string representing the child cell info (row x column)
  5789. * @param child defines the control to get info from
  5790. * @returns a string containing the child cell info (row x column)
  5791. */
  5792. Grid.prototype.getChildCellInfo = function (child) {
  5793. return child._tag;
  5794. };
  5795. Grid.prototype._removeCell = function (cell, key) {
  5796. if (!cell) {
  5797. return;
  5798. }
  5799. _super.prototype.removeControl.call(this, cell);
  5800. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5801. var control = _a[_i];
  5802. var childIndex = this._childControls.indexOf(control);
  5803. if (childIndex !== -1) {
  5804. this._childControls.splice(childIndex, 1);
  5805. }
  5806. }
  5807. delete this._cells[key];
  5808. };
  5809. Grid.prototype._offsetCell = function (previousKey, key) {
  5810. if (!this._cells[key]) {
  5811. return;
  5812. }
  5813. this._cells[previousKey] = this._cells[key];
  5814. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5815. var control = _a[_i];
  5816. control._tag = previousKey;
  5817. }
  5818. delete this._cells[key];
  5819. };
  5820. /**
  5821. * Remove a column definition at specified index
  5822. * @param index defines the index of the column to remove
  5823. * @returns the current grid
  5824. */
  5825. Grid.prototype.removeColumnDefinition = function (index) {
  5826. if (index < 0 || index >= this._columnDefinitions.length) {
  5827. return this;
  5828. }
  5829. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5830. var key = x + ":" + index;
  5831. var cell = this._cells[key];
  5832. this._removeCell(cell, key);
  5833. }
  5834. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5835. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5836. var previousKey = x + ":" + (y - 1);
  5837. var key = x + ":" + y;
  5838. this._offsetCell(previousKey, key);
  5839. }
  5840. }
  5841. this._columnDefinitions.splice(index, 1);
  5842. this._markAsDirty();
  5843. return this;
  5844. };
  5845. /**
  5846. * Remove a row definition at specified index
  5847. * @param index defines the index of the row to remove
  5848. * @returns the current grid
  5849. */
  5850. Grid.prototype.removeRowDefinition = function (index) {
  5851. if (index < 0 || index >= this._rowDefinitions.length) {
  5852. return this;
  5853. }
  5854. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5855. var key = index + ":" + y;
  5856. var cell = this._cells[key];
  5857. this._removeCell(cell, key);
  5858. }
  5859. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5860. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5861. var previousKey = x - 1 + ":" + y;
  5862. var key = x + ":" + y;
  5863. this._offsetCell(previousKey, key);
  5864. }
  5865. }
  5866. this._rowDefinitions.splice(index, 1);
  5867. this._markAsDirty();
  5868. return this;
  5869. };
  5870. /**
  5871. * Adds a new control to the current grid
  5872. * @param control defines the control to add
  5873. * @param row defines the row where to add the control (0 by default)
  5874. * @param column defines the column where to add the control (0 by default)
  5875. * @returns the current grid
  5876. */
  5877. Grid.prototype.addControl = function (control, row, column) {
  5878. if (row === void 0) { row = 0; }
  5879. if (column === void 0) { column = 0; }
  5880. if (this._rowDefinitions.length === 0) {
  5881. // Add default row definition
  5882. this.addRowDefinition(1, false);
  5883. }
  5884. if (this._columnDefinitions.length === 0) {
  5885. // Add default column definition
  5886. this.addColumnDefinition(1, false);
  5887. }
  5888. var x = Math.min(row, this._rowDefinitions.length - 1);
  5889. var y = Math.min(column, this._columnDefinitions.length - 1);
  5890. var key = x + ":" + y;
  5891. var goodContainer = this._cells[key];
  5892. if (!goodContainer) {
  5893. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5894. this._cells[key] = goodContainer;
  5895. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5896. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5897. _super.prototype.addControl.call(this, goodContainer);
  5898. }
  5899. goodContainer.addControl(control);
  5900. this._childControls.push(control);
  5901. control._tag = key;
  5902. control.parent = this;
  5903. this._markAsDirty();
  5904. return this;
  5905. };
  5906. /**
  5907. * Removes a control from the current container
  5908. * @param control defines the control to remove
  5909. * @returns the current container
  5910. */
  5911. Grid.prototype.removeControl = function (control) {
  5912. var index = this._childControls.indexOf(control);
  5913. if (index !== -1) {
  5914. this._childControls.splice(index, 1);
  5915. }
  5916. var cell = this._cells[control._tag];
  5917. if (cell) {
  5918. cell.removeControl(control);
  5919. }
  5920. this._markAsDirty();
  5921. return this;
  5922. };
  5923. Grid.prototype._getTypeName = function () {
  5924. return "Grid";
  5925. };
  5926. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5927. var widths = [];
  5928. var heights = [];
  5929. var lefts = [];
  5930. var tops = [];
  5931. var availableWidth = this._currentMeasure.width;
  5932. var globalWidthPercentage = 0;
  5933. var availableHeight = this._currentMeasure.height;
  5934. var globalHeightPercentage = 0;
  5935. // Heights
  5936. var index = 0;
  5937. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5938. var value = _a[_i];
  5939. if (value.isPixel) {
  5940. var height = value.getValue(this._host);
  5941. availableHeight -= height;
  5942. heights[index] = height;
  5943. }
  5944. else {
  5945. globalHeightPercentage += value.internalValue;
  5946. }
  5947. index++;
  5948. }
  5949. var top = 0;
  5950. index = 0;
  5951. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  5952. var value = _c[_b];
  5953. tops.push(top);
  5954. if (!value.isPixel) {
  5955. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  5956. top += height;
  5957. heights[index] = height;
  5958. }
  5959. else {
  5960. top += value.getValue(this._host);
  5961. }
  5962. index++;
  5963. }
  5964. // Widths
  5965. index = 0;
  5966. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  5967. var value = _e[_d];
  5968. if (value.isPixel) {
  5969. var width = value.getValue(this._host);
  5970. availableWidth -= width;
  5971. widths[index] = width;
  5972. }
  5973. else {
  5974. globalWidthPercentage += value.internalValue;
  5975. }
  5976. index++;
  5977. }
  5978. var left = 0;
  5979. index = 0;
  5980. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  5981. var value = _g[_f];
  5982. lefts.push(left);
  5983. if (!value.isPixel) {
  5984. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  5985. left += width;
  5986. widths[index] = width;
  5987. }
  5988. else {
  5989. left += value.getValue(this._host);
  5990. }
  5991. index++;
  5992. }
  5993. definitionCallback(lefts, tops, widths, heights);
  5994. };
  5995. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  5996. var _this = this;
  5997. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  5998. // Setting child sizes
  5999. for (var key in _this._cells) {
  6000. if (!_this._cells.hasOwnProperty(key)) {
  6001. continue;
  6002. }
  6003. var split = key.split(":");
  6004. var x = parseInt(split[0]);
  6005. var y = parseInt(split[1]);
  6006. var cell = _this._cells[key];
  6007. cell.left = lefts[y] + "px";
  6008. cell.top = tops[x] + "px";
  6009. cell.width = widths[y] + "px";
  6010. cell.height = heights[x] + "px";
  6011. cell._left.ignoreAdaptiveScaling = true;
  6012. cell._top.ignoreAdaptiveScaling = true;
  6013. cell._width.ignoreAdaptiveScaling = true;
  6014. cell._height.ignoreAdaptiveScaling = true;
  6015. }
  6016. });
  6017. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6018. };
  6019. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6020. for (var key in this._cells) {
  6021. if (!this._cells.hasOwnProperty(key)) {
  6022. continue;
  6023. }
  6024. var child = this._cells[key];
  6025. child._markMatrixAsDirty();
  6026. }
  6027. };
  6028. Grid.prototype._renderHighlightSpecific = function (context) {
  6029. var _this = this;
  6030. _super.prototype._renderHighlightSpecific.call(this, context);
  6031. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6032. // Columns
  6033. for (var index = 0; index < lefts.length; index++) {
  6034. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6035. context.beginPath();
  6036. context.moveTo(left, _this._currentMeasure.top);
  6037. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6038. context.stroke();
  6039. }
  6040. // Rows
  6041. for (var index = 0; index < tops.length; index++) {
  6042. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6043. context.beginPath();
  6044. context.moveTo(_this._currentMeasure.left, top_1);
  6045. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6046. context.stroke();
  6047. }
  6048. });
  6049. context.restore();
  6050. };
  6051. /** Releases associated resources */
  6052. Grid.prototype.dispose = function () {
  6053. _super.prototype.dispose.call(this);
  6054. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6055. var control = _a[_i];
  6056. control.dispose();
  6057. }
  6058. this._childControls = [];
  6059. };
  6060. return Grid;
  6061. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6062. /***/ }),
  6063. /***/ "./2D/controls/image.ts":
  6064. /*!******************************!*\
  6065. !*** ./2D/controls/image.ts ***!
  6066. \******************************/
  6067. /*! exports provided: Image */
  6068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6069. "use strict";
  6070. __webpack_require__.r(__webpack_exports__);
  6071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6072. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6073. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  6074. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6075. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6076. /**
  6077. * Class used to create 2D images
  6078. */
  6079. var Image = /** @class */ (function (_super) {
  6080. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6081. /**
  6082. * Creates a new Image
  6083. * @param name defines the control name
  6084. * @param url defines the image url
  6085. */
  6086. function Image(name, url) {
  6087. if (url === void 0) { url = null; }
  6088. var _this = _super.call(this, name) || this;
  6089. _this.name = name;
  6090. _this._loaded = false;
  6091. _this._stretch = Image.STRETCH_FILL;
  6092. _this._autoScale = false;
  6093. _this._sourceLeft = 0;
  6094. _this._sourceTop = 0;
  6095. _this._sourceWidth = 0;
  6096. _this._sourceHeight = 0;
  6097. _this._cellWidth = 0;
  6098. _this._cellHeight = 0;
  6099. _this._cellId = -1;
  6100. _this._populateNinePatchSlicesFromImage = false;
  6101. /**
  6102. * Observable notified when the content is loaded
  6103. */
  6104. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6105. _this.source = url;
  6106. return _this;
  6107. }
  6108. Object.defineProperty(Image.prototype, "isLoaded", {
  6109. /**
  6110. * Gets a boolean indicating that the content is loaded
  6111. */
  6112. get: function () {
  6113. return this._loaded;
  6114. },
  6115. enumerable: true,
  6116. configurable: true
  6117. });
  6118. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6119. /**
  6120. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6121. */
  6122. get: function () {
  6123. return this._populateNinePatchSlicesFromImage;
  6124. },
  6125. set: function (value) {
  6126. if (this._populateNinePatchSlicesFromImage === value) {
  6127. return;
  6128. }
  6129. this._populateNinePatchSlicesFromImage = value;
  6130. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6131. this._extractNinePatchSliceDataFromImage();
  6132. }
  6133. },
  6134. enumerable: true,
  6135. configurable: true
  6136. });
  6137. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6138. /**
  6139. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6140. * Beware using this as this will comsume more memory as the image has to be stored twice
  6141. */
  6142. get: function () {
  6143. return this._detectPointerOnOpaqueOnly;
  6144. },
  6145. set: function (value) {
  6146. if (this._detectPointerOnOpaqueOnly === value) {
  6147. return;
  6148. }
  6149. this._detectPointerOnOpaqueOnly = value;
  6150. },
  6151. enumerable: true,
  6152. configurable: true
  6153. });
  6154. Object.defineProperty(Image.prototype, "sliceLeft", {
  6155. /**
  6156. * Gets or sets the left value for slicing (9-patch)
  6157. */
  6158. get: function () {
  6159. return this._sliceLeft;
  6160. },
  6161. set: function (value) {
  6162. if (this._sliceLeft === value) {
  6163. return;
  6164. }
  6165. this._sliceLeft = value;
  6166. this._markAsDirty();
  6167. },
  6168. enumerable: true,
  6169. configurable: true
  6170. });
  6171. Object.defineProperty(Image.prototype, "sliceRight", {
  6172. /**
  6173. * Gets or sets the right value for slicing (9-patch)
  6174. */
  6175. get: function () {
  6176. return this._sliceRight;
  6177. },
  6178. set: function (value) {
  6179. if (this._sliceRight === value) {
  6180. return;
  6181. }
  6182. this._sliceRight = value;
  6183. this._markAsDirty();
  6184. },
  6185. enumerable: true,
  6186. configurable: true
  6187. });
  6188. Object.defineProperty(Image.prototype, "sliceTop", {
  6189. /**
  6190. * Gets or sets the top value for slicing (9-patch)
  6191. */
  6192. get: function () {
  6193. return this._sliceTop;
  6194. },
  6195. set: function (value) {
  6196. if (this._sliceTop === value) {
  6197. return;
  6198. }
  6199. this._sliceTop = value;
  6200. this._markAsDirty();
  6201. },
  6202. enumerable: true,
  6203. configurable: true
  6204. });
  6205. Object.defineProperty(Image.prototype, "sliceBottom", {
  6206. /**
  6207. * Gets or sets the bottom value for slicing (9-patch)
  6208. */
  6209. get: function () {
  6210. return this._sliceBottom;
  6211. },
  6212. set: function (value) {
  6213. if (this._sliceBottom === value) {
  6214. return;
  6215. }
  6216. this._sliceBottom = value;
  6217. this._markAsDirty();
  6218. },
  6219. enumerable: true,
  6220. configurable: true
  6221. });
  6222. Object.defineProperty(Image.prototype, "sourceLeft", {
  6223. /**
  6224. * Gets or sets the left coordinate in the source image
  6225. */
  6226. get: function () {
  6227. return this._sourceLeft;
  6228. },
  6229. set: function (value) {
  6230. if (this._sourceLeft === value) {
  6231. return;
  6232. }
  6233. this._sourceLeft = value;
  6234. this._markAsDirty();
  6235. },
  6236. enumerable: true,
  6237. configurable: true
  6238. });
  6239. Object.defineProperty(Image.prototype, "sourceTop", {
  6240. /**
  6241. * Gets or sets the top coordinate in the source image
  6242. */
  6243. get: function () {
  6244. return this._sourceTop;
  6245. },
  6246. set: function (value) {
  6247. if (this._sourceTop === value) {
  6248. return;
  6249. }
  6250. this._sourceTop = value;
  6251. this._markAsDirty();
  6252. },
  6253. enumerable: true,
  6254. configurable: true
  6255. });
  6256. Object.defineProperty(Image.prototype, "sourceWidth", {
  6257. /**
  6258. * Gets or sets the width to capture in the source image
  6259. */
  6260. get: function () {
  6261. return this._sourceWidth;
  6262. },
  6263. set: function (value) {
  6264. if (this._sourceWidth === value) {
  6265. return;
  6266. }
  6267. this._sourceWidth = value;
  6268. this._markAsDirty();
  6269. },
  6270. enumerable: true,
  6271. configurable: true
  6272. });
  6273. Object.defineProperty(Image.prototype, "sourceHeight", {
  6274. /**
  6275. * Gets or sets the height to capture in the source image
  6276. */
  6277. get: function () {
  6278. return this._sourceHeight;
  6279. },
  6280. set: function (value) {
  6281. if (this._sourceHeight === value) {
  6282. return;
  6283. }
  6284. this._sourceHeight = value;
  6285. this._markAsDirty();
  6286. },
  6287. enumerable: true,
  6288. configurable: true
  6289. });
  6290. Object.defineProperty(Image.prototype, "autoScale", {
  6291. /**
  6292. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6293. * @see http://doc.babylonjs.com/how_to/gui#image
  6294. */
  6295. get: function () {
  6296. return this._autoScale;
  6297. },
  6298. set: function (value) {
  6299. if (this._autoScale === value) {
  6300. return;
  6301. }
  6302. this._autoScale = value;
  6303. if (value && this._loaded) {
  6304. this.synchronizeSizeWithContent();
  6305. }
  6306. },
  6307. enumerable: true,
  6308. configurable: true
  6309. });
  6310. Object.defineProperty(Image.prototype, "stretch", {
  6311. /** Gets or sets the streching mode used by the image */
  6312. get: function () {
  6313. return this._stretch;
  6314. },
  6315. set: function (value) {
  6316. if (this._stretch === value) {
  6317. return;
  6318. }
  6319. this._stretch = value;
  6320. this._markAsDirty();
  6321. },
  6322. enumerable: true,
  6323. configurable: true
  6324. });
  6325. Object.defineProperty(Image.prototype, "domImage", {
  6326. get: function () {
  6327. return this._domImage;
  6328. },
  6329. /**
  6330. * Gets or sets the internal DOM image used to render the control
  6331. */
  6332. set: function (value) {
  6333. var _this = this;
  6334. this._domImage = value;
  6335. this._loaded = false;
  6336. if (this._domImage.width) {
  6337. this._onImageLoaded();
  6338. }
  6339. else {
  6340. this._domImage.onload = function () {
  6341. _this._onImageLoaded();
  6342. };
  6343. }
  6344. },
  6345. enumerable: true,
  6346. configurable: true
  6347. });
  6348. Image.prototype._onImageLoaded = function () {
  6349. this._imageWidth = this._domImage.width;
  6350. this._imageHeight = this._domImage.height;
  6351. this._loaded = true;
  6352. if (this._populateNinePatchSlicesFromImage) {
  6353. this._extractNinePatchSliceDataFromImage();
  6354. }
  6355. if (this._autoScale) {
  6356. this.synchronizeSizeWithContent();
  6357. }
  6358. this.onImageLoadedObservable.notifyObservers(this);
  6359. this._markAsDirty();
  6360. };
  6361. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6362. if (!Image._WorkingCanvas) {
  6363. Image._WorkingCanvas = document.createElement('canvas');
  6364. }
  6365. var canvas = Image._WorkingCanvas;
  6366. var context = canvas.getContext('2d');
  6367. var width = this._domImage.width;
  6368. var height = this._domImage.height;
  6369. canvas.width = width;
  6370. canvas.height = height;
  6371. context.drawImage(this._domImage, 0, 0, width, height);
  6372. var imageData = context.getImageData(0, 0, width, height);
  6373. // Left and right
  6374. this._sliceLeft = -1;
  6375. this._sliceRight = -1;
  6376. for (var x = 0; x < width; x++) {
  6377. var alpha = imageData.data[x * 4 + 3];
  6378. if (alpha > 127 && this._sliceLeft === -1) {
  6379. this._sliceLeft = x;
  6380. continue;
  6381. }
  6382. if (alpha < 127 && this._sliceLeft > -1) {
  6383. this._sliceRight = x;
  6384. break;
  6385. }
  6386. }
  6387. // top and bottom
  6388. this._sliceTop = -1;
  6389. this._sliceBottom = -1;
  6390. for (var y = 0; y < height; y++) {
  6391. var alpha = imageData.data[y * width * 4 + 3];
  6392. if (alpha > 127 && this._sliceTop === -1) {
  6393. this._sliceTop = y;
  6394. continue;
  6395. }
  6396. if (alpha < 127 && this._sliceTop > -1) {
  6397. this._sliceBottom = y;
  6398. break;
  6399. }
  6400. }
  6401. };
  6402. Object.defineProperty(Image.prototype, "source", {
  6403. /**
  6404. * Gets or sets image source url
  6405. */
  6406. set: function (value) {
  6407. var _this = this;
  6408. if (this._source === value) {
  6409. return;
  6410. }
  6411. this._loaded = false;
  6412. this._source = value;
  6413. this._domImage = document.createElement("img");
  6414. this._domImage.onload = function () {
  6415. _this._onImageLoaded();
  6416. };
  6417. if (value) {
  6418. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6419. this._domImage.src = value;
  6420. }
  6421. },
  6422. enumerable: true,
  6423. configurable: true
  6424. });
  6425. Object.defineProperty(Image.prototype, "cellWidth", {
  6426. /**
  6427. * Gets or sets the cell width to use when animation sheet is enabled
  6428. * @see http://doc.babylonjs.com/how_to/gui#image
  6429. */
  6430. get: function () {
  6431. return this._cellWidth;
  6432. },
  6433. set: function (value) {
  6434. if (this._cellWidth === value) {
  6435. return;
  6436. }
  6437. this._cellWidth = value;
  6438. this._markAsDirty();
  6439. },
  6440. enumerable: true,
  6441. configurable: true
  6442. });
  6443. Object.defineProperty(Image.prototype, "cellHeight", {
  6444. /**
  6445. * Gets or sets the cell height to use when animation sheet is enabled
  6446. * @see http://doc.babylonjs.com/how_to/gui#image
  6447. */
  6448. get: function () {
  6449. return this._cellHeight;
  6450. },
  6451. set: function (value) {
  6452. if (this._cellHeight === value) {
  6453. return;
  6454. }
  6455. this._cellHeight = value;
  6456. this._markAsDirty();
  6457. },
  6458. enumerable: true,
  6459. configurable: true
  6460. });
  6461. Object.defineProperty(Image.prototype, "cellId", {
  6462. /**
  6463. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6464. * @see http://doc.babylonjs.com/how_to/gui#image
  6465. */
  6466. get: function () {
  6467. return this._cellId;
  6468. },
  6469. set: function (value) {
  6470. if (this._cellId === value) {
  6471. return;
  6472. }
  6473. this._cellId = value;
  6474. this._markAsDirty();
  6475. },
  6476. enumerable: true,
  6477. configurable: true
  6478. });
  6479. /**
  6480. * Tests if a given coordinates belong to the current control
  6481. * @param x defines x coordinate to test
  6482. * @param y defines y coordinate to test
  6483. * @returns true if the coordinates are inside the control
  6484. */
  6485. Image.prototype.contains = function (x, y) {
  6486. if (!_super.prototype.contains.call(this, x, y)) {
  6487. return false;
  6488. }
  6489. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6490. return true;
  6491. }
  6492. var canvas = Image._WorkingCanvas;
  6493. var context = canvas.getContext("2d");
  6494. var width = this._currentMeasure.width | 0;
  6495. var height = this._currentMeasure.height | 0;
  6496. var imageData = context.getImageData(0, 0, width, height).data;
  6497. x = (x - this._currentMeasure.left) | 0;
  6498. y = (y - this._currentMeasure.top) | 0;
  6499. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6500. return pickedPixel > 0;
  6501. };
  6502. Image.prototype._getTypeName = function () {
  6503. return "Image";
  6504. };
  6505. /** Force the control to synchronize with its content */
  6506. Image.prototype.synchronizeSizeWithContent = function () {
  6507. if (!this._loaded) {
  6508. return;
  6509. }
  6510. this.width = this._domImage.width + "px";
  6511. this.height = this._domImage.height + "px";
  6512. };
  6513. Image.prototype._processMeasures = function (parentMeasure, context) {
  6514. if (this._loaded) {
  6515. switch (this._stretch) {
  6516. case Image.STRETCH_NONE:
  6517. break;
  6518. case Image.STRETCH_FILL:
  6519. break;
  6520. case Image.STRETCH_UNIFORM:
  6521. break;
  6522. case Image.STRETCH_NINE_PATCH:
  6523. break;
  6524. case Image.STRETCH_EXTEND:
  6525. if (this._autoScale) {
  6526. this.synchronizeSizeWithContent();
  6527. }
  6528. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6529. this.parent.adaptWidthToChildren = true;
  6530. this.parent.adaptHeightToChildren = true;
  6531. }
  6532. break;
  6533. }
  6534. }
  6535. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6536. };
  6537. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6538. if (!this._detectPointerOnOpaqueOnly) {
  6539. return;
  6540. }
  6541. if (!Image._WorkingCanvas) {
  6542. Image._WorkingCanvas = document.createElement('canvas');
  6543. }
  6544. var canvas = Image._WorkingCanvas;
  6545. var width = this._currentMeasure.width;
  6546. var height = this._currentMeasure.height;
  6547. var context = canvas.getContext("2d");
  6548. canvas.width = width;
  6549. canvas.height = height;
  6550. context.clearRect(0, 0, width, height);
  6551. };
  6552. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6553. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6554. if (!this._detectPointerOnOpaqueOnly) {
  6555. return;
  6556. }
  6557. var canvas = Image._WorkingCanvas;
  6558. context = canvas.getContext("2d");
  6559. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6560. };
  6561. Image.prototype._draw = function (context) {
  6562. context.save();
  6563. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6564. context.shadowColor = this.shadowColor;
  6565. context.shadowBlur = this.shadowBlur;
  6566. context.shadowOffsetX = this.shadowOffsetX;
  6567. context.shadowOffsetY = this.shadowOffsetY;
  6568. }
  6569. var x, y, width, height;
  6570. if (this.cellId == -1) {
  6571. x = this._sourceLeft;
  6572. y = this._sourceTop;
  6573. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6574. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6575. }
  6576. else {
  6577. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6578. var column = (this.cellId / rowCount) >> 0;
  6579. var row = this.cellId % rowCount;
  6580. x = this.cellWidth * row;
  6581. y = this.cellHeight * column;
  6582. width = this.cellWidth;
  6583. height = this.cellHeight;
  6584. }
  6585. this._prepareWorkingCanvasForOpaqueDetection();
  6586. this._applyStates(context);
  6587. if (this._loaded) {
  6588. switch (this._stretch) {
  6589. case Image.STRETCH_NONE:
  6590. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6591. break;
  6592. case Image.STRETCH_FILL:
  6593. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6594. break;
  6595. case Image.STRETCH_UNIFORM:
  6596. var hRatio = this._currentMeasure.width / width;
  6597. var vRatio = this._currentMeasure.height / height;
  6598. var ratio = Math.min(hRatio, vRatio);
  6599. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6600. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6601. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6602. break;
  6603. case Image.STRETCH_EXTEND:
  6604. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6605. break;
  6606. case Image.STRETCH_NINE_PATCH:
  6607. this._renderNinePatch(context);
  6608. break;
  6609. }
  6610. }
  6611. context.restore();
  6612. };
  6613. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6614. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6615. };
  6616. Image.prototype._renderNinePatch = function (context) {
  6617. var height = this._imageHeight;
  6618. var leftWidth = this._sliceLeft;
  6619. var topHeight = this._sliceTop;
  6620. var bottomHeight = this._imageHeight - this._sliceBottom;
  6621. var rightWidth = this._imageWidth - this._sliceRight;
  6622. var left = 0;
  6623. var top = 0;
  6624. if (this._populateNinePatchSlicesFromImage) {
  6625. left = 1;
  6626. top = 1;
  6627. height -= 2;
  6628. leftWidth -= 1;
  6629. topHeight -= 1;
  6630. bottomHeight -= 1;
  6631. rightWidth -= 1;
  6632. }
  6633. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6634. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6635. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6636. // Corners
  6637. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6638. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6639. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6640. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6641. // Center
  6642. 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);
  6643. // Borders
  6644. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6645. 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);
  6646. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6647. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6648. };
  6649. Image.prototype.dispose = function () {
  6650. _super.prototype.dispose.call(this);
  6651. this.onImageLoadedObservable.clear();
  6652. };
  6653. Image._WorkingCanvas = null;
  6654. // Static
  6655. /** STRETCH_NONE */
  6656. Image.STRETCH_NONE = 0;
  6657. /** STRETCH_FILL */
  6658. Image.STRETCH_FILL = 1;
  6659. /** STRETCH_UNIFORM */
  6660. Image.STRETCH_UNIFORM = 2;
  6661. /** STRETCH_EXTEND */
  6662. Image.STRETCH_EXTEND = 3;
  6663. /** NINE_PATCH */
  6664. Image.STRETCH_NINE_PATCH = 4;
  6665. return Image;
  6666. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6667. /***/ }),
  6668. /***/ "./2D/controls/index.ts":
  6669. /*!******************************!*\
  6670. !*** ./2D/controls/index.ts ***!
  6671. \******************************/
  6672. /*! 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 */
  6673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6674. "use strict";
  6675. __webpack_require__.r(__webpack_exports__);
  6676. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6678. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6680. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6682. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6684. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6686. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6688. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6690. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6692. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6694. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6696. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6698. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6700. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6702. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6704. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6710. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6712. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6715. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6718. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6720. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6722. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6724. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6726. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6728. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6730. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6732. /***/ }),
  6733. /***/ "./2D/controls/inputPassword.ts":
  6734. /*!**************************************!*\
  6735. !*** ./2D/controls/inputPassword.ts ***!
  6736. \**************************************/
  6737. /*! exports provided: InputPassword */
  6738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6739. "use strict";
  6740. __webpack_require__.r(__webpack_exports__);
  6741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6742. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6743. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6744. /**
  6745. * Class used to create a password control
  6746. */
  6747. var InputPassword = /** @class */ (function (_super) {
  6748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6749. function InputPassword() {
  6750. return _super !== null && _super.apply(this, arguments) || this;
  6751. }
  6752. InputPassword.prototype._beforeRenderText = function (text) {
  6753. var txt = "";
  6754. for (var i = 0; i < text.length; i++) {
  6755. txt += "\u2022";
  6756. }
  6757. return txt;
  6758. };
  6759. return InputPassword;
  6760. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6761. /***/ }),
  6762. /***/ "./2D/controls/inputText.ts":
  6763. /*!**********************************!*\
  6764. !*** ./2D/controls/inputText.ts ***!
  6765. \**********************************/
  6766. /*! exports provided: InputText */
  6767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6768. "use strict";
  6769. __webpack_require__.r(__webpack_exports__);
  6770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6771. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6772. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  6773. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6774. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6775. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6776. /**
  6777. * Class used to create input text control
  6778. */
  6779. var InputText = /** @class */ (function (_super) {
  6780. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6781. /**
  6782. * Creates a new InputText
  6783. * @param name defines the control name
  6784. * @param text defines the text of the control
  6785. */
  6786. function InputText(name, text) {
  6787. if (text === void 0) { text = ""; }
  6788. var _this = _super.call(this, name) || this;
  6789. _this.name = name;
  6790. _this._text = "";
  6791. _this._placeholderText = "";
  6792. _this._background = "#222222";
  6793. _this._focusedBackground = "#000000";
  6794. _this._focusedColor = "white";
  6795. _this._placeholderColor = "gray";
  6796. _this._thickness = 1;
  6797. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6798. _this._autoStretchWidth = true;
  6799. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6800. _this._isFocused = false;
  6801. _this._blinkIsEven = false;
  6802. _this._cursorOffset = 0;
  6803. _this._deadKey = false;
  6804. _this._addKey = true;
  6805. _this._currentKey = "";
  6806. _this._isTextHighlightOn = false;
  6807. _this._textHighlightColor = "#d5e0ff";
  6808. _this._highligherOpacity = 0.4;
  6809. _this._highlightedText = "";
  6810. _this._startHighlightIndex = 0;
  6811. _this._endHighlightIndex = 0;
  6812. _this._cursorIndex = -1;
  6813. _this._onFocusSelectAll = false;
  6814. _this._isPointerDown = false;
  6815. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6816. _this.promptMessage = "Please enter text:";
  6817. /** Observable raised when the text changes */
  6818. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6819. /** Observable raised just before an entered character is to be added */
  6820. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6821. /** Observable raised when the control gets the focus */
  6822. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6823. /** Observable raised when the control loses the focus */
  6824. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6825. /**Observable raised when the text is highlighted */
  6826. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6827. /**Observable raised when copy event is triggered */
  6828. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6829. /** Observable raised when cut event is triggered */
  6830. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6831. /** Observable raised when paste event is triggered */
  6832. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6833. /** Observable raised when a key event was processed */
  6834. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6835. _this.text = text;
  6836. _this.isPointerBlocker = true;
  6837. return _this;
  6838. }
  6839. Object.defineProperty(InputText.prototype, "maxWidth", {
  6840. /** Gets or sets the maximum width allowed by the control */
  6841. get: function () {
  6842. return this._maxWidth.toString(this._host);
  6843. },
  6844. set: function (value) {
  6845. if (this._maxWidth.toString(this._host) === value) {
  6846. return;
  6847. }
  6848. if (this._maxWidth.fromString(value)) {
  6849. this._markAsDirty();
  6850. }
  6851. },
  6852. enumerable: true,
  6853. configurable: true
  6854. });
  6855. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6856. /** Gets the maximum width allowed by the control in pixels */
  6857. get: function () {
  6858. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6859. },
  6860. enumerable: true,
  6861. configurable: true
  6862. });
  6863. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6864. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6865. get: function () {
  6866. return this._highligherOpacity;
  6867. },
  6868. set: function (value) {
  6869. if (this._highligherOpacity === value) {
  6870. return;
  6871. }
  6872. this._highligherOpacity = value;
  6873. this._markAsDirty();
  6874. },
  6875. enumerable: true,
  6876. configurable: true
  6877. });
  6878. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6879. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6880. get: function () {
  6881. return this._onFocusSelectAll;
  6882. },
  6883. set: function (value) {
  6884. if (this._onFocusSelectAll === value) {
  6885. return;
  6886. }
  6887. this._onFocusSelectAll = value;
  6888. this._markAsDirty();
  6889. },
  6890. enumerable: true,
  6891. configurable: true
  6892. });
  6893. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6894. /** Gets or sets the text hightlight color */
  6895. get: function () {
  6896. return this._textHighlightColor;
  6897. },
  6898. set: function (value) {
  6899. if (this._textHighlightColor === value) {
  6900. return;
  6901. }
  6902. this._textHighlightColor = value;
  6903. this._markAsDirty();
  6904. },
  6905. enumerable: true,
  6906. configurable: true
  6907. });
  6908. Object.defineProperty(InputText.prototype, "margin", {
  6909. /** Gets or sets control margin */
  6910. get: function () {
  6911. return this._margin.toString(this._host);
  6912. },
  6913. set: function (value) {
  6914. if (this._margin.toString(this._host) === value) {
  6915. return;
  6916. }
  6917. if (this._margin.fromString(value)) {
  6918. this._markAsDirty();
  6919. }
  6920. },
  6921. enumerable: true,
  6922. configurable: true
  6923. });
  6924. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6925. /** Gets control margin in pixels */
  6926. get: function () {
  6927. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6928. },
  6929. enumerable: true,
  6930. configurable: true
  6931. });
  6932. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6933. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6934. get: function () {
  6935. return this._autoStretchWidth;
  6936. },
  6937. set: function (value) {
  6938. if (this._autoStretchWidth === value) {
  6939. return;
  6940. }
  6941. this._autoStretchWidth = value;
  6942. this._markAsDirty();
  6943. },
  6944. enumerable: true,
  6945. configurable: true
  6946. });
  6947. Object.defineProperty(InputText.prototype, "thickness", {
  6948. /** Gets or sets border thickness */
  6949. get: function () {
  6950. return this._thickness;
  6951. },
  6952. set: function (value) {
  6953. if (this._thickness === value) {
  6954. return;
  6955. }
  6956. this._thickness = value;
  6957. this._markAsDirty();
  6958. },
  6959. enumerable: true,
  6960. configurable: true
  6961. });
  6962. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6963. /** Gets or sets the background color when focused */
  6964. get: function () {
  6965. return this._focusedBackground;
  6966. },
  6967. set: function (value) {
  6968. if (this._focusedBackground === value) {
  6969. return;
  6970. }
  6971. this._focusedBackground = value;
  6972. this._markAsDirty();
  6973. },
  6974. enumerable: true,
  6975. configurable: true
  6976. });
  6977. Object.defineProperty(InputText.prototype, "focusedColor", {
  6978. /** Gets or sets the background color when focused */
  6979. get: function () {
  6980. return this._focusedColor;
  6981. },
  6982. set: function (value) {
  6983. if (this._focusedColor === value) {
  6984. return;
  6985. }
  6986. this._focusedColor = value;
  6987. this._markAsDirty();
  6988. },
  6989. enumerable: true,
  6990. configurable: true
  6991. });
  6992. Object.defineProperty(InputText.prototype, "background", {
  6993. /** Gets or sets the background color */
  6994. get: function () {
  6995. return this._background;
  6996. },
  6997. set: function (value) {
  6998. if (this._background === value) {
  6999. return;
  7000. }
  7001. this._background = value;
  7002. this._markAsDirty();
  7003. },
  7004. enumerable: true,
  7005. configurable: true
  7006. });
  7007. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7008. /** Gets or sets the placeholder color */
  7009. get: function () {
  7010. return this._placeholderColor;
  7011. },
  7012. set: function (value) {
  7013. if (this._placeholderColor === value) {
  7014. return;
  7015. }
  7016. this._placeholderColor = value;
  7017. this._markAsDirty();
  7018. },
  7019. enumerable: true,
  7020. configurable: true
  7021. });
  7022. Object.defineProperty(InputText.prototype, "placeholderText", {
  7023. /** Gets or sets the text displayed when the control is empty */
  7024. get: function () {
  7025. return this._placeholderText;
  7026. },
  7027. set: function (value) {
  7028. if (this._placeholderText === value) {
  7029. return;
  7030. }
  7031. this._placeholderText = value;
  7032. this._markAsDirty();
  7033. },
  7034. enumerable: true,
  7035. configurable: true
  7036. });
  7037. Object.defineProperty(InputText.prototype, "deadKey", {
  7038. /** Gets or sets the dead key flag */
  7039. get: function () {
  7040. return this._deadKey;
  7041. },
  7042. set: function (flag) {
  7043. this._deadKey = flag;
  7044. },
  7045. enumerable: true,
  7046. configurable: true
  7047. });
  7048. Object.defineProperty(InputText.prototype, "highlightedText", {
  7049. /** Gets or sets the highlight text */
  7050. get: function () {
  7051. return this._highlightedText;
  7052. },
  7053. set: function (text) {
  7054. if (this._highlightedText === text) {
  7055. return;
  7056. }
  7057. this._highlightedText = text;
  7058. this._markAsDirty();
  7059. },
  7060. enumerable: true,
  7061. configurable: true
  7062. });
  7063. Object.defineProperty(InputText.prototype, "addKey", {
  7064. /** Gets or sets if the current key should be added */
  7065. get: function () {
  7066. return this._addKey;
  7067. },
  7068. set: function (flag) {
  7069. this._addKey = flag;
  7070. },
  7071. enumerable: true,
  7072. configurable: true
  7073. });
  7074. Object.defineProperty(InputText.prototype, "currentKey", {
  7075. /** Gets or sets the value of the current key being entered */
  7076. get: function () {
  7077. return this._currentKey;
  7078. },
  7079. set: function (key) {
  7080. this._currentKey = key;
  7081. },
  7082. enumerable: true,
  7083. configurable: true
  7084. });
  7085. Object.defineProperty(InputText.prototype, "text", {
  7086. /** Gets or sets the text displayed in the control */
  7087. get: function () {
  7088. return this._text;
  7089. },
  7090. set: function (value) {
  7091. var valueAsString = value.toString(); // Forcing convertion
  7092. if (this._text === valueAsString) {
  7093. return;
  7094. }
  7095. this._text = valueAsString;
  7096. this._markAsDirty();
  7097. this.onTextChangedObservable.notifyObservers(this);
  7098. },
  7099. enumerable: true,
  7100. configurable: true
  7101. });
  7102. Object.defineProperty(InputText.prototype, "width", {
  7103. /** Gets or sets control width */
  7104. get: function () {
  7105. return this._width.toString(this._host);
  7106. },
  7107. set: function (value) {
  7108. if (this._width.toString(this._host) === value) {
  7109. return;
  7110. }
  7111. if (this._width.fromString(value)) {
  7112. this._markAsDirty();
  7113. }
  7114. this.autoStretchWidth = false;
  7115. },
  7116. enumerable: true,
  7117. configurable: true
  7118. });
  7119. /** @hidden */
  7120. InputText.prototype.onBlur = function () {
  7121. this._isFocused = false;
  7122. this._scrollLeft = null;
  7123. this._cursorOffset = 0;
  7124. clearTimeout(this._blinkTimeout);
  7125. this._markAsDirty();
  7126. this.onBlurObservable.notifyObservers(this);
  7127. this._host.unRegisterClipboardEvents();
  7128. if (this._onClipboardObserver) {
  7129. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7130. }
  7131. var scene = this._host.getScene();
  7132. if (this._onPointerDblTapObserver && scene) {
  7133. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7134. }
  7135. };
  7136. /** @hidden */
  7137. InputText.prototype.onFocus = function () {
  7138. var _this = this;
  7139. if (!this._isEnabled) {
  7140. return;
  7141. }
  7142. this._scrollLeft = null;
  7143. this._isFocused = true;
  7144. this._blinkIsEven = false;
  7145. this._cursorOffset = 0;
  7146. this._markAsDirty();
  7147. this.onFocusObservable.notifyObservers(this);
  7148. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7149. var value = prompt(this.promptMessage);
  7150. if (value !== null) {
  7151. this.text = value;
  7152. }
  7153. this._host.focusedControl = null;
  7154. return;
  7155. }
  7156. this._host.registerClipboardEvents();
  7157. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7158. // process clipboard event, can be configured.
  7159. switch (clipboardInfo.type) {
  7160. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7161. _this._onCopyText(clipboardInfo.event);
  7162. _this.onTextCopyObservable.notifyObservers(_this);
  7163. break;
  7164. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7165. _this._onCutText(clipboardInfo.event);
  7166. _this.onTextCutObservable.notifyObservers(_this);
  7167. break;
  7168. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7169. _this._onPasteText(clipboardInfo.event);
  7170. _this.onTextPasteObservable.notifyObservers(_this);
  7171. break;
  7172. default: return;
  7173. }
  7174. });
  7175. var scene = this._host.getScene();
  7176. if (scene) {
  7177. //register the pointer double tap event
  7178. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7179. if (!_this._isFocused) {
  7180. return;
  7181. }
  7182. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7183. _this._processDblClick(pointerInfo);
  7184. }
  7185. });
  7186. }
  7187. if (this._onFocusSelectAll) {
  7188. this._selectAllText();
  7189. }
  7190. };
  7191. InputText.prototype._getTypeName = function () {
  7192. return "InputText";
  7193. };
  7194. /**
  7195. * Function called to get the list of controls that should not steal the focus from this control
  7196. * @returns an array of controls
  7197. */
  7198. InputText.prototype.keepsFocusWith = function () {
  7199. if (!this._connectedVirtualKeyboard) {
  7200. return null;
  7201. }
  7202. return [this._connectedVirtualKeyboard];
  7203. };
  7204. /** @hidden */
  7205. InputText.prototype.processKey = function (keyCode, key, evt) {
  7206. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7207. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7208. return;
  7209. }
  7210. //select all
  7211. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7212. this._selectAllText();
  7213. evt.preventDefault();
  7214. return;
  7215. }
  7216. // Specific cases
  7217. switch (keyCode) {
  7218. case 32: //SPACE
  7219. key = " "; //ie11 key for space is "Spacebar"
  7220. break;
  7221. case 191: //SLASH
  7222. if (evt) {
  7223. evt.preventDefault();
  7224. }
  7225. break;
  7226. case 8: // BACKSPACE
  7227. if (this._text && this._text.length > 0) {
  7228. //delete the highlighted text
  7229. if (this._isTextHighlightOn) {
  7230. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7231. this._isTextHighlightOn = false;
  7232. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7233. this._blinkIsEven = false;
  7234. if (evt) {
  7235. evt.preventDefault();
  7236. }
  7237. return;
  7238. }
  7239. //delete single character
  7240. if (this._cursorOffset === 0) {
  7241. this.text = this._text.substr(0, this._text.length - 1);
  7242. }
  7243. else {
  7244. var deletePosition = this._text.length - this._cursorOffset;
  7245. if (deletePosition > 0) {
  7246. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7247. }
  7248. }
  7249. }
  7250. if (evt) {
  7251. evt.preventDefault();
  7252. }
  7253. return;
  7254. case 46: // DELETE
  7255. if (this._isTextHighlightOn) {
  7256. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7257. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7258. while (decrementor > 0 && this._cursorOffset > 0) {
  7259. this._cursorOffset--;
  7260. }
  7261. this._isTextHighlightOn = false;
  7262. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7263. if (evt) {
  7264. evt.preventDefault();
  7265. }
  7266. return;
  7267. }
  7268. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7269. var deletePosition = this._text.length - this._cursorOffset;
  7270. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7271. this._cursorOffset--;
  7272. }
  7273. if (evt) {
  7274. evt.preventDefault();
  7275. }
  7276. return;
  7277. case 13: // RETURN
  7278. this._host.focusedControl = null;
  7279. this._isTextHighlightOn = false;
  7280. return;
  7281. case 35: // END
  7282. this._cursorOffset = 0;
  7283. this._blinkIsEven = false;
  7284. this._isTextHighlightOn = false;
  7285. this._markAsDirty();
  7286. return;
  7287. case 36: // HOME
  7288. this._cursorOffset = this._text.length;
  7289. this._blinkIsEven = false;
  7290. this._isTextHighlightOn = false;
  7291. this._markAsDirty();
  7292. return;
  7293. case 37: // LEFT
  7294. this._cursorOffset++;
  7295. if (this._cursorOffset > this._text.length) {
  7296. this._cursorOffset = this._text.length;
  7297. }
  7298. if (evt && evt.shiftKey) {
  7299. // update the cursor
  7300. this._blinkIsEven = false;
  7301. // shift + ctrl/cmd + <-
  7302. if (evt.ctrlKey || evt.metaKey) {
  7303. if (!this._isTextHighlightOn) {
  7304. if (this._text.length === this._cursorOffset) {
  7305. return;
  7306. }
  7307. else {
  7308. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7309. }
  7310. }
  7311. this._startHighlightIndex = 0;
  7312. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7313. this._cursorOffset = this._text.length;
  7314. this._isTextHighlightOn = true;
  7315. this._markAsDirty();
  7316. return;
  7317. }
  7318. //store the starting point
  7319. if (!this._isTextHighlightOn) {
  7320. this._isTextHighlightOn = true;
  7321. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7322. }
  7323. //if text is already highlighted
  7324. else if (this._cursorIndex === -1) {
  7325. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7326. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7327. }
  7328. //set the highlight indexes
  7329. if (this._cursorIndex < this._cursorOffset) {
  7330. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7331. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7332. }
  7333. else if (this._cursorIndex > this._cursorOffset) {
  7334. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7335. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7336. }
  7337. else {
  7338. this._isTextHighlightOn = false;
  7339. }
  7340. this._markAsDirty();
  7341. return;
  7342. }
  7343. if (this._isTextHighlightOn) {
  7344. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7345. this._isTextHighlightOn = false;
  7346. }
  7347. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7348. this._cursorOffset = this.text.length;
  7349. evt.preventDefault();
  7350. }
  7351. this._blinkIsEven = false;
  7352. this._isTextHighlightOn = false;
  7353. this._cursorIndex = -1;
  7354. this._markAsDirty();
  7355. return;
  7356. case 39: // RIGHT
  7357. this._cursorOffset--;
  7358. if (this._cursorOffset < 0) {
  7359. this._cursorOffset = 0;
  7360. }
  7361. if (evt && evt.shiftKey) {
  7362. //update the cursor
  7363. this._blinkIsEven = false;
  7364. //shift + ctrl/cmd + ->
  7365. if (evt.ctrlKey || evt.metaKey) {
  7366. if (!this._isTextHighlightOn) {
  7367. if (this._cursorOffset === 0) {
  7368. return;
  7369. }
  7370. else {
  7371. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7372. }
  7373. }
  7374. this._endHighlightIndex = this._text.length;
  7375. this._isTextHighlightOn = true;
  7376. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7377. this._cursorOffset = 0;
  7378. this._markAsDirty();
  7379. return;
  7380. }
  7381. if (!this._isTextHighlightOn) {
  7382. this._isTextHighlightOn = true;
  7383. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7384. }
  7385. //if text is already highlighted
  7386. else if (this._cursorIndex === -1) {
  7387. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7388. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7389. }
  7390. //set the highlight indexes
  7391. if (this._cursorIndex < this._cursorOffset) {
  7392. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7393. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7394. }
  7395. else if (this._cursorIndex > this._cursorOffset) {
  7396. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7397. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7398. }
  7399. else {
  7400. this._isTextHighlightOn = false;
  7401. }
  7402. this._markAsDirty();
  7403. return;
  7404. }
  7405. if (this._isTextHighlightOn) {
  7406. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7407. this._isTextHighlightOn = false;
  7408. }
  7409. //ctr + ->
  7410. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7411. this._cursorOffset = 0;
  7412. evt.preventDefault();
  7413. }
  7414. this._blinkIsEven = false;
  7415. this._isTextHighlightOn = false;
  7416. this._cursorIndex = -1;
  7417. this._markAsDirty();
  7418. return;
  7419. case 222: // Dead
  7420. if (evt) {
  7421. evt.preventDefault();
  7422. }
  7423. this._cursorIndex = -1;
  7424. this.deadKey = true;
  7425. break;
  7426. }
  7427. // Printable characters
  7428. if (key &&
  7429. ((keyCode === -1) || // Direct access
  7430. (keyCode === 32) || // Space
  7431. (keyCode > 47 && keyCode < 64) || // Numbers
  7432. (keyCode > 64 && keyCode < 91) || // Letters
  7433. (keyCode > 159 && keyCode < 193) || // Special characters
  7434. (keyCode > 218 && keyCode < 223) || // Special characters
  7435. (keyCode > 95 && keyCode < 112))) { // Numpad
  7436. this._currentKey = key;
  7437. this.onBeforeKeyAddObservable.notifyObservers(this);
  7438. key = this._currentKey;
  7439. if (this._addKey) {
  7440. if (this._isTextHighlightOn) {
  7441. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7442. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7443. this._isTextHighlightOn = false;
  7444. this._blinkIsEven = false;
  7445. this._markAsDirty();
  7446. }
  7447. else if (this._cursorOffset === 0) {
  7448. this.text += key;
  7449. }
  7450. else {
  7451. var insertPosition = this._text.length - this._cursorOffset;
  7452. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7453. }
  7454. }
  7455. }
  7456. };
  7457. /** @hidden */
  7458. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7459. //update the cursor
  7460. this._blinkIsEven = false;
  7461. if (this._cursorIndex === -1) {
  7462. this._cursorIndex = offset;
  7463. }
  7464. else {
  7465. if (this._cursorIndex < this._cursorOffset) {
  7466. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7467. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7468. }
  7469. else if (this._cursorIndex > this._cursorOffset) {
  7470. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7471. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7472. }
  7473. else {
  7474. this._isTextHighlightOn = false;
  7475. this._markAsDirty();
  7476. return;
  7477. }
  7478. }
  7479. this._isTextHighlightOn = true;
  7480. this._markAsDirty();
  7481. };
  7482. /** @hidden */
  7483. InputText.prototype._processDblClick = function (evt) {
  7484. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7485. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7486. this._endHighlightIndex = this._startHighlightIndex;
  7487. var rWord = /\w+/g, moveLeft, moveRight;
  7488. do {
  7489. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7490. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7491. } while (moveLeft || moveRight);
  7492. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7493. this.onTextHighlightObservable.notifyObservers(this);
  7494. this._isTextHighlightOn = true;
  7495. this._clickedCoordinate = null;
  7496. this._blinkIsEven = true;
  7497. this._cursorIndex = -1;
  7498. this._markAsDirty();
  7499. };
  7500. /** @hidden */
  7501. InputText.prototype._selectAllText = function () {
  7502. this._blinkIsEven = true;
  7503. this._isTextHighlightOn = true;
  7504. this._startHighlightIndex = 0;
  7505. this._endHighlightIndex = this._text.length;
  7506. this._cursorOffset = this._text.length;
  7507. this._cursorIndex = -1;
  7508. this._markAsDirty();
  7509. };
  7510. /**
  7511. * Handles the keyboard event
  7512. * @param evt Defines the KeyboardEvent
  7513. */
  7514. InputText.prototype.processKeyboard = function (evt) {
  7515. // process pressed key
  7516. this.processKey(evt.keyCode, evt.key, evt);
  7517. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7518. };
  7519. /** @hidden */
  7520. InputText.prototype._onCopyText = function (ev) {
  7521. this._isTextHighlightOn = false;
  7522. //when write permission to clipbaord data is denied
  7523. try {
  7524. ev.clipboardData.setData("text/plain", this._highlightedText);
  7525. }
  7526. catch (_a) { } //pass
  7527. this._host.clipboardData = this._highlightedText;
  7528. };
  7529. /** @hidden */
  7530. InputText.prototype._onCutText = function (ev) {
  7531. if (!this._highlightedText) {
  7532. return;
  7533. }
  7534. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7535. this._isTextHighlightOn = false;
  7536. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7537. //when write permission to clipbaord data is denied
  7538. try {
  7539. ev.clipboardData.setData("text/plain", this._highlightedText);
  7540. }
  7541. catch (_a) { } //pass
  7542. this._host.clipboardData = this._highlightedText;
  7543. this._highlightedText = "";
  7544. };
  7545. /** @hidden */
  7546. InputText.prototype._onPasteText = function (ev) {
  7547. var data = "";
  7548. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7549. data = ev.clipboardData.getData("text/plain");
  7550. }
  7551. else {
  7552. //get the cached data; returns blank string by default
  7553. data = this._host.clipboardData;
  7554. }
  7555. var insertPosition = this._text.length - this._cursorOffset;
  7556. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7557. };
  7558. InputText.prototype._draw = function (context) {
  7559. var _this = this;
  7560. context.save();
  7561. this._applyStates(context);
  7562. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7563. context.shadowColor = this.shadowColor;
  7564. context.shadowBlur = this.shadowBlur;
  7565. context.shadowOffsetX = this.shadowOffsetX;
  7566. context.shadowOffsetY = this.shadowOffsetY;
  7567. }
  7568. // Background
  7569. if (this._isFocused) {
  7570. if (this._focusedBackground) {
  7571. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7572. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7573. }
  7574. }
  7575. else if (this._background) {
  7576. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7577. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7578. }
  7579. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7580. context.shadowBlur = 0;
  7581. context.shadowOffsetX = 0;
  7582. context.shadowOffsetY = 0;
  7583. }
  7584. if (!this._fontOffset) {
  7585. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7586. }
  7587. // Text
  7588. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7589. if (this.color) {
  7590. context.fillStyle = this.color;
  7591. }
  7592. var text = this._beforeRenderText(this._text);
  7593. if (!this._isFocused && !this._text && this._placeholderText) {
  7594. text = this._placeholderText;
  7595. if (this._placeholderColor) {
  7596. context.fillStyle = this._placeholderColor;
  7597. }
  7598. }
  7599. this._textWidth = context.measureText(text).width;
  7600. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7601. if (this._autoStretchWidth) {
  7602. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7603. }
  7604. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7605. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7606. context.save();
  7607. context.beginPath();
  7608. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7609. context.clip();
  7610. if (this._isFocused && this._textWidth > availableWidth) {
  7611. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7612. if (!this._scrollLeft) {
  7613. this._scrollLeft = textLeft;
  7614. }
  7615. }
  7616. else {
  7617. this._scrollLeft = clipTextLeft;
  7618. }
  7619. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7620. // Cursor
  7621. if (this._isFocused) {
  7622. // Need to move cursor
  7623. if (this._clickedCoordinate) {
  7624. var rightPosition = this._scrollLeft + this._textWidth;
  7625. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7626. var currentSize = 0;
  7627. this._cursorOffset = 0;
  7628. var previousDist = 0;
  7629. do {
  7630. if (this._cursorOffset) {
  7631. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7632. }
  7633. this._cursorOffset++;
  7634. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7635. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7636. // Find closest move
  7637. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7638. this._cursorOffset--;
  7639. }
  7640. this._blinkIsEven = false;
  7641. this._clickedCoordinate = null;
  7642. }
  7643. // Render cursor
  7644. if (!this._blinkIsEven) {
  7645. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7646. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7647. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7648. if (cursorLeft < clipTextLeft) {
  7649. this._scrollLeft += (clipTextLeft - cursorLeft);
  7650. cursorLeft = clipTextLeft;
  7651. this._markAsDirty();
  7652. }
  7653. else if (cursorLeft > clipTextLeft + availableWidth) {
  7654. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7655. cursorLeft = clipTextLeft + availableWidth;
  7656. this._markAsDirty();
  7657. }
  7658. if (!this._isTextHighlightOn) {
  7659. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7660. }
  7661. }
  7662. clearTimeout(this._blinkTimeout);
  7663. this._blinkTimeout = setTimeout(function () {
  7664. _this._blinkIsEven = !_this._blinkIsEven;
  7665. _this._markAsDirty();
  7666. }, 500);
  7667. //show the highlighted text
  7668. if (this._isTextHighlightOn) {
  7669. clearTimeout(this._blinkTimeout);
  7670. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7671. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7672. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7673. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7674. if (highlightCursorLeft < clipTextLeft) {
  7675. width = width - (clipTextLeft - highlightCursorLeft);
  7676. if (!width) {
  7677. // when using left arrow on text.length > availableWidth;
  7678. // assigns the width of the first letter after clipTextLeft
  7679. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7680. }
  7681. highlightCursorLeft = clipTextLeft;
  7682. }
  7683. //for transparancy
  7684. context.globalAlpha = this._highligherOpacity;
  7685. context.fillStyle = this._textHighlightColor;
  7686. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7687. context.globalAlpha = 1.0;
  7688. }
  7689. }
  7690. context.restore();
  7691. // Border
  7692. if (this._thickness) {
  7693. if (this._isFocused) {
  7694. if (this.focusedColor) {
  7695. context.strokeStyle = this.focusedColor;
  7696. }
  7697. }
  7698. else {
  7699. if (this.color) {
  7700. context.strokeStyle = this.color;
  7701. }
  7702. }
  7703. context.lineWidth = this._thickness;
  7704. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7705. }
  7706. context.restore();
  7707. };
  7708. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7709. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7710. return false;
  7711. }
  7712. this._clickedCoordinate = coordinates.x;
  7713. this._isTextHighlightOn = false;
  7714. this._highlightedText = "";
  7715. this._cursorIndex = -1;
  7716. this._isPointerDown = true;
  7717. this._host._capturingControl[pointerId] = this;
  7718. if (this._host.focusedControl === this) {
  7719. // Move cursor
  7720. clearTimeout(this._blinkTimeout);
  7721. this._markAsDirty();
  7722. return true;
  7723. }
  7724. if (!this._isEnabled) {
  7725. return false;
  7726. }
  7727. this._host.focusedControl = this;
  7728. return true;
  7729. };
  7730. InputText.prototype._onPointerMove = function (target, coordinates) {
  7731. if (this._host.focusedControl === this && this._isPointerDown) {
  7732. this._clickedCoordinate = coordinates.x;
  7733. this._markAsDirty();
  7734. this._updateValueFromCursorIndex(this._cursorOffset);
  7735. }
  7736. _super.prototype._onPointerMove.call(this, target, coordinates);
  7737. };
  7738. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7739. this._isPointerDown = false;
  7740. delete this._host._capturingControl[pointerId];
  7741. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7742. };
  7743. InputText.prototype._beforeRenderText = function (text) {
  7744. return text;
  7745. };
  7746. InputText.prototype.dispose = function () {
  7747. _super.prototype.dispose.call(this);
  7748. this.onBlurObservable.clear();
  7749. this.onFocusObservable.clear();
  7750. this.onTextChangedObservable.clear();
  7751. this.onTextCopyObservable.clear();
  7752. this.onTextCutObservable.clear();
  7753. this.onTextPasteObservable.clear();
  7754. this.onTextHighlightObservable.clear();
  7755. this.onKeyboardEventProcessedObservable.clear();
  7756. };
  7757. return InputText;
  7758. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7759. /***/ }),
  7760. /***/ "./2D/controls/line.ts":
  7761. /*!*****************************!*\
  7762. !*** ./2D/controls/line.ts ***!
  7763. \*****************************/
  7764. /*! exports provided: Line */
  7765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7766. "use strict";
  7767. __webpack_require__.r(__webpack_exports__);
  7768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7769. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7770. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  7771. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7772. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7773. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7774. /** Class used to render 2D lines */
  7775. var Line = /** @class */ (function (_super) {
  7776. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7777. /**
  7778. * Creates a new Line
  7779. * @param name defines the control name
  7780. */
  7781. function Line(name) {
  7782. var _this = _super.call(this, name) || this;
  7783. _this.name = name;
  7784. _this._lineWidth = 1;
  7785. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7786. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7787. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7788. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7789. _this._dash = new Array();
  7790. _this.isHitTestVisible = false;
  7791. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7792. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7793. return _this;
  7794. }
  7795. Object.defineProperty(Line.prototype, "dash", {
  7796. /** Gets or sets the dash pattern */
  7797. get: function () {
  7798. return this._dash;
  7799. },
  7800. set: function (value) {
  7801. if (this._dash === value) {
  7802. return;
  7803. }
  7804. this._dash = value;
  7805. this._markAsDirty();
  7806. },
  7807. enumerable: true,
  7808. configurable: true
  7809. });
  7810. Object.defineProperty(Line.prototype, "connectedControl", {
  7811. /** Gets or sets the control connected with the line end */
  7812. get: function () {
  7813. return this._connectedControl;
  7814. },
  7815. set: function (value) {
  7816. var _this = this;
  7817. if (this._connectedControl === value) {
  7818. return;
  7819. }
  7820. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7821. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7822. this._connectedControlDirtyObserver = null;
  7823. }
  7824. if (value) {
  7825. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7826. }
  7827. this._connectedControl = value;
  7828. this._markAsDirty();
  7829. },
  7830. enumerable: true,
  7831. configurable: true
  7832. });
  7833. Object.defineProperty(Line.prototype, "x1", {
  7834. /** Gets or sets start coordinates on X axis */
  7835. get: function () {
  7836. return this._x1.toString(this._host);
  7837. },
  7838. set: function (value) {
  7839. if (this._x1.toString(this._host) === value) {
  7840. return;
  7841. }
  7842. if (this._x1.fromString(value)) {
  7843. this._markAsDirty();
  7844. }
  7845. },
  7846. enumerable: true,
  7847. configurable: true
  7848. });
  7849. Object.defineProperty(Line.prototype, "y1", {
  7850. /** Gets or sets start coordinates on Y axis */
  7851. get: function () {
  7852. return this._y1.toString(this._host);
  7853. },
  7854. set: function (value) {
  7855. if (this._y1.toString(this._host) === value) {
  7856. return;
  7857. }
  7858. if (this._y1.fromString(value)) {
  7859. this._markAsDirty();
  7860. }
  7861. },
  7862. enumerable: true,
  7863. configurable: true
  7864. });
  7865. Object.defineProperty(Line.prototype, "x2", {
  7866. /** Gets or sets end coordinates on X axis */
  7867. get: function () {
  7868. return this._x2.toString(this._host);
  7869. },
  7870. set: function (value) {
  7871. if (this._x2.toString(this._host) === value) {
  7872. return;
  7873. }
  7874. if (this._x2.fromString(value)) {
  7875. this._markAsDirty();
  7876. }
  7877. },
  7878. enumerable: true,
  7879. configurable: true
  7880. });
  7881. Object.defineProperty(Line.prototype, "y2", {
  7882. /** Gets or sets end coordinates on Y axis */
  7883. get: function () {
  7884. return this._y2.toString(this._host);
  7885. },
  7886. set: function (value) {
  7887. if (this._y2.toString(this._host) === value) {
  7888. return;
  7889. }
  7890. if (this._y2.fromString(value)) {
  7891. this._markAsDirty();
  7892. }
  7893. },
  7894. enumerable: true,
  7895. configurable: true
  7896. });
  7897. Object.defineProperty(Line.prototype, "lineWidth", {
  7898. /** Gets or sets line width */
  7899. get: function () {
  7900. return this._lineWidth;
  7901. },
  7902. set: function (value) {
  7903. if (this._lineWidth === value) {
  7904. return;
  7905. }
  7906. this._lineWidth = value;
  7907. this._markAsDirty();
  7908. },
  7909. enumerable: true,
  7910. configurable: true
  7911. });
  7912. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7913. /** Gets or sets horizontal alignment */
  7914. set: function (value) {
  7915. return;
  7916. },
  7917. enumerable: true,
  7918. configurable: true
  7919. });
  7920. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7921. /** Gets or sets vertical alignment */
  7922. set: function (value) {
  7923. return;
  7924. },
  7925. enumerable: true,
  7926. configurable: true
  7927. });
  7928. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7929. get: function () {
  7930. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7931. },
  7932. enumerable: true,
  7933. configurable: true
  7934. });
  7935. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7936. get: function () {
  7937. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7938. },
  7939. enumerable: true,
  7940. configurable: true
  7941. });
  7942. Line.prototype._getTypeName = function () {
  7943. return "Line";
  7944. };
  7945. Line.prototype._draw = function (context) {
  7946. context.save();
  7947. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7948. context.shadowColor = this.shadowColor;
  7949. context.shadowBlur = this.shadowBlur;
  7950. context.shadowOffsetX = this.shadowOffsetX;
  7951. context.shadowOffsetY = this.shadowOffsetY;
  7952. }
  7953. this._applyStates(context);
  7954. context.strokeStyle = this.color;
  7955. context.lineWidth = this._lineWidth;
  7956. context.setLineDash(this._dash);
  7957. context.beginPath();
  7958. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.left + this._y1.getValue(this._host));
  7959. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.left + this._effectiveY2);
  7960. context.stroke();
  7961. context.restore();
  7962. };
  7963. Line.prototype._measure = function () {
  7964. // Width / Height
  7965. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7966. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7967. };
  7968. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7969. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7970. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7971. };
  7972. /**
  7973. * Move one end of the line given 3D cartesian coordinates.
  7974. * @param position Targeted world position
  7975. * @param scene Scene
  7976. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7977. */
  7978. Line.prototype.moveToVector3 = function (position, scene, end) {
  7979. if (end === void 0) { end = false; }
  7980. if (!this._host || this.parent !== this._host._rootContainer) {
  7981. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  7982. return;
  7983. }
  7984. var globalViewport = this._host._getGlobalViewport(scene);
  7985. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  7986. this._moveToProjectedPosition(projectedPosition, end);
  7987. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  7988. this.notRenderable = true;
  7989. return;
  7990. }
  7991. this.notRenderable = false;
  7992. };
  7993. /**
  7994. * Move one end of the line to a position in screen absolute space.
  7995. * @param projectedPosition Position in screen absolute space (X, Y)
  7996. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7997. */
  7998. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  7999. if (end === void 0) { end = false; }
  8000. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8001. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8002. if (end) {
  8003. this.x2 = x;
  8004. this.y2 = y;
  8005. this._x2.ignoreAdaptiveScaling = true;
  8006. this._y2.ignoreAdaptiveScaling = true;
  8007. }
  8008. else {
  8009. this.x1 = x;
  8010. this.y1 = y;
  8011. this._x1.ignoreAdaptiveScaling = true;
  8012. this._y1.ignoreAdaptiveScaling = true;
  8013. }
  8014. };
  8015. return Line;
  8016. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8017. /***/ }),
  8018. /***/ "./2D/controls/multiLine.ts":
  8019. /*!**********************************!*\
  8020. !*** ./2D/controls/multiLine.ts ***!
  8021. \**********************************/
  8022. /*! exports provided: MultiLine */
  8023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8024. "use strict";
  8025. __webpack_require__.r(__webpack_exports__);
  8026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8027. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8028. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/tools");
  8029. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8030. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8031. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8032. /**
  8033. * Class used to create multi line control
  8034. */
  8035. var MultiLine = /** @class */ (function (_super) {
  8036. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8037. /**
  8038. * Creates a new MultiLine
  8039. * @param name defines the control name
  8040. */
  8041. function MultiLine(name) {
  8042. var _this = _super.call(this, name) || this;
  8043. _this.name = name;
  8044. _this._lineWidth = 1;
  8045. /** Function called when a point is updated */
  8046. _this.onPointUpdate = function () {
  8047. _this._markAsDirty();
  8048. };
  8049. _this.isHitTestVisible = false;
  8050. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8051. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8052. _this._dash = [];
  8053. _this._points = [];
  8054. return _this;
  8055. }
  8056. Object.defineProperty(MultiLine.prototype, "dash", {
  8057. /** Gets or sets dash pattern */
  8058. get: function () {
  8059. return this._dash;
  8060. },
  8061. set: function (value) {
  8062. if (this._dash === value) {
  8063. return;
  8064. }
  8065. this._dash = value;
  8066. this._markAsDirty();
  8067. },
  8068. enumerable: true,
  8069. configurable: true
  8070. });
  8071. /**
  8072. * Gets point stored at specified index
  8073. * @param index defines the index to look for
  8074. * @returns the requested point if found
  8075. */
  8076. MultiLine.prototype.getAt = function (index) {
  8077. if (!this._points[index]) {
  8078. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8079. }
  8080. return this._points[index];
  8081. };
  8082. /**
  8083. * Adds new points to the point collection
  8084. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8085. * @returns the list of created MultiLinePoint
  8086. */
  8087. MultiLine.prototype.add = function () {
  8088. var _this = this;
  8089. var items = [];
  8090. for (var _i = 0; _i < arguments.length; _i++) {
  8091. items[_i] = arguments[_i];
  8092. }
  8093. return items.map(function (item) { return _this.push(item); });
  8094. };
  8095. /**
  8096. * Adds a new point to the point collection
  8097. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8098. * @returns the created MultiLinePoint
  8099. */
  8100. MultiLine.prototype.push = function (item) {
  8101. var point = this.getAt(this._points.length);
  8102. if (item == null) {
  8103. return point;
  8104. }
  8105. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8106. point.mesh = item;
  8107. }
  8108. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8109. point.control = item;
  8110. }
  8111. else if (item.x != null && item.y != null) {
  8112. point.x = item.x;
  8113. point.y = item.y;
  8114. }
  8115. return point;
  8116. };
  8117. /**
  8118. * Remove a specific value or point from the active point collection
  8119. * @param value defines the value or point to remove
  8120. */
  8121. MultiLine.prototype.remove = function (value) {
  8122. var index;
  8123. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8124. index = this._points.indexOf(value);
  8125. if (index === -1) {
  8126. return;
  8127. }
  8128. }
  8129. else {
  8130. index = value;
  8131. }
  8132. var point = this._points[index];
  8133. if (!point) {
  8134. return;
  8135. }
  8136. point.dispose();
  8137. this._points.splice(index, 1);
  8138. };
  8139. /**
  8140. * Resets this object to initial state (no point)
  8141. */
  8142. MultiLine.prototype.reset = function () {
  8143. while (this._points.length > 0) {
  8144. this.remove(this._points.length - 1);
  8145. }
  8146. };
  8147. /**
  8148. * Resets all links
  8149. */
  8150. MultiLine.prototype.resetLinks = function () {
  8151. this._points.forEach(function (point) {
  8152. if (point != null) {
  8153. point.resetLinks();
  8154. }
  8155. });
  8156. };
  8157. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8158. /** Gets or sets line width */
  8159. get: function () {
  8160. return this._lineWidth;
  8161. },
  8162. set: function (value) {
  8163. if (this._lineWidth === value) {
  8164. return;
  8165. }
  8166. this._lineWidth = value;
  8167. this._markAsDirty();
  8168. },
  8169. enumerable: true,
  8170. configurable: true
  8171. });
  8172. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8173. set: function (value) {
  8174. return;
  8175. },
  8176. enumerable: true,
  8177. configurable: true
  8178. });
  8179. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8180. set: function (value) {
  8181. return;
  8182. },
  8183. enumerable: true,
  8184. configurable: true
  8185. });
  8186. MultiLine.prototype._getTypeName = function () {
  8187. return "MultiLine";
  8188. };
  8189. MultiLine.prototype._draw = function (context) {
  8190. context.save();
  8191. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8192. context.shadowColor = this.shadowColor;
  8193. context.shadowBlur = this.shadowBlur;
  8194. context.shadowOffsetX = this.shadowOffsetX;
  8195. context.shadowOffsetY = this.shadowOffsetY;
  8196. }
  8197. this._applyStates(context);
  8198. context.strokeStyle = this.color;
  8199. context.lineWidth = this._lineWidth;
  8200. context.setLineDash(this._dash);
  8201. context.beginPath();
  8202. var first = true; //first index is not necessarily 0
  8203. this._points.forEach(function (point) {
  8204. if (!point) {
  8205. return;
  8206. }
  8207. if (first) {
  8208. context.moveTo(point._point.x, point._point.y);
  8209. first = false;
  8210. }
  8211. else {
  8212. context.lineTo(point._point.x, point._point.y);
  8213. }
  8214. });
  8215. context.stroke();
  8216. context.restore();
  8217. };
  8218. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8219. var _this = this;
  8220. this._minX = null;
  8221. this._minY = null;
  8222. this._maxX = null;
  8223. this._maxY = null;
  8224. this._points.forEach(function (point, index) {
  8225. if (!point) {
  8226. return;
  8227. }
  8228. point.translate();
  8229. if (_this._minX == null || point._point.x < _this._minX) {
  8230. _this._minX = point._point.x;
  8231. }
  8232. if (_this._minY == null || point._point.y < _this._minY) {
  8233. _this._minY = point._point.y;
  8234. }
  8235. if (_this._maxX == null || point._point.x > _this._maxX) {
  8236. _this._maxX = point._point.x;
  8237. }
  8238. if (_this._maxY == null || point._point.y > _this._maxY) {
  8239. _this._maxY = point._point.y;
  8240. }
  8241. });
  8242. if (this._minX == null) {
  8243. this._minX = 0;
  8244. }
  8245. if (this._minY == null) {
  8246. this._minY = 0;
  8247. }
  8248. if (this._maxX == null) {
  8249. this._maxX = 0;
  8250. }
  8251. if (this._maxY == null) {
  8252. this._maxY = 0;
  8253. }
  8254. };
  8255. MultiLine.prototype._measure = function () {
  8256. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8257. return;
  8258. }
  8259. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8260. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8261. };
  8262. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8263. if (this._minX == null || this._minY == null) {
  8264. return;
  8265. }
  8266. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8267. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8268. };
  8269. MultiLine.prototype.dispose = function () {
  8270. this.reset();
  8271. _super.prototype.dispose.call(this);
  8272. };
  8273. return MultiLine;
  8274. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8275. /***/ }),
  8276. /***/ "./2D/controls/radioButton.ts":
  8277. /*!************************************!*\
  8278. !*** ./2D/controls/radioButton.ts ***!
  8279. \************************************/
  8280. /*! exports provided: RadioButton */
  8281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8282. "use strict";
  8283. __webpack_require__.r(__webpack_exports__);
  8284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8285. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8286. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  8287. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8288. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8289. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8290. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8291. /**
  8292. * Class used to create radio button controls
  8293. */
  8294. var RadioButton = /** @class */ (function (_super) {
  8295. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8296. /**
  8297. * Creates a new RadioButton
  8298. * @param name defines the control name
  8299. */
  8300. function RadioButton(name) {
  8301. var _this = _super.call(this, name) || this;
  8302. _this.name = name;
  8303. _this._isChecked = false;
  8304. _this._background = "black";
  8305. _this._checkSizeRatio = 0.8;
  8306. _this._thickness = 1;
  8307. /** Gets or sets group name */
  8308. _this.group = "";
  8309. /** Observable raised when isChecked is changed */
  8310. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8311. _this.isPointerBlocker = true;
  8312. return _this;
  8313. }
  8314. Object.defineProperty(RadioButton.prototype, "thickness", {
  8315. /** Gets or sets border thickness */
  8316. get: function () {
  8317. return this._thickness;
  8318. },
  8319. set: function (value) {
  8320. if (this._thickness === value) {
  8321. return;
  8322. }
  8323. this._thickness = value;
  8324. this._markAsDirty();
  8325. },
  8326. enumerable: true,
  8327. configurable: true
  8328. });
  8329. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8330. /** Gets or sets a value indicating the ratio between overall size and check size */
  8331. get: function () {
  8332. return this._checkSizeRatio;
  8333. },
  8334. set: function (value) {
  8335. value = Math.max(Math.min(1, value), 0);
  8336. if (this._checkSizeRatio === value) {
  8337. return;
  8338. }
  8339. this._checkSizeRatio = value;
  8340. this._markAsDirty();
  8341. },
  8342. enumerable: true,
  8343. configurable: true
  8344. });
  8345. Object.defineProperty(RadioButton.prototype, "background", {
  8346. /** Gets or sets background color */
  8347. get: function () {
  8348. return this._background;
  8349. },
  8350. set: function (value) {
  8351. if (this._background === value) {
  8352. return;
  8353. }
  8354. this._background = value;
  8355. this._markAsDirty();
  8356. },
  8357. enumerable: true,
  8358. configurable: true
  8359. });
  8360. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8361. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8362. get: function () {
  8363. return this._isChecked;
  8364. },
  8365. set: function (value) {
  8366. var _this = this;
  8367. if (this._isChecked === value) {
  8368. return;
  8369. }
  8370. this._isChecked = value;
  8371. this._markAsDirty();
  8372. this.onIsCheckedChangedObservable.notifyObservers(value);
  8373. if (this._isChecked && this._host) {
  8374. // Update all controls from same group
  8375. this._host.executeOnAllControls(function (control) {
  8376. if (control === _this) {
  8377. return;
  8378. }
  8379. if (control.group === undefined) {
  8380. return;
  8381. }
  8382. var childRadio = control;
  8383. if (childRadio.group === _this.group) {
  8384. childRadio.isChecked = false;
  8385. }
  8386. });
  8387. }
  8388. },
  8389. enumerable: true,
  8390. configurable: true
  8391. });
  8392. RadioButton.prototype._getTypeName = function () {
  8393. return "RadioButton";
  8394. };
  8395. RadioButton.prototype._draw = function (context) {
  8396. context.save();
  8397. this._applyStates(context);
  8398. var actualWidth = this._currentMeasure.width - this._thickness;
  8399. var actualHeight = this._currentMeasure.height - this._thickness;
  8400. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8401. context.shadowColor = this.shadowColor;
  8402. context.shadowBlur = this.shadowBlur;
  8403. context.shadowOffsetX = this.shadowOffsetX;
  8404. context.shadowOffsetY = this.shadowOffsetY;
  8405. }
  8406. // Outer
  8407. _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);
  8408. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8409. context.fill();
  8410. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8411. context.shadowBlur = 0;
  8412. context.shadowOffsetX = 0;
  8413. context.shadowOffsetY = 0;
  8414. }
  8415. context.strokeStyle = this.color;
  8416. context.lineWidth = this._thickness;
  8417. context.stroke();
  8418. // Inner
  8419. if (this._isChecked) {
  8420. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8421. var offsetWidth = actualWidth * this._checkSizeRatio;
  8422. var offseHeight = actualHeight * this._checkSizeRatio;
  8423. _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);
  8424. context.fill();
  8425. }
  8426. context.restore();
  8427. };
  8428. // Events
  8429. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8430. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8431. return false;
  8432. }
  8433. if (!this.isChecked) {
  8434. this.isChecked = true;
  8435. }
  8436. return true;
  8437. };
  8438. /**
  8439. * Utility function to easily create a radio button with a header
  8440. * @param title defines the label to use for the header
  8441. * @param group defines the group to use for the radio button
  8442. * @param isChecked defines the initial state of the radio button
  8443. * @param onValueChanged defines the callback to call when value changes
  8444. * @returns a StackPanel containing the radio button and a textBlock
  8445. */
  8446. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8447. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8448. panel.isVertical = false;
  8449. panel.height = "30px";
  8450. var radio = new RadioButton();
  8451. radio.width = "20px";
  8452. radio.height = "20px";
  8453. radio.isChecked = isChecked;
  8454. radio.color = "green";
  8455. radio.group = group;
  8456. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8457. panel.addControl(radio);
  8458. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8459. header.text = title;
  8460. header.width = "180px";
  8461. header.paddingLeft = "5px";
  8462. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8463. header.color = "white";
  8464. panel.addControl(header);
  8465. return panel;
  8466. };
  8467. return RadioButton;
  8468. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8469. /***/ }),
  8470. /***/ "./2D/controls/rectangle.ts":
  8471. /*!**********************************!*\
  8472. !*** ./2D/controls/rectangle.ts ***!
  8473. \**********************************/
  8474. /*! exports provided: Rectangle */
  8475. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8476. "use strict";
  8477. __webpack_require__.r(__webpack_exports__);
  8478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8479. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8480. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8481. /** Class used to create rectangle container */
  8482. var Rectangle = /** @class */ (function (_super) {
  8483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8484. /**
  8485. * Creates a new Rectangle
  8486. * @param name defines the control name
  8487. */
  8488. function Rectangle(name) {
  8489. var _this = _super.call(this, name) || this;
  8490. _this.name = name;
  8491. _this._thickness = 1;
  8492. _this._cornerRadius = 0;
  8493. return _this;
  8494. }
  8495. Object.defineProperty(Rectangle.prototype, "thickness", {
  8496. /** Gets or sets border thickness */
  8497. get: function () {
  8498. return this._thickness;
  8499. },
  8500. set: function (value) {
  8501. if (this._thickness === value) {
  8502. return;
  8503. }
  8504. this._thickness = value;
  8505. this._markAsDirty();
  8506. },
  8507. enumerable: true,
  8508. configurable: true
  8509. });
  8510. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8511. /** Gets or sets the corner radius angle */
  8512. get: function () {
  8513. return this._cornerRadius;
  8514. },
  8515. set: function (value) {
  8516. if (value < 0) {
  8517. value = 0;
  8518. }
  8519. if (this._cornerRadius === value) {
  8520. return;
  8521. }
  8522. this._cornerRadius = value;
  8523. this._markAsDirty();
  8524. },
  8525. enumerable: true,
  8526. configurable: true
  8527. });
  8528. Rectangle.prototype._getTypeName = function () {
  8529. return "Rectangle";
  8530. };
  8531. Rectangle.prototype._localDraw = function (context) {
  8532. context.save();
  8533. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8534. context.shadowColor = this.shadowColor;
  8535. context.shadowBlur = this.shadowBlur;
  8536. context.shadowOffsetX = this.shadowOffsetX;
  8537. context.shadowOffsetY = this.shadowOffsetY;
  8538. }
  8539. if (this._background) {
  8540. context.fillStyle = this._background;
  8541. if (this._cornerRadius) {
  8542. this._drawRoundedRect(context, this._thickness / 2);
  8543. context.fill();
  8544. }
  8545. else {
  8546. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8547. }
  8548. }
  8549. if (this._thickness) {
  8550. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8551. context.shadowBlur = 0;
  8552. context.shadowOffsetX = 0;
  8553. context.shadowOffsetY = 0;
  8554. }
  8555. if (this.color) {
  8556. context.strokeStyle = this.color;
  8557. }
  8558. context.lineWidth = this._thickness;
  8559. if (this._cornerRadius) {
  8560. this._drawRoundedRect(context, this._thickness / 2);
  8561. context.stroke();
  8562. }
  8563. else {
  8564. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8565. }
  8566. }
  8567. context.restore();
  8568. };
  8569. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8570. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8571. this._measureForChildren.width -= 2 * this._thickness;
  8572. this._measureForChildren.height -= 2 * this._thickness;
  8573. this._measureForChildren.left += this._thickness;
  8574. this._measureForChildren.top += this._thickness;
  8575. };
  8576. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8577. if (offset === void 0) { offset = 0; }
  8578. var x = this._currentMeasure.left + offset;
  8579. var y = this._currentMeasure.top + offset;
  8580. var width = this._currentMeasure.width - offset * 2;
  8581. var height = this._currentMeasure.height - offset * 2;
  8582. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8583. context.beginPath();
  8584. context.moveTo(x + radius, y);
  8585. context.lineTo(x + width - radius, y);
  8586. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8587. context.lineTo(x + width, y + height - radius);
  8588. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8589. context.lineTo(x + radius, y + height);
  8590. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8591. context.lineTo(x, y + radius);
  8592. context.quadraticCurveTo(x, y, x + radius, y);
  8593. context.closePath();
  8594. };
  8595. Rectangle.prototype._clipForChildren = function (context) {
  8596. if (this._cornerRadius) {
  8597. this._drawRoundedRect(context, this._thickness);
  8598. context.clip();
  8599. }
  8600. };
  8601. return Rectangle;
  8602. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8603. /***/ }),
  8604. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8605. /*!***************************************************!*\
  8606. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8607. \***************************************************/
  8608. /*! exports provided: ScrollViewer */
  8609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8610. "use strict";
  8611. __webpack_require__.r(__webpack_exports__);
  8612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8613. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8614. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/tools");
  8615. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8616. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8617. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8618. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8619. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8620. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8621. /**
  8622. * Class used to hold a viewer window and sliders in a grid
  8623. */
  8624. var ScrollViewer = /** @class */ (function (_super) {
  8625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8626. /**
  8627. * Creates a new ScrollViewer
  8628. * @param name of ScrollViewer
  8629. */
  8630. function ScrollViewer(name) {
  8631. var _this = _super.call(this, name) || this;
  8632. _this._barSize = 20;
  8633. _this._pointerIsOver = false;
  8634. _this._wheelPrecision = 0.05;
  8635. _this.onDirtyObservable.add(function () {
  8636. _this._horizontalBarSpace.color = _this.color;
  8637. _this._verticalBarSpace.color = _this.color;
  8638. _this._dragSpace.color = _this.color;
  8639. });
  8640. _this.onPointerEnterObservable.add(function () {
  8641. _this._pointerIsOver = true;
  8642. });
  8643. _this.onPointerOutObservable.add(function () {
  8644. _this._pointerIsOver = false;
  8645. });
  8646. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8647. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8648. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8649. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8650. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8651. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8652. _this._grid.addColumnDefinition(1);
  8653. _this._grid.addColumnDefinition(0, true);
  8654. _this._grid.addRowDefinition(1);
  8655. _this._grid.addRowDefinition(0, true);
  8656. _super.prototype.addControl.call(_this, _this._grid);
  8657. _this._grid.addControl(_this._window, 0, 0);
  8658. _this._verticalBar.paddingLeft = 0;
  8659. _this._verticalBar.width = "100%";
  8660. _this._verticalBar.height = "100%";
  8661. _this._verticalBar.barOffset = 0;
  8662. _this._verticalBar.value = 0;
  8663. _this._verticalBar.maximum = 1;
  8664. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8665. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8666. _this._verticalBar.isVertical = true;
  8667. _this._verticalBar.rotation = Math.PI;
  8668. _this._verticalBar.isVisible = false;
  8669. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8670. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8671. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8672. _this._verticalBarSpace.thickness = 1;
  8673. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8674. _this._verticalBarSpace.addControl(_this._verticalBar);
  8675. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8676. _this._window.top = value * _this._endTop + "px";
  8677. });
  8678. _this._horizontalBar.paddingLeft = 0;
  8679. _this._horizontalBar.width = "100%";
  8680. _this._horizontalBar.height = "100%";
  8681. _this._horizontalBar.barOffset = 0;
  8682. _this._horizontalBar.value = 0;
  8683. _this._horizontalBar.maximum = 1;
  8684. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8685. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8686. _this._horizontalBar.isVisible = false;
  8687. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8688. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8689. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8690. _this._horizontalBarSpace.thickness = 1;
  8691. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8692. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8693. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8694. _this._window.left = value * _this._endLeft + "px";
  8695. });
  8696. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8697. _this._dragSpace.thickness = 1;
  8698. _this._grid.addControl(_this._dragSpace, 1, 1);
  8699. // Colors
  8700. _this.barColor = "grey";
  8701. _this.barBackground = "transparent";
  8702. return _this;
  8703. }
  8704. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8705. /**
  8706. * Gets the horizontal scrollbar
  8707. */
  8708. get: function () {
  8709. return this._horizontalBar;
  8710. },
  8711. enumerable: true,
  8712. configurable: true
  8713. });
  8714. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8715. /**
  8716. * Gets the vertical scrollbar
  8717. */
  8718. get: function () {
  8719. return this._verticalBar;
  8720. },
  8721. enumerable: true,
  8722. configurable: true
  8723. });
  8724. /**
  8725. * Adds a new control to the current container
  8726. * @param control defines the control to add
  8727. * @returns the current container
  8728. */
  8729. ScrollViewer.prototype.addControl = function (control) {
  8730. if (!control) {
  8731. return this;
  8732. }
  8733. this._window.addControl(control);
  8734. return this;
  8735. };
  8736. /**
  8737. * Removes a control from the current container
  8738. * @param control defines the control to remove
  8739. * @returns the current container
  8740. */
  8741. ScrollViewer.prototype.removeControl = function (control) {
  8742. this._window.removeControl(control);
  8743. return this;
  8744. };
  8745. Object.defineProperty(ScrollViewer.prototype, "children", {
  8746. /** Gets the list of children */
  8747. get: function () {
  8748. return this._window.children;
  8749. },
  8750. enumerable: true,
  8751. configurable: true
  8752. });
  8753. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8754. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8755. var child = _a[_i];
  8756. child._markMatrixAsDirty();
  8757. }
  8758. };
  8759. /** Reset the scroll viewer window to initial size */
  8760. ScrollViewer.prototype.resetWindow = function () {
  8761. this._window.width = "100%";
  8762. this._window.height = "100%";
  8763. };
  8764. ScrollViewer.prototype._getTypeName = function () {
  8765. return "ScrollViewer";
  8766. };
  8767. ScrollViewer.prototype._buildClientSizes = function () {
  8768. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8769. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8770. this._clientWidth = this._window.parentClientWidth;
  8771. this._clientHeight = this._window.parentClientHeight;
  8772. };
  8773. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8774. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8775. this._buildClientSizes();
  8776. };
  8777. ScrollViewer.prototype._postMeasure = function () {
  8778. _super.prototype._postMeasure.call(this);
  8779. this._updateScroller();
  8780. };
  8781. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8782. /**
  8783. * Gets or sets the mouse wheel precision
  8784. * from 0 to 1 with a default value of 0.05
  8785. * */
  8786. get: function () {
  8787. return this._wheelPrecision;
  8788. },
  8789. set: function (value) {
  8790. if (this._wheelPrecision === value) {
  8791. return;
  8792. }
  8793. if (value < 0) {
  8794. value = 0;
  8795. }
  8796. if (value > 1) {
  8797. value = 1;
  8798. }
  8799. this._wheelPrecision = value;
  8800. },
  8801. enumerable: true,
  8802. configurable: true
  8803. });
  8804. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8805. /** Gets or sets the bar color */
  8806. get: function () {
  8807. return this._barColor;
  8808. },
  8809. set: function (color) {
  8810. if (this._barColor === color) {
  8811. return;
  8812. }
  8813. this._barColor = color;
  8814. this._horizontalBar.color = color;
  8815. this._verticalBar.color = color;
  8816. },
  8817. enumerable: true,
  8818. configurable: true
  8819. });
  8820. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8821. /** Gets or sets the size of the bar */
  8822. get: function () {
  8823. return this._barSize;
  8824. },
  8825. set: function (value) {
  8826. if (this._barSize === value) {
  8827. return;
  8828. }
  8829. this._barSize = value;
  8830. this._markAsDirty();
  8831. if (this._horizontalBar.isVisible) {
  8832. this._grid.setRowDefinition(1, this._barSize, true);
  8833. }
  8834. if (this._verticalBar.isVisible) {
  8835. this._grid.setColumnDefinition(1, this._barSize, true);
  8836. }
  8837. },
  8838. enumerable: true,
  8839. configurable: true
  8840. });
  8841. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8842. /** Gets or sets the bar background */
  8843. get: function () {
  8844. return this._barBackground;
  8845. },
  8846. set: function (color) {
  8847. if (this._barBackground === color) {
  8848. return;
  8849. }
  8850. this._barBackground = color;
  8851. this._horizontalBar.background = color;
  8852. this._verticalBar.background = color;
  8853. this._dragSpace.background = color;
  8854. },
  8855. enumerable: true,
  8856. configurable: true
  8857. });
  8858. /** @hidden */
  8859. ScrollViewer.prototype._updateScroller = function () {
  8860. var windowContentsWidth = this._window._currentMeasure.width;
  8861. var windowContentsHeight = this._window._currentMeasure.height;
  8862. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8863. this._grid.setRowDefinition(1, 0, true);
  8864. this._horizontalBar.isVisible = false;
  8865. this._horizontalBar.value = 0;
  8866. this._rebuildLayout = true;
  8867. }
  8868. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8869. this._grid.setRowDefinition(1, this._barSize, true);
  8870. this._horizontalBar.isVisible = true;
  8871. this._rebuildLayout = true;
  8872. }
  8873. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8874. this._grid.setColumnDefinition(1, 0, true);
  8875. this._verticalBar.isVisible = false;
  8876. this._verticalBar.value = 0;
  8877. this._rebuildLayout = true;
  8878. }
  8879. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8880. this._grid.setColumnDefinition(1, this._barSize, true);
  8881. this._verticalBar.isVisible = true;
  8882. this._rebuildLayout = true;
  8883. }
  8884. this._buildClientSizes();
  8885. this._endLeft = this._clientWidth - windowContentsWidth;
  8886. this._endTop = this._clientHeight - windowContentsHeight;
  8887. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8888. var newTop = this._verticalBar.value * this._endTop + "px";
  8889. if (newLeft !== this._window.left) {
  8890. this._window.left = newLeft;
  8891. this._rebuildLayout = true;
  8892. }
  8893. if (newTop !== this._window.top) {
  8894. this._window.top = newTop;
  8895. this._rebuildLayout = true;
  8896. }
  8897. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8898. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8899. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8900. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8901. };
  8902. ScrollViewer.prototype._link = function (host) {
  8903. _super.prototype._link.call(this, host);
  8904. this._attachWheel();
  8905. };
  8906. /** @hidden */
  8907. ScrollViewer.prototype._attachWheel = function () {
  8908. var _this = this;
  8909. if (!this._host || this._onPointerObserver) {
  8910. return;
  8911. }
  8912. var scene = this._host.getScene();
  8913. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8914. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8915. return;
  8916. }
  8917. if (_this._verticalBar.isVisible == true) {
  8918. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8919. _this._verticalBar.value -= _this._wheelPrecision;
  8920. }
  8921. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8922. _this._verticalBar.value += _this._wheelPrecision;
  8923. }
  8924. }
  8925. if (_this._horizontalBar.isVisible == true) {
  8926. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8927. _this._horizontalBar.value += _this._wheelPrecision;
  8928. }
  8929. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8930. _this._horizontalBar.value -= _this._wheelPrecision;
  8931. }
  8932. }
  8933. });
  8934. };
  8935. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8936. if (!this.isHighlighted) {
  8937. return;
  8938. }
  8939. _super.prototype._renderHighlightSpecific.call(this, context);
  8940. this._grid._renderHighlightSpecific(context);
  8941. context.restore();
  8942. };
  8943. /** Releases associated resources */
  8944. ScrollViewer.prototype.dispose = function () {
  8945. var scene = this._host.getScene();
  8946. if (scene && this._onPointerObserver) {
  8947. scene.onPointerObservable.remove(this._onPointerObserver);
  8948. this._onPointerObserver = null;
  8949. }
  8950. _super.prototype.dispose.call(this);
  8951. };
  8952. return ScrollViewer;
  8953. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8954. /***/ }),
  8955. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8956. /*!*********************************************************!*\
  8957. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8958. \*********************************************************/
  8959. /*! exports provided: _ScrollViewerWindow */
  8960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8961. "use strict";
  8962. __webpack_require__.r(__webpack_exports__);
  8963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8964. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8965. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8966. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8967. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8968. /**
  8969. * Class used to hold a the container for ScrollViewer
  8970. * @hidden
  8971. */
  8972. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8973. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  8974. /**
  8975. * Creates a new ScrollViewerWindow
  8976. * @param name of ScrollViewerWindow
  8977. */
  8978. function _ScrollViewerWindow(name) {
  8979. return _super.call(this, name) || this;
  8980. }
  8981. _ScrollViewerWindow.prototype._getTypeName = function () {
  8982. return "ScrollViewerWindow";
  8983. };
  8984. /** @hidden */
  8985. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  8986. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8987. this._measureForChildren.left = this._currentMeasure.left;
  8988. this._measureForChildren.top = this._currentMeasure.top;
  8989. this._measureForChildren.width = parentMeasure.width;
  8990. this._measureForChildren.height = parentMeasure.height;
  8991. };
  8992. _ScrollViewerWindow.prototype._postMeasure = function () {
  8993. var maxWidth = this.parentClientWidth;
  8994. var maxHeight = this.parentClientHeight;
  8995. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  8996. var child = _a[_i];
  8997. if (!child.isVisible || child.notRenderable) {
  8998. continue;
  8999. }
  9000. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9001. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9002. }
  9003. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9004. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9005. }
  9006. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9007. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9008. }
  9009. if (this._currentMeasure.width !== maxWidth) {
  9010. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9011. this._currentMeasure.width = maxWidth;
  9012. this._rebuildLayout = true;
  9013. this._isDirty = true;
  9014. }
  9015. if (this._currentMeasure.height !== maxHeight) {
  9016. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9017. this._currentMeasure.height = maxHeight;
  9018. this._rebuildLayout = true;
  9019. this._isDirty = true;
  9020. }
  9021. _super.prototype._postMeasure.call(this);
  9022. };
  9023. return _ScrollViewerWindow;
  9024. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9025. /***/ }),
  9026. /***/ "./2D/controls/selector.ts":
  9027. /*!*********************************!*\
  9028. !*** ./2D/controls/selector.ts ***!
  9029. \*********************************/
  9030. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9032. "use strict";
  9033. __webpack_require__.r(__webpack_exports__);
  9034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9040. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9041. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9042. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9043. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9044. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9045. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9046. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9047. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9048. /** Class used to create a RadioGroup
  9049. * which contains groups of radio buttons
  9050. */
  9051. var SelectorGroup = /** @class */ (function () {
  9052. /**
  9053. * Creates a new SelectorGroup
  9054. * @param name of group, used as a group heading
  9055. */
  9056. function SelectorGroup(
  9057. /** name of SelectorGroup */
  9058. name) {
  9059. this.name = name;
  9060. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9061. this._selectors = new Array();
  9062. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9063. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9064. this._groupHeader = this._addGroupHeader(name);
  9065. }
  9066. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9067. /** Gets the groupPanel of the SelectorGroup */
  9068. get: function () {
  9069. return this._groupPanel;
  9070. },
  9071. enumerable: true,
  9072. configurable: true
  9073. });
  9074. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9075. /** Gets the selectors array */
  9076. get: function () {
  9077. return this._selectors;
  9078. },
  9079. enumerable: true,
  9080. configurable: true
  9081. });
  9082. Object.defineProperty(SelectorGroup.prototype, "header", {
  9083. /** Gets and sets the group header */
  9084. get: function () {
  9085. return this._groupHeader.text;
  9086. },
  9087. set: function (label) {
  9088. if (this._groupHeader.text === "label") {
  9089. return;
  9090. }
  9091. this._groupHeader.text = label;
  9092. },
  9093. enumerable: true,
  9094. configurable: true
  9095. });
  9096. /** @hidden */
  9097. SelectorGroup.prototype._addGroupHeader = function (text) {
  9098. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9099. groupHeading.width = 0.9;
  9100. groupHeading.height = "30px";
  9101. groupHeading.textWrapping = true;
  9102. groupHeading.color = "black";
  9103. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9104. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9105. groupHeading.left = "2px";
  9106. this._groupPanel.addControl(groupHeading);
  9107. return groupHeading;
  9108. };
  9109. /** @hidden*/
  9110. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9111. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9112. return;
  9113. }
  9114. return this._selectors[selectorNb];
  9115. };
  9116. /** Removes the selector at the given position
  9117. * @param selectorNb the position of the selector within the group
  9118. */
  9119. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9120. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9121. return;
  9122. }
  9123. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9124. this._selectors.splice(selectorNb, 1);
  9125. };
  9126. return SelectorGroup;
  9127. }());
  9128. /** Class used to create a CheckboxGroup
  9129. * which contains groups of checkbox buttons
  9130. */
  9131. var CheckboxGroup = /** @class */ (function (_super) {
  9132. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9133. function CheckboxGroup() {
  9134. return _super !== null && _super.apply(this, arguments) || this;
  9135. }
  9136. /** Adds a checkbox as a control
  9137. * @param text is the label for the selector
  9138. * @param func is the function called when the Selector is checked
  9139. * @param checked is true when Selector is checked
  9140. */
  9141. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9142. if (func === void 0) { func = function (s) { }; }
  9143. if (checked === void 0) { checked = false; }
  9144. var checked = checked || false;
  9145. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9146. button.width = "20px";
  9147. button.height = "20px";
  9148. button.color = "#364249";
  9149. button.background = "#CCCCCC";
  9150. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9151. button.onIsCheckedChangedObservable.add(function (state) {
  9152. func(state);
  9153. });
  9154. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9155. _selector.height = "30px";
  9156. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9157. _selector.left = "4px";
  9158. this.groupPanel.addControl(_selector);
  9159. this.selectors.push(_selector);
  9160. button.isChecked = checked;
  9161. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9162. button.color = this.groupPanel.parent.parent.buttonColor;
  9163. button.background = this.groupPanel.parent.parent.buttonBackground;
  9164. }
  9165. };
  9166. /** @hidden */
  9167. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9168. this.selectors[selectorNb].children[1].text = label;
  9169. };
  9170. /** @hidden */
  9171. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9172. this.selectors[selectorNb].children[1].color = color;
  9173. };
  9174. /** @hidden */
  9175. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9176. this.selectors[selectorNb].children[0].color = color;
  9177. };
  9178. /** @hidden */
  9179. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9180. this.selectors[selectorNb].children[0].background = color;
  9181. };
  9182. return CheckboxGroup;
  9183. }(SelectorGroup));
  9184. /** Class used to create a RadioGroup
  9185. * which contains groups of radio buttons
  9186. */
  9187. var RadioGroup = /** @class */ (function (_super) {
  9188. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9189. function RadioGroup() {
  9190. var _this = _super !== null && _super.apply(this, arguments) || this;
  9191. _this._selectNb = 0;
  9192. return _this;
  9193. }
  9194. /** Adds a radio button as a control
  9195. * @param label is the label for the selector
  9196. * @param func is the function called when the Selector is checked
  9197. * @param checked is true when Selector is checked
  9198. */
  9199. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9200. if (func === void 0) { func = function (n) { }; }
  9201. if (checked === void 0) { checked = false; }
  9202. var nb = this._selectNb++;
  9203. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9204. button.name = label;
  9205. button.width = "20px";
  9206. button.height = "20px";
  9207. button.color = "#364249";
  9208. button.background = "#CCCCCC";
  9209. button.group = this.name;
  9210. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9211. button.onIsCheckedChangedObservable.add(function (state) {
  9212. if (state) {
  9213. func(nb);
  9214. }
  9215. });
  9216. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9217. _selector.height = "30px";
  9218. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9219. _selector.left = "4px";
  9220. this.groupPanel.addControl(_selector);
  9221. this.selectors.push(_selector);
  9222. button.isChecked = checked;
  9223. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9224. button.color = this.groupPanel.parent.parent.buttonColor;
  9225. button.background = this.groupPanel.parent.parent.buttonBackground;
  9226. }
  9227. };
  9228. /** @hidden */
  9229. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9230. this.selectors[selectorNb].children[1].text = label;
  9231. };
  9232. /** @hidden */
  9233. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9234. this.selectors[selectorNb].children[1].color = color;
  9235. };
  9236. /** @hidden */
  9237. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9238. this.selectors[selectorNb].children[0].color = color;
  9239. };
  9240. /** @hidden */
  9241. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9242. this.selectors[selectorNb].children[0].background = color;
  9243. };
  9244. return RadioGroup;
  9245. }(SelectorGroup));
  9246. /** Class used to create a SliderGroup
  9247. * which contains groups of slider buttons
  9248. */
  9249. var SliderGroup = /** @class */ (function (_super) {
  9250. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9251. function SliderGroup() {
  9252. return _super !== null && _super.apply(this, arguments) || this;
  9253. }
  9254. /**
  9255. * Adds a slider to the SelectorGroup
  9256. * @param label is the label for the SliderBar
  9257. * @param func is the function called when the Slider moves
  9258. * @param unit is a string describing the units used, eg degrees or metres
  9259. * @param min is the minimum value for the Slider
  9260. * @param max is the maximum value for the Slider
  9261. * @param value is the start value for the Slider between min and max
  9262. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9263. */
  9264. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9265. if (func === void 0) { func = function (v) { }; }
  9266. if (unit === void 0) { unit = "Units"; }
  9267. if (min === void 0) { min = 0; }
  9268. if (max === void 0) { max = 0; }
  9269. if (value === void 0) { value = 0; }
  9270. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9271. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9272. button.name = unit;
  9273. button.value = value;
  9274. button.minimum = min;
  9275. button.maximum = max;
  9276. button.width = 0.9;
  9277. button.height = "20px";
  9278. button.color = "#364249";
  9279. button.background = "#CCCCCC";
  9280. button.borderColor = "black";
  9281. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9282. button.left = "4px";
  9283. button.paddingBottom = "4px";
  9284. button.onValueChangedObservable.add(function (value) {
  9285. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9286. func(value);
  9287. });
  9288. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9289. _selector.height = "60px";
  9290. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9291. _selector.left = "4px";
  9292. _selector.children[0].name = label;
  9293. this.groupPanel.addControl(_selector);
  9294. this.selectors.push(_selector);
  9295. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9296. button.color = this.groupPanel.parent.parent.buttonColor;
  9297. button.background = this.groupPanel.parent.parent.buttonBackground;
  9298. }
  9299. };
  9300. /** @hidden */
  9301. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9302. this.selectors[selectorNb].children[0].name = label;
  9303. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9304. };
  9305. /** @hidden */
  9306. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9307. this.selectors[selectorNb].children[0].color = color;
  9308. };
  9309. /** @hidden */
  9310. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9311. this.selectors[selectorNb].children[1].color = color;
  9312. };
  9313. /** @hidden */
  9314. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9315. this.selectors[selectorNb].children[1].background = color;
  9316. };
  9317. return SliderGroup;
  9318. }(SelectorGroup));
  9319. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9320. * @see http://doc.babylonjs.com/how_to/selector
  9321. */
  9322. var SelectionPanel = /** @class */ (function (_super) {
  9323. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9324. /**
  9325. * Creates a new SelectionPanel
  9326. * @param name of SelectionPanel
  9327. * @param groups is an array of SelectionGroups
  9328. */
  9329. function SelectionPanel(
  9330. /** name of SelectionPanel */
  9331. name,
  9332. /** an array of SelectionGroups */
  9333. groups) {
  9334. if (groups === void 0) { groups = []; }
  9335. var _this = _super.call(this, name) || this;
  9336. _this.name = name;
  9337. _this.groups = groups;
  9338. _this._buttonColor = "#364249";
  9339. _this._buttonBackground = "#CCCCCC";
  9340. _this._headerColor = "black";
  9341. _this._barColor = "white";
  9342. _this._barHeight = "2px";
  9343. _this._spacerHeight = "20px";
  9344. _this._bars = new Array();
  9345. _this._groups = groups;
  9346. _this.thickness = 2;
  9347. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9348. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9349. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9350. _this._panel.top = 5;
  9351. _this._panel.left = 5;
  9352. _this._panel.width = 0.95;
  9353. if (groups.length > 0) {
  9354. for (var i = 0; i < groups.length - 1; i++) {
  9355. _this._panel.addControl(groups[i].groupPanel);
  9356. _this._addSpacer();
  9357. }
  9358. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9359. }
  9360. _this.addControl(_this._panel);
  9361. return _this;
  9362. }
  9363. SelectionPanel.prototype._getTypeName = function () {
  9364. return "SelectionPanel";
  9365. };
  9366. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9367. /** Gets or sets the headerColor */
  9368. get: function () {
  9369. return this._headerColor;
  9370. },
  9371. set: function (color) {
  9372. if (this._headerColor === color) {
  9373. return;
  9374. }
  9375. this._headerColor = color;
  9376. this._setHeaderColor();
  9377. },
  9378. enumerable: true,
  9379. configurable: true
  9380. });
  9381. SelectionPanel.prototype._setHeaderColor = function () {
  9382. for (var i = 0; i < this._groups.length; i++) {
  9383. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9384. }
  9385. };
  9386. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9387. /** Gets or sets the button color */
  9388. get: function () {
  9389. return this._buttonColor;
  9390. },
  9391. set: function (color) {
  9392. if (this._buttonColor === color) {
  9393. return;
  9394. }
  9395. this._buttonColor = color;
  9396. this._setbuttonColor();
  9397. },
  9398. enumerable: true,
  9399. configurable: true
  9400. });
  9401. SelectionPanel.prototype._setbuttonColor = function () {
  9402. for (var i = 0; i < this._groups.length; i++) {
  9403. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9404. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9405. }
  9406. }
  9407. };
  9408. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9409. /** Gets or sets the label color */
  9410. get: function () {
  9411. return this._labelColor;
  9412. },
  9413. set: function (color) {
  9414. if (this._labelColor === color) {
  9415. return;
  9416. }
  9417. this._labelColor = color;
  9418. this._setLabelColor();
  9419. },
  9420. enumerable: true,
  9421. configurable: true
  9422. });
  9423. SelectionPanel.prototype._setLabelColor = function () {
  9424. for (var i = 0; i < this._groups.length; i++) {
  9425. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9426. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9427. }
  9428. }
  9429. };
  9430. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9431. /** Gets or sets the button background */
  9432. get: function () {
  9433. return this._buttonBackground;
  9434. },
  9435. set: function (color) {
  9436. if (this._buttonBackground === color) {
  9437. return;
  9438. }
  9439. this._buttonBackground = color;
  9440. this._setButtonBackground();
  9441. },
  9442. enumerable: true,
  9443. configurable: true
  9444. });
  9445. SelectionPanel.prototype._setButtonBackground = function () {
  9446. for (var i = 0; i < this._groups.length; i++) {
  9447. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9448. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9449. }
  9450. }
  9451. };
  9452. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9453. /** Gets or sets the color of separator bar */
  9454. get: function () {
  9455. return this._barColor;
  9456. },
  9457. set: function (color) {
  9458. if (this._barColor === color) {
  9459. return;
  9460. }
  9461. this._barColor = color;
  9462. this._setBarColor();
  9463. },
  9464. enumerable: true,
  9465. configurable: true
  9466. });
  9467. SelectionPanel.prototype._setBarColor = function () {
  9468. for (var i = 0; i < this._bars.length; i++) {
  9469. this._bars[i].children[0].background = this._barColor;
  9470. }
  9471. };
  9472. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9473. /** Gets or sets the height of separator bar */
  9474. get: function () {
  9475. return this._barHeight;
  9476. },
  9477. set: function (value) {
  9478. if (this._barHeight === value) {
  9479. return;
  9480. }
  9481. this._barHeight = value;
  9482. this._setBarHeight();
  9483. },
  9484. enumerable: true,
  9485. configurable: true
  9486. });
  9487. SelectionPanel.prototype._setBarHeight = function () {
  9488. for (var i = 0; i < this._bars.length; i++) {
  9489. this._bars[i].children[0].height = this._barHeight;
  9490. }
  9491. };
  9492. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9493. /** Gets or sets the height of spacers*/
  9494. get: function () {
  9495. return this._spacerHeight;
  9496. },
  9497. set: function (value) {
  9498. if (this._spacerHeight === value) {
  9499. return;
  9500. }
  9501. this._spacerHeight = value;
  9502. this._setSpacerHeight();
  9503. },
  9504. enumerable: true,
  9505. configurable: true
  9506. });
  9507. SelectionPanel.prototype._setSpacerHeight = function () {
  9508. for (var i = 0; i < this._bars.length; i++) {
  9509. this._bars[i].height = this._spacerHeight;
  9510. }
  9511. };
  9512. /** Adds a bar between groups */
  9513. SelectionPanel.prototype._addSpacer = function () {
  9514. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9515. separator.width = 1;
  9516. separator.height = this._spacerHeight;
  9517. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9518. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9519. bar.width = 1;
  9520. bar.height = this._barHeight;
  9521. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9522. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9523. bar.background = this._barColor;
  9524. bar.color = "transparent";
  9525. separator.addControl(bar);
  9526. this._panel.addControl(separator);
  9527. this._bars.push(separator);
  9528. };
  9529. /** Add a group to the selection panel
  9530. * @param group is the selector group to add
  9531. */
  9532. SelectionPanel.prototype.addGroup = function (group) {
  9533. if (this._groups.length > 0) {
  9534. this._addSpacer();
  9535. }
  9536. this._panel.addControl(group.groupPanel);
  9537. this._groups.push(group);
  9538. group.groupPanel.children[0].color = this._headerColor;
  9539. for (var j = 0; j < group.selectors.length; j++) {
  9540. group._setSelectorButtonColor(j, this._buttonColor);
  9541. group._setSelectorButtonBackground(j, this._buttonBackground);
  9542. }
  9543. };
  9544. /** Remove the group from the given position
  9545. * @param groupNb is the position of the group in the list
  9546. */
  9547. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9548. if (groupNb < 0 || groupNb >= this._groups.length) {
  9549. return;
  9550. }
  9551. var group = this._groups[groupNb];
  9552. this._panel.removeControl(group.groupPanel);
  9553. this._groups.splice(groupNb, 1);
  9554. if (groupNb < this._bars.length) {
  9555. this._panel.removeControl(this._bars[groupNb]);
  9556. this._bars.splice(groupNb, 1);
  9557. }
  9558. };
  9559. /** Change a group header label
  9560. * @param label is the new group header label
  9561. * @param groupNb is the number of the group to relabel
  9562. * */
  9563. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9564. if (groupNb < 0 || groupNb >= this._groups.length) {
  9565. return;
  9566. }
  9567. var group = this._groups[groupNb];
  9568. group.groupPanel.children[0].text = label;
  9569. };
  9570. /** Change selector label to the one given
  9571. * @param label is the new selector label
  9572. * @param groupNb is the number of the groupcontaining the selector
  9573. * @param selectorNb is the number of the selector within a group to relabel
  9574. * */
  9575. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9576. if (groupNb < 0 || groupNb >= this._groups.length) {
  9577. return;
  9578. }
  9579. var group = this._groups[groupNb];
  9580. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9581. return;
  9582. }
  9583. group._setSelectorLabel(selectorNb, label);
  9584. };
  9585. /** For a given group position remove the selector at the given position
  9586. * @param groupNb is the number of the group to remove the selector from
  9587. * @param selectorNb is the number of the selector within the group
  9588. */
  9589. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9590. if (groupNb < 0 || groupNb >= this._groups.length) {
  9591. return;
  9592. }
  9593. var group = this._groups[groupNb];
  9594. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9595. return;
  9596. }
  9597. group.removeSelector(selectorNb);
  9598. };
  9599. /** For a given group position of correct type add a checkbox button
  9600. * @param groupNb is the number of the group to remove the selector from
  9601. * @param label is the label for the selector
  9602. * @param func is the function called when the Selector is checked
  9603. * @param checked is true when Selector is checked
  9604. */
  9605. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9606. if (func === void 0) { func = function () { }; }
  9607. if (checked === void 0) { checked = false; }
  9608. if (groupNb < 0 || groupNb >= this._groups.length) {
  9609. return;
  9610. }
  9611. var group = this._groups[groupNb];
  9612. group.addCheckbox(label, func, checked);
  9613. };
  9614. /** For a given group position of correct type add a radio button
  9615. * @param groupNb is the number of the group to remove the selector from
  9616. * @param label is the label for the selector
  9617. * @param func is the function called when the Selector is checked
  9618. * @param checked is true when Selector is checked
  9619. */
  9620. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9621. if (func === void 0) { func = function () { }; }
  9622. if (checked === void 0) { checked = false; }
  9623. if (groupNb < 0 || groupNb >= this._groups.length) {
  9624. return;
  9625. }
  9626. var group = this._groups[groupNb];
  9627. group.addRadio(label, func, checked);
  9628. };
  9629. /**
  9630. * For a given slider group add a slider
  9631. * @param groupNb is the number of the group to add the slider to
  9632. * @param label is the label for the Slider
  9633. * @param func is the function called when the Slider moves
  9634. * @param unit is a string describing the units used, eg degrees or metres
  9635. * @param min is the minimum value for the Slider
  9636. * @param max is the maximum value for the Slider
  9637. * @param value is the start value for the Slider between min and max
  9638. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9639. */
  9640. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9641. if (func === void 0) { func = function () { }; }
  9642. if (unit === void 0) { unit = "Units"; }
  9643. if (min === void 0) { min = 0; }
  9644. if (max === void 0) { max = 0; }
  9645. if (value === void 0) { value = 0; }
  9646. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9647. if (groupNb < 0 || groupNb >= this._groups.length) {
  9648. return;
  9649. }
  9650. var group = this._groups[groupNb];
  9651. group.addSlider(label, func, unit, min, max, value, onVal);
  9652. };
  9653. return SelectionPanel;
  9654. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9655. /***/ }),
  9656. /***/ "./2D/controls/sliders/baseSlider.ts":
  9657. /*!*******************************************!*\
  9658. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9659. \*******************************************/
  9660. /*! exports provided: BaseSlider */
  9661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9662. "use strict";
  9663. __webpack_require__.r(__webpack_exports__);
  9664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9665. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9666. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  9667. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9668. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9669. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9670. /**
  9671. * Class used to create slider controls
  9672. */
  9673. var BaseSlider = /** @class */ (function (_super) {
  9674. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9675. /**
  9676. * Creates a new BaseSlider
  9677. * @param name defines the control name
  9678. */
  9679. function BaseSlider(name) {
  9680. var _this = _super.call(this, name) || this;
  9681. _this.name = name;
  9682. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9683. _this._minimum = 0;
  9684. _this._maximum = 100;
  9685. _this._value = 50;
  9686. _this._isVertical = false;
  9687. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9688. _this._isThumbClamped = false;
  9689. _this._displayThumb = true;
  9690. _this._step = 0;
  9691. // Shared rendering info
  9692. _this._effectiveBarOffset = 0;
  9693. /** Observable raised when the sldier value changes */
  9694. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9695. // Events
  9696. _this._pointerIsDown = false;
  9697. _this.isPointerBlocker = true;
  9698. return _this;
  9699. }
  9700. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9701. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9702. get: function () {
  9703. return this._displayThumb;
  9704. },
  9705. set: function (value) {
  9706. if (this._displayThumb === value) {
  9707. return;
  9708. }
  9709. this._displayThumb = value;
  9710. this._markAsDirty();
  9711. },
  9712. enumerable: true,
  9713. configurable: true
  9714. });
  9715. Object.defineProperty(BaseSlider.prototype, "step", {
  9716. /** Gets or sets a step to apply to values (0 by default) */
  9717. get: function () {
  9718. return this._step;
  9719. },
  9720. set: function (value) {
  9721. if (this._step === value) {
  9722. return;
  9723. }
  9724. this._step = value;
  9725. this._markAsDirty();
  9726. },
  9727. enumerable: true,
  9728. configurable: true
  9729. });
  9730. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9731. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9732. get: function () {
  9733. return this._barOffset.toString(this._host);
  9734. },
  9735. set: function (value) {
  9736. if (this._barOffset.toString(this._host) === value) {
  9737. return;
  9738. }
  9739. if (this._barOffset.fromString(value)) {
  9740. this._markAsDirty();
  9741. }
  9742. },
  9743. enumerable: true,
  9744. configurable: true
  9745. });
  9746. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9747. /** Gets main bar offset in pixels*/
  9748. get: function () {
  9749. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9750. },
  9751. enumerable: true,
  9752. configurable: true
  9753. });
  9754. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9755. /** Gets or sets thumb width */
  9756. get: function () {
  9757. return this._thumbWidth.toString(this._host);
  9758. },
  9759. set: function (value) {
  9760. if (this._thumbWidth.toString(this._host) === value) {
  9761. return;
  9762. }
  9763. if (this._thumbWidth.fromString(value)) {
  9764. this._markAsDirty();
  9765. }
  9766. },
  9767. enumerable: true,
  9768. configurable: true
  9769. });
  9770. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9771. /** Gets thumb width in pixels */
  9772. get: function () {
  9773. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9774. },
  9775. enumerable: true,
  9776. configurable: true
  9777. });
  9778. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9779. /** Gets or sets minimum value */
  9780. get: function () {
  9781. return this._minimum;
  9782. },
  9783. set: function (value) {
  9784. if (this._minimum === value) {
  9785. return;
  9786. }
  9787. this._minimum = value;
  9788. this._markAsDirty();
  9789. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9790. },
  9791. enumerable: true,
  9792. configurable: true
  9793. });
  9794. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9795. /** Gets or sets maximum value */
  9796. get: function () {
  9797. return this._maximum;
  9798. },
  9799. set: function (value) {
  9800. if (this._maximum === value) {
  9801. return;
  9802. }
  9803. this._maximum = value;
  9804. this._markAsDirty();
  9805. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9806. },
  9807. enumerable: true,
  9808. configurable: true
  9809. });
  9810. Object.defineProperty(BaseSlider.prototype, "value", {
  9811. /** Gets or sets current value */
  9812. get: function () {
  9813. return this._value;
  9814. },
  9815. set: function (value) {
  9816. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9817. if (this._value === value) {
  9818. return;
  9819. }
  9820. this._value = value;
  9821. this._markAsDirty();
  9822. this.onValueChangedObservable.notifyObservers(this._value);
  9823. },
  9824. enumerable: true,
  9825. configurable: true
  9826. });
  9827. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9828. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9829. get: function () {
  9830. return this._isVertical;
  9831. },
  9832. set: function (value) {
  9833. if (this._isVertical === value) {
  9834. return;
  9835. }
  9836. this._isVertical = value;
  9837. this._markAsDirty();
  9838. },
  9839. enumerable: true,
  9840. configurable: true
  9841. });
  9842. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9843. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9844. get: function () {
  9845. return this._isThumbClamped;
  9846. },
  9847. set: function (value) {
  9848. if (this._isThumbClamped === value) {
  9849. return;
  9850. }
  9851. this._isThumbClamped = value;
  9852. this._markAsDirty();
  9853. },
  9854. enumerable: true,
  9855. configurable: true
  9856. });
  9857. BaseSlider.prototype._getTypeName = function () {
  9858. return "BaseSlider";
  9859. };
  9860. BaseSlider.prototype._getThumbPosition = function () {
  9861. if (this.isVertical) {
  9862. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9863. }
  9864. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9865. };
  9866. BaseSlider.prototype._getThumbThickness = function (type) {
  9867. var thumbThickness = 0;
  9868. switch (type) {
  9869. case "circle":
  9870. if (this._thumbWidth.isPixel) {
  9871. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9872. }
  9873. else {
  9874. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9875. }
  9876. break;
  9877. case "rectangle":
  9878. if (this._thumbWidth.isPixel) {
  9879. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9880. }
  9881. else {
  9882. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9883. }
  9884. }
  9885. return thumbThickness;
  9886. };
  9887. BaseSlider.prototype._prepareRenderingData = function (type) {
  9888. // Main bar
  9889. this._effectiveBarOffset = 0;
  9890. this._renderLeft = this._currentMeasure.left;
  9891. this._renderTop = this._currentMeasure.top;
  9892. this._renderWidth = this._currentMeasure.width;
  9893. this._renderHeight = this._currentMeasure.height;
  9894. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9895. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9896. this._effectiveThumbThickness = this._getThumbThickness(type);
  9897. if (this.displayThumb) {
  9898. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9899. }
  9900. //throw error when height is less than width for vertical slider
  9901. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9902. console.error("Height should be greater than width");
  9903. return;
  9904. }
  9905. if (this._barOffset.isPixel) {
  9906. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9907. }
  9908. else {
  9909. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9910. }
  9911. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9912. if (this.isVertical) {
  9913. this._renderLeft += this._effectiveBarOffset;
  9914. if (!this.isThumbClamped && this.displayThumb) {
  9915. this._renderTop += (this._effectiveThumbThickness / 2);
  9916. }
  9917. this._renderHeight = this._backgroundBoxLength;
  9918. this._renderWidth = this._backgroundBoxThickness;
  9919. }
  9920. else {
  9921. this._renderTop += this._effectiveBarOffset;
  9922. if (!this.isThumbClamped && this.displayThumb) {
  9923. this._renderLeft += (this._effectiveThumbThickness / 2);
  9924. }
  9925. this._renderHeight = this._backgroundBoxThickness;
  9926. this._renderWidth = this._backgroundBoxLength;
  9927. }
  9928. };
  9929. /** @hidden */
  9930. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9931. if (this.rotation != 0) {
  9932. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9933. x = this._transformedPosition.x;
  9934. y = this._transformedPosition.y;
  9935. }
  9936. var value;
  9937. if (this._isVertical) {
  9938. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9939. }
  9940. else {
  9941. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9942. }
  9943. var mult = (1 / this._step) | 0;
  9944. this.value = this._step ? ((value * mult) | 0) / mult : value;
  9945. };
  9946. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9947. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9948. return false;
  9949. }
  9950. this._pointerIsDown = true;
  9951. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9952. this._host._capturingControl[pointerId] = this;
  9953. return true;
  9954. };
  9955. BaseSlider.prototype._onPointerMove = function (target, coordinates) {
  9956. if (this._pointerIsDown) {
  9957. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9958. }
  9959. _super.prototype._onPointerMove.call(this, target, coordinates);
  9960. };
  9961. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9962. this._pointerIsDown = false;
  9963. delete this._host._capturingControl[pointerId];
  9964. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9965. };
  9966. return BaseSlider;
  9967. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9968. /***/ }),
  9969. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  9970. /*!*************************************************!*\
  9971. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  9972. \*************************************************/
  9973. /*! exports provided: ImageBasedSlider */
  9974. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9975. "use strict";
  9976. __webpack_require__.r(__webpack_exports__);
  9977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  9978. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9979. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  9980. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9981. /**
  9982. * Class used to create slider controls based on images
  9983. */
  9984. var ImageBasedSlider = /** @class */ (function (_super) {
  9985. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  9986. /**
  9987. * Creates a new ImageBasedSlider
  9988. * @param name defines the control name
  9989. */
  9990. function ImageBasedSlider(name) {
  9991. var _this = _super.call(this, name) || this;
  9992. _this.name = name;
  9993. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  9994. return _this;
  9995. }
  9996. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  9997. get: function () {
  9998. return this._displayThumb && this.thumbImage != null;
  9999. },
  10000. set: function (value) {
  10001. if (this._displayThumb === value) {
  10002. return;
  10003. }
  10004. this._displayThumb = value;
  10005. this._markAsDirty();
  10006. },
  10007. enumerable: true,
  10008. configurable: true
  10009. });
  10010. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10011. /**
  10012. * Gets or sets the image used to render the background
  10013. */
  10014. get: function () {
  10015. return this._backgroundImage;
  10016. },
  10017. set: function (value) {
  10018. var _this = this;
  10019. if (this._backgroundImage === value) {
  10020. return;
  10021. }
  10022. this._backgroundImage = value;
  10023. if (value && !value.isLoaded) {
  10024. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10025. }
  10026. this._markAsDirty();
  10027. },
  10028. enumerable: true,
  10029. configurable: true
  10030. });
  10031. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10032. /**
  10033. * Gets or sets the image used to render the value bar
  10034. */
  10035. get: function () {
  10036. return this._valueBarImage;
  10037. },
  10038. set: function (value) {
  10039. var _this = this;
  10040. if (this._valueBarImage === value) {
  10041. return;
  10042. }
  10043. this._valueBarImage = value;
  10044. if (value && !value.isLoaded) {
  10045. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10046. }
  10047. this._markAsDirty();
  10048. },
  10049. enumerable: true,
  10050. configurable: true
  10051. });
  10052. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10053. /**
  10054. * Gets or sets the image used to render the thumb
  10055. */
  10056. get: function () {
  10057. return this._thumbImage;
  10058. },
  10059. set: function (value) {
  10060. var _this = this;
  10061. if (this._thumbImage === value) {
  10062. return;
  10063. }
  10064. this._thumbImage = value;
  10065. if (value && !value.isLoaded) {
  10066. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10067. }
  10068. this._markAsDirty();
  10069. },
  10070. enumerable: true,
  10071. configurable: true
  10072. });
  10073. ImageBasedSlider.prototype._getTypeName = function () {
  10074. return "ImageBasedSlider";
  10075. };
  10076. ImageBasedSlider.prototype._draw = function (context) {
  10077. context.save();
  10078. this._applyStates(context);
  10079. this._prepareRenderingData("rectangle");
  10080. var thumbPosition = this._getThumbPosition();
  10081. var left = this._renderLeft;
  10082. var top = this._renderTop;
  10083. var width = this._renderWidth;
  10084. var height = this._renderHeight;
  10085. // Background
  10086. if (this._backgroundImage) {
  10087. this._tempMeasure.copyFromFloats(left, top, width, height);
  10088. if (this.isThumbClamped && this.displayThumb) {
  10089. if (this.isVertical) {
  10090. this._tempMeasure.height += this._effectiveThumbThickness;
  10091. }
  10092. else {
  10093. this._tempMeasure.width += this._effectiveThumbThickness;
  10094. }
  10095. }
  10096. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10097. this._backgroundImage._draw(context);
  10098. }
  10099. // Bar
  10100. if (this._valueBarImage) {
  10101. if (this.isVertical) {
  10102. if (this.isThumbClamped && this.displayThumb) {
  10103. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10104. }
  10105. else {
  10106. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10107. }
  10108. }
  10109. else {
  10110. if (this.isThumbClamped && this.displayThumb) {
  10111. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10112. }
  10113. else {
  10114. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10115. }
  10116. }
  10117. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10118. this._valueBarImage._draw(context);
  10119. }
  10120. // Thumb
  10121. if (this.displayThumb) {
  10122. if (this.isVertical) {
  10123. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10124. }
  10125. else {
  10126. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10127. }
  10128. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10129. this._thumbImage._draw(context);
  10130. }
  10131. context.restore();
  10132. };
  10133. return ImageBasedSlider;
  10134. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10135. /***/ }),
  10136. /***/ "./2D/controls/sliders/scrollBar.ts":
  10137. /*!******************************************!*\
  10138. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10139. \******************************************/
  10140. /*! exports provided: ScrollBar */
  10141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10142. "use strict";
  10143. __webpack_require__.r(__webpack_exports__);
  10144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10145. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10146. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10147. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10148. /**
  10149. * Class used to create slider controls
  10150. */
  10151. var ScrollBar = /** @class */ (function (_super) {
  10152. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10153. /**
  10154. * Creates a new Slider
  10155. * @param name defines the control name
  10156. */
  10157. function ScrollBar(name) {
  10158. var _this = _super.call(this, name) || this;
  10159. _this.name = name;
  10160. _this._background = "black";
  10161. _this._borderColor = "white";
  10162. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10163. return _this;
  10164. }
  10165. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10166. /** Gets or sets border color */
  10167. get: function () {
  10168. return this._borderColor;
  10169. },
  10170. set: function (value) {
  10171. if (this._borderColor === value) {
  10172. return;
  10173. }
  10174. this._borderColor = value;
  10175. this._markAsDirty();
  10176. },
  10177. enumerable: true,
  10178. configurable: true
  10179. });
  10180. Object.defineProperty(ScrollBar.prototype, "background", {
  10181. /** Gets or sets background color */
  10182. get: function () {
  10183. return this._background;
  10184. },
  10185. set: function (value) {
  10186. if (this._background === value) {
  10187. return;
  10188. }
  10189. this._background = value;
  10190. this._markAsDirty();
  10191. },
  10192. enumerable: true,
  10193. configurable: true
  10194. });
  10195. ScrollBar.prototype._getTypeName = function () {
  10196. return "Scrollbar";
  10197. };
  10198. ScrollBar.prototype._getThumbThickness = function () {
  10199. var thumbThickness = 0;
  10200. if (this._thumbWidth.isPixel) {
  10201. thumbThickness = this._thumbWidth.getValue(this._host);
  10202. }
  10203. else {
  10204. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10205. }
  10206. return thumbThickness;
  10207. };
  10208. ScrollBar.prototype._draw = function (context) {
  10209. context.save();
  10210. this._applyStates(context);
  10211. this._prepareRenderingData("rectangle");
  10212. var left = this._renderLeft;
  10213. var thumbPosition = this._getThumbPosition();
  10214. context.fillStyle = this._background;
  10215. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10216. // Value bar
  10217. context.fillStyle = this.color;
  10218. // Thumb
  10219. if (this.isVertical) {
  10220. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10221. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10222. this._thumbMeasure.width = this._currentMeasure.width;
  10223. this._thumbMeasure.height = this._effectiveThumbThickness;
  10224. }
  10225. else {
  10226. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10227. this._thumbMeasure.top = this._currentMeasure.top;
  10228. this._thumbMeasure.width = this._effectiveThumbThickness;
  10229. this._thumbMeasure.height = this._currentMeasure.height;
  10230. }
  10231. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10232. context.restore();
  10233. };
  10234. /** @hidden */
  10235. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10236. if (this.rotation != 0) {
  10237. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10238. x = this._transformedPosition.x;
  10239. y = this._transformedPosition.y;
  10240. }
  10241. if (this._first) {
  10242. this._first = false;
  10243. this._originX = x;
  10244. this._originY = y;
  10245. // Check if move is required
  10246. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10247. if (this.isVertical) {
  10248. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10249. }
  10250. else {
  10251. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10252. }
  10253. }
  10254. }
  10255. // Delta mode
  10256. var delta = 0;
  10257. if (this.isVertical) {
  10258. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10259. }
  10260. else {
  10261. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10262. }
  10263. this.value += delta * (this.maximum - this.minimum);
  10264. this._originX = x;
  10265. this._originY = y;
  10266. };
  10267. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10268. this._first = true;
  10269. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10270. };
  10271. return ScrollBar;
  10272. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10273. /***/ }),
  10274. /***/ "./2D/controls/sliders/slider.ts":
  10275. /*!***************************************!*\
  10276. !*** ./2D/controls/sliders/slider.ts ***!
  10277. \***************************************/
  10278. /*! exports provided: Slider */
  10279. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10280. "use strict";
  10281. __webpack_require__.r(__webpack_exports__);
  10282. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10283. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10284. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10285. /**
  10286. * Class used to create slider controls
  10287. */
  10288. var Slider = /** @class */ (function (_super) {
  10289. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10290. /**
  10291. * Creates a new Slider
  10292. * @param name defines the control name
  10293. */
  10294. function Slider(name) {
  10295. var _this = _super.call(this, name) || this;
  10296. _this.name = name;
  10297. _this._background = "black";
  10298. _this._borderColor = "white";
  10299. _this._isThumbCircle = false;
  10300. _this._displayValueBar = true;
  10301. return _this;
  10302. }
  10303. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10304. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10305. get: function () {
  10306. return this._displayValueBar;
  10307. },
  10308. set: function (value) {
  10309. if (this._displayValueBar === value) {
  10310. return;
  10311. }
  10312. this._displayValueBar = value;
  10313. this._markAsDirty();
  10314. },
  10315. enumerable: true,
  10316. configurable: true
  10317. });
  10318. Object.defineProperty(Slider.prototype, "borderColor", {
  10319. /** Gets or sets border color */
  10320. get: function () {
  10321. return this._borderColor;
  10322. },
  10323. set: function (value) {
  10324. if (this._borderColor === value) {
  10325. return;
  10326. }
  10327. this._borderColor = value;
  10328. this._markAsDirty();
  10329. },
  10330. enumerable: true,
  10331. configurable: true
  10332. });
  10333. Object.defineProperty(Slider.prototype, "background", {
  10334. /** Gets or sets background color */
  10335. get: function () {
  10336. return this._background;
  10337. },
  10338. set: function (value) {
  10339. if (this._background === value) {
  10340. return;
  10341. }
  10342. this._background = value;
  10343. this._markAsDirty();
  10344. },
  10345. enumerable: true,
  10346. configurable: true
  10347. });
  10348. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10349. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10350. get: function () {
  10351. return this._isThumbCircle;
  10352. },
  10353. set: function (value) {
  10354. if (this._isThumbCircle === value) {
  10355. return;
  10356. }
  10357. this._isThumbCircle = value;
  10358. this._markAsDirty();
  10359. },
  10360. enumerable: true,
  10361. configurable: true
  10362. });
  10363. Slider.prototype._getTypeName = function () {
  10364. return "Slider";
  10365. };
  10366. Slider.prototype._draw = function (context) {
  10367. context.save();
  10368. this._applyStates(context);
  10369. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10370. var left = this._renderLeft;
  10371. var top = this._renderTop;
  10372. var width = this._renderWidth;
  10373. var height = this._renderHeight;
  10374. var radius = 0;
  10375. if (this.isThumbClamped && this.isThumbCircle) {
  10376. if (this.isVertical) {
  10377. top += (this._effectiveThumbThickness / 2);
  10378. }
  10379. else {
  10380. left += (this._effectiveThumbThickness / 2);
  10381. }
  10382. radius = this._backgroundBoxThickness / 2;
  10383. }
  10384. else {
  10385. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10386. }
  10387. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10388. context.shadowColor = this.shadowColor;
  10389. context.shadowBlur = this.shadowBlur;
  10390. context.shadowOffsetX = this.shadowOffsetX;
  10391. context.shadowOffsetY = this.shadowOffsetY;
  10392. }
  10393. var thumbPosition = this._getThumbPosition();
  10394. context.fillStyle = this._background;
  10395. if (this.isVertical) {
  10396. if (this.isThumbClamped) {
  10397. if (this.isThumbCircle) {
  10398. context.beginPath();
  10399. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10400. context.fill();
  10401. context.fillRect(left, top, width, height);
  10402. }
  10403. else {
  10404. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10405. }
  10406. }
  10407. else {
  10408. context.fillRect(left, top, width, height);
  10409. }
  10410. }
  10411. else {
  10412. if (this.isThumbClamped) {
  10413. if (this.isThumbCircle) {
  10414. context.beginPath();
  10415. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10416. context.fill();
  10417. context.fillRect(left, top, width, height);
  10418. }
  10419. else {
  10420. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10421. }
  10422. }
  10423. else {
  10424. context.fillRect(left, top, width, height);
  10425. }
  10426. }
  10427. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10428. context.shadowBlur = 0;
  10429. context.shadowOffsetX = 0;
  10430. context.shadowOffsetY = 0;
  10431. }
  10432. // Value bar
  10433. context.fillStyle = this.color;
  10434. if (this._displayValueBar) {
  10435. if (this.isVertical) {
  10436. if (this.isThumbClamped) {
  10437. if (this.isThumbCircle) {
  10438. context.beginPath();
  10439. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10440. context.fill();
  10441. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10442. }
  10443. else {
  10444. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10445. }
  10446. }
  10447. else {
  10448. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10449. }
  10450. }
  10451. else {
  10452. if (this.isThumbClamped) {
  10453. if (this.isThumbCircle) {
  10454. context.beginPath();
  10455. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10456. context.fill();
  10457. context.fillRect(left, top, thumbPosition, height);
  10458. }
  10459. else {
  10460. context.fillRect(left, top, thumbPosition, height);
  10461. }
  10462. }
  10463. else {
  10464. context.fillRect(left, top, thumbPosition, height);
  10465. }
  10466. }
  10467. }
  10468. // Thumb
  10469. if (this.displayThumb) {
  10470. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10471. context.shadowColor = this.shadowColor;
  10472. context.shadowBlur = this.shadowBlur;
  10473. context.shadowOffsetX = this.shadowOffsetX;
  10474. context.shadowOffsetY = this.shadowOffsetY;
  10475. }
  10476. if (this._isThumbCircle) {
  10477. context.beginPath();
  10478. if (this.isVertical) {
  10479. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10480. }
  10481. else {
  10482. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10483. }
  10484. context.fill();
  10485. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10486. context.shadowBlur = 0;
  10487. context.shadowOffsetX = 0;
  10488. context.shadowOffsetY = 0;
  10489. }
  10490. context.strokeStyle = this._borderColor;
  10491. context.stroke();
  10492. }
  10493. else {
  10494. if (this.isVertical) {
  10495. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10496. }
  10497. else {
  10498. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10499. }
  10500. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10501. context.shadowBlur = 0;
  10502. context.shadowOffsetX = 0;
  10503. context.shadowOffsetY = 0;
  10504. }
  10505. context.strokeStyle = this._borderColor;
  10506. if (this.isVertical) {
  10507. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10508. }
  10509. else {
  10510. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10511. }
  10512. }
  10513. }
  10514. context.restore();
  10515. };
  10516. return Slider;
  10517. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10518. /***/ }),
  10519. /***/ "./2D/controls/stackPanel.ts":
  10520. /*!***********************************!*\
  10521. !*** ./2D/controls/stackPanel.ts ***!
  10522. \***********************************/
  10523. /*! exports provided: StackPanel */
  10524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10525. "use strict";
  10526. __webpack_require__.r(__webpack_exports__);
  10527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10528. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10529. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  10530. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10531. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10532. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10533. /**
  10534. * Class used to create a 2D stack panel container
  10535. */
  10536. var StackPanel = /** @class */ (function (_super) {
  10537. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10538. /**
  10539. * Creates a new StackPanel
  10540. * @param name defines control name
  10541. */
  10542. function StackPanel(name) {
  10543. var _this = _super.call(this, name) || this;
  10544. _this.name = name;
  10545. _this._isVertical = true;
  10546. _this._manualWidth = false;
  10547. _this._manualHeight = false;
  10548. _this._doNotTrackManualChanges = false;
  10549. return _this;
  10550. }
  10551. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10552. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10553. get: function () {
  10554. return this._isVertical;
  10555. },
  10556. set: function (value) {
  10557. if (this._isVertical === value) {
  10558. return;
  10559. }
  10560. this._isVertical = value;
  10561. this._markAsDirty();
  10562. },
  10563. enumerable: true,
  10564. configurable: true
  10565. });
  10566. Object.defineProperty(StackPanel.prototype, "width", {
  10567. get: function () {
  10568. return this._width.toString(this._host);
  10569. },
  10570. /**
  10571. * Gets or sets panel width.
  10572. * This value should not be set when in horizontal mode as it will be computed automatically
  10573. */
  10574. set: function (value) {
  10575. if (!this._doNotTrackManualChanges) {
  10576. this._manualWidth = true;
  10577. }
  10578. if (this._width.toString(this._host) === value) {
  10579. return;
  10580. }
  10581. if (this._width.fromString(value)) {
  10582. this._markAsDirty();
  10583. }
  10584. },
  10585. enumerable: true,
  10586. configurable: true
  10587. });
  10588. Object.defineProperty(StackPanel.prototype, "height", {
  10589. get: function () {
  10590. return this._height.toString(this._host);
  10591. },
  10592. /**
  10593. * Gets or sets panel height.
  10594. * This value should not be set when in vertical mode as it will be computed automatically
  10595. */
  10596. set: function (value) {
  10597. if (!this._doNotTrackManualChanges) {
  10598. this._manualHeight = true;
  10599. }
  10600. if (this._height.toString(this._host) === value) {
  10601. return;
  10602. }
  10603. if (this._height.fromString(value)) {
  10604. this._markAsDirty();
  10605. }
  10606. },
  10607. enumerable: true,
  10608. configurable: true
  10609. });
  10610. StackPanel.prototype._getTypeName = function () {
  10611. return "StackPanel";
  10612. };
  10613. /** @hidden */
  10614. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10615. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10616. var child = _a[_i];
  10617. if (this._isVertical) {
  10618. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10619. }
  10620. else {
  10621. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10622. }
  10623. }
  10624. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10625. };
  10626. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10627. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10628. this._measureForChildren.copyFrom(parentMeasure);
  10629. this._measureForChildren.left = this._currentMeasure.left;
  10630. this._measureForChildren.top = this._currentMeasure.top;
  10631. if (!this.isVertical || this._manualWidth) {
  10632. this._measureForChildren.width = this._currentMeasure.width;
  10633. }
  10634. if (this.isVertical || this._manualHeight) {
  10635. this._measureForChildren.height = this._currentMeasure.height;
  10636. }
  10637. };
  10638. StackPanel.prototype._postMeasure = function () {
  10639. var stackWidth = 0;
  10640. var stackHeight = 0;
  10641. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10642. var child = _a[_i];
  10643. if (!child.isVisible || child.notRenderable) {
  10644. continue;
  10645. }
  10646. if (this._isVertical) {
  10647. if (child.top !== stackHeight + "px") {
  10648. child.top = stackHeight + "px";
  10649. this._rebuildLayout = true;
  10650. child._top.ignoreAdaptiveScaling = true;
  10651. }
  10652. if (child._height.isPercentage) {
  10653. 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");
  10654. }
  10655. else {
  10656. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10657. }
  10658. }
  10659. else {
  10660. if (child.left !== stackWidth + "px") {
  10661. child.left = stackWidth + "px";
  10662. this._rebuildLayout = true;
  10663. child._left.ignoreAdaptiveScaling = true;
  10664. }
  10665. if (child._width.isPercentage) {
  10666. 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");
  10667. }
  10668. else {
  10669. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10670. }
  10671. }
  10672. }
  10673. this._doNotTrackManualChanges = true;
  10674. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10675. // User can now define their own height and width for stack panel.
  10676. var panelWidthChanged = false;
  10677. var panelHeightChanged = false;
  10678. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10679. var previousHeight = this.height;
  10680. this.height = stackHeight + "px";
  10681. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10682. }
  10683. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10684. var previousWidth = this.width;
  10685. this.width = stackWidth + "px";
  10686. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10687. }
  10688. if (panelHeightChanged) {
  10689. this._height.ignoreAdaptiveScaling = true;
  10690. }
  10691. if (panelWidthChanged) {
  10692. this._width.ignoreAdaptiveScaling = true;
  10693. }
  10694. this._doNotTrackManualChanges = false;
  10695. if (panelWidthChanged || panelHeightChanged) {
  10696. this._rebuildLayout = true;
  10697. }
  10698. _super.prototype._postMeasure.call(this);
  10699. };
  10700. return StackPanel;
  10701. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10702. /***/ }),
  10703. /***/ "./2D/controls/statics.ts":
  10704. /*!********************************!*\
  10705. !*** ./2D/controls/statics.ts ***!
  10706. \********************************/
  10707. /*! exports provided: name */
  10708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10709. "use strict";
  10710. __webpack_require__.r(__webpack_exports__);
  10711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10712. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10713. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10714. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10715. /**
  10716. * Forcing an export so that this code will execute
  10717. * @hidden
  10718. */
  10719. var name = "Statics";
  10720. /**
  10721. * Creates a stack panel that can be used to render headers
  10722. * @param control defines the control to associate with the header
  10723. * @param text defines the text of the header
  10724. * @param size defines the size of the header
  10725. * @param options defines options used to configure the header
  10726. * @returns a new StackPanel
  10727. */
  10728. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10729. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10730. var isHorizontal = options ? options.isHorizontal : true;
  10731. var controlFirst = options ? options.controlFirst : true;
  10732. panel.isVertical = !isHorizontal;
  10733. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10734. header.text = text;
  10735. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10736. if (isHorizontal) {
  10737. header.width = size;
  10738. }
  10739. else {
  10740. header.height = size;
  10741. }
  10742. if (controlFirst) {
  10743. panel.addControl(control);
  10744. panel.addControl(header);
  10745. header.paddingLeft = "5px";
  10746. }
  10747. else {
  10748. panel.addControl(header);
  10749. panel.addControl(control);
  10750. header.paddingRight = "5px";
  10751. }
  10752. header.shadowBlur = control.shadowBlur;
  10753. header.shadowColor = control.shadowColor;
  10754. header.shadowOffsetX = control.shadowOffsetX;
  10755. header.shadowOffsetY = control.shadowOffsetY;
  10756. return panel;
  10757. };
  10758. /***/ }),
  10759. /***/ "./2D/controls/textBlock.ts":
  10760. /*!**********************************!*\
  10761. !*** ./2D/controls/textBlock.ts ***!
  10762. \**********************************/
  10763. /*! exports provided: TextWrapping, TextBlock */
  10764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10765. "use strict";
  10766. __webpack_require__.r(__webpack_exports__);
  10767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10769. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10770. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  10771. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10772. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10773. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10774. /**
  10775. * Enum that determines the text-wrapping mode to use.
  10776. */
  10777. var TextWrapping;
  10778. (function (TextWrapping) {
  10779. /**
  10780. * Clip the text when it's larger than Control.width; this is the default mode.
  10781. */
  10782. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10783. /**
  10784. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10785. */
  10786. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10787. /**
  10788. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10789. */
  10790. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10791. })(TextWrapping || (TextWrapping = {}));
  10792. /**
  10793. * Class used to create text block control
  10794. */
  10795. var TextBlock = /** @class */ (function (_super) {
  10796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10797. /**
  10798. * Creates a new TextBlock object
  10799. * @param name defines the name of the control
  10800. * @param text defines the text to display (emptry string by default)
  10801. */
  10802. function TextBlock(
  10803. /**
  10804. * Defines the name of the control
  10805. */
  10806. name, text) {
  10807. if (text === void 0) { text = ""; }
  10808. var _this = _super.call(this, name) || this;
  10809. _this.name = name;
  10810. _this._text = "";
  10811. _this._textWrapping = TextWrapping.Clip;
  10812. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10813. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10814. _this._resizeToFit = false;
  10815. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10816. _this._outlineWidth = 0;
  10817. _this._outlineColor = "white";
  10818. /**
  10819. * An event triggered after the text is changed
  10820. */
  10821. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10822. /**
  10823. * An event triggered after the text was broken up into lines
  10824. */
  10825. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10826. _this.text = text;
  10827. return _this;
  10828. }
  10829. Object.defineProperty(TextBlock.prototype, "lines", {
  10830. /**
  10831. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10832. */
  10833. get: function () {
  10834. return this._lines;
  10835. },
  10836. enumerable: true,
  10837. configurable: true
  10838. });
  10839. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10840. /**
  10841. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10842. */
  10843. get: function () {
  10844. return this._resizeToFit;
  10845. },
  10846. /**
  10847. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10848. */
  10849. set: function (value) {
  10850. if (this._resizeToFit === value) {
  10851. return;
  10852. }
  10853. this._resizeToFit = value;
  10854. if (this._resizeToFit) {
  10855. this._width.ignoreAdaptiveScaling = true;
  10856. this._height.ignoreAdaptiveScaling = true;
  10857. }
  10858. this._markAsDirty();
  10859. },
  10860. enumerable: true,
  10861. configurable: true
  10862. });
  10863. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10864. /**
  10865. * Gets or sets a boolean indicating if text must be wrapped
  10866. */
  10867. get: function () {
  10868. return this._textWrapping;
  10869. },
  10870. /**
  10871. * Gets or sets a boolean indicating if text must be wrapped
  10872. */
  10873. set: function (value) {
  10874. if (this._textWrapping === value) {
  10875. return;
  10876. }
  10877. this._textWrapping = +value;
  10878. this._markAsDirty();
  10879. },
  10880. enumerable: true,
  10881. configurable: true
  10882. });
  10883. Object.defineProperty(TextBlock.prototype, "text", {
  10884. /**
  10885. * Gets or sets text to display
  10886. */
  10887. get: function () {
  10888. return this._text;
  10889. },
  10890. /**
  10891. * Gets or sets text to display
  10892. */
  10893. set: function (value) {
  10894. if (this._text === value) {
  10895. return;
  10896. }
  10897. this._text = value;
  10898. this._markAsDirty();
  10899. this.onTextChangedObservable.notifyObservers(this);
  10900. },
  10901. enumerable: true,
  10902. configurable: true
  10903. });
  10904. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10905. /**
  10906. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10907. */
  10908. get: function () {
  10909. return this._textHorizontalAlignment;
  10910. },
  10911. /**
  10912. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10913. */
  10914. set: function (value) {
  10915. if (this._textHorizontalAlignment === value) {
  10916. return;
  10917. }
  10918. this._textHorizontalAlignment = value;
  10919. this._markAsDirty();
  10920. },
  10921. enumerable: true,
  10922. configurable: true
  10923. });
  10924. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10925. /**
  10926. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10927. */
  10928. get: function () {
  10929. return this._textVerticalAlignment;
  10930. },
  10931. /**
  10932. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10933. */
  10934. set: function (value) {
  10935. if (this._textVerticalAlignment === value) {
  10936. return;
  10937. }
  10938. this._textVerticalAlignment = value;
  10939. this._markAsDirty();
  10940. },
  10941. enumerable: true,
  10942. configurable: true
  10943. });
  10944. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10945. /**
  10946. * Gets or sets line spacing value
  10947. */
  10948. get: function () {
  10949. return this._lineSpacing.toString(this._host);
  10950. },
  10951. /**
  10952. * Gets or sets line spacing value
  10953. */
  10954. set: function (value) {
  10955. if (this._lineSpacing.fromString(value)) {
  10956. this._markAsDirty();
  10957. }
  10958. },
  10959. enumerable: true,
  10960. configurable: true
  10961. });
  10962. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10963. /**
  10964. * Gets or sets outlineWidth of the text to display
  10965. */
  10966. get: function () {
  10967. return this._outlineWidth;
  10968. },
  10969. /**
  10970. * Gets or sets outlineWidth of the text to display
  10971. */
  10972. set: function (value) {
  10973. if (this._outlineWidth === value) {
  10974. return;
  10975. }
  10976. this._outlineWidth = value;
  10977. this._markAsDirty();
  10978. },
  10979. enumerable: true,
  10980. configurable: true
  10981. });
  10982. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  10983. /**
  10984. * Gets or sets outlineColor of the text to display
  10985. */
  10986. get: function () {
  10987. return this._outlineColor;
  10988. },
  10989. /**
  10990. * Gets or sets outlineColor of the text to display
  10991. */
  10992. set: function (value) {
  10993. if (this._outlineColor === value) {
  10994. return;
  10995. }
  10996. this._outlineColor = value;
  10997. this._markAsDirty();
  10998. },
  10999. enumerable: true,
  11000. configurable: true
  11001. });
  11002. TextBlock.prototype._getTypeName = function () {
  11003. return "TextBlock";
  11004. };
  11005. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11006. if (!this._fontOffset) {
  11007. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11008. }
  11009. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11010. // Prepare lines
  11011. this._lines = this._breakLines(this._currentMeasure.width, context);
  11012. this.onLinesReadyObservable.notifyObservers(this);
  11013. var maxLineWidth = 0;
  11014. for (var i = 0; i < this._lines.length; i++) {
  11015. var line = this._lines[i];
  11016. if (line.width > maxLineWidth) {
  11017. maxLineWidth = line.width;
  11018. }
  11019. }
  11020. if (this._resizeToFit) {
  11021. if (this._textWrapping === TextWrapping.Clip) {
  11022. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11023. if (newWidth !== this._width.internalValue) {
  11024. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11025. this._rebuildLayout = true;
  11026. }
  11027. }
  11028. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11029. if (newHeight !== this._height.internalValue) {
  11030. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11031. this._rebuildLayout = true;
  11032. }
  11033. }
  11034. };
  11035. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11036. var width = this._currentMeasure.width;
  11037. var x = 0;
  11038. switch (this._textHorizontalAlignment) {
  11039. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11040. x = 0;
  11041. break;
  11042. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11043. x = width - textWidth;
  11044. break;
  11045. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11046. x = (width - textWidth) / 2;
  11047. break;
  11048. }
  11049. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11050. context.shadowColor = this.shadowColor;
  11051. context.shadowBlur = this.shadowBlur;
  11052. context.shadowOffsetX = this.shadowOffsetX;
  11053. context.shadowOffsetY = this.shadowOffsetY;
  11054. }
  11055. if (this.outlineWidth) {
  11056. context.strokeText(text, this._currentMeasure.left + x, y);
  11057. }
  11058. context.fillText(text, this._currentMeasure.left + x, y);
  11059. };
  11060. /** @hidden */
  11061. TextBlock.prototype._draw = function (context) {
  11062. context.save();
  11063. this._applyStates(context);
  11064. // Render lines
  11065. this._renderLines(context);
  11066. context.restore();
  11067. };
  11068. TextBlock.prototype._applyStates = function (context) {
  11069. _super.prototype._applyStates.call(this, context);
  11070. if (this.outlineWidth) {
  11071. context.lineWidth = this.outlineWidth;
  11072. context.strokeStyle = this.outlineColor;
  11073. }
  11074. };
  11075. TextBlock.prototype._breakLines = function (refWidth, context) {
  11076. var lines = [];
  11077. var _lines = this.text.split("\n");
  11078. if (this._textWrapping === TextWrapping.Ellipsis) {
  11079. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11080. var _line = _lines_1[_i];
  11081. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11082. }
  11083. }
  11084. else if (this._textWrapping === TextWrapping.WordWrap) {
  11085. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11086. var _line = _lines_2[_a];
  11087. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11088. }
  11089. }
  11090. else {
  11091. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11092. var _line = _lines_3[_b];
  11093. lines.push(this._parseLine(_line, context));
  11094. }
  11095. }
  11096. return lines;
  11097. };
  11098. TextBlock.prototype._parseLine = function (line, context) {
  11099. if (line === void 0) { line = ''; }
  11100. return { text: line, width: context.measureText(line).width };
  11101. };
  11102. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11103. if (line === void 0) { line = ''; }
  11104. var lineWidth = context.measureText(line).width;
  11105. if (lineWidth > width) {
  11106. line += '…';
  11107. }
  11108. while (line.length > 2 && lineWidth > width) {
  11109. line = line.slice(0, -2) + '…';
  11110. lineWidth = context.measureText(line).width;
  11111. }
  11112. return { text: line, width: lineWidth };
  11113. };
  11114. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11115. if (line === void 0) { line = ''; }
  11116. var lines = [];
  11117. var words = line.split(' ');
  11118. var lineWidth = 0;
  11119. for (var n = 0; n < words.length; n++) {
  11120. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11121. var metrics = context.measureText(testLine);
  11122. var testWidth = metrics.width;
  11123. if (testWidth > width && n > 0) {
  11124. lines.push({ text: line, width: lineWidth });
  11125. line = words[n];
  11126. lineWidth = context.measureText(line).width;
  11127. }
  11128. else {
  11129. lineWidth = testWidth;
  11130. line = testLine;
  11131. }
  11132. }
  11133. lines.push({ text: line, width: lineWidth });
  11134. return lines;
  11135. };
  11136. TextBlock.prototype._renderLines = function (context) {
  11137. var height = this._currentMeasure.height;
  11138. var rootY = 0;
  11139. switch (this._textVerticalAlignment) {
  11140. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11141. rootY = this._fontOffset.ascent;
  11142. break;
  11143. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11144. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11145. break;
  11146. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11147. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11148. break;
  11149. }
  11150. rootY += this._currentMeasure.top;
  11151. for (var i = 0; i < this._lines.length; i++) {
  11152. var line = this._lines[i];
  11153. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11154. if (this._lineSpacing.isPixel) {
  11155. rootY += this._lineSpacing.getValue(this._host);
  11156. }
  11157. else {
  11158. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11159. }
  11160. }
  11161. this._drawText(line.text, line.width, rootY, context);
  11162. rootY += this._fontOffset.height;
  11163. }
  11164. };
  11165. /**
  11166. * Given a width constraint applied on the text block, find the expected height
  11167. * @returns expected height
  11168. */
  11169. TextBlock.prototype.computeExpectedHeight = function () {
  11170. if (this.text && this.widthInPixels) {
  11171. var context_1 = document.createElement('canvas').getContext('2d');
  11172. if (context_1) {
  11173. this._applyStates(context_1);
  11174. if (!this._fontOffset) {
  11175. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11176. }
  11177. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11178. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11179. }
  11180. }
  11181. return 0;
  11182. };
  11183. TextBlock.prototype.dispose = function () {
  11184. _super.prototype.dispose.call(this);
  11185. this.onTextChangedObservable.clear();
  11186. };
  11187. return TextBlock;
  11188. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11189. /***/ }),
  11190. /***/ "./2D/controls/virtualKeyboard.ts":
  11191. /*!****************************************!*\
  11192. !*** ./2D/controls/virtualKeyboard.ts ***!
  11193. \****************************************/
  11194. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11195. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11196. "use strict";
  11197. __webpack_require__.r(__webpack_exports__);
  11198. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11200. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11201. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  11202. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11203. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11204. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11205. /**
  11206. * Class used to store key control properties
  11207. */
  11208. var KeyPropertySet = /** @class */ (function () {
  11209. function KeyPropertySet() {
  11210. }
  11211. return KeyPropertySet;
  11212. }());
  11213. /**
  11214. * Class used to create virtual keyboard
  11215. */
  11216. var VirtualKeyboard = /** @class */ (function (_super) {
  11217. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11218. function VirtualKeyboard() {
  11219. var _this = _super !== null && _super.apply(this, arguments) || this;
  11220. /** Observable raised when a key is pressed */
  11221. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11222. /** Gets or sets default key button width */
  11223. _this.defaultButtonWidth = "40px";
  11224. /** Gets or sets default key button height */
  11225. _this.defaultButtonHeight = "40px";
  11226. /** Gets or sets default key button left padding */
  11227. _this.defaultButtonPaddingLeft = "2px";
  11228. /** Gets or sets default key button right padding */
  11229. _this.defaultButtonPaddingRight = "2px";
  11230. /** Gets or sets default key button top padding */
  11231. _this.defaultButtonPaddingTop = "2px";
  11232. /** Gets or sets default key button bottom padding */
  11233. _this.defaultButtonPaddingBottom = "2px";
  11234. /** Gets or sets default key button foreground color */
  11235. _this.defaultButtonColor = "#DDD";
  11236. /** Gets or sets default key button background color */
  11237. _this.defaultButtonBackground = "#070707";
  11238. /** Gets or sets shift button foreground color */
  11239. _this.shiftButtonColor = "#7799FF";
  11240. /** Gets or sets shift button thickness*/
  11241. _this.selectedShiftThickness = 1;
  11242. /** Gets shift key state */
  11243. _this.shiftState = 0;
  11244. _this._currentlyConnectedInputText = null;
  11245. _this._connectedInputTexts = [];
  11246. _this._onKeyPressObserver = null;
  11247. return _this;
  11248. }
  11249. VirtualKeyboard.prototype._getTypeName = function () {
  11250. return "VirtualKeyboard";
  11251. };
  11252. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11253. var _this = this;
  11254. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11255. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11256. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11257. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11258. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11259. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11260. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11261. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11262. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11263. button.thickness = 0;
  11264. button.isFocusInvisible = true;
  11265. button.shadowColor = this.shadowColor;
  11266. button.shadowBlur = this.shadowBlur;
  11267. button.shadowOffsetX = this.shadowOffsetX;
  11268. button.shadowOffsetY = this.shadowOffsetY;
  11269. button.onPointerUpObservable.add(function () {
  11270. _this.onKeyPressObservable.notifyObservers(key);
  11271. });
  11272. return button;
  11273. };
  11274. /**
  11275. * Adds a new row of keys
  11276. * @param keys defines the list of keys to add
  11277. * @param propertySets defines the associated property sets
  11278. */
  11279. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11280. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11281. panel.isVertical = false;
  11282. panel.isFocusInvisible = true;
  11283. for (var i = 0; i < keys.length; i++) {
  11284. var properties = null;
  11285. if (propertySets && propertySets.length === keys.length) {
  11286. properties = propertySets[i];
  11287. }
  11288. panel.addControl(this._createKey(keys[i], properties));
  11289. }
  11290. this.addControl(panel);
  11291. };
  11292. /**
  11293. * Set the shift key to a specific state
  11294. * @param shiftState defines the new shift state
  11295. */
  11296. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11297. if (!this.children) {
  11298. return;
  11299. }
  11300. for (var i = 0; i < this.children.length; i++) {
  11301. var row = this.children[i];
  11302. if (!row || !row.children) {
  11303. continue;
  11304. }
  11305. var rowContainer = row;
  11306. for (var j = 0; j < rowContainer.children.length; j++) {
  11307. var button = rowContainer.children[j];
  11308. if (!button || !button.children[0]) {
  11309. continue;
  11310. }
  11311. var button_tblock = button.children[0];
  11312. if (button_tblock.text === "\u21E7") {
  11313. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11314. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11315. }
  11316. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11317. }
  11318. }
  11319. };
  11320. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11321. /** Gets the input text control currently attached to the keyboard */
  11322. get: function () {
  11323. return this._currentlyConnectedInputText;
  11324. },
  11325. enumerable: true,
  11326. configurable: true
  11327. });
  11328. /**
  11329. * Connects the keyboard with an input text control
  11330. *
  11331. * @param input defines the target control
  11332. */
  11333. VirtualKeyboard.prototype.connect = function (input) {
  11334. var _this = this;
  11335. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11336. if (inputTextAlreadyConnected) {
  11337. return;
  11338. }
  11339. if (this._onKeyPressObserver === null) {
  11340. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11341. if (!_this._currentlyConnectedInputText) {
  11342. return;
  11343. }
  11344. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11345. switch (key) {
  11346. case "\u21E7":
  11347. _this.shiftState++;
  11348. if (_this.shiftState > 2) {
  11349. _this.shiftState = 0;
  11350. }
  11351. _this.applyShiftState(_this.shiftState);
  11352. return;
  11353. case "\u2190":
  11354. _this._currentlyConnectedInputText.processKey(8);
  11355. return;
  11356. case "\u21B5":
  11357. _this._currentlyConnectedInputText.processKey(13);
  11358. return;
  11359. }
  11360. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11361. if (_this.shiftState === 1) {
  11362. _this.shiftState = 0;
  11363. _this.applyShiftState(_this.shiftState);
  11364. }
  11365. });
  11366. }
  11367. this.isVisible = false;
  11368. this._currentlyConnectedInputText = input;
  11369. input._connectedVirtualKeyboard = this;
  11370. // Events hooking
  11371. var onFocusObserver = input.onFocusObservable.add(function () {
  11372. _this._currentlyConnectedInputText = input;
  11373. input._connectedVirtualKeyboard = _this;
  11374. _this.isVisible = true;
  11375. });
  11376. var onBlurObserver = input.onBlurObservable.add(function () {
  11377. input._connectedVirtualKeyboard = null;
  11378. _this._currentlyConnectedInputText = null;
  11379. _this.isVisible = false;
  11380. });
  11381. this._connectedInputTexts.push({
  11382. input: input,
  11383. onBlurObserver: onBlurObserver,
  11384. onFocusObserver: onFocusObserver
  11385. });
  11386. };
  11387. /**
  11388. * Disconnects the keyboard from connected InputText controls
  11389. *
  11390. * @param input optionally defines a target control, otherwise all are disconnected
  11391. */
  11392. VirtualKeyboard.prototype.disconnect = function (input) {
  11393. var _this = this;
  11394. if (input) {
  11395. // .find not available on IE
  11396. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11397. if (filtered.length === 1) {
  11398. this._removeConnectedInputObservables(filtered[0]);
  11399. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11400. if (this._currentlyConnectedInputText === input) {
  11401. this._currentlyConnectedInputText = null;
  11402. }
  11403. }
  11404. }
  11405. else {
  11406. this._connectedInputTexts.forEach(function (connectedInputText) {
  11407. _this._removeConnectedInputObservables(connectedInputText);
  11408. });
  11409. this._connectedInputTexts = [];
  11410. }
  11411. if (this._connectedInputTexts.length === 0) {
  11412. this._currentlyConnectedInputText = null;
  11413. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11414. this._onKeyPressObserver = null;
  11415. }
  11416. };
  11417. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11418. connectedInputText.input._connectedVirtualKeyboard = null;
  11419. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11420. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11421. };
  11422. /**
  11423. * Release all resources
  11424. */
  11425. VirtualKeyboard.prototype.dispose = function () {
  11426. _super.prototype.dispose.call(this);
  11427. this.disconnect();
  11428. };
  11429. // Statics
  11430. /**
  11431. * Creates a new keyboard using a default layout
  11432. *
  11433. * @param name defines control name
  11434. * @returns a new VirtualKeyboard
  11435. */
  11436. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11437. var returnValue = new VirtualKeyboard(name);
  11438. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11439. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11440. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11441. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11442. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11443. return returnValue;
  11444. };
  11445. return VirtualKeyboard;
  11446. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11447. /***/ }),
  11448. /***/ "./2D/index.ts":
  11449. /*!*********************!*\
  11450. !*** ./2D/index.ts ***!
  11451. \*********************/
  11452. /*! 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 */
  11453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11454. "use strict";
  11455. __webpack_require__.r(__webpack_exports__);
  11456. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11488. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11490. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11492. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11495. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11497. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11499. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11501. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11503. /***/ }),
  11504. /***/ "./2D/math2D.ts":
  11505. /*!**********************!*\
  11506. !*** ./2D/math2D.ts ***!
  11507. \**********************/
  11508. /*! exports provided: Vector2WithInfo, Matrix2D */
  11509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11510. "use strict";
  11511. __webpack_require__.r(__webpack_exports__);
  11512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11514. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11515. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11516. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11517. /**
  11518. * Class used to transport Vector2 information for pointer events
  11519. */
  11520. var Vector2WithInfo = /** @class */ (function (_super) {
  11521. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11522. /**
  11523. * Creates a new Vector2WithInfo
  11524. * @param source defines the vector2 data to transport
  11525. * @param buttonIndex defines the current mouse button index
  11526. */
  11527. function Vector2WithInfo(source,
  11528. /** defines the current mouse button index */
  11529. buttonIndex) {
  11530. if (buttonIndex === void 0) { buttonIndex = 0; }
  11531. var _this = _super.call(this, source.x, source.y) || this;
  11532. _this.buttonIndex = buttonIndex;
  11533. return _this;
  11534. }
  11535. return Vector2WithInfo;
  11536. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11537. /** Class used to provide 2D matrix features */
  11538. var Matrix2D = /** @class */ (function () {
  11539. /**
  11540. * Creates a new matrix
  11541. * @param m00 defines value for (0, 0)
  11542. * @param m01 defines value for (0, 1)
  11543. * @param m10 defines value for (1, 0)
  11544. * @param m11 defines value for (1, 1)
  11545. * @param m20 defines value for (2, 0)
  11546. * @param m21 defines value for (2, 1)
  11547. */
  11548. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11549. /** Gets the internal array of 6 floats used to store matrix data */
  11550. this.m = new Float32Array(6);
  11551. this.fromValues(m00, m01, m10, m11, m20, m21);
  11552. }
  11553. /**
  11554. * Fills the matrix from direct values
  11555. * @param m00 defines value for (0, 0)
  11556. * @param m01 defines value for (0, 1)
  11557. * @param m10 defines value for (1, 0)
  11558. * @param m11 defines value for (1, 1)
  11559. * @param m20 defines value for (2, 0)
  11560. * @param m21 defines value for (2, 1)
  11561. * @returns the current modified matrix
  11562. */
  11563. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11564. this.m[0] = m00;
  11565. this.m[1] = m01;
  11566. this.m[2] = m10;
  11567. this.m[3] = m11;
  11568. this.m[4] = m20;
  11569. this.m[5] = m21;
  11570. return this;
  11571. };
  11572. /**
  11573. * Gets matrix determinant
  11574. * @returns the determinant
  11575. */
  11576. Matrix2D.prototype.determinant = function () {
  11577. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11578. };
  11579. /**
  11580. * Inverses the matrix and stores it in a target matrix
  11581. * @param result defines the target matrix
  11582. * @returns the current matrix
  11583. */
  11584. Matrix2D.prototype.invertToRef = function (result) {
  11585. var l0 = this.m[0];
  11586. var l1 = this.m[1];
  11587. var l2 = this.m[2];
  11588. var l3 = this.m[3];
  11589. var l4 = this.m[4];
  11590. var l5 = this.m[5];
  11591. var det = this.determinant();
  11592. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11593. result.m[0] = 0;
  11594. result.m[1] = 0;
  11595. result.m[2] = 0;
  11596. result.m[3] = 0;
  11597. result.m[4] = 0;
  11598. result.m[5] = 0;
  11599. return this;
  11600. }
  11601. var detDiv = 1 / det;
  11602. var det4 = l2 * l5 - l3 * l4;
  11603. var det5 = l1 * l4 - l0 * l5;
  11604. result.m[0] = l3 * detDiv;
  11605. result.m[1] = -l1 * detDiv;
  11606. result.m[2] = -l2 * detDiv;
  11607. result.m[3] = l0 * detDiv;
  11608. result.m[4] = det4 * detDiv;
  11609. result.m[5] = det5 * detDiv;
  11610. return this;
  11611. };
  11612. /**
  11613. * Multiplies the current matrix with another one
  11614. * @param other defines the second operand
  11615. * @param result defines the target matrix
  11616. * @returns the current matrix
  11617. */
  11618. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11619. var l0 = this.m[0];
  11620. var l1 = this.m[1];
  11621. var l2 = this.m[2];
  11622. var l3 = this.m[3];
  11623. var l4 = this.m[4];
  11624. var l5 = this.m[5];
  11625. var r0 = other.m[0];
  11626. var r1 = other.m[1];
  11627. var r2 = other.m[2];
  11628. var r3 = other.m[3];
  11629. var r4 = other.m[4];
  11630. var r5 = other.m[5];
  11631. result.m[0] = l0 * r0 + l1 * r2;
  11632. result.m[1] = l0 * r1 + l1 * r3;
  11633. result.m[2] = l2 * r0 + l3 * r2;
  11634. result.m[3] = l2 * r1 + l3 * r3;
  11635. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11636. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11637. return this;
  11638. };
  11639. /**
  11640. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11641. * @param x defines the x coordinate to transform
  11642. * @param y defines the x coordinate to transform
  11643. * @param result defines the target vector2
  11644. * @returns the current matrix
  11645. */
  11646. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11647. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11648. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11649. return this;
  11650. };
  11651. // Statics
  11652. /**
  11653. * Creates an identity matrix
  11654. * @returns a new matrix
  11655. */
  11656. Matrix2D.Identity = function () {
  11657. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11658. };
  11659. /**
  11660. * Creates a translation matrix and stores it in a target matrix
  11661. * @param x defines the x coordinate of the translation
  11662. * @param y defines the y coordinate of the translation
  11663. * @param result defines the target matrix
  11664. */
  11665. Matrix2D.TranslationToRef = function (x, y, result) {
  11666. result.fromValues(1, 0, 0, 1, x, y);
  11667. };
  11668. /**
  11669. * Creates a scaling matrix and stores it in a target matrix
  11670. * @param x defines the x coordinate of the scaling
  11671. * @param y defines the y coordinate of the scaling
  11672. * @param result defines the target matrix
  11673. */
  11674. Matrix2D.ScalingToRef = function (x, y, result) {
  11675. result.fromValues(x, 0, 0, y, 0, 0);
  11676. };
  11677. /**
  11678. * Creates a rotation matrix and stores it in a target matrix
  11679. * @param angle defines the rotation angle
  11680. * @param result defines the target matrix
  11681. */
  11682. Matrix2D.RotationToRef = function (angle, result) {
  11683. var s = Math.sin(angle);
  11684. var c = Math.cos(angle);
  11685. result.fromValues(c, s, -s, c, 0, 0);
  11686. };
  11687. /**
  11688. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11689. * @param tx defines the x coordinate of the translation
  11690. * @param ty defines the y coordinate of the translation
  11691. * @param angle defines the rotation angle
  11692. * @param scaleX defines the x coordinate of the scaling
  11693. * @param scaleY defines the y coordinate of the scaling
  11694. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11695. * @param result defines the target matrix
  11696. */
  11697. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11698. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11699. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11700. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11701. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11702. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11703. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11704. if (parentMatrix) {
  11705. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11706. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11707. }
  11708. else {
  11709. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11710. }
  11711. };
  11712. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11713. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11714. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11715. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11716. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11717. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11718. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11719. return Matrix2D;
  11720. }());
  11721. /***/ }),
  11722. /***/ "./2D/measure.ts":
  11723. /*!***********************!*\
  11724. !*** ./2D/measure.ts ***!
  11725. \***********************/
  11726. /*! exports provided: Measure */
  11727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11728. "use strict";
  11729. __webpack_require__.r(__webpack_exports__);
  11730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11731. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11732. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11733. /**
  11734. * Class used to store 2D control sizes
  11735. */
  11736. var Measure = /** @class */ (function () {
  11737. /**
  11738. * Creates a new measure
  11739. * @param left defines left coordinate
  11740. * @param top defines top coordinate
  11741. * @param width defines width dimension
  11742. * @param height defines height dimension
  11743. */
  11744. function Measure(
  11745. /** defines left coordinate */
  11746. left,
  11747. /** defines top coordinate */
  11748. top,
  11749. /** defines width dimension */
  11750. width,
  11751. /** defines height dimension */
  11752. height) {
  11753. this.left = left;
  11754. this.top = top;
  11755. this.width = width;
  11756. this.height = height;
  11757. }
  11758. /**
  11759. * Copy from another measure
  11760. * @param other defines the other measure to copy from
  11761. */
  11762. Measure.prototype.copyFrom = function (other) {
  11763. this.left = other.left;
  11764. this.top = other.top;
  11765. this.width = other.width;
  11766. this.height = other.height;
  11767. };
  11768. /**
  11769. * Copy from a group of 4 floats
  11770. * @param left defines left coordinate
  11771. * @param top defines top coordinate
  11772. * @param width defines width dimension
  11773. * @param height defines height dimension
  11774. */
  11775. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11776. this.left = left;
  11777. this.top = top;
  11778. this.width = width;
  11779. this.height = height;
  11780. };
  11781. /**
  11782. * Computes the axis aligned bounding box measure for two given measures
  11783. * @param a Input measure
  11784. * @param b Input measure
  11785. * @param result the resulting bounding measure
  11786. */
  11787. Measure.CombineToRef = function (a, b, result) {
  11788. var left = Math.min(a.left, b.left);
  11789. var top = Math.min(a.top, b.top);
  11790. var right = Math.max(a.left + a.width, b.left + b.width);
  11791. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11792. result.left = left;
  11793. result.top = top;
  11794. result.width = right - left;
  11795. result.height = bottom - top;
  11796. };
  11797. /**
  11798. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11799. * @param transform the matrix to transform the measure before computing the AABB
  11800. * @param result the resulting AABB
  11801. */
  11802. Measure.prototype.transformToRef = function (transform, result) {
  11803. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11804. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11805. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11806. for (var i = 0; i < 4; i++) {
  11807. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11808. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11809. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11810. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11811. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11812. }
  11813. result.left = min.x;
  11814. result.top = min.y;
  11815. result.width = max.x - min.x;
  11816. result.height = max.y - min.y;
  11817. };
  11818. /**
  11819. * Check equality between this measure and another one
  11820. * @param other defines the other measures
  11821. * @returns true if both measures are equals
  11822. */
  11823. Measure.prototype.isEqualsTo = function (other) {
  11824. if (this.left !== other.left) {
  11825. return false;
  11826. }
  11827. if (this.top !== other.top) {
  11828. return false;
  11829. }
  11830. if (this.width !== other.width) {
  11831. return false;
  11832. }
  11833. if (this.height !== other.height) {
  11834. return false;
  11835. }
  11836. return true;
  11837. };
  11838. /**
  11839. * Creates an empty measure
  11840. * @returns a new measure
  11841. */
  11842. Measure.Empty = function () {
  11843. return new Measure(0, 0, 0, 0);
  11844. };
  11845. return Measure;
  11846. }());
  11847. /***/ }),
  11848. /***/ "./2D/multiLinePoint.ts":
  11849. /*!******************************!*\
  11850. !*** ./2D/multiLinePoint.ts ***!
  11851. \******************************/
  11852. /*! exports provided: MultiLinePoint */
  11853. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11854. "use strict";
  11855. __webpack_require__.r(__webpack_exports__);
  11856. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11857. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11858. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11859. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11860. /**
  11861. * Class used to store a point for a MultiLine object.
  11862. * The point can be pure 2D coordinates, a mesh or a control
  11863. */
  11864. var MultiLinePoint = /** @class */ (function () {
  11865. /**
  11866. * Creates a new MultiLinePoint
  11867. * @param multiLine defines the source MultiLine object
  11868. */
  11869. function MultiLinePoint(multiLine) {
  11870. this._multiLine = multiLine;
  11871. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11872. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11873. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11874. }
  11875. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11876. /** Gets or sets x coordinate */
  11877. get: function () {
  11878. return this._x.toString(this._multiLine._host);
  11879. },
  11880. set: function (value) {
  11881. if (this._x.toString(this._multiLine._host) === value) {
  11882. return;
  11883. }
  11884. if (this._x.fromString(value)) {
  11885. this._multiLine._markAsDirty();
  11886. }
  11887. },
  11888. enumerable: true,
  11889. configurable: true
  11890. });
  11891. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11892. /** Gets or sets y coordinate */
  11893. get: function () {
  11894. return this._y.toString(this._multiLine._host);
  11895. },
  11896. set: function (value) {
  11897. if (this._y.toString(this._multiLine._host) === value) {
  11898. return;
  11899. }
  11900. if (this._y.fromString(value)) {
  11901. this._multiLine._markAsDirty();
  11902. }
  11903. },
  11904. enumerable: true,
  11905. configurable: true
  11906. });
  11907. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11908. /** Gets or sets the control associated with this point */
  11909. get: function () {
  11910. return this._control;
  11911. },
  11912. set: function (value) {
  11913. if (this._control === value) {
  11914. return;
  11915. }
  11916. if (this._control && this._controlObserver) {
  11917. this._control.onDirtyObservable.remove(this._controlObserver);
  11918. this._controlObserver = null;
  11919. }
  11920. this._control = value;
  11921. if (this._control) {
  11922. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11923. }
  11924. this._multiLine._markAsDirty();
  11925. },
  11926. enumerable: true,
  11927. configurable: true
  11928. });
  11929. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11930. /** Gets or sets the mesh associated with this point */
  11931. get: function () {
  11932. return this._mesh;
  11933. },
  11934. set: function (value) {
  11935. if (this._mesh === value) {
  11936. return;
  11937. }
  11938. if (this._mesh && this._meshObserver) {
  11939. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11940. }
  11941. this._mesh = value;
  11942. if (this._mesh) {
  11943. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11944. }
  11945. this._multiLine._markAsDirty();
  11946. },
  11947. enumerable: true,
  11948. configurable: true
  11949. });
  11950. /** Resets links */
  11951. MultiLinePoint.prototype.resetLinks = function () {
  11952. this.control = null;
  11953. this.mesh = null;
  11954. };
  11955. /**
  11956. * Gets a translation vector
  11957. * @returns the translation vector
  11958. */
  11959. MultiLinePoint.prototype.translate = function () {
  11960. this._point = this._translatePoint();
  11961. return this._point;
  11962. };
  11963. MultiLinePoint.prototype._translatePoint = function () {
  11964. if (this._mesh != null) {
  11965. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  11966. }
  11967. else if (this._control != null) {
  11968. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  11969. }
  11970. else {
  11971. var host = this._multiLine._host;
  11972. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  11973. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  11974. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  11975. }
  11976. };
  11977. /** Release associated resources */
  11978. MultiLinePoint.prototype.dispose = function () {
  11979. this.resetLinks();
  11980. };
  11981. return MultiLinePoint;
  11982. }());
  11983. /***/ }),
  11984. /***/ "./2D/style.ts":
  11985. /*!*********************!*\
  11986. !*** ./2D/style.ts ***!
  11987. \*********************/
  11988. /*! exports provided: Style */
  11989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11990. "use strict";
  11991. __webpack_require__.r(__webpack_exports__);
  11992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  11993. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  11994. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  11995. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11996. /**
  11997. * Define a style used by control to automatically setup properties based on a template.
  11998. * Only support font related properties so far
  11999. */
  12000. var Style = /** @class */ (function () {
  12001. /**
  12002. * Creates a new style object
  12003. * @param host defines the AdvancedDynamicTexture which hosts this style
  12004. */
  12005. function Style(host) {
  12006. this._fontFamily = "Arial";
  12007. this._fontStyle = "";
  12008. this._fontWeight = "";
  12009. /** @hidden */
  12010. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12011. /**
  12012. * Observable raised when the style values are changed
  12013. */
  12014. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12015. this._host = host;
  12016. }
  12017. Object.defineProperty(Style.prototype, "fontSize", {
  12018. /**
  12019. * Gets or sets the font size
  12020. */
  12021. get: function () {
  12022. return this._fontSize.toString(this._host);
  12023. },
  12024. set: function (value) {
  12025. if (this._fontSize.toString(this._host) === value) {
  12026. return;
  12027. }
  12028. if (this._fontSize.fromString(value)) {
  12029. this.onChangedObservable.notifyObservers(this);
  12030. }
  12031. },
  12032. enumerable: true,
  12033. configurable: true
  12034. });
  12035. Object.defineProperty(Style.prototype, "fontFamily", {
  12036. /**
  12037. * Gets or sets the font family
  12038. */
  12039. get: function () {
  12040. return this._fontFamily;
  12041. },
  12042. set: function (value) {
  12043. if (this._fontFamily === value) {
  12044. return;
  12045. }
  12046. this._fontFamily = value;
  12047. this.onChangedObservable.notifyObservers(this);
  12048. },
  12049. enumerable: true,
  12050. configurable: true
  12051. });
  12052. Object.defineProperty(Style.prototype, "fontStyle", {
  12053. /**
  12054. * Gets or sets the font style
  12055. */
  12056. get: function () {
  12057. return this._fontStyle;
  12058. },
  12059. set: function (value) {
  12060. if (this._fontStyle === value) {
  12061. return;
  12062. }
  12063. this._fontStyle = value;
  12064. this.onChangedObservable.notifyObservers(this);
  12065. },
  12066. enumerable: true,
  12067. configurable: true
  12068. });
  12069. Object.defineProperty(Style.prototype, "fontWeight", {
  12070. /** Gets or sets font weight */
  12071. get: function () {
  12072. return this._fontWeight;
  12073. },
  12074. set: function (value) {
  12075. if (this._fontWeight === value) {
  12076. return;
  12077. }
  12078. this._fontWeight = value;
  12079. this.onChangedObservable.notifyObservers(this);
  12080. },
  12081. enumerable: true,
  12082. configurable: true
  12083. });
  12084. /** Dispose all associated resources */
  12085. Style.prototype.dispose = function () {
  12086. this.onChangedObservable.clear();
  12087. };
  12088. return Style;
  12089. }());
  12090. /***/ }),
  12091. /***/ "./2D/valueAndUnit.ts":
  12092. /*!****************************!*\
  12093. !*** ./2D/valueAndUnit.ts ***!
  12094. \****************************/
  12095. /*! exports provided: ValueAndUnit */
  12096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12097. "use strict";
  12098. __webpack_require__.r(__webpack_exports__);
  12099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12100. /**
  12101. * Class used to specific a value and its associated unit
  12102. */
  12103. var ValueAndUnit = /** @class */ (function () {
  12104. /**
  12105. * Creates a new ValueAndUnit
  12106. * @param value defines the value to store
  12107. * @param unit defines the unit to store
  12108. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12109. */
  12110. function ValueAndUnit(value,
  12111. /** defines the unit to store */
  12112. unit,
  12113. /** defines a boolean indicating if the value can be negative */
  12114. negativeValueAllowed) {
  12115. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12116. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12117. this.unit = unit;
  12118. this.negativeValueAllowed = negativeValueAllowed;
  12119. this._value = 1;
  12120. /**
  12121. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12122. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12123. */
  12124. this.ignoreAdaptiveScaling = false;
  12125. this._value = value;
  12126. this._originalUnit = unit;
  12127. }
  12128. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12129. /** Gets a boolean indicating if the value is a percentage */
  12130. get: function () {
  12131. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12132. },
  12133. enumerable: true,
  12134. configurable: true
  12135. });
  12136. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12137. /** Gets a boolean indicating if the value is store as pixel */
  12138. get: function () {
  12139. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12140. },
  12141. enumerable: true,
  12142. configurable: true
  12143. });
  12144. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12145. /** Gets direct internal value */
  12146. get: function () {
  12147. return this._value;
  12148. },
  12149. enumerable: true,
  12150. configurable: true
  12151. });
  12152. /**
  12153. * Gets value as pixel
  12154. * @param host defines the root host
  12155. * @param refValue defines the reference value for percentages
  12156. * @returns the value as pixel
  12157. */
  12158. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12159. if (this.isPixel) {
  12160. return this.getValue(host);
  12161. }
  12162. return this.getValue(host) * refValue;
  12163. };
  12164. /**
  12165. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12166. * @param value defines the value to store
  12167. * @param unit defines the unit to store
  12168. * @returns the current ValueAndUnit
  12169. */
  12170. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12171. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12172. this._value = value;
  12173. this.unit = unit;
  12174. return this;
  12175. };
  12176. /**
  12177. * Gets the value accordingly to its unit
  12178. * @param host defines the root host
  12179. * @returns the value
  12180. */
  12181. ValueAndUnit.prototype.getValue = function (host) {
  12182. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12183. var width = 0;
  12184. var height = 0;
  12185. if (host.idealWidth) {
  12186. width = (this._value * host.getSize().width) / host.idealWidth;
  12187. }
  12188. if (host.idealHeight) {
  12189. height = (this._value * host.getSize().height) / host.idealHeight;
  12190. }
  12191. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12192. return window.innerWidth < window.innerHeight ? width : height;
  12193. }
  12194. if (host.idealWidth) { // horizontal
  12195. return width;
  12196. }
  12197. if (host.idealHeight) { // vertical
  12198. return height;
  12199. }
  12200. }
  12201. return this._value;
  12202. };
  12203. /**
  12204. * Gets a string representation of the value
  12205. * @param host defines the root host
  12206. * @param decimals defines an optional number of decimals to display
  12207. * @returns a string
  12208. */
  12209. ValueAndUnit.prototype.toString = function (host, decimals) {
  12210. switch (this.unit) {
  12211. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12212. var percentage = this.getValue(host) * 100;
  12213. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12214. case ValueAndUnit.UNITMODE_PIXEL:
  12215. var pixels = this.getValue(host);
  12216. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12217. }
  12218. return this.unit.toString();
  12219. };
  12220. /**
  12221. * Store a value parsed from a string
  12222. * @param source defines the source string
  12223. * @returns true if the value was successfully parsed
  12224. */
  12225. ValueAndUnit.prototype.fromString = function (source) {
  12226. var match = ValueAndUnit._Regex.exec(source.toString());
  12227. if (!match || match.length === 0) {
  12228. return false;
  12229. }
  12230. var sourceValue = parseFloat(match[1]);
  12231. var sourceUnit = this._originalUnit;
  12232. if (!this.negativeValueAllowed) {
  12233. if (sourceValue < 0) {
  12234. sourceValue = 0;
  12235. }
  12236. }
  12237. if (match.length === 4) {
  12238. switch (match[3]) {
  12239. case "px":
  12240. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12241. break;
  12242. case "%":
  12243. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12244. sourceValue /= 100.0;
  12245. break;
  12246. }
  12247. }
  12248. if (sourceValue === this._value && sourceUnit === this.unit) {
  12249. return false;
  12250. }
  12251. this._value = sourceValue;
  12252. this.unit = sourceUnit;
  12253. return true;
  12254. };
  12255. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12256. /** UNITMODE_PERCENTAGE */
  12257. get: function () {
  12258. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12259. },
  12260. enumerable: true,
  12261. configurable: true
  12262. });
  12263. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12264. /** UNITMODE_PIXEL */
  12265. get: function () {
  12266. return ValueAndUnit._UNITMODE_PIXEL;
  12267. },
  12268. enumerable: true,
  12269. configurable: true
  12270. });
  12271. // Static
  12272. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12273. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12274. ValueAndUnit._UNITMODE_PIXEL = 1;
  12275. return ValueAndUnit;
  12276. }());
  12277. /***/ }),
  12278. /***/ "./3D/controls/abstractButton3D.ts":
  12279. /*!*****************************************!*\
  12280. !*** ./3D/controls/abstractButton3D.ts ***!
  12281. \*****************************************/
  12282. /*! exports provided: AbstractButton3D */
  12283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12284. "use strict";
  12285. __webpack_require__.r(__webpack_exports__);
  12286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12287. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12288. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/tools");
  12289. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12290. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12291. /**
  12292. * Class used as a root to all buttons
  12293. */
  12294. var AbstractButton3D = /** @class */ (function (_super) {
  12295. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12296. /**
  12297. * Creates a new button
  12298. * @param name defines the control name
  12299. */
  12300. function AbstractButton3D(name) {
  12301. return _super.call(this, name) || this;
  12302. }
  12303. AbstractButton3D.prototype._getTypeName = function () {
  12304. return "AbstractButton3D";
  12305. };
  12306. // Mesh association
  12307. AbstractButton3D.prototype._createNode = function (scene) {
  12308. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12309. };
  12310. return AbstractButton3D;
  12311. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12312. /***/ }),
  12313. /***/ "./3D/controls/button3D.ts":
  12314. /*!*********************************!*\
  12315. !*** ./3D/controls/button3D.ts ***!
  12316. \*********************************/
  12317. /*! exports provided: Button3D */
  12318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12319. "use strict";
  12320. __webpack_require__.r(__webpack_exports__);
  12321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12322. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12323. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  12324. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12325. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12326. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12327. /**
  12328. * Class used to create a button in 3D
  12329. */
  12330. var Button3D = /** @class */ (function (_super) {
  12331. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12332. /**
  12333. * Creates a new button
  12334. * @param name defines the control name
  12335. */
  12336. function Button3D(name) {
  12337. var _this = _super.call(this, name) || this;
  12338. _this._contentResolution = 512;
  12339. _this._contentScaleRatio = 2;
  12340. // Default animations
  12341. _this.pointerEnterAnimation = function () {
  12342. if (!_this.mesh) {
  12343. return;
  12344. }
  12345. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12346. };
  12347. _this.pointerOutAnimation = function () {
  12348. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12349. };
  12350. _this.pointerDownAnimation = function () {
  12351. if (!_this.mesh) {
  12352. return;
  12353. }
  12354. _this.mesh.scaling.scaleInPlace(0.95);
  12355. };
  12356. _this.pointerUpAnimation = function () {
  12357. if (!_this.mesh) {
  12358. return;
  12359. }
  12360. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12361. };
  12362. return _this;
  12363. }
  12364. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12365. /**
  12366. * Gets or sets the texture resolution used to render content (512 by default)
  12367. */
  12368. get: function () {
  12369. return this._contentResolution;
  12370. },
  12371. set: function (value) {
  12372. if (this._contentResolution === value) {
  12373. return;
  12374. }
  12375. this._contentResolution = value;
  12376. this._resetContent();
  12377. },
  12378. enumerable: true,
  12379. configurable: true
  12380. });
  12381. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12382. /**
  12383. * Gets or sets the texture scale ratio used to render content (2 by default)
  12384. */
  12385. get: function () {
  12386. return this._contentScaleRatio;
  12387. },
  12388. set: function (value) {
  12389. if (this._contentScaleRatio === value) {
  12390. return;
  12391. }
  12392. this._contentScaleRatio = value;
  12393. this._resetContent();
  12394. },
  12395. enumerable: true,
  12396. configurable: true
  12397. });
  12398. Button3D.prototype._disposeFacadeTexture = function () {
  12399. if (this._facadeTexture) {
  12400. this._facadeTexture.dispose();
  12401. this._facadeTexture = null;
  12402. }
  12403. };
  12404. Button3D.prototype._resetContent = function () {
  12405. this._disposeFacadeTexture();
  12406. this.content = this._content;
  12407. };
  12408. Object.defineProperty(Button3D.prototype, "content", {
  12409. /**
  12410. * Gets or sets the GUI 2D content used to display the button's facade
  12411. */
  12412. get: function () {
  12413. return this._content;
  12414. },
  12415. set: function (value) {
  12416. this._content = value;
  12417. if (!this._host || !this._host.utilityLayer) {
  12418. return;
  12419. }
  12420. if (!this._facadeTexture) {
  12421. 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);
  12422. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12423. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12424. this._facadeTexture.premulAlpha = true;
  12425. }
  12426. this._facadeTexture.addControl(value);
  12427. this._applyFacade(this._facadeTexture);
  12428. },
  12429. enumerable: true,
  12430. configurable: true
  12431. });
  12432. /**
  12433. * Apply the facade texture (created from the content property).
  12434. * This function can be overloaded by child classes
  12435. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12436. */
  12437. Button3D.prototype._applyFacade = function (facadeTexture) {
  12438. this._currentMaterial.emissiveTexture = facadeTexture;
  12439. };
  12440. Button3D.prototype._getTypeName = function () {
  12441. return "Button3D";
  12442. };
  12443. // Mesh association
  12444. Button3D.prototype._createNode = function (scene) {
  12445. var faceUV = new Array(6);
  12446. for (var i = 0; i < 6; i++) {
  12447. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12448. }
  12449. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12450. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12451. width: 1.0,
  12452. height: 1.0,
  12453. depth: 0.08,
  12454. faceUV: faceUV
  12455. }, scene);
  12456. return mesh;
  12457. };
  12458. Button3D.prototype._affectMaterial = function (mesh) {
  12459. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12460. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12461. mesh.material = material;
  12462. this._currentMaterial = material;
  12463. this._resetContent();
  12464. };
  12465. /**
  12466. * Releases all associated resources
  12467. */
  12468. Button3D.prototype.dispose = function () {
  12469. _super.prototype.dispose.call(this);
  12470. this._disposeFacadeTexture();
  12471. if (this._currentMaterial) {
  12472. this._currentMaterial.dispose();
  12473. }
  12474. };
  12475. return Button3D;
  12476. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12477. /***/ }),
  12478. /***/ "./3D/controls/container3D.ts":
  12479. /*!************************************!*\
  12480. !*** ./3D/controls/container3D.ts ***!
  12481. \************************************/
  12482. /*! exports provided: Container3D */
  12483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12484. "use strict";
  12485. __webpack_require__.r(__webpack_exports__);
  12486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12487. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12488. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/tools");
  12489. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12490. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12491. /**
  12492. * Class used to create containers for controls
  12493. */
  12494. var Container3D = /** @class */ (function (_super) {
  12495. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12496. /**
  12497. * Creates a new container
  12498. * @param name defines the container name
  12499. */
  12500. function Container3D(name) {
  12501. var _this = _super.call(this, name) || this;
  12502. _this._blockLayout = false;
  12503. /**
  12504. * Gets the list of child controls
  12505. */
  12506. _this._children = new Array();
  12507. return _this;
  12508. }
  12509. Object.defineProperty(Container3D.prototype, "children", {
  12510. /**
  12511. * Gets the list of child controls
  12512. */
  12513. get: function () {
  12514. return this._children;
  12515. },
  12516. enumerable: true,
  12517. configurable: true
  12518. });
  12519. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12520. /**
  12521. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12522. * This is helpful to optimize layout operation when adding multiple children in a row
  12523. */
  12524. get: function () {
  12525. return this._blockLayout;
  12526. },
  12527. set: function (value) {
  12528. if (this._blockLayout === value) {
  12529. return;
  12530. }
  12531. this._blockLayout = value;
  12532. if (!this._blockLayout) {
  12533. this._arrangeChildren();
  12534. }
  12535. },
  12536. enumerable: true,
  12537. configurable: true
  12538. });
  12539. /**
  12540. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12541. * @returns the current container
  12542. */
  12543. Container3D.prototype.updateLayout = function () {
  12544. this._arrangeChildren();
  12545. return this;
  12546. };
  12547. /**
  12548. * Gets a boolean indicating if the given control is in the children of this control
  12549. * @param control defines the control to check
  12550. * @returns true if the control is in the child list
  12551. */
  12552. Container3D.prototype.containsControl = function (control) {
  12553. return this._children.indexOf(control) !== -1;
  12554. };
  12555. /**
  12556. * Adds a control to the children of this control
  12557. * @param control defines the control to add
  12558. * @returns the current container
  12559. */
  12560. Container3D.prototype.addControl = function (control) {
  12561. var index = this._children.indexOf(control);
  12562. if (index !== -1) {
  12563. return this;
  12564. }
  12565. control.parent = this;
  12566. control._host = this._host;
  12567. this._children.push(control);
  12568. if (this._host.utilityLayer) {
  12569. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12570. if (control.node) {
  12571. control.node.parent = this.node;
  12572. }
  12573. if (!this.blockLayout) {
  12574. this._arrangeChildren();
  12575. }
  12576. }
  12577. return this;
  12578. };
  12579. /**
  12580. * This function will be called everytime a new control is added
  12581. */
  12582. Container3D.prototype._arrangeChildren = function () {
  12583. };
  12584. Container3D.prototype._createNode = function (scene) {
  12585. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12586. };
  12587. /**
  12588. * Removes a control from the children of this control
  12589. * @param control defines the control to remove
  12590. * @returns the current container
  12591. */
  12592. Container3D.prototype.removeControl = function (control) {
  12593. var index = this._children.indexOf(control);
  12594. if (index !== -1) {
  12595. this._children.splice(index, 1);
  12596. control.parent = null;
  12597. control._disposeNode();
  12598. }
  12599. return this;
  12600. };
  12601. Container3D.prototype._getTypeName = function () {
  12602. return "Container3D";
  12603. };
  12604. /**
  12605. * Releases all associated resources
  12606. */
  12607. Container3D.prototype.dispose = function () {
  12608. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12609. var control = _a[_i];
  12610. control.dispose();
  12611. }
  12612. this._children = [];
  12613. _super.prototype.dispose.call(this);
  12614. };
  12615. /** Control rotation will remain unchanged */
  12616. Container3D.UNSET_ORIENTATION = 0;
  12617. /** Control will rotate to make it look at sphere central axis */
  12618. Container3D.FACEORIGIN_ORIENTATION = 1;
  12619. /** Control will rotate to make it look back at sphere central axis */
  12620. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12621. /** Control will rotate to look at z axis (0, 0, 1) */
  12622. Container3D.FACEFORWARD_ORIENTATION = 3;
  12623. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12624. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12625. return Container3D;
  12626. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12627. /***/ }),
  12628. /***/ "./3D/controls/control3D.ts":
  12629. /*!**********************************!*\
  12630. !*** ./3D/controls/control3D.ts ***!
  12631. \**********************************/
  12632. /*! exports provided: Control3D */
  12633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12634. "use strict";
  12635. __webpack_require__.r(__webpack_exports__);
  12636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12637. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  12638. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12639. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12640. /**
  12641. * Class used as base class for controls
  12642. */
  12643. var Control3D = /** @class */ (function () {
  12644. /**
  12645. * Creates a new control
  12646. * @param name defines the control name
  12647. */
  12648. function Control3D(
  12649. /** Defines the control name */
  12650. name) {
  12651. this.name = name;
  12652. this._downCount = 0;
  12653. this._enterCount = -1;
  12654. this._downPointerIds = {};
  12655. this._isVisible = true;
  12656. /**
  12657. * An event triggered when the pointer move over the control
  12658. */
  12659. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12660. /**
  12661. * An event triggered when the pointer move out of the control
  12662. */
  12663. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12664. /**
  12665. * An event triggered when the pointer taps the control
  12666. */
  12667. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12668. /**
  12669. * An event triggered when pointer is up
  12670. */
  12671. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12672. /**
  12673. * An event triggered when a control is clicked on (with a mouse)
  12674. */
  12675. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12676. /**
  12677. * An event triggered when pointer enters the control
  12678. */
  12679. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12680. // Behaviors
  12681. this._behaviors = new Array();
  12682. }
  12683. Object.defineProperty(Control3D.prototype, "position", {
  12684. /** Gets or sets the control position in world space */
  12685. get: function () {
  12686. if (!this._node) {
  12687. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12688. }
  12689. return this._node.position;
  12690. },
  12691. set: function (value) {
  12692. if (!this._node) {
  12693. return;
  12694. }
  12695. this._node.position = value;
  12696. },
  12697. enumerable: true,
  12698. configurable: true
  12699. });
  12700. Object.defineProperty(Control3D.prototype, "scaling", {
  12701. /** Gets or sets the control scaling in world space */
  12702. get: function () {
  12703. if (!this._node) {
  12704. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12705. }
  12706. return this._node.scaling;
  12707. },
  12708. set: function (value) {
  12709. if (!this._node) {
  12710. return;
  12711. }
  12712. this._node.scaling = value;
  12713. },
  12714. enumerable: true,
  12715. configurable: true
  12716. });
  12717. Object.defineProperty(Control3D.prototype, "behaviors", {
  12718. /**
  12719. * Gets the list of attached behaviors
  12720. * @see http://doc.babylonjs.com/features/behaviour
  12721. */
  12722. get: function () {
  12723. return this._behaviors;
  12724. },
  12725. enumerable: true,
  12726. configurable: true
  12727. });
  12728. /**
  12729. * Attach a behavior to the control
  12730. * @see http://doc.babylonjs.com/features/behaviour
  12731. * @param behavior defines the behavior to attach
  12732. * @returns the current control
  12733. */
  12734. Control3D.prototype.addBehavior = function (behavior) {
  12735. var _this = this;
  12736. var index = this._behaviors.indexOf(behavior);
  12737. if (index !== -1) {
  12738. return this;
  12739. }
  12740. behavior.init();
  12741. var scene = this._host.scene;
  12742. if (scene.isLoading) {
  12743. // We defer the attach when the scene will be loaded
  12744. scene.onDataLoadedObservable.addOnce(function () {
  12745. behavior.attach(_this);
  12746. });
  12747. }
  12748. else {
  12749. behavior.attach(this);
  12750. }
  12751. this._behaviors.push(behavior);
  12752. return this;
  12753. };
  12754. /**
  12755. * Remove an attached behavior
  12756. * @see http://doc.babylonjs.com/features/behaviour
  12757. * @param behavior defines the behavior to attach
  12758. * @returns the current control
  12759. */
  12760. Control3D.prototype.removeBehavior = function (behavior) {
  12761. var index = this._behaviors.indexOf(behavior);
  12762. if (index === -1) {
  12763. return this;
  12764. }
  12765. this._behaviors[index].detach();
  12766. this._behaviors.splice(index, 1);
  12767. return this;
  12768. };
  12769. /**
  12770. * Gets an attached behavior by name
  12771. * @param name defines the name of the behavior to look for
  12772. * @see http://doc.babylonjs.com/features/behaviour
  12773. * @returns null if behavior was not found else the requested behavior
  12774. */
  12775. Control3D.prototype.getBehaviorByName = function (name) {
  12776. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12777. var behavior = _a[_i];
  12778. if (behavior.name === name) {
  12779. return behavior;
  12780. }
  12781. }
  12782. return null;
  12783. };
  12784. Object.defineProperty(Control3D.prototype, "isVisible", {
  12785. /** Gets or sets a boolean indicating if the control is visible */
  12786. get: function () {
  12787. return this._isVisible;
  12788. },
  12789. set: function (value) {
  12790. if (this._isVisible === value) {
  12791. return;
  12792. }
  12793. this._isVisible = value;
  12794. var mesh = this.mesh;
  12795. if (mesh) {
  12796. mesh.setEnabled(value);
  12797. }
  12798. },
  12799. enumerable: true,
  12800. configurable: true
  12801. });
  12802. Object.defineProperty(Control3D.prototype, "typeName", {
  12803. /**
  12804. * Gets a string representing the class name
  12805. */
  12806. get: function () {
  12807. return this._getTypeName();
  12808. },
  12809. enumerable: true,
  12810. configurable: true
  12811. });
  12812. /**
  12813. * Get the current class name of the control.
  12814. * @returns current class name
  12815. */
  12816. Control3D.prototype.getClassName = function () {
  12817. return this._getTypeName();
  12818. };
  12819. Control3D.prototype._getTypeName = function () {
  12820. return "Control3D";
  12821. };
  12822. Object.defineProperty(Control3D.prototype, "node", {
  12823. /**
  12824. * Gets the transform node used by this control
  12825. */
  12826. get: function () {
  12827. return this._node;
  12828. },
  12829. enumerable: true,
  12830. configurable: true
  12831. });
  12832. Object.defineProperty(Control3D.prototype, "mesh", {
  12833. /**
  12834. * Gets the mesh used to render this control
  12835. */
  12836. get: function () {
  12837. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12838. return this._node;
  12839. }
  12840. return null;
  12841. },
  12842. enumerable: true,
  12843. configurable: true
  12844. });
  12845. /**
  12846. * Link the control as child of the given node
  12847. * @param node defines the node to link to. Use null to unlink the control
  12848. * @returns the current control
  12849. */
  12850. Control3D.prototype.linkToTransformNode = function (node) {
  12851. if (this._node) {
  12852. this._node.parent = node;
  12853. }
  12854. return this;
  12855. };
  12856. /** @hidden **/
  12857. Control3D.prototype._prepareNode = function (scene) {
  12858. if (!this._node) {
  12859. this._node = this._createNode(scene);
  12860. if (!this.node) {
  12861. return;
  12862. }
  12863. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12864. this._node.position = this.position;
  12865. this._node.scaling = this.scaling;
  12866. var mesh = this.mesh;
  12867. if (mesh) {
  12868. mesh.isPickable = true;
  12869. this._affectMaterial(mesh);
  12870. }
  12871. }
  12872. };
  12873. /**
  12874. * Node creation.
  12875. * Can be overriden by children
  12876. * @param scene defines the scene where the node must be attached
  12877. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12878. */
  12879. Control3D.prototype._createNode = function (scene) {
  12880. // Do nothing by default
  12881. return null;
  12882. };
  12883. /**
  12884. * Affect a material to the given mesh
  12885. * @param mesh defines the mesh which will represent the control
  12886. */
  12887. Control3D.prototype._affectMaterial = function (mesh) {
  12888. mesh.material = null;
  12889. };
  12890. // Pointers
  12891. /** @hidden */
  12892. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12893. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12894. };
  12895. /** @hidden */
  12896. Control3D.prototype._onPointerEnter = function (target) {
  12897. if (this._enterCount > 0) {
  12898. return false;
  12899. }
  12900. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12901. this._enterCount = 0;
  12902. }
  12903. this._enterCount++;
  12904. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12905. if (this.pointerEnterAnimation) {
  12906. this.pointerEnterAnimation();
  12907. }
  12908. return true;
  12909. };
  12910. /** @hidden */
  12911. Control3D.prototype._onPointerOut = function (target) {
  12912. this._enterCount = 0;
  12913. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12914. if (this.pointerOutAnimation) {
  12915. this.pointerOutAnimation();
  12916. }
  12917. };
  12918. /** @hidden */
  12919. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12920. if (this._downCount !== 0) {
  12921. return false;
  12922. }
  12923. this._downCount++;
  12924. this._downPointerIds[pointerId] = true;
  12925. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12926. if (this.pointerDownAnimation) {
  12927. this.pointerDownAnimation();
  12928. }
  12929. return true;
  12930. };
  12931. /** @hidden */
  12932. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12933. this._downCount = 0;
  12934. delete this._downPointerIds[pointerId];
  12935. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12936. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12937. }
  12938. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12939. if (this.pointerUpAnimation) {
  12940. this.pointerUpAnimation();
  12941. }
  12942. };
  12943. /** @hidden */
  12944. Control3D.prototype.forcePointerUp = function (pointerId) {
  12945. if (pointerId === void 0) { pointerId = null; }
  12946. if (pointerId !== null) {
  12947. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12948. }
  12949. else {
  12950. for (var key in this._downPointerIds) {
  12951. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12952. }
  12953. }
  12954. };
  12955. /** @hidden */
  12956. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  12957. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  12958. this._onPointerMove(this, pickedPoint);
  12959. var previousControlOver = this._host._lastControlOver[pointerId];
  12960. if (previousControlOver && previousControlOver !== this) {
  12961. previousControlOver._onPointerOut(this);
  12962. }
  12963. if (previousControlOver !== this) {
  12964. this._onPointerEnter(this);
  12965. }
  12966. this._host._lastControlOver[pointerId] = this;
  12967. return true;
  12968. }
  12969. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  12970. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  12971. this._host._lastControlDown[pointerId] = this;
  12972. this._host._lastPickedControl = this;
  12973. return true;
  12974. }
  12975. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  12976. if (this._host._lastControlDown[pointerId]) {
  12977. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  12978. }
  12979. delete this._host._lastControlDown[pointerId];
  12980. return true;
  12981. }
  12982. return false;
  12983. };
  12984. /** @hidden */
  12985. Control3D.prototype._disposeNode = function () {
  12986. if (this._node) {
  12987. this._node.dispose();
  12988. this._node = null;
  12989. }
  12990. };
  12991. /**
  12992. * Releases all associated resources
  12993. */
  12994. Control3D.prototype.dispose = function () {
  12995. this.onPointerDownObservable.clear();
  12996. this.onPointerEnterObservable.clear();
  12997. this.onPointerMoveObservable.clear();
  12998. this.onPointerOutObservable.clear();
  12999. this.onPointerUpObservable.clear();
  13000. this.onPointerClickObservable.clear();
  13001. this._disposeNode();
  13002. // Behaviors
  13003. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13004. var behavior = _a[_i];
  13005. behavior.detach();
  13006. }
  13007. };
  13008. return Control3D;
  13009. }());
  13010. /***/ }),
  13011. /***/ "./3D/controls/cylinderPanel.ts":
  13012. /*!**************************************!*\
  13013. !*** ./3D/controls/cylinderPanel.ts ***!
  13014. \**************************************/
  13015. /*! exports provided: CylinderPanel */
  13016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13017. "use strict";
  13018. __webpack_require__.r(__webpack_exports__);
  13019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13020. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13021. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13022. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13023. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13024. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13025. /**
  13026. * Class used to create a container panel deployed on the surface of a cylinder
  13027. */
  13028. var CylinderPanel = /** @class */ (function (_super) {
  13029. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13030. function CylinderPanel() {
  13031. var _this = _super !== null && _super.apply(this, arguments) || this;
  13032. _this._radius = 5.0;
  13033. return _this;
  13034. }
  13035. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13036. /**
  13037. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13038. */
  13039. get: function () {
  13040. return this._radius;
  13041. },
  13042. set: function (value) {
  13043. var _this = this;
  13044. if (this._radius === value) {
  13045. return;
  13046. }
  13047. this._radius = value;
  13048. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13049. _this._arrangeChildren();
  13050. });
  13051. },
  13052. enumerable: true,
  13053. configurable: true
  13054. });
  13055. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13056. var mesh = control.mesh;
  13057. if (!mesh) {
  13058. return;
  13059. }
  13060. var newPos = this._cylindricalMapping(nodePosition);
  13061. control.position = newPos;
  13062. switch (this.orientation) {
  13063. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13064. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13065. break;
  13066. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13067. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13068. break;
  13069. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13070. break;
  13071. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13072. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13073. break;
  13074. }
  13075. };
  13076. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13077. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13078. var yAngle = (source.x / this._radius);
  13079. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13080. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13081. };
  13082. return CylinderPanel;
  13083. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13084. /***/ }),
  13085. /***/ "./3D/controls/holographicButton.ts":
  13086. /*!******************************************!*\
  13087. !*** ./3D/controls/holographicButton.ts ***!
  13088. \******************************************/
  13089. /*! exports provided: HolographicButton */
  13090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13091. "use strict";
  13092. __webpack_require__.r(__webpack_exports__);
  13093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13094. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13095. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13096. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  13097. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13098. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13099. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13100. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13101. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13102. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13103. /**
  13104. * Class used to create a holographic button in 3D
  13105. */
  13106. var HolographicButton = /** @class */ (function (_super) {
  13107. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13108. /**
  13109. * Creates a new button
  13110. * @param name defines the control name
  13111. */
  13112. function HolographicButton(name, shareMaterials) {
  13113. if (shareMaterials === void 0) { shareMaterials = true; }
  13114. var _this = _super.call(this, name) || this;
  13115. _this._shareMaterials = true;
  13116. _this._shareMaterials = shareMaterials;
  13117. // Default animations
  13118. _this.pointerEnterAnimation = function () {
  13119. if (!_this.mesh) {
  13120. return;
  13121. }
  13122. _this._frontPlate.setEnabled(true);
  13123. };
  13124. _this.pointerOutAnimation = function () {
  13125. if (!_this.mesh) {
  13126. return;
  13127. }
  13128. _this._frontPlate.setEnabled(false);
  13129. };
  13130. return _this;
  13131. }
  13132. HolographicButton.prototype._disposeTooltip = function () {
  13133. this._tooltipFade = null;
  13134. if (this._tooltipTextBlock) {
  13135. this._tooltipTextBlock.dispose();
  13136. }
  13137. if (this._tooltipTexture) {
  13138. this._tooltipTexture.dispose();
  13139. }
  13140. if (this._tooltipMesh) {
  13141. this._tooltipMesh.dispose();
  13142. }
  13143. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13144. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13145. };
  13146. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13147. get: function () {
  13148. if (this._tooltipTextBlock) {
  13149. return this._tooltipTextBlock.text;
  13150. }
  13151. return null;
  13152. },
  13153. /**
  13154. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13155. */
  13156. set: function (text) {
  13157. var _this = this;
  13158. if (!text) {
  13159. this._disposeTooltip();
  13160. return;
  13161. }
  13162. if (!this._tooltipFade) {
  13163. // Create tooltip with mesh and text
  13164. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13165. 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);
  13166. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13167. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13168. tooltipBackground.material = mat;
  13169. tooltipBackground.isPickable = false;
  13170. this._tooltipMesh.addChild(tooltipBackground);
  13171. tooltipBackground.position.z = 0.05;
  13172. this._tooltipMesh.scaling.y = 1 / 3;
  13173. this._tooltipMesh.position.y = 0.7;
  13174. this._tooltipMesh.position.z = -0.15;
  13175. this._tooltipMesh.isPickable = false;
  13176. this._tooltipMesh.parent = this._backPlate;
  13177. // Create text texture for the tooltip
  13178. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13179. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13180. this._tooltipTextBlock.scaleY = 3;
  13181. this._tooltipTextBlock.color = "white";
  13182. this._tooltipTextBlock.fontSize = 130;
  13183. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13184. // Add hover action to tooltip
  13185. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13186. this._tooltipFade.delay = 500;
  13187. this._tooltipMesh.addBehavior(this._tooltipFade);
  13188. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13189. if (_this._tooltipFade) {
  13190. _this._tooltipFade.fadeIn(true);
  13191. }
  13192. });
  13193. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13194. if (_this._tooltipFade) {
  13195. _this._tooltipFade.fadeIn(false);
  13196. }
  13197. });
  13198. }
  13199. if (this._tooltipTextBlock) {
  13200. this._tooltipTextBlock.text = text;
  13201. }
  13202. },
  13203. enumerable: true,
  13204. configurable: true
  13205. });
  13206. Object.defineProperty(HolographicButton.prototype, "text", {
  13207. /**
  13208. * Gets or sets text for the button
  13209. */
  13210. get: function () {
  13211. return this._text;
  13212. },
  13213. set: function (value) {
  13214. if (this._text === value) {
  13215. return;
  13216. }
  13217. this._text = value;
  13218. this._rebuildContent();
  13219. },
  13220. enumerable: true,
  13221. configurable: true
  13222. });
  13223. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13224. /**
  13225. * Gets or sets the image url for the button
  13226. */
  13227. get: function () {
  13228. return this._imageUrl;
  13229. },
  13230. set: function (value) {
  13231. if (this._imageUrl === value) {
  13232. return;
  13233. }
  13234. this._imageUrl = value;
  13235. this._rebuildContent();
  13236. },
  13237. enumerable: true,
  13238. configurable: true
  13239. });
  13240. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13241. /**
  13242. * Gets the back material used by this button
  13243. */
  13244. get: function () {
  13245. return this._backMaterial;
  13246. },
  13247. enumerable: true,
  13248. configurable: true
  13249. });
  13250. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13251. /**
  13252. * Gets the front material used by this button
  13253. */
  13254. get: function () {
  13255. return this._frontMaterial;
  13256. },
  13257. enumerable: true,
  13258. configurable: true
  13259. });
  13260. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13261. /**
  13262. * Gets the plate material used by this button
  13263. */
  13264. get: function () {
  13265. return this._plateMaterial;
  13266. },
  13267. enumerable: true,
  13268. configurable: true
  13269. });
  13270. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13271. /**
  13272. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13273. */
  13274. get: function () {
  13275. return this._shareMaterials;
  13276. },
  13277. enumerable: true,
  13278. configurable: true
  13279. });
  13280. HolographicButton.prototype._getTypeName = function () {
  13281. return "HolographicButton";
  13282. };
  13283. HolographicButton.prototype._rebuildContent = function () {
  13284. this._disposeFacadeTexture();
  13285. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13286. panel.isVertical = true;
  13287. if (this._imageUrl) {
  13288. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13289. image.source = this._imageUrl;
  13290. image.paddingTop = "40px";
  13291. image.height = "180px";
  13292. image.width = "100px";
  13293. image.paddingBottom = "40px";
  13294. panel.addControl(image);
  13295. }
  13296. if (this._text) {
  13297. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13298. text.text = this._text;
  13299. text.color = "white";
  13300. text.height = "30px";
  13301. text.fontSize = 24;
  13302. panel.addControl(text);
  13303. }
  13304. if (this._frontPlate) {
  13305. this.content = panel;
  13306. }
  13307. };
  13308. // Mesh association
  13309. HolographicButton.prototype._createNode = function (scene) {
  13310. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13311. width: 1.0,
  13312. height: 1.0,
  13313. depth: 0.08
  13314. }, scene);
  13315. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13316. width: 1.0,
  13317. height: 1.0,
  13318. depth: 0.08
  13319. }, scene);
  13320. this._frontPlate.parent = this._backPlate;
  13321. this._frontPlate.position.z = -0.08;
  13322. this._frontPlate.isPickable = false;
  13323. this._frontPlate.setEnabled(false);
  13324. this._textPlate = _super.prototype._createNode.call(this, scene);
  13325. this._textPlate.parent = this._backPlate;
  13326. this._textPlate.position.z = -0.08;
  13327. this._textPlate.isPickable = false;
  13328. return this._backPlate;
  13329. };
  13330. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13331. this._plateMaterial.emissiveTexture = facadeTexture;
  13332. this._plateMaterial.opacityTexture = facadeTexture;
  13333. };
  13334. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13335. var _this = this;
  13336. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13337. this._backMaterial.renderHoverLight = true;
  13338. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13339. if (pickedPoint) {
  13340. _this._backMaterial.hoverPosition = pickedPoint;
  13341. _this._backMaterial.hoverColor.a = 1.0;
  13342. }
  13343. else {
  13344. _this._backMaterial.hoverColor.a = 0;
  13345. }
  13346. });
  13347. };
  13348. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13349. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13350. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13351. this._frontMaterial.alpha = 0.5; // Additive
  13352. this._frontMaterial.renderBorders = true;
  13353. };
  13354. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13355. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13356. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13357. };
  13358. HolographicButton.prototype._affectMaterial = function (mesh) {
  13359. // Back
  13360. if (this._shareMaterials) {
  13361. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13362. this._createBackMaterial(mesh);
  13363. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13364. }
  13365. else {
  13366. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13367. }
  13368. // Front
  13369. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13370. this._createFrontMaterial(mesh);
  13371. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13372. }
  13373. else {
  13374. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13375. }
  13376. }
  13377. else {
  13378. this._createBackMaterial(mesh);
  13379. this._createFrontMaterial(mesh);
  13380. }
  13381. this._createPlateMaterial(mesh);
  13382. this._backPlate.material = this._backMaterial;
  13383. this._frontPlate.material = this._frontMaterial;
  13384. this._textPlate.material = this._plateMaterial;
  13385. this._rebuildContent();
  13386. };
  13387. /**
  13388. * Releases all associated resources
  13389. */
  13390. HolographicButton.prototype.dispose = function () {
  13391. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13392. this._disposeTooltip();
  13393. if (!this.shareMaterials) {
  13394. this._backMaterial.dispose();
  13395. this._frontMaterial.dispose();
  13396. this._plateMaterial.dispose();
  13397. if (this._pickedPointObserver) {
  13398. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13399. this._pickedPointObserver = null;
  13400. }
  13401. }
  13402. };
  13403. return HolographicButton;
  13404. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13405. /***/ }),
  13406. /***/ "./3D/controls/index.ts":
  13407. /*!******************************!*\
  13408. !*** ./3D/controls/index.ts ***!
  13409. \******************************/
  13410. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13412. "use strict";
  13413. __webpack_require__.r(__webpack_exports__);
  13414. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13416. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13418. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13420. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13422. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13424. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13426. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13428. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13430. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13432. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13434. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13436. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13438. /***/ }),
  13439. /***/ "./3D/controls/meshButton3D.ts":
  13440. /*!*************************************!*\
  13441. !*** ./3D/controls/meshButton3D.ts ***!
  13442. \*************************************/
  13443. /*! exports provided: MeshButton3D */
  13444. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13445. "use strict";
  13446. __webpack_require__.r(__webpack_exports__);
  13447. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13448. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13449. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13450. /**
  13451. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13452. */
  13453. var MeshButton3D = /** @class */ (function (_super) {
  13454. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13455. /**
  13456. * Creates a new 3D button based on a mesh
  13457. * @param mesh mesh to become a 3D button
  13458. * @param name defines the control name
  13459. */
  13460. function MeshButton3D(mesh, name) {
  13461. var _this = _super.call(this, name) || this;
  13462. _this._currentMesh = mesh;
  13463. /**
  13464. * Provides a default behavior on hover/out & up/down
  13465. * Override those function to create your own desired behavior specific to your mesh
  13466. */
  13467. _this.pointerEnterAnimation = function () {
  13468. if (!_this.mesh) {
  13469. return;
  13470. }
  13471. _this.mesh.scaling.scaleInPlace(1.1);
  13472. };
  13473. _this.pointerOutAnimation = function () {
  13474. if (!_this.mesh) {
  13475. return;
  13476. }
  13477. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13478. };
  13479. _this.pointerDownAnimation = function () {
  13480. if (!_this.mesh) {
  13481. return;
  13482. }
  13483. _this.mesh.scaling.scaleInPlace(0.95);
  13484. };
  13485. _this.pointerUpAnimation = function () {
  13486. if (!_this.mesh) {
  13487. return;
  13488. }
  13489. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13490. };
  13491. return _this;
  13492. }
  13493. MeshButton3D.prototype._getTypeName = function () {
  13494. return "MeshButton3D";
  13495. };
  13496. // Mesh association
  13497. MeshButton3D.prototype._createNode = function (scene) {
  13498. var _this = this;
  13499. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13500. mesh.metadata = _this;
  13501. });
  13502. return this._currentMesh;
  13503. };
  13504. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13505. };
  13506. return MeshButton3D;
  13507. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13508. /***/ }),
  13509. /***/ "./3D/controls/planePanel.ts":
  13510. /*!***********************************!*\
  13511. !*** ./3D/controls/planePanel.ts ***!
  13512. \***********************************/
  13513. /*! exports provided: PlanePanel */
  13514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13515. "use strict";
  13516. __webpack_require__.r(__webpack_exports__);
  13517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13518. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13519. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  13520. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13521. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13522. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13523. /**
  13524. * Class used to create a container panel deployed on the surface of a plane
  13525. */
  13526. var PlanePanel = /** @class */ (function (_super) {
  13527. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13528. function PlanePanel() {
  13529. return _super !== null && _super.apply(this, arguments) || this;
  13530. }
  13531. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13532. var mesh = control.mesh;
  13533. if (!mesh) {
  13534. return;
  13535. }
  13536. control.position = nodePosition.clone();
  13537. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13538. target.copyFrom(nodePosition);
  13539. switch (this.orientation) {
  13540. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13541. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13542. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13543. mesh.lookAt(target);
  13544. break;
  13545. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13546. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13547. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13548. mesh.lookAt(target);
  13549. break;
  13550. }
  13551. };
  13552. return PlanePanel;
  13553. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13554. /***/ }),
  13555. /***/ "./3D/controls/scatterPanel.ts":
  13556. /*!*************************************!*\
  13557. !*** ./3D/controls/scatterPanel.ts ***!
  13558. \*************************************/
  13559. /*! exports provided: ScatterPanel */
  13560. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13561. "use strict";
  13562. __webpack_require__.r(__webpack_exports__);
  13563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13564. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13565. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13566. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13567. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13568. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13569. /**
  13570. * Class used to create a container panel where items get randomized planar mapping
  13571. */
  13572. var ScatterPanel = /** @class */ (function (_super) {
  13573. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13574. function ScatterPanel() {
  13575. var _this = _super !== null && _super.apply(this, arguments) || this;
  13576. _this._iteration = 100.0;
  13577. return _this;
  13578. }
  13579. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13580. /**
  13581. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13582. */
  13583. get: function () {
  13584. return this._iteration;
  13585. },
  13586. set: function (value) {
  13587. var _this = this;
  13588. if (this._iteration === value) {
  13589. return;
  13590. }
  13591. this._iteration = value;
  13592. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13593. _this._arrangeChildren();
  13594. });
  13595. },
  13596. enumerable: true,
  13597. configurable: true
  13598. });
  13599. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13600. var mesh = control.mesh;
  13601. var newPos = this._scatterMapping(nodePosition);
  13602. if (!mesh) {
  13603. return;
  13604. }
  13605. switch (this.orientation) {
  13606. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13607. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13608. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13609. break;
  13610. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13611. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13612. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13613. break;
  13614. }
  13615. control.position = newPos;
  13616. };
  13617. ScatterPanel.prototype._scatterMapping = function (source) {
  13618. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13619. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13620. return source;
  13621. };
  13622. ScatterPanel.prototype._finalProcessing = function () {
  13623. var meshes = [];
  13624. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13625. var child = _a[_i];
  13626. if (!child.mesh) {
  13627. continue;
  13628. }
  13629. meshes.push(child.mesh);
  13630. }
  13631. for (var count = 0; count < this._iteration; count++) {
  13632. meshes.sort(function (a, b) {
  13633. var distance1 = a.position.lengthSquared();
  13634. var distance2 = b.position.lengthSquared();
  13635. if (distance1 < distance2) {
  13636. return 1;
  13637. }
  13638. else if (distance1 > distance2) {
  13639. return -1;
  13640. }
  13641. return 0;
  13642. });
  13643. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13644. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13645. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13646. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13647. for (var i = 0; i < meshes.length - 1; i++) {
  13648. for (var j = i + 1; j < meshes.length; j++) {
  13649. if (i != j) {
  13650. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13651. // Ignore Z axis
  13652. difference2D.x = difference.x;
  13653. difference2D.y = difference.y;
  13654. var combinedRadius = cellSize;
  13655. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13656. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13657. distance -= minSeparation;
  13658. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13659. difference2D.normalize();
  13660. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13661. meshes[j].position.addInPlace(difference);
  13662. meshes[i].position.subtractInPlace(difference);
  13663. }
  13664. }
  13665. }
  13666. }
  13667. }
  13668. };
  13669. return ScatterPanel;
  13670. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13671. /***/ }),
  13672. /***/ "./3D/controls/spherePanel.ts":
  13673. /*!************************************!*\
  13674. !*** ./3D/controls/spherePanel.ts ***!
  13675. \************************************/
  13676. /*! exports provided: SpherePanel */
  13677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13678. "use strict";
  13679. __webpack_require__.r(__webpack_exports__);
  13680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13682. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13683. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13684. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13685. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13686. /**
  13687. * Class used to create a container panel deployed on the surface of a sphere
  13688. */
  13689. var SpherePanel = /** @class */ (function (_super) {
  13690. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13691. function SpherePanel() {
  13692. var _this = _super !== null && _super.apply(this, arguments) || this;
  13693. _this._radius = 5.0;
  13694. return _this;
  13695. }
  13696. Object.defineProperty(SpherePanel.prototype, "radius", {
  13697. /**
  13698. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13699. */
  13700. get: function () {
  13701. return this._radius;
  13702. },
  13703. set: function (value) {
  13704. var _this = this;
  13705. if (this._radius === value) {
  13706. return;
  13707. }
  13708. this._radius = value;
  13709. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13710. _this._arrangeChildren();
  13711. });
  13712. },
  13713. enumerable: true,
  13714. configurable: true
  13715. });
  13716. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13717. var mesh = control.mesh;
  13718. if (!mesh) {
  13719. return;
  13720. }
  13721. var newPos = this._sphericalMapping(nodePosition);
  13722. control.position = newPos;
  13723. switch (this.orientation) {
  13724. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13725. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13726. break;
  13727. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13728. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13729. break;
  13730. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13731. break;
  13732. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13733. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13734. break;
  13735. }
  13736. };
  13737. SpherePanel.prototype._sphericalMapping = function (source) {
  13738. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13739. var xAngle = (source.y / this._radius);
  13740. var yAngle = -(source.x / this._radius);
  13741. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13742. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13743. };
  13744. return SpherePanel;
  13745. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13746. /***/ }),
  13747. /***/ "./3D/controls/stackPanel3D.ts":
  13748. /*!*************************************!*\
  13749. !*** ./3D/controls/stackPanel3D.ts ***!
  13750. \*************************************/
  13751. /*! exports provided: StackPanel3D */
  13752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13753. "use strict";
  13754. __webpack_require__.r(__webpack_exports__);
  13755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13756. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13757. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13758. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13759. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13760. /**
  13761. * Class used to create a stack panel in 3D on XY plane
  13762. */
  13763. var StackPanel3D = /** @class */ (function (_super) {
  13764. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13765. /**
  13766. * Creates new StackPanel
  13767. * @param isVertical
  13768. */
  13769. function StackPanel3D(isVertical) {
  13770. if (isVertical === void 0) { isVertical = false; }
  13771. var _this = _super.call(this) || this;
  13772. _this._isVertical = false;
  13773. /**
  13774. * Gets or sets the distance between elements
  13775. */
  13776. _this.margin = 0.1;
  13777. _this._isVertical = isVertical;
  13778. return _this;
  13779. }
  13780. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13781. /**
  13782. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13783. */
  13784. get: function () {
  13785. return this._isVertical;
  13786. },
  13787. set: function (value) {
  13788. var _this = this;
  13789. if (this._isVertical === value) {
  13790. return;
  13791. }
  13792. this._isVertical = value;
  13793. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13794. _this._arrangeChildren();
  13795. });
  13796. },
  13797. enumerable: true,
  13798. configurable: true
  13799. });
  13800. StackPanel3D.prototype._arrangeChildren = function () {
  13801. var width = 0;
  13802. var height = 0;
  13803. var controlCount = 0;
  13804. var extendSizes = [];
  13805. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13806. // Measure
  13807. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13808. var child = _a[_i];
  13809. if (!child.mesh) {
  13810. continue;
  13811. }
  13812. controlCount++;
  13813. child.mesh.computeWorldMatrix(true);
  13814. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13815. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13816. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13817. extendSizes.push(extendSize);
  13818. if (this._isVertical) {
  13819. height += extendSize.y;
  13820. }
  13821. else {
  13822. width += extendSize.x;
  13823. }
  13824. }
  13825. if (this._isVertical) {
  13826. height += (controlCount - 1) * this.margin / 2;
  13827. }
  13828. else {
  13829. width += (controlCount - 1) * this.margin / 2;
  13830. }
  13831. // Arrange
  13832. var offset;
  13833. if (this._isVertical) {
  13834. offset = -height;
  13835. }
  13836. else {
  13837. offset = -width;
  13838. }
  13839. var index = 0;
  13840. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13841. var child = _c[_b];
  13842. if (!child.mesh) {
  13843. continue;
  13844. }
  13845. controlCount--;
  13846. var extendSize = extendSizes[index++];
  13847. if (this._isVertical) {
  13848. child.position.y = offset + extendSize.y;
  13849. child.position.x = 0;
  13850. offset += extendSize.y * 2;
  13851. }
  13852. else {
  13853. child.position.x = offset + extendSize.x;
  13854. child.position.y = 0;
  13855. offset += extendSize.x * 2;
  13856. }
  13857. offset += (controlCount > 0 ? this.margin : 0);
  13858. }
  13859. };
  13860. return StackPanel3D;
  13861. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13862. /***/ }),
  13863. /***/ "./3D/controls/volumeBasedPanel.ts":
  13864. /*!*****************************************!*\
  13865. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13866. \*****************************************/
  13867. /*! exports provided: VolumeBasedPanel */
  13868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13869. "use strict";
  13870. __webpack_require__.r(__webpack_exports__);
  13871. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13872. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13873. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13874. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13875. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13876. /**
  13877. * Abstract class used to create a container panel deployed on the surface of a volume
  13878. */
  13879. var VolumeBasedPanel = /** @class */ (function (_super) {
  13880. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13881. /**
  13882. * Creates new VolumeBasedPanel
  13883. */
  13884. function VolumeBasedPanel() {
  13885. var _this = _super.call(this) || this;
  13886. _this._columns = 10;
  13887. _this._rows = 0;
  13888. _this._rowThenColum = true;
  13889. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13890. /**
  13891. * Gets or sets the distance between elements
  13892. */
  13893. _this.margin = 0;
  13894. return _this;
  13895. }
  13896. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13897. /**
  13898. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13899. * | Value | Type | Description |
  13900. * | ----- | ----------------------------------- | ----------- |
  13901. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13902. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13903. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13904. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13905. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13906. */
  13907. get: function () {
  13908. return this._orientation;
  13909. },
  13910. set: function (value) {
  13911. var _this = this;
  13912. if (this._orientation === value) {
  13913. return;
  13914. }
  13915. this._orientation = value;
  13916. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13917. _this._arrangeChildren();
  13918. });
  13919. },
  13920. enumerable: true,
  13921. configurable: true
  13922. });
  13923. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13924. /**
  13925. * Gets or sets the number of columns requested (10 by default).
  13926. * The panel will automatically compute the number of rows based on number of child controls.
  13927. */
  13928. get: function () {
  13929. return this._columns;
  13930. },
  13931. set: function (value) {
  13932. var _this = this;
  13933. if (this._columns === value) {
  13934. return;
  13935. }
  13936. this._columns = value;
  13937. this._rowThenColum = true;
  13938. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13939. _this._arrangeChildren();
  13940. });
  13941. },
  13942. enumerable: true,
  13943. configurable: true
  13944. });
  13945. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13946. /**
  13947. * Gets or sets a the number of rows requested.
  13948. * The panel will automatically compute the number of columns based on number of child controls.
  13949. */
  13950. get: function () {
  13951. return this._rows;
  13952. },
  13953. set: function (value) {
  13954. var _this = this;
  13955. if (this._rows === value) {
  13956. return;
  13957. }
  13958. this._rows = value;
  13959. this._rowThenColum = false;
  13960. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13961. _this._arrangeChildren();
  13962. });
  13963. },
  13964. enumerable: true,
  13965. configurable: true
  13966. });
  13967. VolumeBasedPanel.prototype._arrangeChildren = function () {
  13968. this._cellWidth = 0;
  13969. this._cellHeight = 0;
  13970. var rows = 0;
  13971. var columns = 0;
  13972. var controlCount = 0;
  13973. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13974. // Measure
  13975. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13976. var child = _a[_i];
  13977. if (!child.mesh) {
  13978. continue;
  13979. }
  13980. controlCount++;
  13981. child.mesh.computeWorldMatrix(true);
  13982. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  13983. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  13984. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13985. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  13986. boundingBox.max.subtractToRef(boundingBox.min, diff);
  13987. diff.scaleInPlace(0.5);
  13988. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  13989. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  13990. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  13991. }
  13992. this._cellWidth += this.margin * 2;
  13993. this._cellHeight += this.margin * 2;
  13994. // Arrange
  13995. if (this._rowThenColum) {
  13996. columns = this._columns;
  13997. rows = Math.ceil(controlCount / this._columns);
  13998. }
  13999. else {
  14000. rows = this._rows;
  14001. columns = Math.ceil(controlCount / this._rows);
  14002. }
  14003. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14004. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14005. var nodeGrid = [];
  14006. var cellCounter = 0;
  14007. if (this._rowThenColum) {
  14008. for (var r = 0; r < rows; r++) {
  14009. for (var c = 0; c < columns; c++) {
  14010. 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));
  14011. cellCounter++;
  14012. if (cellCounter > controlCount) {
  14013. break;
  14014. }
  14015. }
  14016. }
  14017. }
  14018. else {
  14019. for (var c = 0; c < columns; c++) {
  14020. for (var r = 0; r < rows; r++) {
  14021. 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));
  14022. cellCounter++;
  14023. if (cellCounter > controlCount) {
  14024. break;
  14025. }
  14026. }
  14027. }
  14028. }
  14029. cellCounter = 0;
  14030. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14031. var child = _c[_b];
  14032. if (!child.mesh) {
  14033. continue;
  14034. }
  14035. this._mapGridNode(child, nodeGrid[cellCounter]);
  14036. cellCounter++;
  14037. }
  14038. this._finalProcessing();
  14039. };
  14040. /** Child classes can implement this function to provide additional processing */
  14041. VolumeBasedPanel.prototype._finalProcessing = function () {
  14042. };
  14043. return VolumeBasedPanel;
  14044. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14045. /***/ }),
  14046. /***/ "./3D/gui3DManager.ts":
  14047. /*!****************************!*\
  14048. !*** ./3D/gui3DManager.ts ***!
  14049. \****************************/
  14050. /*! exports provided: GUI3DManager */
  14051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14052. "use strict";
  14053. __webpack_require__.r(__webpack_exports__);
  14054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14055. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  14056. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14057. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14058. /**
  14059. * Class used to manage 3D user interface
  14060. * @see http://doc.babylonjs.com/how_to/gui3d
  14061. */
  14062. var GUI3DManager = /** @class */ (function () {
  14063. /**
  14064. * Creates a new GUI3DManager
  14065. * @param scene
  14066. */
  14067. function GUI3DManager(scene) {
  14068. var _this = this;
  14069. /** @hidden */
  14070. this._lastControlOver = {};
  14071. /** @hidden */
  14072. this._lastControlDown = {};
  14073. /**
  14074. * Observable raised when the point picked by the pointer events changed
  14075. */
  14076. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14077. // Shared resources
  14078. /** @hidden */
  14079. this._sharedMaterials = {};
  14080. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14081. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14082. _this._sceneDisposeObserver = null;
  14083. _this._utilityLayer = null;
  14084. _this.dispose();
  14085. });
  14086. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14087. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14088. this._utilityLayer.pickUtilitySceneFirst = false;
  14089. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14090. return mesh && mesh.metadata && mesh.metadata._node;
  14091. };
  14092. // Root
  14093. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14094. this._rootContainer._host = this;
  14095. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14096. // Events
  14097. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14098. _this._handlePointerOut(pointerId, true);
  14099. });
  14100. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14101. _this._doPicking(pi);
  14102. });
  14103. // Scene
  14104. this._utilityLayer.utilityLayerScene.autoClear = false;
  14105. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14106. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14107. }
  14108. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14109. /** Gets the hosting scene */
  14110. get: function () {
  14111. return this._scene;
  14112. },
  14113. enumerable: true,
  14114. configurable: true
  14115. });
  14116. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14117. /** Gets associated utility layer */
  14118. get: function () {
  14119. return this._utilityLayer;
  14120. },
  14121. enumerable: true,
  14122. configurable: true
  14123. });
  14124. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14125. var previousControlOver = this._lastControlOver[pointerId];
  14126. if (previousControlOver) {
  14127. previousControlOver._onPointerOut(previousControlOver);
  14128. delete this._lastControlOver[pointerId];
  14129. }
  14130. if (isPointerUp) {
  14131. if (this._lastControlDown[pointerId]) {
  14132. this._lastControlDown[pointerId].forcePointerUp();
  14133. delete this._lastControlDown[pointerId];
  14134. }
  14135. }
  14136. this.onPickedPointChangedObservable.notifyObservers(null);
  14137. };
  14138. GUI3DManager.prototype._doPicking = function (pi) {
  14139. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14140. return false;
  14141. }
  14142. var pointerEvent = (pi.event);
  14143. var pointerId = pointerEvent.pointerId || 0;
  14144. var buttonIndex = pointerEvent.button;
  14145. var pickingInfo = pi.pickInfo;
  14146. if (!pickingInfo || !pickingInfo.hit) {
  14147. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14148. return false;
  14149. }
  14150. var control = (pickingInfo.pickedMesh.metadata);
  14151. if (pickingInfo.pickedPoint) {
  14152. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14153. }
  14154. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14155. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14156. if (this._lastControlOver[pointerId]) {
  14157. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14158. }
  14159. delete this._lastControlOver[pointerId];
  14160. }
  14161. }
  14162. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14163. if (this._lastControlDown[pointerEvent.pointerId]) {
  14164. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14165. delete this._lastControlDown[pointerEvent.pointerId];
  14166. }
  14167. if (pointerEvent.pointerType === "touch") {
  14168. this._handlePointerOut(pointerId, false);
  14169. }
  14170. }
  14171. return true;
  14172. };
  14173. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14174. /**
  14175. * Gets the root container
  14176. */
  14177. get: function () {
  14178. return this._rootContainer;
  14179. },
  14180. enumerable: true,
  14181. configurable: true
  14182. });
  14183. /**
  14184. * Gets a boolean indicating if the given control is in the root child list
  14185. * @param control defines the control to check
  14186. * @returns true if the control is in the root child list
  14187. */
  14188. GUI3DManager.prototype.containsControl = function (control) {
  14189. return this._rootContainer.containsControl(control);
  14190. };
  14191. /**
  14192. * Adds a control to the root child list
  14193. * @param control defines the control to add
  14194. * @returns the current manager
  14195. */
  14196. GUI3DManager.prototype.addControl = function (control) {
  14197. this._rootContainer.addControl(control);
  14198. return this;
  14199. };
  14200. /**
  14201. * Removes a control from the root child list
  14202. * @param control defines the control to remove
  14203. * @returns the current container
  14204. */
  14205. GUI3DManager.prototype.removeControl = function (control) {
  14206. this._rootContainer.removeControl(control);
  14207. return this;
  14208. };
  14209. /**
  14210. * Releases all associated resources
  14211. */
  14212. GUI3DManager.prototype.dispose = function () {
  14213. this._rootContainer.dispose();
  14214. for (var materialName in this._sharedMaterials) {
  14215. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14216. continue;
  14217. }
  14218. this._sharedMaterials[materialName].dispose();
  14219. }
  14220. this._sharedMaterials = {};
  14221. if (this._pointerOutObserver && this._utilityLayer) {
  14222. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14223. this._pointerOutObserver = null;
  14224. }
  14225. this.onPickedPointChangedObservable.clear();
  14226. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14227. if (utilityLayerScene) {
  14228. if (this._pointerObserver) {
  14229. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14230. this._pointerObserver = null;
  14231. }
  14232. }
  14233. if (this._scene) {
  14234. if (this._sceneDisposeObserver) {
  14235. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14236. this._sceneDisposeObserver = null;
  14237. }
  14238. }
  14239. if (this._utilityLayer) {
  14240. this._utilityLayer.dispose();
  14241. }
  14242. };
  14243. return GUI3DManager;
  14244. }());
  14245. /***/ }),
  14246. /***/ "./3D/index.ts":
  14247. /*!*********************!*\
  14248. !*** ./3D/index.ts ***!
  14249. \*********************/
  14250. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14252. "use strict";
  14253. __webpack_require__.r(__webpack_exports__);
  14254. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14267. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14270. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14272. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14274. /***/ }),
  14275. /***/ "./3D/materials/fluentMaterial.ts":
  14276. /*!****************************************!*\
  14277. !*** ./3D/materials/fluentMaterial.ts ***!
  14278. \****************************************/
  14279. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14281. "use strict";
  14282. __webpack_require__.r(__webpack_exports__);
  14283. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14285. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14286. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/tools");
  14287. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14288. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14289. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14290. /** @hidden */
  14291. var FluentMaterialDefines = /** @class */ (function (_super) {
  14292. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14293. function FluentMaterialDefines() {
  14294. var _this = _super.call(this) || this;
  14295. _this.INNERGLOW = false;
  14296. _this.BORDER = false;
  14297. _this.HOVERLIGHT = false;
  14298. _this.TEXTURE = false;
  14299. _this.rebuild();
  14300. return _this;
  14301. }
  14302. return FluentMaterialDefines;
  14303. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14304. /**
  14305. * Class used to render controls with fluent desgin
  14306. */
  14307. var FluentMaterial = /** @class */ (function (_super) {
  14308. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14309. /**
  14310. * Creates a new Fluent material
  14311. * @param name defines the name of the material
  14312. * @param scene defines the hosting scene
  14313. */
  14314. function FluentMaterial(name, scene) {
  14315. var _this = _super.call(this, name, scene) || this;
  14316. /**
  14317. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14318. */
  14319. _this.innerGlowColorIntensity = 0.5;
  14320. /**
  14321. * Gets or sets the inner glow color (white by default)
  14322. */
  14323. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14324. /**
  14325. * Gets or sets alpha value (default is 1.0)
  14326. */
  14327. _this.alpha = 1.0;
  14328. /**
  14329. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14330. */
  14331. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14332. /**
  14333. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14334. */
  14335. _this.renderBorders = false;
  14336. /**
  14337. * Gets or sets border width (default is 0.5)
  14338. */
  14339. _this.borderWidth = 0.5;
  14340. /**
  14341. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14342. */
  14343. _this.edgeSmoothingValue = 0.02;
  14344. /**
  14345. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14346. */
  14347. _this.borderMinValue = 0.1;
  14348. /**
  14349. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14350. */
  14351. _this.renderHoverLight = false;
  14352. /**
  14353. * Gets or sets the radius used to render the hover light (default is 1.0)
  14354. */
  14355. _this.hoverRadius = 1.0;
  14356. /**
  14357. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14358. */
  14359. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14360. /**
  14361. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14362. */
  14363. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14364. return _this;
  14365. }
  14366. FluentMaterial.prototype.needAlphaBlending = function () {
  14367. return this.alpha !== 1.0;
  14368. };
  14369. FluentMaterial.prototype.needAlphaTesting = function () {
  14370. return false;
  14371. };
  14372. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14373. return null;
  14374. };
  14375. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14376. if (this.isFrozen) {
  14377. if (this._wasPreviouslyReady && subMesh.effect) {
  14378. return true;
  14379. }
  14380. }
  14381. if (!subMesh._materialDefines) {
  14382. subMesh._materialDefines = new FluentMaterialDefines();
  14383. }
  14384. var scene = this.getScene();
  14385. var defines = subMesh._materialDefines;
  14386. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14387. if (defines._renderId === scene.getRenderId()) {
  14388. return true;
  14389. }
  14390. }
  14391. if (defines._areTexturesDirty) {
  14392. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14393. defines.BORDER = this.renderBorders;
  14394. defines.HOVERLIGHT = this.renderHoverLight;
  14395. if (this._albedoTexture) {
  14396. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14397. return false;
  14398. }
  14399. else {
  14400. defines.TEXTURE = true;
  14401. }
  14402. }
  14403. else {
  14404. defines.TEXTURE = false;
  14405. }
  14406. }
  14407. var engine = scene.getEngine();
  14408. // Get correct effect
  14409. if (defines.isDirty) {
  14410. defines.markAsProcessed();
  14411. scene.resetCachedMaterial();
  14412. //Attributes
  14413. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14414. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14415. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14416. var shaderName = "fluent";
  14417. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14418. "hoverColor", "hoverPosition", "hoverRadius"
  14419. ];
  14420. var samplers = ["albedoSampler"];
  14421. var uniformBuffers = new Array();
  14422. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14423. uniformsNames: uniforms,
  14424. uniformBuffersNames: uniformBuffers,
  14425. samplers: samplers,
  14426. defines: defines,
  14427. maxSimultaneousLights: 4
  14428. });
  14429. var join = defines.toString();
  14430. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14431. attributes: attribs,
  14432. uniformsNames: uniforms,
  14433. uniformBuffersNames: uniformBuffers,
  14434. samplers: samplers,
  14435. defines: join,
  14436. fallbacks: null,
  14437. onCompiled: this.onCompiled,
  14438. onError: this.onError,
  14439. indexParameters: { maxSimultaneousLights: 4 }
  14440. }, engine));
  14441. }
  14442. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14443. return false;
  14444. }
  14445. defines._renderId = scene.getRenderId();
  14446. this._wasPreviouslyReady = true;
  14447. return true;
  14448. };
  14449. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14450. var scene = this.getScene();
  14451. var defines = subMesh._materialDefines;
  14452. if (!defines) {
  14453. return;
  14454. }
  14455. var effect = subMesh.effect;
  14456. if (!effect) {
  14457. return;
  14458. }
  14459. this._activeEffect = effect;
  14460. // Matrices
  14461. this.bindOnlyWorldMatrix(world);
  14462. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14463. if (this._mustRebind(scene, effect)) {
  14464. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14465. if (defines.INNERGLOW) {
  14466. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14467. }
  14468. if (defines.BORDER) {
  14469. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14470. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14471. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14472. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14473. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14474. }
  14475. if (defines.HOVERLIGHT) {
  14476. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14477. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14478. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14479. }
  14480. if (defines.TEXTURE) {
  14481. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14482. }
  14483. }
  14484. this._afterBind(mesh, this._activeEffect);
  14485. };
  14486. FluentMaterial.prototype.getActiveTextures = function () {
  14487. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14488. return activeTextures;
  14489. };
  14490. FluentMaterial.prototype.hasTexture = function (texture) {
  14491. if (_super.prototype.hasTexture.call(this, texture)) {
  14492. return true;
  14493. }
  14494. return false;
  14495. };
  14496. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14497. _super.prototype.dispose.call(this, forceDisposeEffect);
  14498. };
  14499. FluentMaterial.prototype.clone = function (name) {
  14500. var _this = this;
  14501. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14502. };
  14503. FluentMaterial.prototype.serialize = function () {
  14504. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14505. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14506. return serializationObject;
  14507. };
  14508. FluentMaterial.prototype.getClassName = function () {
  14509. return "FluentMaterial";
  14510. };
  14511. // Statics
  14512. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14513. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14514. };
  14515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14516. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14517. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14518. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14519. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14520. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14521. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14523. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14524. ], FluentMaterial.prototype, "alpha", void 0);
  14525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14526. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14527. ], FluentMaterial.prototype, "albedoColor", void 0);
  14528. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14529. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14530. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14531. ], FluentMaterial.prototype, "renderBorders", void 0);
  14532. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14533. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14534. ], FluentMaterial.prototype, "borderWidth", void 0);
  14535. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14536. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14537. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14539. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14540. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14542. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14543. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14544. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14546. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14547. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14549. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14550. ], FluentMaterial.prototype, "hoverColor", void 0);
  14551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14552. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14553. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14555. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14556. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14558. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14559. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14560. return FluentMaterial;
  14561. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14562. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14563. /***/ }),
  14564. /***/ "./3D/materials/index.ts":
  14565. /*!*******************************!*\
  14566. !*** ./3D/materials/index.ts ***!
  14567. \*******************************/
  14568. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14570. "use strict";
  14571. __webpack_require__.r(__webpack_exports__);
  14572. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14575. /***/ }),
  14576. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14577. /*!*************************************************!*\
  14578. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14579. \*************************************************/
  14580. /*! exports provided: fluentPixelShader */
  14581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14582. "use strict";
  14583. __webpack_require__.r(__webpack_exports__);
  14584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14585. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/tools");
  14586. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14587. var name = 'fluentPixelShader';
  14588. 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}";
  14589. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14590. /** @hidden */
  14591. var fluentPixelShader = { name: name, shader: shader };
  14592. /***/ }),
  14593. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14594. /*!***********************************************!*\
  14595. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14596. \***********************************************/
  14597. /*! exports provided: fluentVertexShader */
  14598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14599. "use strict";
  14600. __webpack_require__.r(__webpack_exports__);
  14601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14602. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/tools");
  14603. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14604. var name = 'fluentVertexShader';
  14605. 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";
  14606. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14607. /** @hidden */
  14608. var fluentVertexShader = { name: name, shader: shader };
  14609. /***/ }),
  14610. /***/ "./3D/vector3WithInfo.ts":
  14611. /*!*******************************!*\
  14612. !*** ./3D/vector3WithInfo.ts ***!
  14613. \*******************************/
  14614. /*! exports provided: Vector3WithInfo */
  14615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14616. "use strict";
  14617. __webpack_require__.r(__webpack_exports__);
  14618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14619. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14620. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  14621. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14622. /**
  14623. * Class used to transport Vector3 information for pointer events
  14624. */
  14625. var Vector3WithInfo = /** @class */ (function (_super) {
  14626. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14627. /**
  14628. * Creates a new Vector3WithInfo
  14629. * @param source defines the vector3 data to transport
  14630. * @param buttonIndex defines the current mouse button index
  14631. */
  14632. function Vector3WithInfo(source,
  14633. /** defines the current mouse button index */
  14634. buttonIndex) {
  14635. if (buttonIndex === void 0) { buttonIndex = 0; }
  14636. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14637. _this.buttonIndex = buttonIndex;
  14638. return _this;
  14639. }
  14640. return Vector3WithInfo;
  14641. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14642. /***/ }),
  14643. /***/ "./index.ts":
  14644. /*!******************!*\
  14645. !*** ./index.ts ***!
  14646. \******************/
  14647. /*! 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 */
  14648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14649. "use strict";
  14650. __webpack_require__.r(__webpack_exports__);
  14651. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14691. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14708. /***/ }),
  14709. /***/ "./legacy/legacy.ts":
  14710. /*!**************************!*\
  14711. !*** ./legacy/legacy.ts ***!
  14712. \**************************/
  14713. /*! 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 */
  14714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14715. "use strict";
  14716. __webpack_require__.r(__webpack_exports__);
  14717. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14773. /**
  14774. * Legacy support, defining window.BABYLON.GUI (global variable).
  14775. *
  14776. * This is the entry point for the UMD module.
  14777. * The entry point for a future ESM package should be index.ts
  14778. */
  14779. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14780. if (typeof globalObject !== "undefined") {
  14781. globalObject.BABYLON = globalObject.BABYLON || {};
  14782. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14783. }
  14784. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14785. /***/ }),
  14786. /***/ "babylonjs/Misc/tools":
  14787. /*!****************************************************************************************************!*\
  14788. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14789. \****************************************************************************************************/
  14790. /*! no static exports found */
  14791. /***/ (function(module, exports) {
  14792. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_tools__;
  14793. /***/ })
  14794. /******/ });
  14795. });
  14796. //# sourceMappingURL=babylon.gui.js.map