babylon.gui.js 675 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588
  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. })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) {
  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/observable");
  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/observable");
  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. /**
  505. * Define type to string to ensure compatibility across browsers
  506. * Safari doesn't support DataTransfer constructor
  507. */
  508. _this._clipboardData = "";
  509. /**
  510. * Observable event triggered each time an clipboard event is received from the rendering canvas
  511. */
  512. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  513. /**
  514. * Observable event triggered each time a pointer down is intercepted by a control
  515. */
  516. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  517. /**
  518. * Observable event triggered before layout is evaluated
  519. */
  520. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  521. /**
  522. * Observable event triggered after the layout was evaluated
  523. */
  524. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  525. /**
  526. * Observable event triggered before the texture is rendered
  527. */
  528. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  529. /**
  530. * Observable event triggered after the texture was rendered
  531. */
  532. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  533. /**
  534. * Gets or sets a boolean defining if alpha is stored as premultiplied
  535. */
  536. _this.premulAlpha = false;
  537. _this._useInvalidateRectOptimization = true;
  538. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  539. _this._invalidatedRectangle = null;
  540. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  541. /** @hidden */
  542. _this.onClipboardCopy = function (rawEvt) {
  543. var evt = rawEvt;
  544. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  545. _this.onClipboardObservable.notifyObservers(ev);
  546. evt.preventDefault();
  547. };
  548. /** @hidden */
  549. _this.onClipboardCut = function (rawEvt) {
  550. var evt = rawEvt;
  551. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  552. _this.onClipboardObservable.notifyObservers(ev);
  553. evt.preventDefault();
  554. };
  555. /** @hidden */
  556. _this.onClipboardPaste = function (rawEvt) {
  557. var evt = rawEvt;
  558. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  559. _this.onClipboardObservable.notifyObservers(ev);
  560. evt.preventDefault();
  561. };
  562. scene = _this.getScene();
  563. if (!scene || !_this._texture) {
  564. return _this;
  565. }
  566. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  567. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  568. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  569. if (!_this._focusedControl) {
  570. return;
  571. }
  572. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  573. _this._focusedControl.processKeyboard(info.event);
  574. }
  575. info.skipOnPointerObservable = true;
  576. });
  577. _this._rootContainer._link(_this);
  578. _this.hasAlpha = true;
  579. if (!width || !height) {
  580. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  581. _this._onResize();
  582. }
  583. _this._texture.isReady = true;
  584. return _this;
  585. }
  586. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  587. /**
  588. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  589. * Useful when you want more antialiasing
  590. */
  591. get: function () {
  592. return this._renderScale;
  593. },
  594. set: function (value) {
  595. if (value === this._renderScale) {
  596. return;
  597. }
  598. this._renderScale = value;
  599. this._onResize();
  600. },
  601. enumerable: true,
  602. configurable: true
  603. });
  604. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  605. /** Gets or sets the background color */
  606. get: function () {
  607. return this._background;
  608. },
  609. set: function (value) {
  610. if (this._background === value) {
  611. return;
  612. }
  613. this._background = value;
  614. this.markAsDirty();
  615. },
  616. enumerable: true,
  617. configurable: true
  618. });
  619. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  620. /**
  621. * Gets or sets the ideal width used to design controls.
  622. * The GUI will then rescale everything accordingly
  623. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  624. */
  625. get: function () {
  626. return this._idealWidth;
  627. },
  628. set: function (value) {
  629. if (this._idealWidth === value) {
  630. return;
  631. }
  632. this._idealWidth = value;
  633. this.markAsDirty();
  634. this._rootContainer._markAllAsDirty();
  635. },
  636. enumerable: true,
  637. configurable: true
  638. });
  639. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  640. /**
  641. * Gets or sets the ideal height used to design controls.
  642. * The GUI will then rescale everything accordingly
  643. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  644. */
  645. get: function () {
  646. return this._idealHeight;
  647. },
  648. set: function (value) {
  649. if (this._idealHeight === value) {
  650. return;
  651. }
  652. this._idealHeight = value;
  653. this.markAsDirty();
  654. this._rootContainer._markAllAsDirty();
  655. },
  656. enumerable: true,
  657. configurable: true
  658. });
  659. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  660. /**
  661. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  662. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  663. */
  664. get: function () {
  665. return this._useSmallestIdeal;
  666. },
  667. set: function (value) {
  668. if (this._useSmallestIdeal === value) {
  669. return;
  670. }
  671. this._useSmallestIdeal = value;
  672. this.markAsDirty();
  673. this._rootContainer._markAllAsDirty();
  674. },
  675. enumerable: true,
  676. configurable: true
  677. });
  678. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  679. /**
  680. * Gets or sets a boolean indicating if adaptive scaling must be used
  681. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  682. */
  683. get: function () {
  684. return this._renderAtIdealSize;
  685. },
  686. set: function (value) {
  687. if (this._renderAtIdealSize === value) {
  688. return;
  689. }
  690. this._renderAtIdealSize = value;
  691. this._onResize();
  692. },
  693. enumerable: true,
  694. configurable: true
  695. });
  696. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  697. /**
  698. * Gets the underlying layer used to render the texture when in fullscreen mode
  699. */
  700. get: function () {
  701. return this._layerToDispose;
  702. },
  703. enumerable: true,
  704. configurable: true
  705. });
  706. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  707. /**
  708. * Gets the root container control
  709. */
  710. get: function () {
  711. return this._rootContainer;
  712. },
  713. enumerable: true,
  714. configurable: true
  715. });
  716. /**
  717. * Returns an array containing the root container.
  718. * This is mostly used to let the Inspector introspects the ADT
  719. * @returns an array containing the rootContainer
  720. */
  721. AdvancedDynamicTexture.prototype.getChildren = function () {
  722. return [this._rootContainer];
  723. };
  724. /**
  725. * Will return all controls that are inside this texture
  726. * @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
  727. * @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
  728. * @return all child controls
  729. */
  730. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  731. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  732. };
  733. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  734. /**
  735. * Gets or sets the current focused control
  736. */
  737. get: function () {
  738. return this._focusedControl;
  739. },
  740. set: function (control) {
  741. if (this._focusedControl == control) {
  742. return;
  743. }
  744. if (this._focusedControl) {
  745. this._focusedControl.onBlur();
  746. }
  747. if (control) {
  748. control.onFocus();
  749. }
  750. this._focusedControl = control;
  751. },
  752. enumerable: true,
  753. configurable: true
  754. });
  755. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  756. /**
  757. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  758. */
  759. get: function () {
  760. if (!this.layer) {
  761. return true;
  762. }
  763. return (!this.layer.isBackground);
  764. },
  765. set: function (value) {
  766. if (!this.layer) {
  767. return;
  768. }
  769. if (this.layer.isBackground === !value) {
  770. return;
  771. }
  772. this.layer.isBackground = !value;
  773. },
  774. enumerable: true,
  775. configurable: true
  776. });
  777. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  778. /**
  779. * Gets or set information about clipboardData
  780. */
  781. get: function () {
  782. return this._clipboardData;
  783. },
  784. set: function (value) {
  785. this._clipboardData = value;
  786. },
  787. enumerable: true,
  788. configurable: true
  789. });
  790. /**
  791. * Get the current class name of the texture useful for serialization or dynamic coding.
  792. * @returns "AdvancedDynamicTexture"
  793. */
  794. AdvancedDynamicTexture.prototype.getClassName = function () {
  795. return "AdvancedDynamicTexture";
  796. };
  797. /**
  798. * Function used to execute a function on all controls
  799. * @param func defines the function to execute
  800. * @param container defines the container where controls belong. If null the root container will be used
  801. */
  802. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  803. if (!container) {
  804. container = this._rootContainer;
  805. }
  806. func(container);
  807. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  808. var child = _a[_i];
  809. if (child.children) {
  810. this.executeOnAllControls(func, child);
  811. continue;
  812. }
  813. func(child);
  814. }
  815. };
  816. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  817. /**
  818. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  819. */
  820. get: function () {
  821. return this._useInvalidateRectOptimization;
  822. },
  823. set: function (value) {
  824. this._useInvalidateRectOptimization = value;
  825. },
  826. enumerable: true,
  827. configurable: true
  828. });
  829. /**
  830. * Invalidates a rectangle area on the gui texture
  831. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  832. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  833. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  834. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  835. */
  836. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  837. if (!this._useInvalidateRectOptimization) {
  838. return;
  839. }
  840. if (!this._invalidatedRectangle) {
  841. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  842. }
  843. else {
  844. // Compute intersection
  845. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  846. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  847. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  848. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  849. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  850. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  851. }
  852. };
  853. /**
  854. * Marks the texture as dirty forcing a complete update
  855. */
  856. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  857. this._isDirty = true;
  858. };
  859. /**
  860. * Helper function used to create a new style
  861. * @returns a new style
  862. * @see http://doc.babylonjs.com/how_to/gui#styles
  863. */
  864. AdvancedDynamicTexture.prototype.createStyle = function () {
  865. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  866. };
  867. /**
  868. * Adds a new control to the root container
  869. * @param control defines the control to add
  870. * @returns the current texture
  871. */
  872. AdvancedDynamicTexture.prototype.addControl = function (control) {
  873. this._rootContainer.addControl(control);
  874. return this;
  875. };
  876. /**
  877. * Removes a control from the root container
  878. * @param control defines the control to remove
  879. * @returns the current texture
  880. */
  881. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  882. this._rootContainer.removeControl(control);
  883. return this;
  884. };
  885. /**
  886. * Release all resources
  887. */
  888. AdvancedDynamicTexture.prototype.dispose = function () {
  889. var scene = this.getScene();
  890. if (!scene) {
  891. return;
  892. }
  893. this._rootCanvas = null;
  894. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  895. if (this._resizeObserver) {
  896. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  897. }
  898. if (this._pointerMoveObserver) {
  899. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  900. }
  901. if (this._pointerObserver) {
  902. scene.onPointerObservable.remove(this._pointerObserver);
  903. }
  904. if (this._preKeyboardObserver) {
  905. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  906. }
  907. if (this._canvasPointerOutObserver) {
  908. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  909. }
  910. if (this._layerToDispose) {
  911. this._layerToDispose.texture = null;
  912. this._layerToDispose.dispose();
  913. this._layerToDispose = null;
  914. }
  915. this._rootContainer.dispose();
  916. this.onClipboardObservable.clear();
  917. this.onControlPickedObservable.clear();
  918. this.onBeginRenderObservable.clear();
  919. this.onEndRenderObservable.clear();
  920. this.onBeginLayoutObservable.clear();
  921. this.onEndLayoutObservable.clear();
  922. _super.prototype.dispose.call(this);
  923. };
  924. AdvancedDynamicTexture.prototype._onResize = function () {
  925. var scene = this.getScene();
  926. if (!scene) {
  927. return;
  928. }
  929. // Check size
  930. var engine = scene.getEngine();
  931. var textureSize = this.getSize();
  932. var renderWidth = engine.getRenderWidth() * this._renderScale;
  933. var renderHeight = engine.getRenderHeight() * this._renderScale;
  934. if (this._renderAtIdealSize) {
  935. if (this._idealWidth) {
  936. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  937. renderWidth = this._idealWidth;
  938. }
  939. else if (this._idealHeight) {
  940. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  941. renderHeight = this._idealHeight;
  942. }
  943. }
  944. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  945. this.scaleTo(renderWidth, renderHeight);
  946. this.markAsDirty();
  947. if (this._idealWidth || this._idealHeight) {
  948. this._rootContainer._markAllAsDirty();
  949. }
  950. }
  951. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  952. };
  953. /** @hidden */
  954. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  955. var engine = scene.getEngine();
  956. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  957. };
  958. /**
  959. * Get screen coordinates for a vector3
  960. * @param position defines the position to project
  961. * @param worldMatrix defines the world matrix to use
  962. * @returns the projected position
  963. */
  964. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  965. var scene = this.getScene();
  966. if (!scene) {
  967. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  968. }
  969. var globalViewport = this._getGlobalViewport(scene);
  970. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  971. projectedPosition.scaleInPlace(this.renderScale);
  972. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  973. };
  974. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  975. if (this._layerToDispose) {
  976. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  977. return;
  978. }
  979. }
  980. if (this._isFullscreen && this._linkedControls.length) {
  981. var scene = this.getScene();
  982. if (!scene) {
  983. return;
  984. }
  985. var globalViewport = this._getGlobalViewport(scene);
  986. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  987. var control = _a[_i];
  988. if (!control.isVisible) {
  989. continue;
  990. }
  991. var mesh = control._linkedMesh;
  992. if (!mesh || mesh.isDisposed()) {
  993. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  994. control.linkWithMesh(null);
  995. });
  996. continue;
  997. }
  998. var position = mesh.getBoundingInfo().boundingSphere.center;
  999. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1000. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1001. control.notRenderable = true;
  1002. continue;
  1003. }
  1004. control.notRenderable = false;
  1005. // Account for RenderScale.
  1006. projectedPosition.scaleInPlace(this.renderScale);
  1007. control._moveToProjectedPosition(projectedPosition);
  1008. }
  1009. }
  1010. if (!this._isDirty && !this._rootContainer.isDirty) {
  1011. return;
  1012. }
  1013. this._isDirty = false;
  1014. this._render();
  1015. this.update(true, this.premulAlpha);
  1016. };
  1017. AdvancedDynamicTexture.prototype._render = function () {
  1018. var textureSize = this.getSize();
  1019. var renderWidth = textureSize.width;
  1020. var renderHeight = textureSize.height;
  1021. var context = this.getContext();
  1022. context.font = "18px Arial";
  1023. context.strokeStyle = "white";
  1024. // Layout
  1025. this.onBeginLayoutObservable.notifyObservers(this);
  1026. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1027. this._rootContainer._layout(measure, context);
  1028. this.onEndLayoutObservable.notifyObservers(this);
  1029. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1030. // Clear
  1031. if (this._invalidatedRectangle) {
  1032. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1033. }
  1034. else {
  1035. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1036. }
  1037. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1038. if (this._background) {
  1039. context.save();
  1040. context.fillStyle = this._background;
  1041. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1042. context.restore();
  1043. }
  1044. // Render
  1045. this.onBeginRenderObservable.notifyObservers(this);
  1046. this._rootContainer._render(context, this._invalidatedRectangle);
  1047. this.onEndRenderObservable.notifyObservers(this);
  1048. this._invalidatedRectangle = null;
  1049. };
  1050. /** @hidden */
  1051. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1052. if (this._rootCanvas) {
  1053. this._rootCanvas.style.cursor = cursor;
  1054. }
  1055. };
  1056. /** @hidden */
  1057. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1058. this._lastControlDown[pointerId] = control;
  1059. this.onControlPickedObservable.notifyObservers(control);
  1060. };
  1061. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1062. var scene = this.getScene();
  1063. if (!scene) {
  1064. return;
  1065. }
  1066. var engine = scene.getEngine();
  1067. var textureSize = this.getSize();
  1068. if (this._isFullscreen) {
  1069. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1070. var viewport = camera.viewport;
  1071. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1072. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1073. }
  1074. if (this._capturingControl[pointerId]) {
  1075. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1076. return;
  1077. }
  1078. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1079. this._changeCursor("");
  1080. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1081. if (this._lastControlOver[pointerId]) {
  1082. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1083. delete this._lastControlOver[pointerId];
  1084. }
  1085. }
  1086. }
  1087. this._manageFocus();
  1088. };
  1089. /** @hidden */
  1090. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1091. for (var pointerId in list) {
  1092. if (!list.hasOwnProperty(pointerId)) {
  1093. continue;
  1094. }
  1095. var lastControlOver = list[pointerId];
  1096. if (lastControlOver === control) {
  1097. delete list[pointerId];
  1098. }
  1099. }
  1100. };
  1101. /** @hidden */
  1102. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1103. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1104. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1105. };
  1106. /** Attach to all scene events required to support pointer events */
  1107. AdvancedDynamicTexture.prototype.attach = function () {
  1108. var _this = this;
  1109. var scene = this.getScene();
  1110. if (!scene) {
  1111. return;
  1112. }
  1113. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1114. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1115. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1116. return;
  1117. }
  1118. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1119. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1120. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1121. return;
  1122. }
  1123. if (!scene) {
  1124. return;
  1125. }
  1126. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1127. var engine = scene.getEngine();
  1128. if (!camera) {
  1129. tempViewport.x = 0;
  1130. tempViewport.y = 0;
  1131. tempViewport.width = engine.getRenderWidth();
  1132. tempViewport.height = engine.getRenderHeight();
  1133. }
  1134. else {
  1135. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1136. }
  1137. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1138. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1139. _this._shouldBlockPointer = false;
  1140. // Do picking modifies _shouldBlockPointer
  1141. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1142. // Avoid overwriting a true skipOnPointerObservable to false
  1143. if (_this._shouldBlockPointer) {
  1144. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1145. }
  1146. });
  1147. this._attachToOnPointerOut(scene);
  1148. };
  1149. /**
  1150. * Register the clipboard Events onto the canvas
  1151. */
  1152. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1153. self.addEventListener("copy", this.onClipboardCopy, false);
  1154. self.addEventListener("cut", this.onClipboardCut, false);
  1155. self.addEventListener("paste", this.onClipboardPaste, false);
  1156. };
  1157. /**
  1158. * Unregister the clipboard Events from the canvas
  1159. */
  1160. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1161. self.removeEventListener("copy", this.onClipboardCopy);
  1162. self.removeEventListener("cut", this.onClipboardCut);
  1163. self.removeEventListener("paste", this.onClipboardPaste);
  1164. };
  1165. /**
  1166. * Connect the texture to a hosting mesh to enable interactions
  1167. * @param mesh defines the mesh to attach to
  1168. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1169. */
  1170. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1171. var _this = this;
  1172. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1173. var scene = this.getScene();
  1174. if (!scene) {
  1175. return;
  1176. }
  1177. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1178. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1179. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1180. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1181. return;
  1182. }
  1183. var pointerId = pi.event.pointerId || 0;
  1184. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1185. var uv = pi.pickInfo.getTextureCoordinates();
  1186. if (uv) {
  1187. var size = _this.getSize();
  1188. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1189. }
  1190. }
  1191. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1192. if (_this._lastControlDown[pointerId]) {
  1193. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1194. }
  1195. delete _this._lastControlDown[pointerId];
  1196. if (_this.focusedControl) {
  1197. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1198. var canMoveFocus = true;
  1199. if (friendlyControls) {
  1200. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1201. var control = friendlyControls_1[_i];
  1202. // Same host, no need to keep the focus
  1203. if (_this === control._host) {
  1204. continue;
  1205. }
  1206. // Different hosts
  1207. var otherHost = control._host;
  1208. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1209. canMoveFocus = false;
  1210. break;
  1211. }
  1212. }
  1213. }
  1214. if (canMoveFocus) {
  1215. _this.focusedControl = null;
  1216. }
  1217. }
  1218. }
  1219. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1220. if (_this._lastControlOver[pointerId]) {
  1221. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1222. }
  1223. delete _this._lastControlOver[pointerId];
  1224. }
  1225. });
  1226. mesh.enablePointerMoveEvents = supportPointerMove;
  1227. this._attachToOnPointerOut(scene);
  1228. };
  1229. /**
  1230. * Move the focus to a specific control
  1231. * @param control defines the control which will receive the focus
  1232. */
  1233. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1234. this.focusedControl = control;
  1235. this._lastPickedControl = control;
  1236. this._blockNextFocusCheck = true;
  1237. };
  1238. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1239. if (this._blockNextFocusCheck) {
  1240. this._blockNextFocusCheck = false;
  1241. this._lastPickedControl = this._focusedControl;
  1242. return;
  1243. }
  1244. // Focus management
  1245. if (this._focusedControl) {
  1246. if (this._focusedControl !== this._lastPickedControl) {
  1247. if (this._lastPickedControl.isFocusInvisible) {
  1248. return;
  1249. }
  1250. this.focusedControl = null;
  1251. }
  1252. }
  1253. };
  1254. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1255. var _this = this;
  1256. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1257. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1258. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1259. }
  1260. delete _this._lastControlOver[pointerEvent.pointerId];
  1261. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1262. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1263. delete _this._lastControlDown[pointerEvent.pointerId];
  1264. }
  1265. });
  1266. };
  1267. // Statics
  1268. /**
  1269. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1270. * @param mesh defines the mesh which will receive the texture
  1271. * @param width defines the texture width (1024 by default)
  1272. * @param height defines the texture height (1024 by default)
  1273. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1274. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1275. * @returns a new AdvancedDynamicTexture
  1276. */
  1277. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1278. if (width === void 0) { width = 1024; }
  1279. if (height === void 0) { height = 1024; }
  1280. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1281. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1282. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1283. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1284. material.backFaceCulling = false;
  1285. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1286. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1287. if (onlyAlphaTesting) {
  1288. material.diffuseTexture = result;
  1289. material.emissiveTexture = result;
  1290. result.hasAlpha = true;
  1291. }
  1292. else {
  1293. material.emissiveTexture = result;
  1294. material.opacityTexture = result;
  1295. }
  1296. mesh.material = material;
  1297. result.attachToMesh(mesh, supportPointerMove);
  1298. return result;
  1299. };
  1300. /**
  1301. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1302. * In this mode the texture will rely on a layer for its rendering.
  1303. * This allows it to be treated like any other layer.
  1304. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1305. * LayerMask is set through advancedTexture.layer.layerMask
  1306. * @param name defines name for the texture
  1307. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1308. * @param scene defines the hsoting scene
  1309. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1310. * @returns a new AdvancedDynamicTexture
  1311. */
  1312. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1313. if (foreground === void 0) { foreground = true; }
  1314. if (scene === void 0) { scene = null; }
  1315. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1316. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1317. // Display
  1318. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1319. layer.texture = result;
  1320. result._layerToDispose = layer;
  1321. result._isFullscreen = true;
  1322. // Attach
  1323. result.attach();
  1324. return result;
  1325. };
  1326. return AdvancedDynamicTexture;
  1327. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1328. /***/ }),
  1329. /***/ "./2D/controls/button.ts":
  1330. /*!*******************************!*\
  1331. !*** ./2D/controls/button.ts ***!
  1332. \*******************************/
  1333. /*! exports provided: Button */
  1334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1335. "use strict";
  1336. __webpack_require__.r(__webpack_exports__);
  1337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1338. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1339. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1340. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1341. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1342. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1343. /**
  1344. * Class used to create 2D buttons
  1345. */
  1346. var Button = /** @class */ (function (_super) {
  1347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1348. /**
  1349. * Creates a new Button
  1350. * @param name defines the name of the button
  1351. */
  1352. function Button(name) {
  1353. var _this = _super.call(this, name) || this;
  1354. _this.name = name;
  1355. _this.thickness = 1;
  1356. _this.isPointerBlocker = true;
  1357. var alphaStore = null;
  1358. _this.pointerEnterAnimation = function () {
  1359. alphaStore = _this.alpha;
  1360. _this.alpha -= 0.1;
  1361. };
  1362. _this.pointerOutAnimation = function () {
  1363. if (alphaStore !== null) {
  1364. _this.alpha = alphaStore;
  1365. }
  1366. };
  1367. _this.pointerDownAnimation = function () {
  1368. _this.scaleX -= 0.05;
  1369. _this.scaleY -= 0.05;
  1370. };
  1371. _this.pointerUpAnimation = function () {
  1372. _this.scaleX += 0.05;
  1373. _this.scaleY += 0.05;
  1374. };
  1375. return _this;
  1376. }
  1377. Object.defineProperty(Button.prototype, "image", {
  1378. /**
  1379. * Returns the image part of the button (if any)
  1380. */
  1381. get: function () {
  1382. return this._image;
  1383. },
  1384. enumerable: true,
  1385. configurable: true
  1386. });
  1387. Object.defineProperty(Button.prototype, "textBlock", {
  1388. /**
  1389. * Returns the image part of the button (if any)
  1390. */
  1391. get: function () {
  1392. return this._textBlock;
  1393. },
  1394. enumerable: true,
  1395. configurable: true
  1396. });
  1397. Button.prototype._getTypeName = function () {
  1398. return "Button";
  1399. };
  1400. // While being a container, the button behaves like a control.
  1401. /** @hidden */
  1402. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1403. if (!this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1404. return false;
  1405. }
  1406. if (!_super.prototype.contains.call(this, x, y)) {
  1407. return false;
  1408. }
  1409. this._processObservables(type, x, y, pointerId, buttonIndex);
  1410. return true;
  1411. };
  1412. /** @hidden */
  1413. Button.prototype._onPointerEnter = function (target) {
  1414. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1415. return false;
  1416. }
  1417. if (this.pointerEnterAnimation) {
  1418. this.pointerEnterAnimation();
  1419. }
  1420. return true;
  1421. };
  1422. /** @hidden */
  1423. Button.prototype._onPointerOut = function (target, force) {
  1424. if (force === void 0) { force = false; }
  1425. if (this.pointerOutAnimation) {
  1426. this.pointerOutAnimation();
  1427. }
  1428. _super.prototype._onPointerOut.call(this, target, force);
  1429. };
  1430. /** @hidden */
  1431. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1432. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1433. return false;
  1434. }
  1435. if (this.pointerDownAnimation) {
  1436. this.pointerDownAnimation();
  1437. }
  1438. return true;
  1439. };
  1440. /** @hidden */
  1441. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1442. if (this.pointerUpAnimation) {
  1443. this.pointerUpAnimation();
  1444. }
  1445. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1446. };
  1447. // Statics
  1448. /**
  1449. * Creates a new button made with an image and a text
  1450. * @param name defines the name of the button
  1451. * @param text defines the text of the button
  1452. * @param imageUrl defines the url of the image
  1453. * @returns a new Button
  1454. */
  1455. Button.CreateImageButton = function (name, text, imageUrl) {
  1456. var result = new Button(name);
  1457. // Adding text
  1458. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1459. textBlock.textWrapping = true;
  1460. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1461. textBlock.paddingLeft = "20%";
  1462. result.addControl(textBlock);
  1463. // Adding image
  1464. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1465. iconImage.width = "20%";
  1466. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1467. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1468. result.addControl(iconImage);
  1469. // Store
  1470. result._image = iconImage;
  1471. result._textBlock = textBlock;
  1472. return result;
  1473. };
  1474. /**
  1475. * Creates a new button made with an image
  1476. * @param name defines the name of the button
  1477. * @param imageUrl defines the url of the image
  1478. * @returns a new Button
  1479. */
  1480. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1481. var result = new Button(name);
  1482. // Adding image
  1483. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1484. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1485. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1486. result.addControl(iconImage);
  1487. // Store
  1488. result._image = iconImage;
  1489. return result;
  1490. };
  1491. /**
  1492. * Creates a new button made with a text
  1493. * @param name defines the name of the button
  1494. * @param text defines the text of the button
  1495. * @returns a new Button
  1496. */
  1497. Button.CreateSimpleButton = function (name, text) {
  1498. var result = new Button(name);
  1499. // Adding text
  1500. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1501. textBlock.textWrapping = true;
  1502. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1503. result.addControl(textBlock);
  1504. // Store
  1505. result._textBlock = textBlock;
  1506. return result;
  1507. };
  1508. /**
  1509. * Creates a new button made with an image and a centered text
  1510. * @param name defines the name of the button
  1511. * @param text defines the text of the button
  1512. * @param imageUrl defines the url of the image
  1513. * @returns a new Button
  1514. */
  1515. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1516. var result = new Button(name);
  1517. // Adding image
  1518. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1519. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1520. result.addControl(iconImage);
  1521. // Adding text
  1522. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1523. textBlock.textWrapping = true;
  1524. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1525. result.addControl(textBlock);
  1526. // Store
  1527. result._image = iconImage;
  1528. result._textBlock = textBlock;
  1529. return result;
  1530. };
  1531. return Button;
  1532. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1533. /***/ }),
  1534. /***/ "./2D/controls/checkbox.ts":
  1535. /*!*********************************!*\
  1536. !*** ./2D/controls/checkbox.ts ***!
  1537. \*********************************/
  1538. /*! exports provided: Checkbox */
  1539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1540. "use strict";
  1541. __webpack_require__.r(__webpack_exports__);
  1542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1543. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1544. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1545. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1546. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1547. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1548. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1549. /**
  1550. * Class used to represent a 2D checkbox
  1551. */
  1552. var Checkbox = /** @class */ (function (_super) {
  1553. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1554. /**
  1555. * Creates a new CheckBox
  1556. * @param name defines the control name
  1557. */
  1558. function Checkbox(name) {
  1559. var _this = _super.call(this, name) || this;
  1560. _this.name = name;
  1561. _this._isChecked = false;
  1562. _this._background = "black";
  1563. _this._checkSizeRatio = 0.8;
  1564. _this._thickness = 1;
  1565. /**
  1566. * Observable raised when isChecked property changes
  1567. */
  1568. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1569. _this.isPointerBlocker = true;
  1570. return _this;
  1571. }
  1572. Object.defineProperty(Checkbox.prototype, "thickness", {
  1573. /** Gets or sets border thickness */
  1574. get: function () {
  1575. return this._thickness;
  1576. },
  1577. set: function (value) {
  1578. if (this._thickness === value) {
  1579. return;
  1580. }
  1581. this._thickness = value;
  1582. this._markAsDirty();
  1583. },
  1584. enumerable: true,
  1585. configurable: true
  1586. });
  1587. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1588. /** Gets or sets a value indicating the ratio between overall size and check size */
  1589. get: function () {
  1590. return this._checkSizeRatio;
  1591. },
  1592. set: function (value) {
  1593. value = Math.max(Math.min(1, value), 0);
  1594. if (this._checkSizeRatio === value) {
  1595. return;
  1596. }
  1597. this._checkSizeRatio = value;
  1598. this._markAsDirty();
  1599. },
  1600. enumerable: true,
  1601. configurable: true
  1602. });
  1603. Object.defineProperty(Checkbox.prototype, "background", {
  1604. /** Gets or sets background color */
  1605. get: function () {
  1606. return this._background;
  1607. },
  1608. set: function (value) {
  1609. if (this._background === value) {
  1610. return;
  1611. }
  1612. this._background = value;
  1613. this._markAsDirty();
  1614. },
  1615. enumerable: true,
  1616. configurable: true
  1617. });
  1618. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1619. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1620. get: function () {
  1621. return this._isChecked;
  1622. },
  1623. set: function (value) {
  1624. if (this._isChecked === value) {
  1625. return;
  1626. }
  1627. this._isChecked = value;
  1628. this._markAsDirty();
  1629. this.onIsCheckedChangedObservable.notifyObservers(value);
  1630. },
  1631. enumerable: true,
  1632. configurable: true
  1633. });
  1634. Checkbox.prototype._getTypeName = function () {
  1635. return "Checkbox";
  1636. };
  1637. /** @hidden */
  1638. Checkbox.prototype._draw = function (context) {
  1639. context.save();
  1640. this._applyStates(context);
  1641. var actualWidth = this._currentMeasure.width - this._thickness;
  1642. var actualHeight = this._currentMeasure.height - this._thickness;
  1643. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1644. context.shadowColor = this.shadowColor;
  1645. context.shadowBlur = this.shadowBlur;
  1646. context.shadowOffsetX = this.shadowOffsetX;
  1647. context.shadowOffsetY = this.shadowOffsetY;
  1648. }
  1649. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1650. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1651. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1652. context.shadowBlur = 0;
  1653. context.shadowOffsetX = 0;
  1654. context.shadowOffsetY = 0;
  1655. }
  1656. if (this._isChecked) {
  1657. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1658. var offsetWidth = actualWidth * this._checkSizeRatio;
  1659. var offseHeight = actualHeight * this._checkSizeRatio;
  1660. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1661. }
  1662. context.strokeStyle = this.color;
  1663. context.lineWidth = this._thickness;
  1664. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1665. context.restore();
  1666. };
  1667. // Events
  1668. /** @hidden */
  1669. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1670. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1671. return false;
  1672. }
  1673. this.isChecked = !this.isChecked;
  1674. return true;
  1675. };
  1676. /**
  1677. * Utility function to easily create a checkbox with a header
  1678. * @param title defines the label to use for the header
  1679. * @param onValueChanged defines the callback to call when value changes
  1680. * @returns a StackPanel containing the checkbox and a textBlock
  1681. */
  1682. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1683. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1684. panel.isVertical = false;
  1685. panel.height = "30px";
  1686. var checkbox = new Checkbox();
  1687. checkbox.width = "20px";
  1688. checkbox.height = "20px";
  1689. checkbox.isChecked = true;
  1690. checkbox.color = "green";
  1691. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1692. panel.addControl(checkbox);
  1693. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1694. header.text = title;
  1695. header.width = "180px";
  1696. header.paddingLeft = "5px";
  1697. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1698. header.color = "white";
  1699. panel.addControl(header);
  1700. return panel;
  1701. };
  1702. return Checkbox;
  1703. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1704. /***/ }),
  1705. /***/ "./2D/controls/colorpicker.ts":
  1706. /*!************************************!*\
  1707. !*** ./2D/controls/colorpicker.ts ***!
  1708. \************************************/
  1709. /*! exports provided: ColorPicker */
  1710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1711. "use strict";
  1712. __webpack_require__.r(__webpack_exports__);
  1713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1714. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1715. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1716. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1717. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1718. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1719. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1720. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1721. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1722. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1723. /** Class used to create color pickers */
  1724. var ColorPicker = /** @class */ (function (_super) {
  1725. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1726. /**
  1727. * Creates a new ColorPicker
  1728. * @param name defines the control name
  1729. */
  1730. function ColorPicker(name) {
  1731. var _this = _super.call(this, name) || this;
  1732. _this.name = name;
  1733. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1734. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1735. _this._pointerStartedOnSquare = false;
  1736. _this._pointerStartedOnWheel = false;
  1737. _this._squareLeft = 0;
  1738. _this._squareTop = 0;
  1739. _this._squareSize = 0;
  1740. _this._h = 360;
  1741. _this._s = 1;
  1742. _this._v = 1;
  1743. /**
  1744. * Observable raised when the value changes
  1745. */
  1746. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1747. // Events
  1748. _this._pointerIsDown = false;
  1749. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1750. _this.size = "200px";
  1751. _this.isPointerBlocker = true;
  1752. return _this;
  1753. }
  1754. Object.defineProperty(ColorPicker.prototype, "value", {
  1755. /** Gets or sets the color of the color picker */
  1756. get: function () {
  1757. return this._value;
  1758. },
  1759. set: function (value) {
  1760. if (this._value.equals(value)) {
  1761. return;
  1762. }
  1763. this._value.copyFrom(value);
  1764. this._RGBtoHSV(this._value, this._tmpColor);
  1765. this._h = this._tmpColor.r;
  1766. this._s = Math.max(this._tmpColor.g, 0.00001);
  1767. this._v = Math.max(this._tmpColor.b, 0.00001);
  1768. this._markAsDirty();
  1769. if (this._value.r <= ColorPicker._Epsilon) {
  1770. this._value.r = 0;
  1771. }
  1772. if (this._value.g <= ColorPicker._Epsilon) {
  1773. this._value.g = 0;
  1774. }
  1775. if (this._value.b <= ColorPicker._Epsilon) {
  1776. this._value.b = 0;
  1777. }
  1778. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1779. this._value.r = 1.0;
  1780. }
  1781. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1782. this._value.g = 1.0;
  1783. }
  1784. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1785. this._value.b = 1.0;
  1786. }
  1787. this.onValueChangedObservable.notifyObservers(this._value);
  1788. },
  1789. enumerable: true,
  1790. configurable: true
  1791. });
  1792. Object.defineProperty(ColorPicker.prototype, "width", {
  1793. /**
  1794. * Gets or sets control width
  1795. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1796. */
  1797. get: function () {
  1798. return this._width.toString(this._host);
  1799. },
  1800. set: function (value) {
  1801. if (this._width.toString(this._host) === value) {
  1802. return;
  1803. }
  1804. if (this._width.fromString(value)) {
  1805. this._height.fromString(value);
  1806. this._markAsDirty();
  1807. }
  1808. },
  1809. enumerable: true,
  1810. configurable: true
  1811. });
  1812. Object.defineProperty(ColorPicker.prototype, "height", {
  1813. /**
  1814. * Gets or sets control height
  1815. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1816. */
  1817. get: function () {
  1818. return this._height.toString(this._host);
  1819. },
  1820. /** Gets or sets control height */
  1821. set: function (value) {
  1822. if (this._height.toString(this._host) === value) {
  1823. return;
  1824. }
  1825. if (this._height.fromString(value)) {
  1826. this._width.fromString(value);
  1827. this._markAsDirty();
  1828. }
  1829. },
  1830. enumerable: true,
  1831. configurable: true
  1832. });
  1833. Object.defineProperty(ColorPicker.prototype, "size", {
  1834. /** Gets or sets control size */
  1835. get: function () {
  1836. return this.width;
  1837. },
  1838. set: function (value) {
  1839. this.width = value;
  1840. },
  1841. enumerable: true,
  1842. configurable: true
  1843. });
  1844. ColorPicker.prototype._getTypeName = function () {
  1845. return "ColorPicker";
  1846. };
  1847. /** @hidden */
  1848. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1849. if (parentMeasure.width < parentMeasure.height) {
  1850. this._currentMeasure.height = parentMeasure.width;
  1851. }
  1852. else {
  1853. this._currentMeasure.width = parentMeasure.height;
  1854. }
  1855. };
  1856. ColorPicker.prototype._updateSquareProps = function () {
  1857. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1858. var wheelThickness = radius * .2;
  1859. var innerDiameter = (radius - wheelThickness) * 2;
  1860. var squareSize = innerDiameter / (Math.sqrt(2));
  1861. var offset = radius - squareSize * .5;
  1862. this._squareLeft = this._currentMeasure.left + offset;
  1863. this._squareTop = this._currentMeasure.top + offset;
  1864. this._squareSize = squareSize;
  1865. };
  1866. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1867. var lgh = context.createLinearGradient(left, top, width + left, top);
  1868. lgh.addColorStop(0, '#fff');
  1869. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1870. context.fillStyle = lgh;
  1871. context.fillRect(left, top, width, height);
  1872. var lgv = context.createLinearGradient(left, top, left, height + top);
  1873. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1874. lgv.addColorStop(1, '#000');
  1875. context.fillStyle = lgv;
  1876. context.fillRect(left, top, width, height);
  1877. };
  1878. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1879. context.beginPath();
  1880. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1881. context.lineWidth = 3;
  1882. context.strokeStyle = '#333333';
  1883. context.stroke();
  1884. context.beginPath();
  1885. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1886. context.lineWidth = 3;
  1887. context.strokeStyle = '#ffffff';
  1888. context.stroke();
  1889. };
  1890. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1891. var canvas = document.createElement("canvas");
  1892. canvas.width = radius * 2;
  1893. canvas.height = radius * 2;
  1894. var context = canvas.getContext("2d");
  1895. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1896. var data = image.data;
  1897. var color = this._tmpColor;
  1898. var maxDistSq = radius * radius;
  1899. var innerRadius = radius - thickness;
  1900. var minDistSq = innerRadius * innerRadius;
  1901. for (var x = -radius; x < radius; x++) {
  1902. for (var y = -radius; y < radius; y++) {
  1903. var distSq = x * x + y * y;
  1904. if (distSq > maxDistSq || distSq < minDistSq) {
  1905. continue;
  1906. }
  1907. var dist = Math.sqrt(distSq);
  1908. var ang = Math.atan2(y, x);
  1909. this._HSVtoRGB(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1910. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1911. data[index] = color.r * 255;
  1912. data[index + 1] = color.g * 255;
  1913. data[index + 2] = color.b * 255;
  1914. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1915. //apply less alpha to bigger color pickers
  1916. var alphaAmount = .2;
  1917. var maxAlpha = .2;
  1918. var minAlpha = .04;
  1919. var lowerRadius = 50;
  1920. var upperRadius = 150;
  1921. if (radius < lowerRadius) {
  1922. alphaAmount = maxAlpha;
  1923. }
  1924. else if (radius > upperRadius) {
  1925. alphaAmount = minAlpha;
  1926. }
  1927. else {
  1928. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1929. }
  1930. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1931. if (alphaRatio < alphaAmount) {
  1932. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1933. }
  1934. else if (alphaRatio > 1 - alphaAmount) {
  1935. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1936. }
  1937. else {
  1938. data[index + 3] = 255;
  1939. }
  1940. }
  1941. }
  1942. context.putImageData(image, 0, 0);
  1943. return canvas;
  1944. };
  1945. ColorPicker.prototype._RGBtoHSV = function (color, result) {
  1946. var r = color.r;
  1947. var g = color.g;
  1948. var b = color.b;
  1949. var max = Math.max(r, g, b);
  1950. var min = Math.min(r, g, b);
  1951. var h = 0;
  1952. var s = 0;
  1953. var v = max;
  1954. var dm = max - min;
  1955. if (max !== 0) {
  1956. s = dm / max;
  1957. }
  1958. if (max != min) {
  1959. if (max == r) {
  1960. h = (g - b) / dm;
  1961. if (g < b) {
  1962. h += 6;
  1963. }
  1964. }
  1965. else if (max == g) {
  1966. h = (b - r) / dm + 2;
  1967. }
  1968. else if (max == b) {
  1969. h = (r - g) / dm + 4;
  1970. }
  1971. h *= 60;
  1972. }
  1973. result.r = h;
  1974. result.g = s;
  1975. result.b = v;
  1976. };
  1977. ColorPicker.prototype._HSVtoRGB = function (hue, saturation, value, result) {
  1978. var chroma = value * saturation;
  1979. var h = hue / 60;
  1980. var x = chroma * (1 - Math.abs((h % 2) - 1));
  1981. var r = 0;
  1982. var g = 0;
  1983. var b = 0;
  1984. if (h >= 0 && h <= 1) {
  1985. r = chroma;
  1986. g = x;
  1987. }
  1988. else if (h >= 1 && h <= 2) {
  1989. r = x;
  1990. g = chroma;
  1991. }
  1992. else if (h >= 2 && h <= 3) {
  1993. g = chroma;
  1994. b = x;
  1995. }
  1996. else if (h >= 3 && h <= 4) {
  1997. g = x;
  1998. b = chroma;
  1999. }
  2000. else if (h >= 4 && h <= 5) {
  2001. r = x;
  2002. b = chroma;
  2003. }
  2004. else if (h >= 5 && h <= 6) {
  2005. r = chroma;
  2006. b = x;
  2007. }
  2008. var m = value - chroma;
  2009. result.set((r + m), (g + m), (b + m));
  2010. };
  2011. /** @hidden */
  2012. ColorPicker.prototype._draw = function (context) {
  2013. context.save();
  2014. this._applyStates(context);
  2015. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2016. var wheelThickness = radius * .2;
  2017. var left = this._currentMeasure.left;
  2018. var top = this._currentMeasure.top;
  2019. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2020. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2021. }
  2022. this._updateSquareProps();
  2023. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2024. context.shadowColor = this.shadowColor;
  2025. context.shadowBlur = this.shadowBlur;
  2026. context.shadowOffsetX = this.shadowOffsetX;
  2027. context.shadowOffsetY = this.shadowOffsetY;
  2028. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2029. }
  2030. context.drawImage(this._colorWheelCanvas, left, top);
  2031. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2032. context.shadowBlur = 0;
  2033. context.shadowOffsetX = 0;
  2034. context.shadowOffsetY = 0;
  2035. }
  2036. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2037. var cx = this._squareLeft + this._squareSize * this._s;
  2038. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2039. this._drawCircle(cx, cy, radius * .04, context);
  2040. var dist = radius - wheelThickness * .5;
  2041. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2042. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2043. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2044. context.restore();
  2045. };
  2046. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2047. if (this._pointerStartedOnWheel) {
  2048. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2049. var centerX = radius + this._currentMeasure.left;
  2050. var centerY = radius + this._currentMeasure.top;
  2051. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2052. }
  2053. else if (this._pointerStartedOnSquare) {
  2054. this._updateSquareProps();
  2055. this._s = (x - this._squareLeft) / this._squareSize;
  2056. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2057. this._s = Math.min(this._s, 1);
  2058. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2059. this._v = Math.min(this._v, 1);
  2060. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2061. }
  2062. this._HSVtoRGB(this._h, this._s, this._v, this._tmpColor);
  2063. this.value = this._tmpColor;
  2064. };
  2065. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2066. this._updateSquareProps();
  2067. var left = this._squareLeft;
  2068. var top = this._squareTop;
  2069. var size = this._squareSize;
  2070. if (x >= left && x <= left + size &&
  2071. y >= top && y <= top + size) {
  2072. return true;
  2073. }
  2074. return false;
  2075. };
  2076. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2077. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2078. var centerX = radius + this._currentMeasure.left;
  2079. var centerY = radius + this._currentMeasure.top;
  2080. var wheelThickness = radius * .2;
  2081. var innerRadius = radius - wheelThickness;
  2082. var radiusSq = radius * radius;
  2083. var innerRadiusSq = innerRadius * innerRadius;
  2084. var dx = x - centerX;
  2085. var dy = y - centerY;
  2086. var distSq = dx * dx + dy * dy;
  2087. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2088. return true;
  2089. }
  2090. return false;
  2091. };
  2092. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2093. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2094. return false;
  2095. }
  2096. this._pointerIsDown = true;
  2097. this._pointerStartedOnSquare = false;
  2098. this._pointerStartedOnWheel = false;
  2099. // Invert transform
  2100. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2101. var x = this._transformedPosition.x;
  2102. var y = this._transformedPosition.y;
  2103. if (this._isPointOnSquare(x, y)) {
  2104. this._pointerStartedOnSquare = true;
  2105. }
  2106. else if (this._isPointOnWheel(x, y)) {
  2107. this._pointerStartedOnWheel = true;
  2108. }
  2109. this._updateValueFromPointer(x, y);
  2110. this._host._capturingControl[pointerId] = this;
  2111. return true;
  2112. };
  2113. ColorPicker.prototype._onPointerMove = function (target, coordinates) {
  2114. // Invert transform
  2115. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2116. var x = this._transformedPosition.x;
  2117. var y = this._transformedPosition.y;
  2118. if (this._pointerIsDown) {
  2119. this._updateValueFromPointer(x, y);
  2120. }
  2121. _super.prototype._onPointerMove.call(this, target, coordinates);
  2122. };
  2123. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2124. this._pointerIsDown = false;
  2125. delete this._host._capturingControl[pointerId];
  2126. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2127. };
  2128. /**
  2129. * This function expands the color picker by creating a color picker dialog with manual
  2130. * color value input and the ability to save colors into an array to be used later in
  2131. * subsequent launches of the dialogue.
  2132. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2133. * @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.
  2134. * @returns picked color as a hex string and the saved colors array as hex strings.
  2135. */
  2136. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2137. return new Promise(function (resolve, reject) {
  2138. // Default options
  2139. options.pickerWidth = options.pickerWidth || "640px";
  2140. options.pickerHeight = options.pickerHeight || "400px";
  2141. options.headerHeight = options.headerHeight || "35px";
  2142. options.lastColor = options.lastColor || "#000000";
  2143. options.swatchLimit = options.swatchLimit || 20;
  2144. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2145. // Window size settings
  2146. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2147. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2148. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2149. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2150. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2151. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2152. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2153. // Button Colors
  2154. var buttonColor = "#c0c0c0";
  2155. var buttonBackgroundColor = "#535353";
  2156. var buttonBackgroundHoverColor = "#414141";
  2157. var buttonBackgroundClickColor = "515151";
  2158. var buttonDisabledColor = "#555555";
  2159. var buttonDisabledBackgroundColor = "#454545";
  2160. var currentSwatchesOutlineColor = "#404040";
  2161. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2162. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2163. var iconColorDark = "#aaaaaa";
  2164. var iconColorLight = "#ffffff";
  2165. var closeIconColor;
  2166. // Button settings
  2167. var buttonFontSize;
  2168. var butEdit;
  2169. var buttonWidth;
  2170. var buttonHeight;
  2171. // Input Text Colors
  2172. var inputFieldLabels = ["R", "G", "B"];
  2173. var inputTextBackgroundColor = "#454545";
  2174. var inputTextColor = "#f0f0f0";
  2175. // This is the current color as set by either the picker or by entering a value
  2176. var currentColor;
  2177. // This int is used for naming swatches and serves as the index for calling them from the list
  2178. var swatchNumber;
  2179. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2180. var swatchDrawer;
  2181. var editSwatchMode = false;
  2182. // Color InputText fields that will be updated upon value change
  2183. var picker;
  2184. var rValInt;
  2185. var gValInt;
  2186. var bValInt;
  2187. var rValDec;
  2188. var gValDec;
  2189. var bValDec;
  2190. var hexVal;
  2191. var newSwatch;
  2192. var lastVal;
  2193. var activeField;
  2194. /**
  2195. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2196. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2197. * are will receive no update. This is to prevent the input from the user being overwritten.
  2198. */
  2199. function updateValues(value, inputField) {
  2200. activeField = inputField;
  2201. var pickedColor = value.toHexString();
  2202. newSwatch.background = pickedColor;
  2203. if (rValInt.name != activeField) {
  2204. rValInt.text = Math.floor(value.r * 255).toString();
  2205. }
  2206. if (gValInt.name != activeField) {
  2207. gValInt.text = Math.floor(value.g * 255).toString();
  2208. }
  2209. if (bValInt.name != activeField) {
  2210. bValInt.text = Math.floor(value.b * 255).toString();
  2211. }
  2212. if (rValDec.name != activeField) {
  2213. rValDec.text = value.r.toString();
  2214. }
  2215. if (gValDec.name != activeField) {
  2216. gValDec.text = value.g.toString();
  2217. }
  2218. if (bValDec.name != activeField) {
  2219. bValDec.text = value.b.toString();
  2220. }
  2221. if (hexVal.name != activeField) {
  2222. var minusPound = pickedColor.split("#");
  2223. hexVal.text = minusPound[1];
  2224. }
  2225. if (picker.name != activeField) {
  2226. picker.value = value;
  2227. }
  2228. }
  2229. // 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.
  2230. function updateInt(field, channel) {
  2231. var newValue = field.text;
  2232. var checkVal = /[^0-9]/g.test(newValue);
  2233. if (checkVal) {
  2234. field.text = lastVal;
  2235. return;
  2236. }
  2237. else {
  2238. if (newValue != "") {
  2239. if (Math.floor(parseInt(newValue)) < 0) {
  2240. newValue = "0";
  2241. }
  2242. else if (Math.floor(parseInt(newValue)) > 255) {
  2243. newValue = "255";
  2244. }
  2245. else if (isNaN(parseInt(newValue))) {
  2246. newValue = "0";
  2247. }
  2248. }
  2249. if (activeField == field.name) {
  2250. lastVal = newValue;
  2251. }
  2252. }
  2253. if (newValue != "") {
  2254. newValue = parseInt(newValue).toString();
  2255. field.text = newValue;
  2256. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2257. if (activeField == field.name) {
  2258. if (channel == "r") {
  2259. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2260. }
  2261. else if (channel == "g") {
  2262. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2263. }
  2264. else {
  2265. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2266. }
  2267. }
  2268. }
  2269. }
  2270. // 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.
  2271. function updateFloat(field, channel) {
  2272. var newValue = field.text;
  2273. var checkVal = /[^0-9\.]/g.test(newValue);
  2274. if (checkVal) {
  2275. field.text = lastVal;
  2276. return;
  2277. }
  2278. else {
  2279. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2280. if (parseFloat(newValue) < 0.0) {
  2281. newValue = "0.0";
  2282. }
  2283. else if (parseFloat(newValue) > 1.0) {
  2284. newValue = "1.0";
  2285. }
  2286. else if (isNaN(parseFloat(newValue))) {
  2287. newValue = "0.0";
  2288. }
  2289. }
  2290. if (activeField == field.name) {
  2291. lastVal = newValue;
  2292. }
  2293. }
  2294. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2295. newValue = parseFloat(newValue).toString();
  2296. field.text = newValue;
  2297. }
  2298. else {
  2299. newValue = "0.0";
  2300. }
  2301. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2302. if (activeField == field.name) {
  2303. if (channel == "r") {
  2304. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2305. }
  2306. else if (channel == "g") {
  2307. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2308. }
  2309. else {
  2310. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2311. }
  2312. }
  2313. }
  2314. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2315. function deleteSwatch(index) {
  2316. if (options.savedColors) {
  2317. options.savedColors.splice(index, 1);
  2318. }
  2319. if (options.savedColors && options.savedColors.length == 0) {
  2320. setEditButtonVisibility(false);
  2321. editSwatchMode = false;
  2322. }
  2323. }
  2324. // Creates and styles an individual swatch when updateSwatches is called.
  2325. function createSwatch() {
  2326. if (options.savedColors && options.savedColors[swatchNumber]) {
  2327. if (editSwatchMode) {
  2328. var icon = "b";
  2329. }
  2330. else {
  2331. var icon = "";
  2332. }
  2333. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2334. swatch.fontFamily = "BabylonJSglyphs";
  2335. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2336. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2337. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2338. if (swatchLuminence > luminanceLimit) {
  2339. swatch.color = iconColorDark;
  2340. }
  2341. else {
  2342. swatch.color = iconColorLight;
  2343. }
  2344. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2345. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2346. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2347. swatch.background = options.savedColors[swatchNumber];
  2348. swatch.thickness = 2;
  2349. var metadata_1 = swatchNumber;
  2350. swatch.pointerDownAnimation = function () {
  2351. swatch.thickness = 4;
  2352. };
  2353. swatch.pointerUpAnimation = function () {
  2354. swatch.thickness = 3;
  2355. };
  2356. swatch.pointerEnterAnimation = function () {
  2357. swatch.thickness = 3;
  2358. };
  2359. swatch.pointerOutAnimation = function () {
  2360. swatch.thickness = 2;
  2361. };
  2362. swatch.onPointerClickObservable.add(function () {
  2363. if (!editSwatchMode) {
  2364. if (options.savedColors) {
  2365. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2366. }
  2367. }
  2368. else {
  2369. deleteSwatch(metadata_1);
  2370. updateSwatches("", butSave);
  2371. }
  2372. });
  2373. return swatch;
  2374. }
  2375. else {
  2376. return null;
  2377. }
  2378. }
  2379. // Mode switch to render button text and close symbols on swatch controls
  2380. function editSwatches(mode) {
  2381. if (mode !== undefined) {
  2382. editSwatchMode = mode;
  2383. }
  2384. if (editSwatchMode) {
  2385. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2386. var thisButton = swatchDrawer.children[i];
  2387. thisButton.textBlock.text = "b";
  2388. }
  2389. if (butEdit !== undefined) {
  2390. butEdit.textBlock.text = "Done";
  2391. }
  2392. }
  2393. else {
  2394. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2395. var thisButton = swatchDrawer.children[i];
  2396. thisButton.textBlock.text = "";
  2397. }
  2398. if (butEdit !== undefined) {
  2399. butEdit.textBlock.text = "Edit";
  2400. }
  2401. }
  2402. }
  2403. /**
  2404. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2405. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2406. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2407. * saved colors there are and how many can be stored per row.
  2408. */
  2409. function updateSwatches(color, button) {
  2410. if (options.savedColors) {
  2411. if (color != "") {
  2412. options.savedColors.push(color);
  2413. }
  2414. swatchNumber = 0;
  2415. swatchDrawer.clearControls();
  2416. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2417. if (rowCount == 0) {
  2418. var gutterCount = 0;
  2419. }
  2420. else {
  2421. var gutterCount = rowCount + 1;
  2422. }
  2423. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2424. var currentRows = swatchDrawer.rowCount;
  2425. for (var i = 0; i < currentRows; i++) {
  2426. swatchDrawer.removeRowDefinition(0);
  2427. }
  2428. for (var i = 0; i < rowCount + gutterCount; i++) {
  2429. if (i % 2) {
  2430. swatchDrawer.addRowDefinition(swatchSize, true);
  2431. }
  2432. else {
  2433. swatchDrawer.addRowDefinition(gutterSize, true);
  2434. }
  2435. }
  2436. }
  2437. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2438. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2439. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2440. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2441. var totalButtonsThisRow = options.numSwatchesPerLine;
  2442. }
  2443. else {
  2444. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2445. }
  2446. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2447. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2448. if (x > options.numSwatchesPerLine) {
  2449. continue;
  2450. }
  2451. var swatch = createSwatch();
  2452. if (swatch != null) {
  2453. swatchDrawer.addControl(swatch, y, w);
  2454. w += 2;
  2455. swatchNumber++;
  2456. }
  2457. else {
  2458. continue;
  2459. }
  2460. }
  2461. }
  2462. if (options.savedColors.length >= options.swatchLimit) {
  2463. disableButton(button, true);
  2464. }
  2465. else {
  2466. disableButton(button, false);
  2467. }
  2468. }
  2469. }
  2470. // Shows or hides edit swatches button depending on if there are saved swatches
  2471. function setEditButtonVisibility(enableButton) {
  2472. if (enableButton) {
  2473. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2474. butEdit.width = buttonWidth;
  2475. butEdit.height = buttonHeight;
  2476. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2477. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2478. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2479. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2480. butEdit.thickness = 2;
  2481. butEdit.color = buttonColor;
  2482. butEdit.fontSize = buttonFontSize;
  2483. butEdit.background = buttonBackgroundColor;
  2484. butEdit.onPointerEnterObservable.add(function () {
  2485. butEdit.background = buttonBackgroundHoverColor;
  2486. });
  2487. butEdit.onPointerOutObservable.add(function () {
  2488. butEdit.background = buttonBackgroundColor;
  2489. });
  2490. butEdit.pointerDownAnimation = function () {
  2491. butEdit.background = buttonBackgroundClickColor;
  2492. };
  2493. butEdit.pointerUpAnimation = function () {
  2494. butEdit.background = buttonBackgroundHoverColor;
  2495. };
  2496. butEdit.onPointerClickObservable.add(function () {
  2497. if (editSwatchMode) {
  2498. editSwatchMode = false;
  2499. }
  2500. else {
  2501. editSwatchMode = true;
  2502. }
  2503. editSwatches();
  2504. });
  2505. pickerGrid.addControl(butEdit, 1, 0);
  2506. }
  2507. else {
  2508. pickerGrid.removeControl(butEdit);
  2509. }
  2510. }
  2511. // Called when the user hits the limit of saved colors in the drawer.
  2512. function disableButton(button, disabled) {
  2513. if (disabled) {
  2514. button.color = buttonDisabledColor;
  2515. button.background = buttonDisabledBackgroundColor;
  2516. }
  2517. else {
  2518. button.color = buttonColor;
  2519. button.background = buttonBackgroundColor;
  2520. }
  2521. }
  2522. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2523. function closePicker(color) {
  2524. if (options.savedColors && options.savedColors.length > 0) {
  2525. resolve({
  2526. savedColors: options.savedColors,
  2527. pickedColor: color
  2528. });
  2529. }
  2530. else {
  2531. resolve({
  2532. pickedColor: color
  2533. });
  2534. }
  2535. advancedTexture.removeControl(dialogContainer);
  2536. }
  2537. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2538. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2539. dialogContainer.name = "Dialog Container";
  2540. dialogContainer.width = options.pickerWidth;
  2541. if (options.savedColors) {
  2542. dialogContainer.height = containerSize;
  2543. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2544. dialogContainer.addRowDefinition(topRow, false);
  2545. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2546. }
  2547. else {
  2548. dialogContainer.height = options.pickerHeight;
  2549. dialogContainer.addRowDefinition(1.0, false);
  2550. }
  2551. advancedTexture.addControl(dialogContainer);
  2552. // Swatch drawer which contains all saved color buttons
  2553. if (options.savedColors) {
  2554. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2555. swatchDrawer.name = "Swatch Drawer";
  2556. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2557. swatchDrawer.background = buttonBackgroundColor;
  2558. swatchDrawer.width = options.pickerWidth;
  2559. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2560. if (initialRows == 0) {
  2561. var gutterCount = 0;
  2562. }
  2563. else {
  2564. var gutterCount = initialRows + 1;
  2565. }
  2566. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2567. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2568. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2569. if (i % 2 != 0) {
  2570. swatchDrawer.addRowDefinition(swatchSize, true);
  2571. }
  2572. else {
  2573. swatchDrawer.addRowDefinition(gutterSize, true);
  2574. }
  2575. }
  2576. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2577. if (i % 2 != 0) {
  2578. swatchDrawer.addColumnDefinition(swatchSize, true);
  2579. }
  2580. else {
  2581. swatchDrawer.addColumnDefinition(gutterSize, true);
  2582. }
  2583. }
  2584. dialogContainer.addControl(swatchDrawer, 1, 0);
  2585. }
  2586. // Picker container
  2587. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2588. pickerPanel.name = "Picker Panel";
  2589. pickerPanel.height = options.pickerHeight;
  2590. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2591. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2592. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2593. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2594. dialogContainer.addControl(pickerPanel, 0, 0);
  2595. // Picker container header
  2596. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2597. header.name = "Dialogue Header Bar";
  2598. header.background = "#cccccc";
  2599. header.thickness = 0;
  2600. pickerPanel.addControl(header, 0, 0);
  2601. // Header close button
  2602. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2603. closeButton.fontFamily = "BabylonJSglyphs";
  2604. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2605. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2606. closeButton.color = closeIconColor.toHexString();
  2607. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2608. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2609. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2610. closeButton.height = closeButton.width = options.headerHeight;
  2611. closeButton.background = header.background;
  2612. closeButton.thickness = 0;
  2613. closeButton.pointerDownAnimation = function () {
  2614. };
  2615. closeButton.pointerUpAnimation = function () {
  2616. closeButton.background = header.background;
  2617. };
  2618. closeButton.pointerEnterAnimation = function () {
  2619. closeButton.color = header.background;
  2620. closeButton.background = "red";
  2621. };
  2622. closeButton.pointerOutAnimation = function () {
  2623. closeButton.color = closeIconColor.toHexString();
  2624. closeButton.background = header.background;
  2625. };
  2626. closeButton.onPointerClickObservable.add(function () {
  2627. closePicker(currentSwatch.background);
  2628. });
  2629. pickerPanel.addControl(closeButton, 0, 0);
  2630. // Dialog container body
  2631. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2632. dialogBody.name = "Dialogue Body";
  2633. dialogBody.background = buttonBackgroundColor;
  2634. var dialogBodyCols = [0.4375, 0.5625];
  2635. dialogBody.addRowDefinition(1.0, false);
  2636. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2637. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2638. pickerPanel.addControl(dialogBody, 1, 0);
  2639. // Picker grid
  2640. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2641. pickerGrid.name = "Picker Grid";
  2642. pickerGrid.addRowDefinition(0.85, false);
  2643. pickerGrid.addRowDefinition(0.15, false);
  2644. dialogBody.addControl(pickerGrid, 0, 0);
  2645. // Picker control
  2646. picker = new ColorPicker();
  2647. picker.name = "GUI Color Picker";
  2648. if (options.pickerHeight < options.pickerWidth) {
  2649. picker.width = 0.89;
  2650. }
  2651. else {
  2652. picker.height = 0.89;
  2653. }
  2654. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2655. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2656. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2657. picker.onPointerDownObservable.add(function () {
  2658. activeField = picker.name;
  2659. lastVal = "";
  2660. editSwatches(false);
  2661. });
  2662. picker.onValueChangedObservable.add(function (value) {
  2663. if (activeField == picker.name) {
  2664. updateValues(value, picker.name);
  2665. }
  2666. });
  2667. pickerGrid.addControl(picker, 0, 0);
  2668. // Picker body right quarant
  2669. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2670. pickerBodyRight.name = "Dialogue Right Half";
  2671. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2672. var pickerBodyRightRows = [0.514, 0.486];
  2673. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2674. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2675. dialogBody.addControl(pickerBodyRight, 1, 1);
  2676. // Picker container swatches and buttons
  2677. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2678. pickerSwatchesButtons.name = "Swatches and Buttons";
  2679. var pickerButtonsCol = [0.417, 0.583];
  2680. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2681. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2682. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2683. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2684. // Picker Swatches quadrant
  2685. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2686. pickerSwatches.name = "New and Current Swatches";
  2687. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2688. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2689. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2690. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2691. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2692. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2693. // Active swatches
  2694. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2695. activeSwatches.name = "Active Swatches";
  2696. activeSwatches.width = 0.67;
  2697. activeSwatches.addRowDefinition(0.5, false);
  2698. activeSwatches.addRowDefinition(0.5, false);
  2699. pickerSwatches.addControl(activeSwatches, 2, 0);
  2700. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2701. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2702. if (options.pickerWidth > options.pickerHeight) {
  2703. var labelTextSize = labelHeight;
  2704. }
  2705. else {
  2706. var labelTextSize = labelWidth;
  2707. }
  2708. // New color swatch and previous color button
  2709. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2710. newText.text = "new";
  2711. newText.name = "New Color Label";
  2712. newText.color = buttonColor;
  2713. newText.fontSize = labelTextSize;
  2714. pickerSwatches.addControl(newText, 1, 0);
  2715. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2716. newSwatch.name = "New Color Swatch";
  2717. newSwatch.background = options.lastColor;
  2718. newSwatch.thickness = 0;
  2719. activeSwatches.addControl(newSwatch, 0, 0);
  2720. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2721. currentSwatch.background = options.lastColor;
  2722. currentSwatch.thickness = 0;
  2723. currentSwatch.onPointerClickObservable.add(function () {
  2724. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2725. updateValues(revertColor, currentSwatch.name);
  2726. editSwatches(false);
  2727. });
  2728. currentSwatch.pointerDownAnimation = function () { };
  2729. currentSwatch.pointerUpAnimation = function () { };
  2730. currentSwatch.pointerEnterAnimation = function () { };
  2731. currentSwatch.pointerOutAnimation = function () { };
  2732. activeSwatches.addControl(currentSwatch, 1, 0);
  2733. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2734. swatchOutline.name = "Swatch Outline";
  2735. swatchOutline.width = 0.67;
  2736. swatchOutline.thickness = 2;
  2737. swatchOutline.color = currentSwatchesOutlineColor;
  2738. swatchOutline.isHitTestVisible = false;
  2739. pickerSwatches.addControl(swatchOutline, 2, 0);
  2740. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2741. currentText.name = "Current Color Label";
  2742. currentText.text = "current";
  2743. currentText.color = buttonColor;
  2744. currentText.fontSize = labelTextSize;
  2745. pickerSwatches.addControl(currentText, 3, 0);
  2746. // Buttons grid
  2747. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2748. buttonGrid.name = "Button Grid";
  2749. buttonGrid.height = 0.8;
  2750. var buttonGridRows = 1 / 3;
  2751. buttonGrid.addRowDefinition(buttonGridRows, false);
  2752. buttonGrid.addRowDefinition(buttonGridRows, false);
  2753. buttonGrid.addRowDefinition(buttonGridRows, false);
  2754. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2755. // Determine pixel width and height for all buttons from overall panel dimensions
  2756. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2757. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2758. // Determine button type size
  2759. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2760. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2761. }
  2762. else {
  2763. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2764. }
  2765. // Panel Buttons
  2766. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2767. butOK.width = buttonWidth;
  2768. butOK.height = buttonHeight;
  2769. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2770. butOK.thickness = 2;
  2771. butOK.color = buttonColor;
  2772. butOK.fontSize = buttonFontSize;
  2773. butOK.background = buttonBackgroundColor;
  2774. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2775. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2776. butOK.pointerDownAnimation = function () {
  2777. butOK.background = buttonBackgroundClickColor;
  2778. };
  2779. butOK.pointerUpAnimation = function () {
  2780. butOK.background = buttonBackgroundHoverColor;
  2781. };
  2782. butOK.onPointerClickObservable.add(function () {
  2783. editSwatches(false);
  2784. closePicker(newSwatch.background);
  2785. });
  2786. buttonGrid.addControl(butOK, 0, 0);
  2787. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2788. butCancel.width = buttonWidth;
  2789. butCancel.height = buttonHeight;
  2790. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2791. butCancel.thickness = 2;
  2792. butCancel.color = buttonColor;
  2793. butCancel.fontSize = buttonFontSize;
  2794. butCancel.background = buttonBackgroundColor;
  2795. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2796. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2797. butCancel.pointerDownAnimation = function () {
  2798. butCancel.background = buttonBackgroundClickColor;
  2799. };
  2800. butCancel.pointerUpAnimation = function () {
  2801. butCancel.background = buttonBackgroundHoverColor;
  2802. };
  2803. butCancel.onPointerClickObservable.add(function () {
  2804. editSwatches(false);
  2805. closePicker(currentSwatch.background);
  2806. });
  2807. buttonGrid.addControl(butCancel, 1, 0);
  2808. if (options.savedColors) {
  2809. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2810. butSave.width = buttonWidth;
  2811. butSave.height = buttonHeight;
  2812. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2813. butSave.thickness = 2;
  2814. butSave.fontSize = buttonFontSize;
  2815. if (options.savedColors.length < options.swatchLimit) {
  2816. butSave.color = buttonColor;
  2817. butSave.background = buttonBackgroundColor;
  2818. }
  2819. else {
  2820. disableButton(butSave, true);
  2821. }
  2822. butSave.onPointerEnterObservable.add(function () {
  2823. if (options.savedColors) {
  2824. if (options.savedColors.length < options.swatchLimit) {
  2825. butSave.background = buttonBackgroundHoverColor;
  2826. }
  2827. }
  2828. });
  2829. butSave.onPointerOutObservable.add(function () {
  2830. if (options.savedColors) {
  2831. if (options.savedColors.length < options.swatchLimit) {
  2832. butSave.background = buttonBackgroundColor;
  2833. }
  2834. }
  2835. });
  2836. butSave.pointerDownAnimation = function () {
  2837. if (options.savedColors) {
  2838. if (options.savedColors.length < options.swatchLimit) {
  2839. butSave.background = buttonBackgroundClickColor;
  2840. }
  2841. }
  2842. };
  2843. butSave.pointerUpAnimation = function () {
  2844. if (options.savedColors) {
  2845. if (options.savedColors.length < options.swatchLimit) {
  2846. butSave.background = buttonBackgroundHoverColor;
  2847. }
  2848. }
  2849. };
  2850. butSave.onPointerClickObservable.add(function () {
  2851. if (options.savedColors) {
  2852. if (options.savedColors.length == 0) {
  2853. setEditButtonVisibility(true);
  2854. }
  2855. if (options.savedColors.length < options.swatchLimit) {
  2856. updateSwatches(newSwatch.background, butSave);
  2857. }
  2858. editSwatches(false);
  2859. }
  2860. });
  2861. if (options.savedColors.length > 0) {
  2862. setEditButtonVisibility(true);
  2863. }
  2864. buttonGrid.addControl(butSave, 2, 0);
  2865. }
  2866. // Picker color values input
  2867. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2868. pickerColorValues.name = "Dialog Lower Right";
  2869. pickerColorValues.addRowDefinition(0.02, false);
  2870. pickerColorValues.addRowDefinition(0.63, false);
  2871. pickerColorValues.addRowDefinition(0.21, false);
  2872. pickerColorValues.addRowDefinition(0.14, false);
  2873. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2874. // RGB values text boxes
  2875. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2876. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2877. rgbValuesQuadrant.name = "RGB Values";
  2878. rgbValuesQuadrant.width = 0.82;
  2879. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2880. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2881. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2882. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2883. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2884. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2885. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2886. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2887. for (var i = 0; i < inputFieldLabels.length; i++) {
  2888. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2889. labelText.text = inputFieldLabels[i];
  2890. labelText.color = buttonColor;
  2891. labelText.fontSize = buttonFontSize;
  2892. rgbValuesQuadrant.addControl(labelText, i, 0);
  2893. }
  2894. // Input fields for RGB values
  2895. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2896. rValInt.width = 0.83;
  2897. rValInt.height = 0.72;
  2898. rValInt.name = "rIntField";
  2899. rValInt.fontSize = buttonFontSize;
  2900. rValInt.text = (currentColor.r * 255).toString();
  2901. rValInt.color = inputTextColor;
  2902. rValInt.background = inputTextBackgroundColor;
  2903. rValInt.onFocusObservable.add(function () {
  2904. activeField = rValInt.name;
  2905. lastVal = rValInt.text;
  2906. editSwatches(false);
  2907. });
  2908. rValInt.onBlurObservable.add(function () {
  2909. if (rValInt.text == "") {
  2910. rValInt.text = "0";
  2911. }
  2912. updateInt(rValInt, "r");
  2913. if (activeField == rValInt.name) {
  2914. activeField = "";
  2915. }
  2916. });
  2917. rValInt.onTextChangedObservable.add(function () {
  2918. if (activeField == rValInt.name) {
  2919. updateInt(rValInt, "r");
  2920. }
  2921. });
  2922. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2923. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2924. gValInt.width = 0.83;
  2925. gValInt.height = 0.72;
  2926. gValInt.name = "gIntField";
  2927. gValInt.fontSize = buttonFontSize;
  2928. gValInt.text = (currentColor.g * 255).toString();
  2929. gValInt.color = inputTextColor;
  2930. gValInt.background = inputTextBackgroundColor;
  2931. gValInt.onFocusObservable.add(function () {
  2932. activeField = gValInt.name;
  2933. lastVal = gValInt.text;
  2934. editSwatches(false);
  2935. });
  2936. gValInt.onBlurObservable.add(function () {
  2937. if (gValInt.text == "") {
  2938. gValInt.text = "0";
  2939. }
  2940. updateInt(gValInt, "g");
  2941. if (activeField == gValInt.name) {
  2942. activeField = "";
  2943. }
  2944. });
  2945. gValInt.onTextChangedObservable.add(function () {
  2946. if (activeField == gValInt.name) {
  2947. updateInt(gValInt, "g");
  2948. }
  2949. });
  2950. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2951. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2952. bValInt.width = 0.83;
  2953. bValInt.height = 0.72;
  2954. bValInt.name = "bIntField";
  2955. bValInt.fontSize = buttonFontSize;
  2956. bValInt.text = (currentColor.b * 255).toString();
  2957. bValInt.color = inputTextColor;
  2958. bValInt.background = inputTextBackgroundColor;
  2959. bValInt.onFocusObservable.add(function () {
  2960. activeField = bValInt.name;
  2961. lastVal = bValInt.text;
  2962. editSwatches(false);
  2963. });
  2964. bValInt.onBlurObservable.add(function () {
  2965. if (bValInt.text == "") {
  2966. bValInt.text = "0";
  2967. }
  2968. updateInt(bValInt, "b");
  2969. if (activeField == bValInt.name) {
  2970. activeField = "";
  2971. }
  2972. });
  2973. bValInt.onTextChangedObservable.add(function () {
  2974. if (activeField == bValInt.name) {
  2975. updateInt(bValInt, "b");
  2976. }
  2977. });
  2978. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2979. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2980. rValDec.width = 0.95;
  2981. rValDec.height = 0.72;
  2982. rValDec.name = "rDecField";
  2983. rValDec.fontSize = buttonFontSize;
  2984. rValDec.text = currentColor.r.toString();
  2985. rValDec.color = inputTextColor;
  2986. rValDec.background = inputTextBackgroundColor;
  2987. rValDec.onFocusObservable.add(function () {
  2988. activeField = rValDec.name;
  2989. lastVal = rValDec.text;
  2990. editSwatches(false);
  2991. });
  2992. rValDec.onBlurObservable.add(function () {
  2993. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2994. rValDec.text = "0";
  2995. updateFloat(rValDec, "r");
  2996. }
  2997. if (activeField == rValDec.name) {
  2998. activeField = "";
  2999. }
  3000. });
  3001. rValDec.onTextChangedObservable.add(function () {
  3002. if (activeField == rValDec.name) {
  3003. updateFloat(rValDec, "r");
  3004. }
  3005. });
  3006. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3007. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3008. gValDec.width = 0.95;
  3009. gValDec.height = 0.72;
  3010. gValDec.name = "gDecField";
  3011. gValDec.fontSize = buttonFontSize;
  3012. gValDec.text = currentColor.g.toString();
  3013. gValDec.color = inputTextColor;
  3014. gValDec.background = inputTextBackgroundColor;
  3015. gValDec.onFocusObservable.add(function () {
  3016. activeField = gValDec.name;
  3017. lastVal = gValDec.text;
  3018. editSwatches(false);
  3019. });
  3020. gValDec.onBlurObservable.add(function () {
  3021. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3022. gValDec.text = "0";
  3023. updateFloat(gValDec, "g");
  3024. }
  3025. if (activeField == gValDec.name) {
  3026. activeField = "";
  3027. }
  3028. });
  3029. gValDec.onTextChangedObservable.add(function () {
  3030. if (activeField == gValDec.name) {
  3031. updateFloat(gValDec, "g");
  3032. }
  3033. });
  3034. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3035. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3036. bValDec.width = 0.95;
  3037. bValDec.height = 0.72;
  3038. bValDec.name = "bDecField";
  3039. bValDec.fontSize = buttonFontSize;
  3040. bValDec.text = currentColor.b.toString();
  3041. bValDec.color = inputTextColor;
  3042. bValDec.background = inputTextBackgroundColor;
  3043. bValDec.onFocusObservable.add(function () {
  3044. activeField = bValDec.name;
  3045. lastVal = bValDec.text;
  3046. editSwatches(false);
  3047. });
  3048. bValDec.onBlurObservable.add(function () {
  3049. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3050. bValDec.text = "0";
  3051. updateFloat(bValDec, "b");
  3052. }
  3053. if (activeField == bValDec.name) {
  3054. activeField = "";
  3055. }
  3056. });
  3057. bValDec.onTextChangedObservable.add(function () {
  3058. if (activeField == bValDec.name) {
  3059. updateFloat(bValDec, "b");
  3060. }
  3061. });
  3062. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3063. // Hex value input
  3064. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3065. hexValueQuadrant.name = "Hex Value";
  3066. hexValueQuadrant.width = 0.82;
  3067. hexValueQuadrant.addRowDefinition(1.0, false);
  3068. hexValueQuadrant.addColumnDefinition(0.1, false);
  3069. hexValueQuadrant.addColumnDefinition(0.9, false);
  3070. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3071. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3072. labelText.text = "#";
  3073. labelText.color = buttonColor;
  3074. labelText.fontSize = buttonFontSize;
  3075. hexValueQuadrant.addControl(labelText, 0, 0);
  3076. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3077. hexVal.width = 0.96;
  3078. hexVal.height = 0.72;
  3079. hexVal.name = "hexField";
  3080. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3081. hexVal.fontSize = buttonFontSize;
  3082. var minusPound = options.lastColor.split("#");
  3083. hexVal.text = minusPound[1];
  3084. hexVal.color = inputTextColor;
  3085. hexVal.background = inputTextBackgroundColor;
  3086. hexVal.onFocusObservable.add(function () {
  3087. activeField = hexVal.name;
  3088. lastVal = hexVal.text;
  3089. editSwatches(false);
  3090. });
  3091. hexVal.onBlurObservable.add(function () {
  3092. if (hexVal.text.length == 3) {
  3093. var val = hexVal.text.split("");
  3094. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3095. }
  3096. if (hexVal.text == "") {
  3097. hexVal.text = "000000";
  3098. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3099. }
  3100. if (activeField == hexVal.name) {
  3101. activeField = "";
  3102. }
  3103. });
  3104. hexVal.onTextChangedObservable.add(function () {
  3105. var newHexValue = hexVal.text;
  3106. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3107. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3108. hexVal.text = lastVal;
  3109. }
  3110. else {
  3111. if (hexVal.text.length < 6) {
  3112. var leadingZero = 6 - hexVal.text.length;
  3113. for (var i = 0; i < leadingZero; i++) {
  3114. newHexValue = "0" + newHexValue;
  3115. }
  3116. }
  3117. if (hexVal.text.length == 3) {
  3118. var val = hexVal.text.split("");
  3119. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3120. }
  3121. newHexValue = "#" + newHexValue;
  3122. if (activeField == hexVal.name) {
  3123. lastVal = hexVal.text;
  3124. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3125. }
  3126. }
  3127. });
  3128. hexValueQuadrant.addControl(hexVal, 0, 1);
  3129. if (options.savedColors && options.savedColors.length > 0) {
  3130. updateSwatches("", butSave);
  3131. }
  3132. });
  3133. };
  3134. ColorPicker._Epsilon = 0.000001;
  3135. return ColorPicker;
  3136. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3137. /***/ }),
  3138. /***/ "./2D/controls/container.ts":
  3139. /*!**********************************!*\
  3140. !*** ./2D/controls/container.ts ***!
  3141. \**********************************/
  3142. /*! exports provided: Container */
  3143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3144. "use strict";
  3145. __webpack_require__.r(__webpack_exports__);
  3146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3147. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3148. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3149. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3150. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3151. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3152. /**
  3153. * Root class for 2D containers
  3154. * @see http://doc.babylonjs.com/how_to/gui#containers
  3155. */
  3156. var Container = /** @class */ (function (_super) {
  3157. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3158. /**
  3159. * Creates a new Container
  3160. * @param name defines the name of the container
  3161. */
  3162. function Container(name) {
  3163. var _this = _super.call(this, name) || this;
  3164. _this.name = name;
  3165. /** @hidden */
  3166. _this._children = new Array();
  3167. /** @hidden */
  3168. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3169. /** @hidden */
  3170. _this._background = "";
  3171. /** @hidden */
  3172. _this._adaptWidthToChildren = false;
  3173. /** @hidden */
  3174. _this._adaptHeightToChildren = false;
  3175. return _this;
  3176. }
  3177. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3178. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3179. get: function () {
  3180. return this._adaptHeightToChildren;
  3181. },
  3182. set: function (value) {
  3183. if (this._adaptHeightToChildren === value) {
  3184. return;
  3185. }
  3186. this._adaptHeightToChildren = value;
  3187. if (value) {
  3188. this.height = "100%";
  3189. }
  3190. this._markAsDirty();
  3191. },
  3192. enumerable: true,
  3193. configurable: true
  3194. });
  3195. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3196. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3197. get: function () {
  3198. return this._adaptWidthToChildren;
  3199. },
  3200. set: function (value) {
  3201. if (this._adaptWidthToChildren === value) {
  3202. return;
  3203. }
  3204. this._adaptWidthToChildren = value;
  3205. if (value) {
  3206. this.width = "100%";
  3207. }
  3208. this._markAsDirty();
  3209. },
  3210. enumerable: true,
  3211. configurable: true
  3212. });
  3213. Object.defineProperty(Container.prototype, "background", {
  3214. /** Gets or sets background color */
  3215. get: function () {
  3216. return this._background;
  3217. },
  3218. set: function (value) {
  3219. if (this._background === value) {
  3220. return;
  3221. }
  3222. this._background = value;
  3223. this._markAsDirty();
  3224. },
  3225. enumerable: true,
  3226. configurable: true
  3227. });
  3228. Object.defineProperty(Container.prototype, "children", {
  3229. /** Gets the list of children */
  3230. get: function () {
  3231. return this._children;
  3232. },
  3233. enumerable: true,
  3234. configurable: true
  3235. });
  3236. Container.prototype._getTypeName = function () {
  3237. return "Container";
  3238. };
  3239. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3240. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3241. var child = _a[_i];
  3242. child._markMatrixAsDirty();
  3243. }
  3244. };
  3245. /**
  3246. * Gets a child using its name
  3247. * @param name defines the child name to look for
  3248. * @returns the child control if found
  3249. */
  3250. Container.prototype.getChildByName = function (name) {
  3251. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3252. var child = _a[_i];
  3253. if (child.name === name) {
  3254. return child;
  3255. }
  3256. }
  3257. return null;
  3258. };
  3259. /**
  3260. * Gets a child using its type and its name
  3261. * @param name defines the child name to look for
  3262. * @param type defines the child type to look for
  3263. * @returns the child control if found
  3264. */
  3265. Container.prototype.getChildByType = function (name, type) {
  3266. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3267. var child = _a[_i];
  3268. if (child.typeName === type) {
  3269. return child;
  3270. }
  3271. }
  3272. return null;
  3273. };
  3274. /**
  3275. * Search for a specific control in children
  3276. * @param control defines the control to look for
  3277. * @returns true if the control is in child list
  3278. */
  3279. Container.prototype.containsControl = function (control) {
  3280. return this.children.indexOf(control) !== -1;
  3281. };
  3282. /**
  3283. * Adds a new control to the current container
  3284. * @param control defines the control to add
  3285. * @returns the current container
  3286. */
  3287. Container.prototype.addControl = function (control) {
  3288. if (!control) {
  3289. return this;
  3290. }
  3291. var index = this._children.indexOf(control);
  3292. if (index !== -1) {
  3293. return this;
  3294. }
  3295. control._link(this._host);
  3296. control._markAllAsDirty();
  3297. this._reOrderControl(control);
  3298. this._markAsDirty();
  3299. return this;
  3300. };
  3301. /**
  3302. * Removes all controls from the current container
  3303. * @returns the current container
  3304. */
  3305. Container.prototype.clearControls = function () {
  3306. var children = this.children.slice();
  3307. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3308. var child = children_1[_i];
  3309. this.removeControl(child);
  3310. }
  3311. return this;
  3312. };
  3313. /**
  3314. * Removes a control from the current container
  3315. * @param control defines the control to remove
  3316. * @returns the current container
  3317. */
  3318. Container.prototype.removeControl = function (control) {
  3319. var index = this._children.indexOf(control);
  3320. if (index !== -1) {
  3321. this._children.splice(index, 1);
  3322. control.parent = null;
  3323. }
  3324. control.linkWithMesh(null);
  3325. if (this._host) {
  3326. this._host._cleanControlAfterRemoval(control);
  3327. }
  3328. this._markAsDirty();
  3329. return this;
  3330. };
  3331. /** @hidden */
  3332. Container.prototype._reOrderControl = function (control) {
  3333. this.removeControl(control);
  3334. var wasAdded = false;
  3335. for (var index = 0; index < this._children.length; index++) {
  3336. if (this._children[index].zIndex > control.zIndex) {
  3337. this._children.splice(index, 0, control);
  3338. wasAdded = true;
  3339. break;
  3340. }
  3341. }
  3342. if (!wasAdded) {
  3343. this._children.push(control);
  3344. }
  3345. control.parent = this;
  3346. this._markAsDirty();
  3347. };
  3348. /** @hidden */
  3349. Container.prototype._offsetLeft = function (offset) {
  3350. _super.prototype._offsetLeft.call(this, offset);
  3351. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3352. var child = _a[_i];
  3353. child._offsetLeft(offset);
  3354. }
  3355. };
  3356. /** @hidden */
  3357. Container.prototype._offsetTop = function (offset) {
  3358. _super.prototype._offsetTop.call(this, offset);
  3359. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3360. var child = _a[_i];
  3361. child._offsetTop(offset);
  3362. }
  3363. };
  3364. /** @hidden */
  3365. Container.prototype._markAllAsDirty = function () {
  3366. _super.prototype._markAllAsDirty.call(this);
  3367. for (var index = 0; index < this._children.length; index++) {
  3368. this._children[index]._markAllAsDirty();
  3369. }
  3370. };
  3371. /** @hidden */
  3372. Container.prototype._localDraw = function (context) {
  3373. if (this._background) {
  3374. context.save();
  3375. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3376. context.shadowColor = this.shadowColor;
  3377. context.shadowBlur = this.shadowBlur;
  3378. context.shadowOffsetX = this.shadowOffsetX;
  3379. context.shadowOffsetY = this.shadowOffsetY;
  3380. }
  3381. context.fillStyle = this._background;
  3382. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3383. context.restore();
  3384. }
  3385. };
  3386. /** @hidden */
  3387. Container.prototype._link = function (host) {
  3388. _super.prototype._link.call(this, host);
  3389. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3390. var child = _a[_i];
  3391. child._link(host);
  3392. }
  3393. };
  3394. /** @hidden */
  3395. Container.prototype._beforeLayout = function () {
  3396. // Do nothing
  3397. };
  3398. /** @hidden */
  3399. Container.prototype._processMeasures = function (parentMeasure, context) {
  3400. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3401. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3402. this._evaluateClippingState(parentMeasure);
  3403. }
  3404. };
  3405. /** @hidden */
  3406. Container.prototype._layout = function (parentMeasure, context) {
  3407. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3408. return false;
  3409. }
  3410. if (this._isDirty) {
  3411. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3412. }
  3413. var rebuildCount = 0;
  3414. context.save();
  3415. this._applyStates(context);
  3416. this._beforeLayout();
  3417. do {
  3418. var computedWidth = -1;
  3419. var computedHeight = -1;
  3420. this._rebuildLayout = false;
  3421. this._processMeasures(parentMeasure, context);
  3422. if (!this._isClipped) {
  3423. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3424. var child = _a[_i];
  3425. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3426. if (child._layout(this._measureForChildren, context)) {
  3427. if (this.adaptWidthToChildren && child._width.isPixel) {
  3428. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3429. }
  3430. if (this.adaptHeightToChildren && child._height.isPixel) {
  3431. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3432. }
  3433. }
  3434. }
  3435. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3436. if (this.width !== computedWidth + "px") {
  3437. this.width = computedWidth + "px";
  3438. this._rebuildLayout = true;
  3439. }
  3440. }
  3441. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3442. if (this.height !== computedHeight + "px") {
  3443. this.height = computedHeight + "px";
  3444. this._rebuildLayout = true;
  3445. }
  3446. }
  3447. this._postMeasure();
  3448. }
  3449. rebuildCount++;
  3450. } while (this._rebuildLayout && rebuildCount < 3);
  3451. if (rebuildCount >= 3) {
  3452. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3453. }
  3454. context.restore();
  3455. if (this._isDirty) {
  3456. this.invalidateRect();
  3457. this._isDirty = false;
  3458. }
  3459. return true;
  3460. };
  3461. Container.prototype._postMeasure = function () {
  3462. // Do nothing by default
  3463. };
  3464. /** @hidden */
  3465. Container.prototype._draw = function (context, invalidatedRectangle) {
  3466. this._localDraw(context);
  3467. if (this.clipChildren) {
  3468. this._clipForChildren(context);
  3469. }
  3470. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3471. var child = _a[_i];
  3472. // Only redraw parts of the screen that are invalidated
  3473. if (invalidatedRectangle) {
  3474. if (!child._intersectsRect(invalidatedRectangle)) {
  3475. continue;
  3476. }
  3477. }
  3478. child._render(context, invalidatedRectangle);
  3479. }
  3480. };
  3481. /** @hidden */
  3482. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3483. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3484. if (!this.children) {
  3485. return;
  3486. }
  3487. for (var index = 0; index < this.children.length; index++) {
  3488. var item = this.children[index];
  3489. if (!predicate || predicate(item)) {
  3490. results.push(item);
  3491. }
  3492. if (!directDescendantsOnly) {
  3493. item._getDescendants(results, false, predicate);
  3494. }
  3495. }
  3496. };
  3497. /** @hidden */
  3498. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3499. if (!this.isVisible || this.notRenderable) {
  3500. return false;
  3501. }
  3502. if (!_super.prototype.contains.call(this, x, y)) {
  3503. return false;
  3504. }
  3505. // Checking backwards to pick closest first
  3506. for (var index = this._children.length - 1; index >= 0; index--) {
  3507. var child = this._children[index];
  3508. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3509. if (child.hoverCursor) {
  3510. this._host._changeCursor(child.hoverCursor);
  3511. }
  3512. return true;
  3513. }
  3514. }
  3515. if (!this.isHitTestVisible) {
  3516. return false;
  3517. }
  3518. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3519. };
  3520. /** @hidden */
  3521. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3522. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3523. this._measureForChildren.copyFrom(this._currentMeasure);
  3524. };
  3525. /** Releases associated resources */
  3526. Container.prototype.dispose = function () {
  3527. _super.prototype.dispose.call(this);
  3528. for (var index = this.children.length - 1; index >= 0; index--) {
  3529. this.children[index].dispose();
  3530. }
  3531. };
  3532. return Container;
  3533. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3534. /***/ }),
  3535. /***/ "./2D/controls/control.ts":
  3536. /*!********************************!*\
  3537. !*** ./2D/controls/control.ts ***!
  3538. \********************************/
  3539. /*! exports provided: Control */
  3540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3541. "use strict";
  3542. __webpack_require__.r(__webpack_exports__);
  3543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3544. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3545. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3546. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3547. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3548. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3549. /**
  3550. * Root class used for all 2D controls
  3551. * @see http://doc.babylonjs.com/how_to/gui#controls
  3552. */
  3553. var Control = /** @class */ (function () {
  3554. // Functions
  3555. /**
  3556. * Creates a new control
  3557. * @param name defines the name of the control
  3558. */
  3559. function Control(
  3560. /** defines the name of the control */
  3561. name) {
  3562. this.name = name;
  3563. this._alpha = 1;
  3564. this._alphaSet = false;
  3565. this._zIndex = 0;
  3566. /** @hidden */
  3567. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3568. this._fontFamily = "Arial";
  3569. this._fontStyle = "";
  3570. this._fontWeight = "";
  3571. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3572. /** @hidden */
  3573. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3574. /** @hidden */
  3575. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3576. this._color = "";
  3577. this._style = null;
  3578. /** @hidden */
  3579. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3580. /** @hidden */
  3581. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3582. /** @hidden */
  3583. this._isDirty = true;
  3584. /** @hidden */
  3585. this._wasDirty = false;
  3586. /** @hidden */
  3587. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3588. /** @hidden */
  3589. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3590. /** @hidden */
  3591. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3592. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3593. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3594. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3595. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3596. /** @hidden */
  3597. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3598. /** @hidden */
  3599. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3600. this._scaleX = 1.0;
  3601. this._scaleY = 1.0;
  3602. this._rotation = 0;
  3603. this._transformCenterX = 0.5;
  3604. this._transformCenterY = 0.5;
  3605. /** @hidden */
  3606. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3607. /** @hidden */
  3608. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3609. /** @hidden */
  3610. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3611. this._isMatrixDirty = true;
  3612. this._isVisible = true;
  3613. this._isHighlighted = false;
  3614. this._fontSet = false;
  3615. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3616. this._downCount = 0;
  3617. this._enterCount = -1;
  3618. this._doNotRender = false;
  3619. this._downPointerIds = {};
  3620. this._isEnabled = true;
  3621. this._disabledColor = "#9a9a9a";
  3622. /** @hidden */
  3623. this._rebuildLayout = false;
  3624. /** @hidden */
  3625. this._isClipped = false;
  3626. /**
  3627. * Gets or sets an object used to store user defined information for the node
  3628. */
  3629. this.metadata = null;
  3630. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3631. this.isHitTestVisible = true;
  3632. /** Gets or sets a boolean indicating if the control can block pointer events */
  3633. this.isPointerBlocker = false;
  3634. /** Gets or sets a boolean indicating if the control can be focusable */
  3635. this.isFocusInvisible = false;
  3636. /**
  3637. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3638. * 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
  3639. */
  3640. this.clipChildren = true;
  3641. /**
  3642. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3643. */
  3644. this.useBitmapCache = false;
  3645. this._shadowOffsetX = 0;
  3646. this._shadowOffsetY = 0;
  3647. this._shadowBlur = 0;
  3648. this._shadowColor = 'black';
  3649. /** Gets or sets the cursor to use when the control is hovered */
  3650. this.hoverCursor = "";
  3651. /** @hidden */
  3652. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3653. /** @hidden */
  3654. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3655. /**
  3656. * An event triggered when the pointer move over the control.
  3657. */
  3658. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3659. /**
  3660. * An event triggered when the pointer move out of the control.
  3661. */
  3662. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3663. /**
  3664. * An event triggered when the pointer taps the control
  3665. */
  3666. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3667. /**
  3668. * An event triggered when pointer up
  3669. */
  3670. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3671. /**
  3672. * An event triggered when a control is clicked on
  3673. */
  3674. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3675. /**
  3676. * An event triggered when pointer enters the control
  3677. */
  3678. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3679. /**
  3680. * An event triggered when the control is marked as dirty
  3681. */
  3682. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3683. /**
  3684. * An event triggered before drawing the control
  3685. */
  3686. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3687. /**
  3688. * An event triggered after the control was drawn
  3689. */
  3690. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3691. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3692. }
  3693. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3694. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3695. get: function () {
  3696. return this._shadowOffsetX;
  3697. },
  3698. set: function (value) {
  3699. if (this._shadowOffsetX === value) {
  3700. return;
  3701. }
  3702. this._shadowOffsetX = value;
  3703. this._markAsDirty();
  3704. },
  3705. enumerable: true,
  3706. configurable: true
  3707. });
  3708. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3709. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3710. get: function () {
  3711. return this._shadowOffsetY;
  3712. },
  3713. set: function (value) {
  3714. if (this._shadowOffsetY === value) {
  3715. return;
  3716. }
  3717. this._shadowOffsetY = value;
  3718. this._markAsDirty();
  3719. },
  3720. enumerable: true,
  3721. configurable: true
  3722. });
  3723. Object.defineProperty(Control.prototype, "shadowBlur", {
  3724. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3725. get: function () {
  3726. return this._shadowBlur;
  3727. },
  3728. set: function (value) {
  3729. if (this._shadowBlur === value) {
  3730. return;
  3731. }
  3732. this._shadowBlur = value;
  3733. this._markAsDirty();
  3734. },
  3735. enumerable: true,
  3736. configurable: true
  3737. });
  3738. Object.defineProperty(Control.prototype, "shadowColor", {
  3739. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3740. get: function () {
  3741. return this._shadowColor;
  3742. },
  3743. set: function (value) {
  3744. if (this._shadowColor === value) {
  3745. return;
  3746. }
  3747. this._shadowColor = value;
  3748. this._markAsDirty();
  3749. },
  3750. enumerable: true,
  3751. configurable: true
  3752. });
  3753. Object.defineProperty(Control.prototype, "typeName", {
  3754. // Properties
  3755. /** Gets the control type name */
  3756. get: function () {
  3757. return this._getTypeName();
  3758. },
  3759. enumerable: true,
  3760. configurable: true
  3761. });
  3762. /**
  3763. * Get the current class name of the control.
  3764. * @returns current class name
  3765. */
  3766. Control.prototype.getClassName = function () {
  3767. return this._getTypeName();
  3768. };
  3769. Object.defineProperty(Control.prototype, "host", {
  3770. /**
  3771. * Get the hosting AdvancedDynamicTexture
  3772. */
  3773. get: function () {
  3774. return this._host;
  3775. },
  3776. enumerable: true,
  3777. configurable: true
  3778. });
  3779. Object.defineProperty(Control.prototype, "fontOffset", {
  3780. /** Gets or set information about font offsets (used to render and align text) */
  3781. get: function () {
  3782. return this._fontOffset;
  3783. },
  3784. set: function (offset) {
  3785. this._fontOffset = offset;
  3786. },
  3787. enumerable: true,
  3788. configurable: true
  3789. });
  3790. Object.defineProperty(Control.prototype, "alpha", {
  3791. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3792. get: function () {
  3793. return this._alpha;
  3794. },
  3795. set: function (value) {
  3796. if (this._alpha === value) {
  3797. return;
  3798. }
  3799. this._alphaSet = true;
  3800. this._alpha = value;
  3801. this._markAsDirty();
  3802. },
  3803. enumerable: true,
  3804. configurable: true
  3805. });
  3806. Object.defineProperty(Control.prototype, "isHighlighted", {
  3807. /**
  3808. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3809. */
  3810. get: function () {
  3811. return this._isHighlighted;
  3812. },
  3813. set: function (value) {
  3814. if (this._isHighlighted === value) {
  3815. return;
  3816. }
  3817. this._isHighlighted = value;
  3818. this._markAsDirty();
  3819. },
  3820. enumerable: true,
  3821. configurable: true
  3822. });
  3823. Object.defineProperty(Control.prototype, "scaleX", {
  3824. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3825. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3826. */
  3827. get: function () {
  3828. return this._scaleX;
  3829. },
  3830. set: function (value) {
  3831. if (this._scaleX === value) {
  3832. return;
  3833. }
  3834. this._scaleX = value;
  3835. this._markAsDirty();
  3836. this._markMatrixAsDirty();
  3837. },
  3838. enumerable: true,
  3839. configurable: true
  3840. });
  3841. Object.defineProperty(Control.prototype, "scaleY", {
  3842. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3843. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3844. */
  3845. get: function () {
  3846. return this._scaleY;
  3847. },
  3848. set: function (value) {
  3849. if (this._scaleY === value) {
  3850. return;
  3851. }
  3852. this._scaleY = value;
  3853. this._markAsDirty();
  3854. this._markMatrixAsDirty();
  3855. },
  3856. enumerable: true,
  3857. configurable: true
  3858. });
  3859. Object.defineProperty(Control.prototype, "rotation", {
  3860. /** Gets or sets the rotation angle (0 by default)
  3861. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3862. */
  3863. get: function () {
  3864. return this._rotation;
  3865. },
  3866. set: function (value) {
  3867. if (this._rotation === value) {
  3868. return;
  3869. }
  3870. this._rotation = value;
  3871. this._markAsDirty();
  3872. this._markMatrixAsDirty();
  3873. },
  3874. enumerable: true,
  3875. configurable: true
  3876. });
  3877. Object.defineProperty(Control.prototype, "transformCenterY", {
  3878. /** Gets or sets the transformation center on Y axis (0 by default)
  3879. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3880. */
  3881. get: function () {
  3882. return this._transformCenterY;
  3883. },
  3884. set: function (value) {
  3885. if (this._transformCenterY === value) {
  3886. return;
  3887. }
  3888. this._transformCenterY = value;
  3889. this._markAsDirty();
  3890. this._markMatrixAsDirty();
  3891. },
  3892. enumerable: true,
  3893. configurable: true
  3894. });
  3895. Object.defineProperty(Control.prototype, "transformCenterX", {
  3896. /** Gets or sets the transformation center on X axis (0 by default)
  3897. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3898. */
  3899. get: function () {
  3900. return this._transformCenterX;
  3901. },
  3902. set: function (value) {
  3903. if (this._transformCenterX === value) {
  3904. return;
  3905. }
  3906. this._transformCenterX = value;
  3907. this._markAsDirty();
  3908. this._markMatrixAsDirty();
  3909. },
  3910. enumerable: true,
  3911. configurable: true
  3912. });
  3913. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3914. /**
  3915. * Gets or sets the horizontal alignment
  3916. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3917. */
  3918. get: function () {
  3919. return this._horizontalAlignment;
  3920. },
  3921. set: function (value) {
  3922. if (this._horizontalAlignment === value) {
  3923. return;
  3924. }
  3925. this._horizontalAlignment = value;
  3926. this._markAsDirty();
  3927. },
  3928. enumerable: true,
  3929. configurable: true
  3930. });
  3931. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3932. /**
  3933. * Gets or sets the vertical alignment
  3934. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3935. */
  3936. get: function () {
  3937. return this._verticalAlignment;
  3938. },
  3939. set: function (value) {
  3940. if (this._verticalAlignment === value) {
  3941. return;
  3942. }
  3943. this._verticalAlignment = value;
  3944. this._markAsDirty();
  3945. },
  3946. enumerable: true,
  3947. configurable: true
  3948. });
  3949. Object.defineProperty(Control.prototype, "width", {
  3950. /**
  3951. * Gets or sets control width
  3952. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3953. */
  3954. get: function () {
  3955. return this._width.toString(this._host);
  3956. },
  3957. set: function (value) {
  3958. if (this._width.toString(this._host) === value) {
  3959. return;
  3960. }
  3961. if (this._width.fromString(value)) {
  3962. this._markAsDirty();
  3963. }
  3964. },
  3965. enumerable: true,
  3966. configurable: true
  3967. });
  3968. Object.defineProperty(Control.prototype, "widthInPixels", {
  3969. /**
  3970. * Gets control width in pixel
  3971. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3972. */
  3973. get: function () {
  3974. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3975. },
  3976. enumerable: true,
  3977. configurable: true
  3978. });
  3979. Object.defineProperty(Control.prototype, "height", {
  3980. /**
  3981. * Gets or sets control height
  3982. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3983. */
  3984. get: function () {
  3985. return this._height.toString(this._host);
  3986. },
  3987. set: function (value) {
  3988. if (this._height.toString(this._host) === value) {
  3989. return;
  3990. }
  3991. if (this._height.fromString(value)) {
  3992. this._markAsDirty();
  3993. }
  3994. },
  3995. enumerable: true,
  3996. configurable: true
  3997. });
  3998. Object.defineProperty(Control.prototype, "heightInPixels", {
  3999. /**
  4000. * Gets control height in pixel
  4001. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4002. */
  4003. get: function () {
  4004. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4005. },
  4006. enumerable: true,
  4007. configurable: true
  4008. });
  4009. Object.defineProperty(Control.prototype, "fontFamily", {
  4010. /** Gets or set font family */
  4011. get: function () {
  4012. if (!this._fontSet) {
  4013. return "";
  4014. }
  4015. return this._fontFamily;
  4016. },
  4017. set: function (value) {
  4018. if (this._fontFamily === value) {
  4019. return;
  4020. }
  4021. this._fontFamily = value;
  4022. this._resetFontCache();
  4023. },
  4024. enumerable: true,
  4025. configurable: true
  4026. });
  4027. Object.defineProperty(Control.prototype, "fontStyle", {
  4028. /** Gets or sets font style */
  4029. get: function () {
  4030. return this._fontStyle;
  4031. },
  4032. set: function (value) {
  4033. if (this._fontStyle === value) {
  4034. return;
  4035. }
  4036. this._fontStyle = value;
  4037. this._resetFontCache();
  4038. },
  4039. enumerable: true,
  4040. configurable: true
  4041. });
  4042. Object.defineProperty(Control.prototype, "fontWeight", {
  4043. /** Gets or sets font weight */
  4044. get: function () {
  4045. return this._fontWeight;
  4046. },
  4047. set: function (value) {
  4048. if (this._fontWeight === value) {
  4049. return;
  4050. }
  4051. this._fontWeight = value;
  4052. this._resetFontCache();
  4053. },
  4054. enumerable: true,
  4055. configurable: true
  4056. });
  4057. Object.defineProperty(Control.prototype, "style", {
  4058. /**
  4059. * Gets or sets style
  4060. * @see http://doc.babylonjs.com/how_to/gui#styles
  4061. */
  4062. get: function () {
  4063. return this._style;
  4064. },
  4065. set: function (value) {
  4066. var _this = this;
  4067. if (this._style) {
  4068. this._style.onChangedObservable.remove(this._styleObserver);
  4069. this._styleObserver = null;
  4070. }
  4071. this._style = value;
  4072. if (this._style) {
  4073. this._styleObserver = this._style.onChangedObservable.add(function () {
  4074. _this._markAsDirty();
  4075. _this._resetFontCache();
  4076. });
  4077. }
  4078. this._markAsDirty();
  4079. this._resetFontCache();
  4080. },
  4081. enumerable: true,
  4082. configurable: true
  4083. });
  4084. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4085. /** @hidden */
  4086. get: function () {
  4087. return this._fontSize.isPercentage;
  4088. },
  4089. enumerable: true,
  4090. configurable: true
  4091. });
  4092. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4093. /** Gets font size in pixels */
  4094. get: function () {
  4095. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4096. if (fontSizeToUse.isPixel) {
  4097. return fontSizeToUse.getValue(this._host);
  4098. }
  4099. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4100. },
  4101. enumerable: true,
  4102. configurable: true
  4103. });
  4104. Object.defineProperty(Control.prototype, "fontSize", {
  4105. /** Gets or sets font size */
  4106. get: function () {
  4107. return this._fontSize.toString(this._host);
  4108. },
  4109. set: function (value) {
  4110. if (this._fontSize.toString(this._host) === value) {
  4111. return;
  4112. }
  4113. if (this._fontSize.fromString(value)) {
  4114. this._markAsDirty();
  4115. this._resetFontCache();
  4116. }
  4117. },
  4118. enumerable: true,
  4119. configurable: true
  4120. });
  4121. Object.defineProperty(Control.prototype, "color", {
  4122. /** Gets or sets foreground color */
  4123. get: function () {
  4124. return this._color;
  4125. },
  4126. set: function (value) {
  4127. if (this._color === value) {
  4128. return;
  4129. }
  4130. this._color = value;
  4131. this._markAsDirty();
  4132. },
  4133. enumerable: true,
  4134. configurable: true
  4135. });
  4136. Object.defineProperty(Control.prototype, "zIndex", {
  4137. /** Gets or sets z index which is used to reorder controls on the z axis */
  4138. get: function () {
  4139. return this._zIndex;
  4140. },
  4141. set: function (value) {
  4142. if (this.zIndex === value) {
  4143. return;
  4144. }
  4145. this._zIndex = value;
  4146. if (this.parent) {
  4147. this.parent._reOrderControl(this);
  4148. }
  4149. },
  4150. enumerable: true,
  4151. configurable: true
  4152. });
  4153. Object.defineProperty(Control.prototype, "notRenderable", {
  4154. /** Gets or sets a boolean indicating if the control can be rendered */
  4155. get: function () {
  4156. return this._doNotRender;
  4157. },
  4158. set: function (value) {
  4159. if (this._doNotRender === value) {
  4160. return;
  4161. }
  4162. this._doNotRender = value;
  4163. this._markAsDirty();
  4164. },
  4165. enumerable: true,
  4166. configurable: true
  4167. });
  4168. Object.defineProperty(Control.prototype, "isVisible", {
  4169. /** Gets or sets a boolean indicating if the control is visible */
  4170. get: function () {
  4171. return this._isVisible;
  4172. },
  4173. set: function (value) {
  4174. if (this._isVisible === value) {
  4175. return;
  4176. }
  4177. this._isVisible = value;
  4178. this._markAsDirty(true);
  4179. },
  4180. enumerable: true,
  4181. configurable: true
  4182. });
  4183. Object.defineProperty(Control.prototype, "isDirty", {
  4184. /** Gets a boolean indicating that the control needs to update its rendering */
  4185. get: function () {
  4186. return this._isDirty;
  4187. },
  4188. enumerable: true,
  4189. configurable: true
  4190. });
  4191. Object.defineProperty(Control.prototype, "linkedMesh", {
  4192. /**
  4193. * Gets the current linked mesh (or null if none)
  4194. */
  4195. get: function () {
  4196. return this._linkedMesh;
  4197. },
  4198. enumerable: true,
  4199. configurable: true
  4200. });
  4201. Object.defineProperty(Control.prototype, "paddingLeft", {
  4202. /**
  4203. * Gets or sets a value indicating the padding to use on the left of the control
  4204. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4205. */
  4206. get: function () {
  4207. return this._paddingLeft.toString(this._host);
  4208. },
  4209. set: function (value) {
  4210. if (this._paddingLeft.fromString(value)) {
  4211. this._markAsDirty();
  4212. }
  4213. },
  4214. enumerable: true,
  4215. configurable: true
  4216. });
  4217. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4218. /**
  4219. * Gets a value indicating the padding in pixels to use on the left of the control
  4220. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4221. */
  4222. get: function () {
  4223. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4224. },
  4225. enumerable: true,
  4226. configurable: true
  4227. });
  4228. Object.defineProperty(Control.prototype, "paddingRight", {
  4229. /**
  4230. * Gets or sets a value indicating the padding to use on the right of the control
  4231. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4232. */
  4233. get: function () {
  4234. return this._paddingRight.toString(this._host);
  4235. },
  4236. set: function (value) {
  4237. if (this._paddingRight.fromString(value)) {
  4238. this._markAsDirty();
  4239. }
  4240. },
  4241. enumerable: true,
  4242. configurable: true
  4243. });
  4244. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4245. /**
  4246. * Gets a value indicating the padding in pixels to use on the right of the control
  4247. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4248. */
  4249. get: function () {
  4250. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4251. },
  4252. enumerable: true,
  4253. configurable: true
  4254. });
  4255. Object.defineProperty(Control.prototype, "paddingTop", {
  4256. /**
  4257. * Gets or sets a value indicating the padding to use on the top of the control
  4258. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4259. */
  4260. get: function () {
  4261. return this._paddingTop.toString(this._host);
  4262. },
  4263. set: function (value) {
  4264. if (this._paddingTop.fromString(value)) {
  4265. this._markAsDirty();
  4266. }
  4267. },
  4268. enumerable: true,
  4269. configurable: true
  4270. });
  4271. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4272. /**
  4273. * Gets a value indicating the padding in pixels to use on the top of the control
  4274. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4275. */
  4276. get: function () {
  4277. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4278. },
  4279. enumerable: true,
  4280. configurable: true
  4281. });
  4282. Object.defineProperty(Control.prototype, "paddingBottom", {
  4283. /**
  4284. * Gets or sets a value indicating the padding to use on the bottom of the control
  4285. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4286. */
  4287. get: function () {
  4288. return this._paddingBottom.toString(this._host);
  4289. },
  4290. set: function (value) {
  4291. if (this._paddingBottom.fromString(value)) {
  4292. this._markAsDirty();
  4293. }
  4294. },
  4295. enumerable: true,
  4296. configurable: true
  4297. });
  4298. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4299. /**
  4300. * Gets a value indicating the padding in pixels to use on the bottom of the control
  4301. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4302. */
  4303. get: function () {
  4304. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4305. },
  4306. enumerable: true,
  4307. configurable: true
  4308. });
  4309. Object.defineProperty(Control.prototype, "left", {
  4310. /**
  4311. * Gets or sets a value indicating the left coordinate of the control
  4312. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4313. */
  4314. get: function () {
  4315. return this._left.toString(this._host);
  4316. },
  4317. set: function (value) {
  4318. if (this._left.fromString(value)) {
  4319. this._markAsDirty();
  4320. }
  4321. },
  4322. enumerable: true,
  4323. configurable: true
  4324. });
  4325. Object.defineProperty(Control.prototype, "leftInPixels", {
  4326. /**
  4327. * Gets a value indicating the left coordinate in pixels of the control
  4328. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4329. */
  4330. get: function () {
  4331. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4332. },
  4333. enumerable: true,
  4334. configurable: true
  4335. });
  4336. Object.defineProperty(Control.prototype, "top", {
  4337. /**
  4338. * Gets or sets a value indicating the top coordinate of the control
  4339. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4340. */
  4341. get: function () {
  4342. return this._top.toString(this._host);
  4343. },
  4344. set: function (value) {
  4345. if (this._top.fromString(value)) {
  4346. this._markAsDirty();
  4347. }
  4348. },
  4349. enumerable: true,
  4350. configurable: true
  4351. });
  4352. Object.defineProperty(Control.prototype, "topInPixels", {
  4353. /**
  4354. * Gets a value indicating the top coordinate in pixels of the control
  4355. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4356. */
  4357. get: function () {
  4358. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4359. },
  4360. enumerable: true,
  4361. configurable: true
  4362. });
  4363. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4364. /**
  4365. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4366. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4367. */
  4368. get: function () {
  4369. return this._linkOffsetX.toString(this._host);
  4370. },
  4371. set: function (value) {
  4372. if (this._linkOffsetX.fromString(value)) {
  4373. this._markAsDirty();
  4374. }
  4375. },
  4376. enumerable: true,
  4377. configurable: true
  4378. });
  4379. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4380. /**
  4381. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  4382. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4383. */
  4384. get: function () {
  4385. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4386. },
  4387. enumerable: true,
  4388. configurable: true
  4389. });
  4390. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4391. /**
  4392. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4393. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4394. */
  4395. get: function () {
  4396. return this._linkOffsetY.toString(this._host);
  4397. },
  4398. set: function (value) {
  4399. if (this._linkOffsetY.fromString(value)) {
  4400. this._markAsDirty();
  4401. }
  4402. },
  4403. enumerable: true,
  4404. configurable: true
  4405. });
  4406. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4407. /**
  4408. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  4409. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4410. */
  4411. get: function () {
  4412. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4413. },
  4414. enumerable: true,
  4415. configurable: true
  4416. });
  4417. Object.defineProperty(Control.prototype, "centerX", {
  4418. /** Gets the center coordinate on X axis */
  4419. get: function () {
  4420. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4421. },
  4422. enumerable: true,
  4423. configurable: true
  4424. });
  4425. Object.defineProperty(Control.prototype, "centerY", {
  4426. /** Gets the center coordinate on Y axis */
  4427. get: function () {
  4428. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4429. },
  4430. enumerable: true,
  4431. configurable: true
  4432. });
  4433. Object.defineProperty(Control.prototype, "isEnabled", {
  4434. /** Gets or sets if control is Enabled*/
  4435. get: function () {
  4436. return this._isEnabled;
  4437. },
  4438. set: function (value) {
  4439. if (this._isEnabled === value) {
  4440. return;
  4441. }
  4442. this._isEnabled = value;
  4443. this._markAsDirty();
  4444. },
  4445. enumerable: true,
  4446. configurable: true
  4447. });
  4448. Object.defineProperty(Control.prototype, "disabledColor", {
  4449. /** Gets or sets background color of control if it's disabled*/
  4450. get: function () {
  4451. return this._disabledColor;
  4452. },
  4453. set: function (value) {
  4454. if (this._disabledColor === value) {
  4455. return;
  4456. }
  4457. this._disabledColor = value;
  4458. this._markAsDirty();
  4459. },
  4460. enumerable: true,
  4461. configurable: true
  4462. });
  4463. /** @hidden */
  4464. Control.prototype._getTypeName = function () {
  4465. return "Control";
  4466. };
  4467. /**
  4468. * Gets the first ascendant in the hierarchy of the given type
  4469. * @param className defines the required type
  4470. * @returns the ascendant or null if not found
  4471. */
  4472. Control.prototype.getAscendantOfClass = function (className) {
  4473. if (!this.parent) {
  4474. return null;
  4475. }
  4476. if (this.parent.getClassName() === className) {
  4477. return this.parent;
  4478. }
  4479. return this.parent.getAscendantOfClass(className);
  4480. };
  4481. /** @hidden */
  4482. Control.prototype._resetFontCache = function () {
  4483. this._fontSet = true;
  4484. this._markAsDirty();
  4485. };
  4486. /**
  4487. * Determines if a container is an ascendant of the current control
  4488. * @param container defines the container to look for
  4489. * @returns true if the container is one of the ascendant of the control
  4490. */
  4491. Control.prototype.isAscendant = function (container) {
  4492. if (!this.parent) {
  4493. return false;
  4494. }
  4495. if (this.parent === container) {
  4496. return true;
  4497. }
  4498. return this.parent.isAscendant(container);
  4499. };
  4500. /**
  4501. * Gets coordinates in local control space
  4502. * @param globalCoordinates defines the coordinates to transform
  4503. * @returns the new coordinates in local space
  4504. */
  4505. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4506. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4507. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4508. return result;
  4509. };
  4510. /**
  4511. * Gets coordinates in local control space
  4512. * @param globalCoordinates defines the coordinates to transform
  4513. * @param result defines the target vector2 where to store the result
  4514. * @returns the current control
  4515. */
  4516. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4517. result.x = globalCoordinates.x - this._currentMeasure.left;
  4518. result.y = globalCoordinates.y - this._currentMeasure.top;
  4519. return this;
  4520. };
  4521. /**
  4522. * Gets coordinates in parent local control space
  4523. * @param globalCoordinates defines the coordinates to transform
  4524. * @returns the new coordinates in parent local space
  4525. */
  4526. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4527. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4528. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4529. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4530. return result;
  4531. };
  4532. /**
  4533. * Move the current control to a vector3 position projected onto the screen.
  4534. * @param position defines the target position
  4535. * @param scene defines the hosting scene
  4536. */
  4537. Control.prototype.moveToVector3 = function (position, scene) {
  4538. if (!this._host || this.parent !== this._host._rootContainer) {
  4539. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4540. return;
  4541. }
  4542. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4543. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4544. var globalViewport = this._host._getGlobalViewport(scene);
  4545. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4546. this._moveToProjectedPosition(projectedPosition);
  4547. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4548. this.notRenderable = true;
  4549. return;
  4550. }
  4551. this.notRenderable = false;
  4552. };
  4553. /** @hidden */
  4554. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4555. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4556. // Do nothing by default
  4557. };
  4558. /**
  4559. * Will return all controls that have this control as ascendant
  4560. * @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
  4561. * @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
  4562. * @return all child controls
  4563. */
  4564. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4565. var results = new Array();
  4566. this._getDescendants(results, directDescendantsOnly, predicate);
  4567. return results;
  4568. };
  4569. /**
  4570. * Link current control with a target mesh
  4571. * @param mesh defines the mesh to link with
  4572. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4573. */
  4574. Control.prototype.linkWithMesh = function (mesh) {
  4575. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4576. if (mesh) {
  4577. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4578. }
  4579. return;
  4580. }
  4581. var index = this._host._linkedControls.indexOf(this);
  4582. if (index !== -1) {
  4583. this._linkedMesh = mesh;
  4584. if (!mesh) {
  4585. this._host._linkedControls.splice(index, 1);
  4586. }
  4587. return;
  4588. }
  4589. else if (!mesh) {
  4590. return;
  4591. }
  4592. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4593. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4594. this._linkedMesh = mesh;
  4595. this._host._linkedControls.push(this);
  4596. };
  4597. /** @hidden */
  4598. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4599. var oldLeft = this._left.getValue(this._host);
  4600. var oldTop = this._top.getValue(this._host);
  4601. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4602. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4603. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4604. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4605. newLeft = oldLeft;
  4606. }
  4607. if (Math.abs(newTop - oldTop) < 0.5) {
  4608. newTop = oldTop;
  4609. }
  4610. }
  4611. this.left = newLeft + "px";
  4612. this.top = newTop + "px";
  4613. this._left.ignoreAdaptiveScaling = true;
  4614. this._top.ignoreAdaptiveScaling = true;
  4615. this._markAsDirty();
  4616. };
  4617. /** @hidden */
  4618. Control.prototype._offsetLeft = function (offset) {
  4619. this._isDirty = true;
  4620. this._currentMeasure.left += offset;
  4621. };
  4622. /** @hidden */
  4623. Control.prototype._offsetTop = function (offset) {
  4624. this._isDirty = true;
  4625. this._currentMeasure.top += offset;
  4626. };
  4627. /** @hidden */
  4628. Control.prototype._markMatrixAsDirty = function () {
  4629. this._isMatrixDirty = true;
  4630. this._flagDescendantsAsMatrixDirty();
  4631. };
  4632. /** @hidden */
  4633. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4634. // No child
  4635. };
  4636. /** @hidden */
  4637. Control.prototype._intersectsRect = function (rect) {
  4638. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4639. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4640. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4641. return false;
  4642. }
  4643. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4644. return false;
  4645. }
  4646. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4647. return false;
  4648. }
  4649. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4650. return false;
  4651. }
  4652. return true;
  4653. };
  4654. /** @hidden */
  4655. Control.prototype.invalidateRect = function () {
  4656. this._transform();
  4657. if (this.host && this.host.useInvalidateRectOptimization) {
  4658. // Rotate by transform to get the measure transformed to global space
  4659. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4660. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4661. // the previous measure is used to properly clear a control that is scaled down
  4662. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4663. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4664. // Expand rect based on shadows
  4665. var shadowOffsetX = this.shadowOffsetX;
  4666. var shadowOffsetY = this.shadowOffsetY;
  4667. var shadowBlur = this.shadowBlur;
  4668. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4669. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4670. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4671. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4672. 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));
  4673. }
  4674. else {
  4675. 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));
  4676. }
  4677. }
  4678. };
  4679. /** @hidden */
  4680. Control.prototype._markAsDirty = function (force) {
  4681. if (force === void 0) { force = false; }
  4682. if (!this._isVisible && !force) {
  4683. return;
  4684. }
  4685. this._isDirty = true;
  4686. // Redraw only this rectangle
  4687. if (this._host) {
  4688. this._host.markAsDirty();
  4689. }
  4690. };
  4691. /** @hidden */
  4692. Control.prototype._markAllAsDirty = function () {
  4693. this._markAsDirty();
  4694. if (this._font) {
  4695. this._prepareFont();
  4696. }
  4697. };
  4698. /** @hidden */
  4699. Control.prototype._link = function (host) {
  4700. this._host = host;
  4701. if (this._host) {
  4702. this.uniqueId = this._host.getScene().getUniqueId();
  4703. }
  4704. };
  4705. /** @hidden */
  4706. Control.prototype._transform = function (context) {
  4707. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4708. return;
  4709. }
  4710. // postTranslate
  4711. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4712. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4713. if (context) {
  4714. context.translate(offsetX, offsetY);
  4715. // rotate
  4716. context.rotate(this._rotation);
  4717. // scale
  4718. context.scale(this._scaleX, this._scaleY);
  4719. // preTranslate
  4720. context.translate(-offsetX, -offsetY);
  4721. }
  4722. // Need to update matrices?
  4723. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4724. this._cachedOffsetX = offsetX;
  4725. this._cachedOffsetY = offsetY;
  4726. this._isMatrixDirty = false;
  4727. this._flagDescendantsAsMatrixDirty();
  4728. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4729. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4730. }
  4731. };
  4732. /** @hidden */
  4733. Control.prototype._renderHighlight = function (context) {
  4734. if (!this.isHighlighted) {
  4735. return;
  4736. }
  4737. context.save();
  4738. context.strokeStyle = "#4affff";
  4739. context.lineWidth = 2;
  4740. this._renderHighlightSpecific(context);
  4741. context.restore();
  4742. };
  4743. /** @hidden */
  4744. Control.prototype._renderHighlightSpecific = function (context) {
  4745. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4746. };
  4747. /** @hidden */
  4748. Control.prototype._applyStates = function (context) {
  4749. if (this._isFontSizeInPercentage) {
  4750. this._fontSet = true;
  4751. }
  4752. if (this._fontSet) {
  4753. this._prepareFont();
  4754. this._fontSet = false;
  4755. }
  4756. if (this._font) {
  4757. context.font = this._font;
  4758. }
  4759. if (this._color) {
  4760. context.fillStyle = this._color;
  4761. }
  4762. if (Control.AllowAlphaInheritance) {
  4763. context.globalAlpha *= this._alpha;
  4764. }
  4765. else if (this._alphaSet) {
  4766. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4767. }
  4768. };
  4769. /** @hidden */
  4770. Control.prototype._layout = function (parentMeasure, context) {
  4771. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4772. return false;
  4773. }
  4774. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4775. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4776. context.save();
  4777. this._applyStates(context);
  4778. var rebuildCount = 0;
  4779. do {
  4780. this._rebuildLayout = false;
  4781. this._processMeasures(parentMeasure, context);
  4782. rebuildCount++;
  4783. } while (this._rebuildLayout && rebuildCount < 3);
  4784. if (rebuildCount >= 3) {
  4785. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4786. }
  4787. context.restore();
  4788. this.invalidateRect();
  4789. this._evaluateClippingState(parentMeasure);
  4790. }
  4791. this._wasDirty = this._isDirty;
  4792. this._isDirty = false;
  4793. return true;
  4794. };
  4795. /** @hidden */
  4796. Control.prototype._processMeasures = function (parentMeasure, context) {
  4797. this._currentMeasure.copyFrom(parentMeasure);
  4798. // Let children take some pre-measurement actions
  4799. this._preMeasure(parentMeasure, context);
  4800. this._measure();
  4801. this._computeAlignment(parentMeasure, context);
  4802. // Convert to int values
  4803. this._currentMeasure.left = this._currentMeasure.left | 0;
  4804. this._currentMeasure.top = this._currentMeasure.top | 0;
  4805. this._currentMeasure.width = this._currentMeasure.width | 0;
  4806. this._currentMeasure.height = this._currentMeasure.height | 0;
  4807. // Let children add more features
  4808. this._additionalProcessing(parentMeasure, context);
  4809. this._cachedParentMeasure.copyFrom(parentMeasure);
  4810. if (this.onDirtyObservable.hasObservers()) {
  4811. this.onDirtyObservable.notifyObservers(this);
  4812. }
  4813. };
  4814. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4815. if (this.parent && this.parent.clipChildren) {
  4816. // Early clip
  4817. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4818. this._isClipped = true;
  4819. return;
  4820. }
  4821. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4822. this._isClipped = true;
  4823. return;
  4824. }
  4825. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4826. this._isClipped = true;
  4827. return;
  4828. }
  4829. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4830. this._isClipped = true;
  4831. return;
  4832. }
  4833. }
  4834. this._isClipped = false;
  4835. };
  4836. /** @hidden */
  4837. Control.prototype._measure = function () {
  4838. // Width / Height
  4839. if (this._width.isPixel) {
  4840. this._currentMeasure.width = this._width.getValue(this._host);
  4841. }
  4842. else {
  4843. this._currentMeasure.width *= this._width.getValue(this._host);
  4844. }
  4845. if (this._height.isPixel) {
  4846. this._currentMeasure.height = this._height.getValue(this._host);
  4847. }
  4848. else {
  4849. this._currentMeasure.height *= this._height.getValue(this._host);
  4850. }
  4851. };
  4852. /** @hidden */
  4853. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4854. var width = this._currentMeasure.width;
  4855. var height = this._currentMeasure.height;
  4856. var parentWidth = parentMeasure.width;
  4857. var parentHeight = parentMeasure.height;
  4858. // Left / top
  4859. var x = 0;
  4860. var y = 0;
  4861. switch (this.horizontalAlignment) {
  4862. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4863. x = 0;
  4864. break;
  4865. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4866. x = parentWidth - width;
  4867. break;
  4868. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4869. x = (parentWidth - width) / 2;
  4870. break;
  4871. }
  4872. switch (this.verticalAlignment) {
  4873. case Control.VERTICAL_ALIGNMENT_TOP:
  4874. y = 0;
  4875. break;
  4876. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4877. y = parentHeight - height;
  4878. break;
  4879. case Control.VERTICAL_ALIGNMENT_CENTER:
  4880. y = (parentHeight - height) / 2;
  4881. break;
  4882. }
  4883. if (this._paddingLeft.isPixel) {
  4884. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4885. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4886. }
  4887. else {
  4888. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4889. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4890. }
  4891. if (this._paddingRight.isPixel) {
  4892. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4893. }
  4894. else {
  4895. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4896. }
  4897. if (this._paddingTop.isPixel) {
  4898. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4899. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4900. }
  4901. else {
  4902. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4903. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4904. }
  4905. if (this._paddingBottom.isPixel) {
  4906. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4907. }
  4908. else {
  4909. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4910. }
  4911. if (this._left.isPixel) {
  4912. this._currentMeasure.left += this._left.getValue(this._host);
  4913. }
  4914. else {
  4915. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4916. }
  4917. if (this._top.isPixel) {
  4918. this._currentMeasure.top += this._top.getValue(this._host);
  4919. }
  4920. else {
  4921. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4922. }
  4923. this._currentMeasure.left += x;
  4924. this._currentMeasure.top += y;
  4925. };
  4926. /** @hidden */
  4927. Control.prototype._preMeasure = function (parentMeasure, context) {
  4928. // Do nothing
  4929. };
  4930. /** @hidden */
  4931. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4932. // Do nothing
  4933. };
  4934. /** @hidden */
  4935. Control.prototype._clipForChildren = function (context) {
  4936. // DO nothing
  4937. };
  4938. Control.prototype._clip = function (context, invalidatedRectangle) {
  4939. context.beginPath();
  4940. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4941. if (invalidatedRectangle) {
  4942. // Rotate the invalidated rect into the control's space
  4943. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4944. // Get the intersection of the rect in context space and the current context
  4945. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4946. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4947. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4948. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4949. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4950. Control._ClipMeasure.copyFrom(intersection);
  4951. }
  4952. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4953. var shadowOffsetX = this.shadowOffsetX;
  4954. var shadowOffsetY = this.shadowOffsetY;
  4955. var shadowBlur = this.shadowBlur;
  4956. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4957. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4958. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4959. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4960. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  4961. }
  4962. else {
  4963. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  4964. }
  4965. context.clip();
  4966. };
  4967. /** @hidden */
  4968. Control.prototype._render = function (context, invalidatedRectangle) {
  4969. if (!this.isVisible || this.notRenderable || this._isClipped) {
  4970. this._isDirty = false;
  4971. return false;
  4972. }
  4973. context.save();
  4974. this._applyStates(context);
  4975. // Transform
  4976. this._transform(context);
  4977. // Clip
  4978. // if (this.clipChildren) {
  4979. this._clip(context, invalidatedRectangle);
  4980. // }
  4981. if (this.onBeforeDrawObservable.hasObservers()) {
  4982. this.onBeforeDrawObservable.notifyObservers(this);
  4983. }
  4984. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  4985. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  4986. }
  4987. else {
  4988. this._draw(context, invalidatedRectangle);
  4989. }
  4990. if (this.useBitmapCache && this._wasDirty) {
  4991. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4992. }
  4993. this._renderHighlight(context);
  4994. if (this.onAfterDrawObservable.hasObservers()) {
  4995. this.onAfterDrawObservable.notifyObservers(this);
  4996. }
  4997. context.restore();
  4998. return true;
  4999. };
  5000. /** @hidden */
  5001. Control.prototype._draw = function (context, invalidatedRectangle) {
  5002. // Do nothing
  5003. };
  5004. /**
  5005. * Tests if a given coordinates belong to the current control
  5006. * @param x defines x coordinate to test
  5007. * @param y defines y coordinate to test
  5008. * @returns true if the coordinates are inside the control
  5009. */
  5010. Control.prototype.contains = function (x, y) {
  5011. // Invert transform
  5012. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5013. x = this._transformedPosition.x;
  5014. y = this._transformedPosition.y;
  5015. // Check
  5016. if (x < this._currentMeasure.left) {
  5017. return false;
  5018. }
  5019. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5020. return false;
  5021. }
  5022. if (y < this._currentMeasure.top) {
  5023. return false;
  5024. }
  5025. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5026. return false;
  5027. }
  5028. if (this.isPointerBlocker) {
  5029. this._host._shouldBlockPointer = true;
  5030. }
  5031. return true;
  5032. };
  5033. /** @hidden */
  5034. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5035. if (!this._isEnabled) {
  5036. return false;
  5037. }
  5038. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5039. return false;
  5040. }
  5041. if (!this.contains(x, y)) {
  5042. return false;
  5043. }
  5044. this._processObservables(type, x, y, pointerId, buttonIndex);
  5045. return true;
  5046. };
  5047. /** @hidden */
  5048. Control.prototype._onPointerMove = function (target, coordinates) {
  5049. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5050. if (canNotify && this.parent != null) {
  5051. this.parent._onPointerMove(target, coordinates);
  5052. }
  5053. };
  5054. /** @hidden */
  5055. Control.prototype._onPointerEnter = function (target) {
  5056. if (!this._isEnabled) {
  5057. return false;
  5058. }
  5059. if (this._enterCount > 0) {
  5060. return false;
  5061. }
  5062. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5063. this._enterCount = 0;
  5064. }
  5065. this._enterCount++;
  5066. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5067. if (canNotify && this.parent != null) {
  5068. this.parent._onPointerEnter(target);
  5069. }
  5070. return true;
  5071. };
  5072. /** @hidden */
  5073. Control.prototype._onPointerOut = function (target, force) {
  5074. if (force === void 0) { force = false; }
  5075. if (!force && (!this._isEnabled || target === this)) {
  5076. return;
  5077. }
  5078. this._enterCount = 0;
  5079. var canNotify = true;
  5080. if (!target.isAscendant(this)) {
  5081. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5082. }
  5083. if (canNotify && this.parent != null) {
  5084. this.parent._onPointerOut(target, force);
  5085. }
  5086. };
  5087. /** @hidden */
  5088. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5089. // Prevent pointerout to lose control context.
  5090. // Event redundancy is checked inside the function.
  5091. this._onPointerEnter(this);
  5092. if (this._downCount !== 0) {
  5093. return false;
  5094. }
  5095. this._downCount++;
  5096. this._downPointerIds[pointerId] = true;
  5097. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5098. if (canNotify && this.parent != null) {
  5099. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5100. }
  5101. return true;
  5102. };
  5103. /** @hidden */
  5104. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5105. if (!this._isEnabled) {
  5106. return;
  5107. }
  5108. this._downCount = 0;
  5109. delete this._downPointerIds[pointerId];
  5110. var canNotifyClick = notifyClick;
  5111. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5112. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5113. }
  5114. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5115. if (canNotify && this.parent != null) {
  5116. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5117. }
  5118. };
  5119. /** @hidden */
  5120. Control.prototype._forcePointerUp = function (pointerId) {
  5121. if (pointerId === void 0) { pointerId = null; }
  5122. if (pointerId !== null) {
  5123. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5124. }
  5125. else {
  5126. for (var key in this._downPointerIds) {
  5127. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5128. }
  5129. }
  5130. };
  5131. /** @hidden */
  5132. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5133. if (!this._isEnabled) {
  5134. return false;
  5135. }
  5136. this._dummyVector2.copyFromFloats(x, y);
  5137. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5138. this._onPointerMove(this, this._dummyVector2);
  5139. var previousControlOver = this._host._lastControlOver[pointerId];
  5140. if (previousControlOver && previousControlOver !== this) {
  5141. previousControlOver._onPointerOut(this);
  5142. }
  5143. if (previousControlOver !== this) {
  5144. this._onPointerEnter(this);
  5145. }
  5146. this._host._lastControlOver[pointerId] = this;
  5147. return true;
  5148. }
  5149. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5150. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5151. this._host._registerLastControlDown(this, pointerId);
  5152. this._host._lastPickedControl = this;
  5153. return true;
  5154. }
  5155. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5156. if (this._host._lastControlDown[pointerId]) {
  5157. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5158. }
  5159. delete this._host._lastControlDown[pointerId];
  5160. return true;
  5161. }
  5162. return false;
  5163. };
  5164. Control.prototype._prepareFont = function () {
  5165. if (!this._font && !this._fontSet) {
  5166. return;
  5167. }
  5168. if (this._style) {
  5169. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5170. }
  5171. else {
  5172. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5173. }
  5174. this._fontOffset = Control._GetFontOffset(this._font);
  5175. };
  5176. /** Releases associated resources */
  5177. Control.prototype.dispose = function () {
  5178. this.onDirtyObservable.clear();
  5179. this.onBeforeDrawObservable.clear();
  5180. this.onAfterDrawObservable.clear();
  5181. this.onPointerDownObservable.clear();
  5182. this.onPointerEnterObservable.clear();
  5183. this.onPointerMoveObservable.clear();
  5184. this.onPointerOutObservable.clear();
  5185. this.onPointerUpObservable.clear();
  5186. this.onPointerClickObservable.clear();
  5187. if (this._styleObserver && this._style) {
  5188. this._style.onChangedObservable.remove(this._styleObserver);
  5189. this._styleObserver = null;
  5190. }
  5191. if (this.parent) {
  5192. this.parent.removeControl(this);
  5193. this.parent = null;
  5194. }
  5195. if (this._host) {
  5196. var index = this._host._linkedControls.indexOf(this);
  5197. if (index > -1) {
  5198. this.linkWithMesh(null);
  5199. }
  5200. }
  5201. };
  5202. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5203. /** HORIZONTAL_ALIGNMENT_LEFT */
  5204. get: function () {
  5205. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5206. },
  5207. enumerable: true,
  5208. configurable: true
  5209. });
  5210. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5211. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5212. get: function () {
  5213. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5214. },
  5215. enumerable: true,
  5216. configurable: true
  5217. });
  5218. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5219. /** HORIZONTAL_ALIGNMENT_CENTER */
  5220. get: function () {
  5221. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5222. },
  5223. enumerable: true,
  5224. configurable: true
  5225. });
  5226. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5227. /** VERTICAL_ALIGNMENT_TOP */
  5228. get: function () {
  5229. return Control._VERTICAL_ALIGNMENT_TOP;
  5230. },
  5231. enumerable: true,
  5232. configurable: true
  5233. });
  5234. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5235. /** VERTICAL_ALIGNMENT_BOTTOM */
  5236. get: function () {
  5237. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5238. },
  5239. enumerable: true,
  5240. configurable: true
  5241. });
  5242. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5243. /** VERTICAL_ALIGNMENT_CENTER */
  5244. get: function () {
  5245. return Control._VERTICAL_ALIGNMENT_CENTER;
  5246. },
  5247. enumerable: true,
  5248. configurable: true
  5249. });
  5250. /** @hidden */
  5251. Control._GetFontOffset = function (font) {
  5252. if (Control._FontHeightSizes[font]) {
  5253. return Control._FontHeightSizes[font];
  5254. }
  5255. var text = document.createElement("span");
  5256. text.innerHTML = "Hg";
  5257. text.style.font = font;
  5258. var block = document.createElement("div");
  5259. block.style.display = "inline-block";
  5260. block.style.width = "1px";
  5261. block.style.height = "0px";
  5262. block.style.verticalAlign = "bottom";
  5263. var div = document.createElement("div");
  5264. div.appendChild(text);
  5265. div.appendChild(block);
  5266. document.body.appendChild(div);
  5267. var fontAscent = 0;
  5268. var fontHeight = 0;
  5269. try {
  5270. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5271. block.style.verticalAlign = "baseline";
  5272. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5273. }
  5274. finally {
  5275. document.body.removeChild(div);
  5276. }
  5277. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5278. Control._FontHeightSizes[font] = result;
  5279. return result;
  5280. };
  5281. /** @hidden */
  5282. Control.drawEllipse = function (x, y, width, height, context) {
  5283. context.translate(x, y);
  5284. context.scale(width, height);
  5285. context.beginPath();
  5286. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5287. context.closePath();
  5288. context.scale(1 / width, 1 / height);
  5289. context.translate(-x, -y);
  5290. };
  5291. /**
  5292. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5293. */
  5294. Control.AllowAlphaInheritance = false;
  5295. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5296. // Statics
  5297. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5298. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5299. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5300. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5301. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5302. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5303. Control._FontHeightSizes = {};
  5304. /**
  5305. * Creates a stack panel that can be used to render headers
  5306. * @param control defines the control to associate with the header
  5307. * @param text defines the text of the header
  5308. * @param size defines the size of the header
  5309. * @param options defines options used to configure the header
  5310. * @returns a new StackPanel
  5311. * @ignore
  5312. * @hidden
  5313. */
  5314. Control.AddHeader = function () { };
  5315. return Control;
  5316. }());
  5317. /***/ }),
  5318. /***/ "./2D/controls/displayGrid.ts":
  5319. /*!************************************!*\
  5320. !*** ./2D/controls/displayGrid.ts ***!
  5321. \************************************/
  5322. /*! exports provided: DisplayGrid */
  5323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5324. "use strict";
  5325. __webpack_require__.r(__webpack_exports__);
  5326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5327. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5328. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5329. /** Class used to render a grid */
  5330. var DisplayGrid = /** @class */ (function (_super) {
  5331. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5332. /**
  5333. * Creates a new GridDisplayRectangle
  5334. * @param name defines the control name
  5335. */
  5336. function DisplayGrid(name) {
  5337. var _this = _super.call(this, name) || this;
  5338. _this.name = name;
  5339. _this._cellWidth = 20;
  5340. _this._cellHeight = 20;
  5341. _this._minorLineTickness = 1;
  5342. _this._minorLineColor = "DarkGray";
  5343. _this._majorLineTickness = 2;
  5344. _this._majorLineColor = "White";
  5345. _this._majorLineFrequency = 5;
  5346. _this._background = "Black";
  5347. _this._displayMajorLines = true;
  5348. _this._displayMinorLines = true;
  5349. return _this;
  5350. }
  5351. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5352. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5353. get: function () {
  5354. return this._displayMinorLines;
  5355. },
  5356. set: function (value) {
  5357. if (this._displayMinorLines === value) {
  5358. return;
  5359. }
  5360. this._displayMinorLines = value;
  5361. this._markAsDirty();
  5362. },
  5363. enumerable: true,
  5364. configurable: true
  5365. });
  5366. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5367. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5368. get: function () {
  5369. return this._displayMajorLines;
  5370. },
  5371. set: function (value) {
  5372. if (this._displayMajorLines === value) {
  5373. return;
  5374. }
  5375. this._displayMajorLines = value;
  5376. this._markAsDirty();
  5377. },
  5378. enumerable: true,
  5379. configurable: true
  5380. });
  5381. Object.defineProperty(DisplayGrid.prototype, "background", {
  5382. /** Gets or sets background color (Black by default) */
  5383. get: function () {
  5384. return this._background;
  5385. },
  5386. set: function (value) {
  5387. if (this._background === value) {
  5388. return;
  5389. }
  5390. this._background = value;
  5391. this._markAsDirty();
  5392. },
  5393. enumerable: true,
  5394. configurable: true
  5395. });
  5396. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5397. /** Gets or sets the width of each cell (20 by default) */
  5398. get: function () {
  5399. return this._cellWidth;
  5400. },
  5401. set: function (value) {
  5402. this._cellWidth = value;
  5403. this._markAsDirty();
  5404. },
  5405. enumerable: true,
  5406. configurable: true
  5407. });
  5408. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5409. /** Gets or sets the height of each cell (20 by default) */
  5410. get: function () {
  5411. return this._cellHeight;
  5412. },
  5413. set: function (value) {
  5414. this._cellHeight = value;
  5415. this._markAsDirty();
  5416. },
  5417. enumerable: true,
  5418. configurable: true
  5419. });
  5420. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5421. /** Gets or sets the tickness of minor lines (1 by default) */
  5422. get: function () {
  5423. return this._minorLineTickness;
  5424. },
  5425. set: function (value) {
  5426. this._minorLineTickness = value;
  5427. this._markAsDirty();
  5428. },
  5429. enumerable: true,
  5430. configurable: true
  5431. });
  5432. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5433. /** Gets or sets the color of minor lines (DarkGray by default) */
  5434. get: function () {
  5435. return this._minorLineColor;
  5436. },
  5437. set: function (value) {
  5438. this._minorLineColor = value;
  5439. this._markAsDirty();
  5440. },
  5441. enumerable: true,
  5442. configurable: true
  5443. });
  5444. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5445. /** Gets or sets the tickness of major lines (2 by default) */
  5446. get: function () {
  5447. return this._majorLineTickness;
  5448. },
  5449. set: function (value) {
  5450. this._majorLineTickness = value;
  5451. this._markAsDirty();
  5452. },
  5453. enumerable: true,
  5454. configurable: true
  5455. });
  5456. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5457. /** Gets or sets the color of major lines (White by default) */
  5458. get: function () {
  5459. return this._majorLineColor;
  5460. },
  5461. set: function (value) {
  5462. this._majorLineColor = value;
  5463. this._markAsDirty();
  5464. },
  5465. enumerable: true,
  5466. configurable: true
  5467. });
  5468. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5469. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5470. get: function () {
  5471. return this._majorLineFrequency;
  5472. },
  5473. set: function (value) {
  5474. this._majorLineFrequency = value;
  5475. this._markAsDirty();
  5476. },
  5477. enumerable: true,
  5478. configurable: true
  5479. });
  5480. DisplayGrid.prototype._draw = function (context) {
  5481. context.save();
  5482. this._applyStates(context);
  5483. if (this._isEnabled) {
  5484. if (this._background) {
  5485. context.fillStyle = this._background;
  5486. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5487. }
  5488. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5489. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5490. // Minor lines
  5491. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5492. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5493. if (this._displayMinorLines) {
  5494. context.strokeStyle = this._minorLineColor;
  5495. context.lineWidth = this._minorLineTickness;
  5496. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5497. var cellX = left + x * this.cellWidth;
  5498. context.beginPath();
  5499. context.moveTo(cellX, this._currentMeasure.top);
  5500. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5501. context.stroke();
  5502. }
  5503. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5504. var cellY = top_1 + y * this.cellHeight;
  5505. context.beginPath();
  5506. context.moveTo(this._currentMeasure.left, cellY);
  5507. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5508. context.stroke();
  5509. }
  5510. }
  5511. // Major lines
  5512. if (this._displayMajorLines) {
  5513. context.strokeStyle = this._majorLineColor;
  5514. context.lineWidth = this._majorLineTickness;
  5515. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5516. var cellX = left + x * this.cellWidth;
  5517. context.beginPath();
  5518. context.moveTo(cellX, this._currentMeasure.top);
  5519. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5520. context.stroke();
  5521. }
  5522. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5523. var cellY = top_1 + y * this.cellHeight;
  5524. context.moveTo(this._currentMeasure.left, cellY);
  5525. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5526. context.closePath();
  5527. context.stroke();
  5528. }
  5529. }
  5530. }
  5531. context.restore();
  5532. };
  5533. DisplayGrid.prototype._getTypeName = function () {
  5534. return "DisplayGrid";
  5535. };
  5536. return DisplayGrid;
  5537. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5538. /***/ }),
  5539. /***/ "./2D/controls/ellipse.ts":
  5540. /*!********************************!*\
  5541. !*** ./2D/controls/ellipse.ts ***!
  5542. \********************************/
  5543. /*! exports provided: Ellipse */
  5544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5545. "use strict";
  5546. __webpack_require__.r(__webpack_exports__);
  5547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5548. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5549. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5550. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5551. /** Class used to create 2D ellipse containers */
  5552. var Ellipse = /** @class */ (function (_super) {
  5553. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5554. /**
  5555. * Creates a new Ellipse
  5556. * @param name defines the control name
  5557. */
  5558. function Ellipse(name) {
  5559. var _this = _super.call(this, name) || this;
  5560. _this.name = name;
  5561. _this._thickness = 1;
  5562. return _this;
  5563. }
  5564. Object.defineProperty(Ellipse.prototype, "thickness", {
  5565. /** Gets or sets border thickness */
  5566. get: function () {
  5567. return this._thickness;
  5568. },
  5569. set: function (value) {
  5570. if (this._thickness === value) {
  5571. return;
  5572. }
  5573. this._thickness = value;
  5574. this._markAsDirty();
  5575. },
  5576. enumerable: true,
  5577. configurable: true
  5578. });
  5579. Ellipse.prototype._getTypeName = function () {
  5580. return "Ellipse";
  5581. };
  5582. Ellipse.prototype._localDraw = function (context) {
  5583. context.save();
  5584. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5585. context.shadowColor = this.shadowColor;
  5586. context.shadowBlur = this.shadowBlur;
  5587. context.shadowOffsetX = this.shadowOffsetX;
  5588. context.shadowOffsetY = this.shadowOffsetY;
  5589. }
  5590. _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);
  5591. if (this._background) {
  5592. context.fillStyle = this._background;
  5593. context.fill();
  5594. }
  5595. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5596. context.shadowBlur = 0;
  5597. context.shadowOffsetX = 0;
  5598. context.shadowOffsetY = 0;
  5599. }
  5600. if (this._thickness) {
  5601. if (this.color) {
  5602. context.strokeStyle = this.color;
  5603. }
  5604. context.lineWidth = this._thickness;
  5605. context.stroke();
  5606. }
  5607. context.restore();
  5608. };
  5609. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5610. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5611. this._measureForChildren.width -= 2 * this._thickness;
  5612. this._measureForChildren.height -= 2 * this._thickness;
  5613. this._measureForChildren.left += this._thickness;
  5614. this._measureForChildren.top += this._thickness;
  5615. };
  5616. Ellipse.prototype._clipForChildren = function (context) {
  5617. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2, this._currentMeasure.height / 2, context);
  5618. context.clip();
  5619. };
  5620. return Ellipse;
  5621. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5622. /***/ }),
  5623. /***/ "./2D/controls/grid.ts":
  5624. /*!*****************************!*\
  5625. !*** ./2D/controls/grid.ts ***!
  5626. \*****************************/
  5627. /*! exports provided: Grid */
  5628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5629. "use strict";
  5630. __webpack_require__.r(__webpack_exports__);
  5631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5632. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5633. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5634. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5635. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5636. /**
  5637. * Class used to create a 2D grid container
  5638. */
  5639. var Grid = /** @class */ (function (_super) {
  5640. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5641. /**
  5642. * Creates a new Grid
  5643. * @param name defines control name
  5644. */
  5645. function Grid(name) {
  5646. var _this = _super.call(this, name) || this;
  5647. _this.name = name;
  5648. _this._rowDefinitions = new Array();
  5649. _this._columnDefinitions = new Array();
  5650. _this._cells = {};
  5651. _this._childControls = new Array();
  5652. return _this;
  5653. }
  5654. Object.defineProperty(Grid.prototype, "columnCount", {
  5655. /**
  5656. * Gets the number of columns
  5657. */
  5658. get: function () {
  5659. return this._columnDefinitions.length;
  5660. },
  5661. enumerable: true,
  5662. configurable: true
  5663. });
  5664. Object.defineProperty(Grid.prototype, "rowCount", {
  5665. /**
  5666. * Gets the number of rows
  5667. */
  5668. get: function () {
  5669. return this._rowDefinitions.length;
  5670. },
  5671. enumerable: true,
  5672. configurable: true
  5673. });
  5674. Object.defineProperty(Grid.prototype, "children", {
  5675. /** Gets the list of children */
  5676. get: function () {
  5677. return this._childControls;
  5678. },
  5679. enumerable: true,
  5680. configurable: true
  5681. });
  5682. /**
  5683. * Gets the definition of a specific row
  5684. * @param index defines the index of the row
  5685. * @returns the row definition
  5686. */
  5687. Grid.prototype.getRowDefinition = function (index) {
  5688. if (index < 0 || index >= this._rowDefinitions.length) {
  5689. return null;
  5690. }
  5691. return this._rowDefinitions[index];
  5692. };
  5693. /**
  5694. * Gets the definition of a specific column
  5695. * @param index defines the index of the column
  5696. * @returns the column definition
  5697. */
  5698. Grid.prototype.getColumnDefinition = function (index) {
  5699. if (index < 0 || index >= this._columnDefinitions.length) {
  5700. return null;
  5701. }
  5702. return this._columnDefinitions[index];
  5703. };
  5704. /**
  5705. * Adds a new row to the grid
  5706. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5707. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5708. * @returns the current grid
  5709. */
  5710. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5711. if (isPixel === void 0) { isPixel = false; }
  5712. 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));
  5713. this._markAsDirty();
  5714. return this;
  5715. };
  5716. /**
  5717. * Adds a new column to the grid
  5718. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5719. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5720. * @returns the current grid
  5721. */
  5722. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5723. if (isPixel === void 0) { isPixel = false; }
  5724. 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));
  5725. this._markAsDirty();
  5726. return this;
  5727. };
  5728. /**
  5729. * Update a row definition
  5730. * @param index defines the index of the row to update
  5731. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5732. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5733. * @returns the current grid
  5734. */
  5735. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5736. if (isPixel === void 0) { isPixel = false; }
  5737. if (index < 0 || index >= this._rowDefinitions.length) {
  5738. return this;
  5739. }
  5740. var current = this._rowDefinitions[index];
  5741. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5742. return this;
  5743. }
  5744. 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);
  5745. this._markAsDirty();
  5746. return this;
  5747. };
  5748. /**
  5749. * Update a column definition
  5750. * @param index defines the index of the column to update
  5751. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5752. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5753. * @returns the current grid
  5754. */
  5755. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5756. if (isPixel === void 0) { isPixel = false; }
  5757. if (index < 0 || index >= this._columnDefinitions.length) {
  5758. return this;
  5759. }
  5760. var current = this._columnDefinitions[index];
  5761. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5762. return this;
  5763. }
  5764. 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);
  5765. this._markAsDirty();
  5766. return this;
  5767. };
  5768. /**
  5769. * Gets the list of children stored in a specific cell
  5770. * @param row defines the row to check
  5771. * @param column defines the column to check
  5772. * @returns the list of controls
  5773. */
  5774. Grid.prototype.getChildrenAt = function (row, column) {
  5775. var cell = this._cells[row + ":" + column];
  5776. if (!cell) {
  5777. return null;
  5778. }
  5779. return cell.children;
  5780. };
  5781. /**
  5782. * Gets a string representing the child cell info (row x column)
  5783. * @param child defines the control to get info from
  5784. * @returns a string containing the child cell info (row x column)
  5785. */
  5786. Grid.prototype.getChildCellInfo = function (child) {
  5787. return child._tag;
  5788. };
  5789. Grid.prototype._removeCell = function (cell, key) {
  5790. if (!cell) {
  5791. return;
  5792. }
  5793. _super.prototype.removeControl.call(this, cell);
  5794. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5795. var control = _a[_i];
  5796. var childIndex = this._childControls.indexOf(control);
  5797. if (childIndex !== -1) {
  5798. this._childControls.splice(childIndex, 1);
  5799. }
  5800. }
  5801. delete this._cells[key];
  5802. };
  5803. Grid.prototype._offsetCell = function (previousKey, key) {
  5804. if (!this._cells[key]) {
  5805. return;
  5806. }
  5807. this._cells[previousKey] = this._cells[key];
  5808. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5809. var control = _a[_i];
  5810. control._tag = previousKey;
  5811. }
  5812. delete this._cells[key];
  5813. };
  5814. /**
  5815. * Remove a column definition at specified index
  5816. * @param index defines the index of the column to remove
  5817. * @returns the current grid
  5818. */
  5819. Grid.prototype.removeColumnDefinition = function (index) {
  5820. if (index < 0 || index >= this._columnDefinitions.length) {
  5821. return this;
  5822. }
  5823. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5824. var key = x + ":" + index;
  5825. var cell = this._cells[key];
  5826. this._removeCell(cell, key);
  5827. }
  5828. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5829. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5830. var previousKey = x + ":" + (y - 1);
  5831. var key = x + ":" + y;
  5832. this._offsetCell(previousKey, key);
  5833. }
  5834. }
  5835. this._columnDefinitions.splice(index, 1);
  5836. this._markAsDirty();
  5837. return this;
  5838. };
  5839. /**
  5840. * Remove a row definition at specified index
  5841. * @param index defines the index of the row to remove
  5842. * @returns the current grid
  5843. */
  5844. Grid.prototype.removeRowDefinition = function (index) {
  5845. if (index < 0 || index >= this._rowDefinitions.length) {
  5846. return this;
  5847. }
  5848. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5849. var key = index + ":" + y;
  5850. var cell = this._cells[key];
  5851. this._removeCell(cell, key);
  5852. }
  5853. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5854. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5855. var previousKey = x - 1 + ":" + y;
  5856. var key = x + ":" + y;
  5857. this._offsetCell(previousKey, key);
  5858. }
  5859. }
  5860. this._rowDefinitions.splice(index, 1);
  5861. this._markAsDirty();
  5862. return this;
  5863. };
  5864. /**
  5865. * Adds a new control to the current grid
  5866. * @param control defines the control to add
  5867. * @param row defines the row where to add the control (0 by default)
  5868. * @param column defines the column where to add the control (0 by default)
  5869. * @returns the current grid
  5870. */
  5871. Grid.prototype.addControl = function (control, row, column) {
  5872. if (row === void 0) { row = 0; }
  5873. if (column === void 0) { column = 0; }
  5874. if (this._rowDefinitions.length === 0) {
  5875. // Add default row definition
  5876. this.addRowDefinition(1, false);
  5877. }
  5878. if (this._columnDefinitions.length === 0) {
  5879. // Add default column definition
  5880. this.addColumnDefinition(1, false);
  5881. }
  5882. var x = Math.min(row, this._rowDefinitions.length - 1);
  5883. var y = Math.min(column, this._columnDefinitions.length - 1);
  5884. var key = x + ":" + y;
  5885. var goodContainer = this._cells[key];
  5886. if (!goodContainer) {
  5887. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5888. this._cells[key] = goodContainer;
  5889. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5890. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5891. _super.prototype.addControl.call(this, goodContainer);
  5892. }
  5893. goodContainer.addControl(control);
  5894. this._childControls.push(control);
  5895. control._tag = key;
  5896. control.parent = this;
  5897. this._markAsDirty();
  5898. return this;
  5899. };
  5900. /**
  5901. * Removes a control from the current container
  5902. * @param control defines the control to remove
  5903. * @returns the current container
  5904. */
  5905. Grid.prototype.removeControl = function (control) {
  5906. var index = this._childControls.indexOf(control);
  5907. if (index !== -1) {
  5908. this._childControls.splice(index, 1);
  5909. }
  5910. var cell = this._cells[control._tag];
  5911. if (cell) {
  5912. cell.removeControl(control);
  5913. }
  5914. this._markAsDirty();
  5915. return this;
  5916. };
  5917. Grid.prototype._getTypeName = function () {
  5918. return "Grid";
  5919. };
  5920. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5921. var widths = [];
  5922. var heights = [];
  5923. var lefts = [];
  5924. var tops = [];
  5925. var availableWidth = this._currentMeasure.width;
  5926. var globalWidthPercentage = 0;
  5927. var availableHeight = this._currentMeasure.height;
  5928. var globalHeightPercentage = 0;
  5929. // Heights
  5930. var index = 0;
  5931. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5932. var value = _a[_i];
  5933. if (value.isPixel) {
  5934. var height = value.getValue(this._host);
  5935. availableHeight -= height;
  5936. heights[index] = height;
  5937. }
  5938. else {
  5939. globalHeightPercentage += value.internalValue;
  5940. }
  5941. index++;
  5942. }
  5943. var top = 0;
  5944. index = 0;
  5945. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  5946. var value = _c[_b];
  5947. tops.push(top);
  5948. if (!value.isPixel) {
  5949. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  5950. top += height;
  5951. heights[index] = height;
  5952. }
  5953. else {
  5954. top += value.getValue(this._host);
  5955. }
  5956. index++;
  5957. }
  5958. // Widths
  5959. index = 0;
  5960. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  5961. var value = _e[_d];
  5962. if (value.isPixel) {
  5963. var width = value.getValue(this._host);
  5964. availableWidth -= width;
  5965. widths[index] = width;
  5966. }
  5967. else {
  5968. globalWidthPercentage += value.internalValue;
  5969. }
  5970. index++;
  5971. }
  5972. var left = 0;
  5973. index = 0;
  5974. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  5975. var value = _g[_f];
  5976. lefts.push(left);
  5977. if (!value.isPixel) {
  5978. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  5979. left += width;
  5980. widths[index] = width;
  5981. }
  5982. else {
  5983. left += value.getValue(this._host);
  5984. }
  5985. index++;
  5986. }
  5987. definitionCallback(lefts, tops, widths, heights);
  5988. };
  5989. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  5990. var _this = this;
  5991. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  5992. // Setting child sizes
  5993. for (var key in _this._cells) {
  5994. if (!_this._cells.hasOwnProperty(key)) {
  5995. continue;
  5996. }
  5997. var split = key.split(":");
  5998. var x = parseInt(split[0]);
  5999. var y = parseInt(split[1]);
  6000. var cell = _this._cells[key];
  6001. cell.left = lefts[y] + "px";
  6002. cell.top = tops[x] + "px";
  6003. cell.width = widths[y] + "px";
  6004. cell.height = heights[x] + "px";
  6005. }
  6006. });
  6007. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6008. };
  6009. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6010. for (var key in this._cells) {
  6011. if (!this._cells.hasOwnProperty(key)) {
  6012. continue;
  6013. }
  6014. var child = this._cells[key];
  6015. child._markMatrixAsDirty();
  6016. }
  6017. };
  6018. Grid.prototype._renderHighlightSpecific = function (context) {
  6019. var _this = this;
  6020. _super.prototype._renderHighlightSpecific.call(this, context);
  6021. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6022. // Columns
  6023. for (var index = 0; index < lefts.length; index++) {
  6024. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6025. context.beginPath();
  6026. context.moveTo(left, _this._currentMeasure.top);
  6027. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6028. context.stroke();
  6029. }
  6030. // Rows
  6031. for (var index = 0; index < tops.length; index++) {
  6032. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6033. context.beginPath();
  6034. context.moveTo(_this._currentMeasure.left, top_1);
  6035. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6036. context.stroke();
  6037. }
  6038. });
  6039. context.restore();
  6040. };
  6041. /** Releases associated resources */
  6042. Grid.prototype.dispose = function () {
  6043. _super.prototype.dispose.call(this);
  6044. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6045. var control = _a[_i];
  6046. control.dispose();
  6047. }
  6048. this._childControls = [];
  6049. };
  6050. return Grid;
  6051. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6052. /***/ }),
  6053. /***/ "./2D/controls/image.ts":
  6054. /*!******************************!*\
  6055. !*** ./2D/controls/image.ts ***!
  6056. \******************************/
  6057. /*! exports provided: Image */
  6058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6059. "use strict";
  6060. __webpack_require__.r(__webpack_exports__);
  6061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6062. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6063. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6064. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6065. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6066. /**
  6067. * Class used to create 2D images
  6068. */
  6069. var Image = /** @class */ (function (_super) {
  6070. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6071. /**
  6072. * Creates a new Image
  6073. * @param name defines the control name
  6074. * @param url defines the image url
  6075. */
  6076. function Image(name, url) {
  6077. if (url === void 0) { url = null; }
  6078. var _this = _super.call(this, name) || this;
  6079. _this.name = name;
  6080. _this._loaded = false;
  6081. _this._stretch = Image.STRETCH_FILL;
  6082. _this._autoScale = false;
  6083. _this._sourceLeft = 0;
  6084. _this._sourceTop = 0;
  6085. _this._sourceWidth = 0;
  6086. _this._sourceHeight = 0;
  6087. _this._cellWidth = 0;
  6088. _this._cellHeight = 0;
  6089. _this._cellId = -1;
  6090. _this._populateNinePatchSlicesFromImage = false;
  6091. /**
  6092. * Observable notified when the content is loaded
  6093. */
  6094. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6095. _this.source = url;
  6096. return _this;
  6097. }
  6098. Object.defineProperty(Image.prototype, "isLoaded", {
  6099. /**
  6100. * Gets a boolean indicating that the content is loaded
  6101. */
  6102. get: function () {
  6103. return this._loaded;
  6104. },
  6105. enumerable: true,
  6106. configurable: true
  6107. });
  6108. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6109. /**
  6110. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6111. */
  6112. get: function () {
  6113. return this._populateNinePatchSlicesFromImage;
  6114. },
  6115. set: function (value) {
  6116. if (this._populateNinePatchSlicesFromImage === value) {
  6117. return;
  6118. }
  6119. this._populateNinePatchSlicesFromImage = value;
  6120. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6121. this._extractNinePatchSliceDataFromImage();
  6122. }
  6123. },
  6124. enumerable: true,
  6125. configurable: true
  6126. });
  6127. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6128. /**
  6129. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6130. * Beware using this as this will comsume more memory as the image has to be stored twice
  6131. */
  6132. get: function () {
  6133. return this._detectPointerOnOpaqueOnly;
  6134. },
  6135. set: function (value) {
  6136. if (this._detectPointerOnOpaqueOnly === value) {
  6137. return;
  6138. }
  6139. this._detectPointerOnOpaqueOnly = value;
  6140. },
  6141. enumerable: true,
  6142. configurable: true
  6143. });
  6144. Object.defineProperty(Image.prototype, "sliceLeft", {
  6145. /**
  6146. * Gets or sets the left value for slicing (9-patch)
  6147. */
  6148. get: function () {
  6149. return this._sliceLeft;
  6150. },
  6151. set: function (value) {
  6152. if (this._sliceLeft === value) {
  6153. return;
  6154. }
  6155. this._sliceLeft = value;
  6156. this._markAsDirty();
  6157. },
  6158. enumerable: true,
  6159. configurable: true
  6160. });
  6161. Object.defineProperty(Image.prototype, "sliceRight", {
  6162. /**
  6163. * Gets or sets the right value for slicing (9-patch)
  6164. */
  6165. get: function () {
  6166. return this._sliceRight;
  6167. },
  6168. set: function (value) {
  6169. if (this._sliceRight === value) {
  6170. return;
  6171. }
  6172. this._sliceRight = value;
  6173. this._markAsDirty();
  6174. },
  6175. enumerable: true,
  6176. configurable: true
  6177. });
  6178. Object.defineProperty(Image.prototype, "sliceTop", {
  6179. /**
  6180. * Gets or sets the top value for slicing (9-patch)
  6181. */
  6182. get: function () {
  6183. return this._sliceTop;
  6184. },
  6185. set: function (value) {
  6186. if (this._sliceTop === value) {
  6187. return;
  6188. }
  6189. this._sliceTop = value;
  6190. this._markAsDirty();
  6191. },
  6192. enumerable: true,
  6193. configurable: true
  6194. });
  6195. Object.defineProperty(Image.prototype, "sliceBottom", {
  6196. /**
  6197. * Gets or sets the bottom value for slicing (9-patch)
  6198. */
  6199. get: function () {
  6200. return this._sliceBottom;
  6201. },
  6202. set: function (value) {
  6203. if (this._sliceBottom === value) {
  6204. return;
  6205. }
  6206. this._sliceBottom = value;
  6207. this._markAsDirty();
  6208. },
  6209. enumerable: true,
  6210. configurable: true
  6211. });
  6212. Object.defineProperty(Image.prototype, "sourceLeft", {
  6213. /**
  6214. * Gets or sets the left coordinate in the source image
  6215. */
  6216. get: function () {
  6217. return this._sourceLeft;
  6218. },
  6219. set: function (value) {
  6220. if (this._sourceLeft === value) {
  6221. return;
  6222. }
  6223. this._sourceLeft = value;
  6224. this._markAsDirty();
  6225. },
  6226. enumerable: true,
  6227. configurable: true
  6228. });
  6229. Object.defineProperty(Image.prototype, "sourceTop", {
  6230. /**
  6231. * Gets or sets the top coordinate in the source image
  6232. */
  6233. get: function () {
  6234. return this._sourceTop;
  6235. },
  6236. set: function (value) {
  6237. if (this._sourceTop === value) {
  6238. return;
  6239. }
  6240. this._sourceTop = value;
  6241. this._markAsDirty();
  6242. },
  6243. enumerable: true,
  6244. configurable: true
  6245. });
  6246. Object.defineProperty(Image.prototype, "sourceWidth", {
  6247. /**
  6248. * Gets or sets the width to capture in the source image
  6249. */
  6250. get: function () {
  6251. return this._sourceWidth;
  6252. },
  6253. set: function (value) {
  6254. if (this._sourceWidth === value) {
  6255. return;
  6256. }
  6257. this._sourceWidth = value;
  6258. this._markAsDirty();
  6259. },
  6260. enumerable: true,
  6261. configurable: true
  6262. });
  6263. Object.defineProperty(Image.prototype, "sourceHeight", {
  6264. /**
  6265. * Gets or sets the height to capture in the source image
  6266. */
  6267. get: function () {
  6268. return this._sourceHeight;
  6269. },
  6270. set: function (value) {
  6271. if (this._sourceHeight === value) {
  6272. return;
  6273. }
  6274. this._sourceHeight = value;
  6275. this._markAsDirty();
  6276. },
  6277. enumerable: true,
  6278. configurable: true
  6279. });
  6280. Object.defineProperty(Image.prototype, "autoScale", {
  6281. /**
  6282. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6283. * @see http://doc.babylonjs.com/how_to/gui#image
  6284. */
  6285. get: function () {
  6286. return this._autoScale;
  6287. },
  6288. set: function (value) {
  6289. if (this._autoScale === value) {
  6290. return;
  6291. }
  6292. this._autoScale = value;
  6293. if (value && this._loaded) {
  6294. this.synchronizeSizeWithContent();
  6295. }
  6296. },
  6297. enumerable: true,
  6298. configurable: true
  6299. });
  6300. Object.defineProperty(Image.prototype, "stretch", {
  6301. /** Gets or sets the streching mode used by the image */
  6302. get: function () {
  6303. return this._stretch;
  6304. },
  6305. set: function (value) {
  6306. if (this._stretch === value) {
  6307. return;
  6308. }
  6309. this._stretch = value;
  6310. this._markAsDirty();
  6311. },
  6312. enumerable: true,
  6313. configurable: true
  6314. });
  6315. Object.defineProperty(Image.prototype, "domImage", {
  6316. get: function () {
  6317. return this._domImage;
  6318. },
  6319. /**
  6320. * Gets or sets the internal DOM image used to render the control
  6321. */
  6322. set: function (value) {
  6323. var _this = this;
  6324. this._domImage = value;
  6325. this._loaded = false;
  6326. if (this._domImage.width) {
  6327. this._onImageLoaded();
  6328. }
  6329. else {
  6330. this._domImage.onload = function () {
  6331. _this._onImageLoaded();
  6332. };
  6333. }
  6334. },
  6335. enumerable: true,
  6336. configurable: true
  6337. });
  6338. Image.prototype._onImageLoaded = function () {
  6339. this._imageWidth = this._domImage.width;
  6340. this._imageHeight = this._domImage.height;
  6341. this._loaded = true;
  6342. if (this._populateNinePatchSlicesFromImage) {
  6343. this._extractNinePatchSliceDataFromImage();
  6344. }
  6345. if (this._autoScale) {
  6346. this.synchronizeSizeWithContent();
  6347. }
  6348. this.onImageLoadedObservable.notifyObservers(this);
  6349. this._markAsDirty();
  6350. };
  6351. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6352. if (!Image._WorkingCanvas) {
  6353. Image._WorkingCanvas = document.createElement('canvas');
  6354. }
  6355. var canvas = Image._WorkingCanvas;
  6356. var context = canvas.getContext('2d');
  6357. var width = this._domImage.width;
  6358. var height = this._domImage.height;
  6359. canvas.width = width;
  6360. canvas.height = height;
  6361. context.drawImage(this._domImage, 0, 0, width, height);
  6362. var imageData = context.getImageData(0, 0, width, height);
  6363. // Left and right
  6364. this._sliceLeft = -1;
  6365. this._sliceRight = -1;
  6366. for (var x = 0; x < width; x++) {
  6367. var alpha = imageData.data[x * 4 + 3];
  6368. if (alpha > 127 && this._sliceLeft === -1) {
  6369. this._sliceLeft = x;
  6370. continue;
  6371. }
  6372. if (alpha < 127 && this._sliceLeft > -1) {
  6373. this._sliceRight = x;
  6374. break;
  6375. }
  6376. }
  6377. // top and bottom
  6378. this._sliceTop = -1;
  6379. this._sliceBottom = -1;
  6380. for (var y = 0; y < height; y++) {
  6381. var alpha = imageData.data[y * width * 4 + 3];
  6382. if (alpha > 127 && this._sliceTop === -1) {
  6383. this._sliceTop = y;
  6384. continue;
  6385. }
  6386. if (alpha < 127 && this._sliceTop > -1) {
  6387. this._sliceBottom = y;
  6388. break;
  6389. }
  6390. }
  6391. };
  6392. Object.defineProperty(Image.prototype, "source", {
  6393. /**
  6394. * Gets or sets image source url
  6395. */
  6396. set: function (value) {
  6397. var _this = this;
  6398. if (this._source === value) {
  6399. return;
  6400. }
  6401. this._loaded = false;
  6402. this._source = value;
  6403. this._domImage = document.createElement("img");
  6404. this._domImage.onload = function () {
  6405. _this._onImageLoaded();
  6406. };
  6407. if (value) {
  6408. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6409. this._domImage.src = value;
  6410. }
  6411. },
  6412. enumerable: true,
  6413. configurable: true
  6414. });
  6415. Object.defineProperty(Image.prototype, "cellWidth", {
  6416. /**
  6417. * Gets or sets the cell width to use when animation sheet is enabled
  6418. * @see http://doc.babylonjs.com/how_to/gui#image
  6419. */
  6420. get: function () {
  6421. return this._cellWidth;
  6422. },
  6423. set: function (value) {
  6424. if (this._cellWidth === value) {
  6425. return;
  6426. }
  6427. this._cellWidth = value;
  6428. this._markAsDirty();
  6429. },
  6430. enumerable: true,
  6431. configurable: true
  6432. });
  6433. Object.defineProperty(Image.prototype, "cellHeight", {
  6434. /**
  6435. * Gets or sets the cell height to use when animation sheet is enabled
  6436. * @see http://doc.babylonjs.com/how_to/gui#image
  6437. */
  6438. get: function () {
  6439. return this._cellHeight;
  6440. },
  6441. set: function (value) {
  6442. if (this._cellHeight === value) {
  6443. return;
  6444. }
  6445. this._cellHeight = value;
  6446. this._markAsDirty();
  6447. },
  6448. enumerable: true,
  6449. configurable: true
  6450. });
  6451. Object.defineProperty(Image.prototype, "cellId", {
  6452. /**
  6453. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6454. * @see http://doc.babylonjs.com/how_to/gui#image
  6455. */
  6456. get: function () {
  6457. return this._cellId;
  6458. },
  6459. set: function (value) {
  6460. if (this._cellId === value) {
  6461. return;
  6462. }
  6463. this._cellId = value;
  6464. this._markAsDirty();
  6465. },
  6466. enumerable: true,
  6467. configurable: true
  6468. });
  6469. /**
  6470. * Tests if a given coordinates belong to the current control
  6471. * @param x defines x coordinate to test
  6472. * @param y defines y coordinate to test
  6473. * @returns true if the coordinates are inside the control
  6474. */
  6475. Image.prototype.contains = function (x, y) {
  6476. if (!_super.prototype.contains.call(this, x, y)) {
  6477. return false;
  6478. }
  6479. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6480. return true;
  6481. }
  6482. var canvas = Image._WorkingCanvas;
  6483. var context = canvas.getContext("2d");
  6484. var width = this._currentMeasure.width | 0;
  6485. var height = this._currentMeasure.height | 0;
  6486. var imageData = context.getImageData(0, 0, width, height).data;
  6487. x = (x - this._currentMeasure.left) | 0;
  6488. y = (y - this._currentMeasure.top) | 0;
  6489. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6490. return pickedPixel > 0;
  6491. };
  6492. Image.prototype._getTypeName = function () {
  6493. return "Image";
  6494. };
  6495. /** Force the control to synchronize with its content */
  6496. Image.prototype.synchronizeSizeWithContent = function () {
  6497. if (!this._loaded) {
  6498. return;
  6499. }
  6500. this.width = this._domImage.width + "px";
  6501. this.height = this._domImage.height + "px";
  6502. };
  6503. Image.prototype._processMeasures = function (parentMeasure, context) {
  6504. if (this._loaded) {
  6505. switch (this._stretch) {
  6506. case Image.STRETCH_NONE:
  6507. break;
  6508. case Image.STRETCH_FILL:
  6509. break;
  6510. case Image.STRETCH_UNIFORM:
  6511. break;
  6512. case Image.STRETCH_NINE_PATCH:
  6513. break;
  6514. case Image.STRETCH_EXTEND:
  6515. if (this._autoScale) {
  6516. this.synchronizeSizeWithContent();
  6517. }
  6518. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6519. this.parent.adaptWidthToChildren = true;
  6520. this.parent.adaptHeightToChildren = true;
  6521. }
  6522. break;
  6523. }
  6524. }
  6525. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6526. };
  6527. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6528. if (!this._detectPointerOnOpaqueOnly) {
  6529. return;
  6530. }
  6531. if (!Image._WorkingCanvas) {
  6532. Image._WorkingCanvas = document.createElement('canvas');
  6533. }
  6534. var canvas = Image._WorkingCanvas;
  6535. var width = this._currentMeasure.width;
  6536. var height = this._currentMeasure.height;
  6537. var context = canvas.getContext("2d");
  6538. canvas.width = width;
  6539. canvas.height = height;
  6540. context.clearRect(0, 0, width, height);
  6541. };
  6542. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6543. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6544. if (!this._detectPointerOnOpaqueOnly) {
  6545. return;
  6546. }
  6547. var canvas = Image._WorkingCanvas;
  6548. context = canvas.getContext("2d");
  6549. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6550. };
  6551. Image.prototype._draw = function (context) {
  6552. context.save();
  6553. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6554. context.shadowColor = this.shadowColor;
  6555. context.shadowBlur = this.shadowBlur;
  6556. context.shadowOffsetX = this.shadowOffsetX;
  6557. context.shadowOffsetY = this.shadowOffsetY;
  6558. }
  6559. var x, y, width, height;
  6560. if (this.cellId == -1) {
  6561. x = this._sourceLeft;
  6562. y = this._sourceTop;
  6563. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6564. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6565. }
  6566. else {
  6567. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6568. var column = (this.cellId / rowCount) >> 0;
  6569. var row = this.cellId % rowCount;
  6570. x = this.cellWidth * row;
  6571. y = this.cellHeight * column;
  6572. width = this.cellWidth;
  6573. height = this.cellHeight;
  6574. }
  6575. this._prepareWorkingCanvasForOpaqueDetection();
  6576. this._applyStates(context);
  6577. if (this._loaded) {
  6578. switch (this._stretch) {
  6579. case Image.STRETCH_NONE:
  6580. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6581. break;
  6582. case Image.STRETCH_FILL:
  6583. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6584. break;
  6585. case Image.STRETCH_UNIFORM:
  6586. var hRatio = this._currentMeasure.width / width;
  6587. var vRatio = this._currentMeasure.height / height;
  6588. var ratio = Math.min(hRatio, vRatio);
  6589. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6590. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6591. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6592. break;
  6593. case Image.STRETCH_EXTEND:
  6594. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6595. break;
  6596. case Image.STRETCH_NINE_PATCH:
  6597. this._renderNinePatch(context);
  6598. break;
  6599. }
  6600. }
  6601. context.restore();
  6602. };
  6603. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6604. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6605. };
  6606. Image.prototype._renderNinePatch = function (context) {
  6607. var height = this._imageHeight;
  6608. var leftWidth = this._sliceLeft;
  6609. var topHeight = this._sliceTop;
  6610. var bottomHeight = this._imageHeight - this._sliceBottom;
  6611. var rightWidth = this._imageWidth - this._sliceRight;
  6612. var left = 0;
  6613. var top = 0;
  6614. if (this._populateNinePatchSlicesFromImage) {
  6615. left = 1;
  6616. top = 1;
  6617. height -= 2;
  6618. leftWidth -= 1;
  6619. topHeight -= 1;
  6620. bottomHeight -= 1;
  6621. rightWidth -= 1;
  6622. }
  6623. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6624. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6625. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6626. // Corners
  6627. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6628. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6629. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6630. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6631. // Center
  6632. 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);
  6633. // Borders
  6634. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6635. 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);
  6636. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6637. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6638. };
  6639. Image.prototype.dispose = function () {
  6640. _super.prototype.dispose.call(this);
  6641. this.onImageLoadedObservable.clear();
  6642. };
  6643. Image._WorkingCanvas = null;
  6644. // Static
  6645. /** STRETCH_NONE */
  6646. Image.STRETCH_NONE = 0;
  6647. /** STRETCH_FILL */
  6648. Image.STRETCH_FILL = 1;
  6649. /** STRETCH_UNIFORM */
  6650. Image.STRETCH_UNIFORM = 2;
  6651. /** STRETCH_EXTEND */
  6652. Image.STRETCH_EXTEND = 3;
  6653. /** NINE_PATCH */
  6654. Image.STRETCH_NINE_PATCH = 4;
  6655. return Image;
  6656. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6657. /***/ }),
  6658. /***/ "./2D/controls/index.ts":
  6659. /*!******************************!*\
  6660. !*** ./2D/controls/index.ts ***!
  6661. \******************************/
  6662. /*! 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 */
  6663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6664. "use strict";
  6665. __webpack_require__.r(__webpack_exports__);
  6666. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6668. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6670. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6672. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6674. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6676. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6678. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6680. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6682. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6684. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6686. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6688. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6690. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6692. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6694. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6700. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6702. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6705. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6708. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6710. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6712. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6714. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6716. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6718. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6720. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6722. /***/ }),
  6723. /***/ "./2D/controls/inputPassword.ts":
  6724. /*!**************************************!*\
  6725. !*** ./2D/controls/inputPassword.ts ***!
  6726. \**************************************/
  6727. /*! exports provided: InputPassword */
  6728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6729. "use strict";
  6730. __webpack_require__.r(__webpack_exports__);
  6731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6732. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6733. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6734. /**
  6735. * Class used to create a password control
  6736. */
  6737. var InputPassword = /** @class */ (function (_super) {
  6738. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6739. function InputPassword() {
  6740. return _super !== null && _super.apply(this, arguments) || this;
  6741. }
  6742. InputPassword.prototype._beforeRenderText = function (text) {
  6743. var txt = "";
  6744. for (var i = 0; i < text.length; i++) {
  6745. txt += "\u2022";
  6746. }
  6747. return txt;
  6748. };
  6749. return InputPassword;
  6750. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6751. /***/ }),
  6752. /***/ "./2D/controls/inputText.ts":
  6753. /*!**********************************!*\
  6754. !*** ./2D/controls/inputText.ts ***!
  6755. \**********************************/
  6756. /*! exports provided: InputText */
  6757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6758. "use strict";
  6759. __webpack_require__.r(__webpack_exports__);
  6760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6762. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6763. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6764. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6765. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6766. /**
  6767. * Class used to create input text control
  6768. */
  6769. var InputText = /** @class */ (function (_super) {
  6770. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6771. /**
  6772. * Creates a new InputText
  6773. * @param name defines the control name
  6774. * @param text defines the text of the control
  6775. */
  6776. function InputText(name, text) {
  6777. if (text === void 0) { text = ""; }
  6778. var _this = _super.call(this, name) || this;
  6779. _this.name = name;
  6780. _this._text = "";
  6781. _this._placeholderText = "";
  6782. _this._background = "#222222";
  6783. _this._focusedBackground = "#000000";
  6784. _this._focusedColor = "white";
  6785. _this._placeholderColor = "gray";
  6786. _this._thickness = 1;
  6787. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6788. _this._autoStretchWidth = true;
  6789. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6790. _this._isFocused = false;
  6791. _this._blinkIsEven = false;
  6792. _this._cursorOffset = 0;
  6793. _this._deadKey = false;
  6794. _this._addKey = true;
  6795. _this._currentKey = "";
  6796. _this._isTextHighlightOn = false;
  6797. _this._textHighlightColor = "#d5e0ff";
  6798. _this._highligherOpacity = 0.4;
  6799. _this._highlightedText = "";
  6800. _this._startHighlightIndex = 0;
  6801. _this._endHighlightIndex = 0;
  6802. _this._cursorIndex = -1;
  6803. _this._onFocusSelectAll = false;
  6804. _this._isPointerDown = false;
  6805. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6806. _this.promptMessage = "Please enter text:";
  6807. /** Observable raised when the text changes */
  6808. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6809. /** Observable raised just before an entered character is to be added */
  6810. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6811. /** Observable raised when the control gets the focus */
  6812. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6813. /** Observable raised when the control loses the focus */
  6814. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6815. /**Observable raised when the text is highlighted */
  6816. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6817. /**Observable raised when copy event is triggered */
  6818. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6819. /** Observable raised when cut event is triggered */
  6820. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6821. /** Observable raised when paste event is triggered */
  6822. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6823. /** Observable raised when a key event was processed */
  6824. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6825. _this.text = text;
  6826. _this.isPointerBlocker = true;
  6827. return _this;
  6828. }
  6829. Object.defineProperty(InputText.prototype, "maxWidth", {
  6830. /** Gets or sets the maximum width allowed by the control */
  6831. get: function () {
  6832. return this._maxWidth.toString(this._host);
  6833. },
  6834. set: function (value) {
  6835. if (this._maxWidth.toString(this._host) === value) {
  6836. return;
  6837. }
  6838. if (this._maxWidth.fromString(value)) {
  6839. this._markAsDirty();
  6840. }
  6841. },
  6842. enumerable: true,
  6843. configurable: true
  6844. });
  6845. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6846. /** Gets the maximum width allowed by the control in pixels */
  6847. get: function () {
  6848. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6849. },
  6850. enumerable: true,
  6851. configurable: true
  6852. });
  6853. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6854. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6855. get: function () {
  6856. return this._highligherOpacity;
  6857. },
  6858. set: function (value) {
  6859. if (this._highligherOpacity === value) {
  6860. return;
  6861. }
  6862. this._highligherOpacity = value;
  6863. this._markAsDirty();
  6864. },
  6865. enumerable: true,
  6866. configurable: true
  6867. });
  6868. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6869. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6870. get: function () {
  6871. return this._onFocusSelectAll;
  6872. },
  6873. set: function (value) {
  6874. if (this._onFocusSelectAll === value) {
  6875. return;
  6876. }
  6877. this._onFocusSelectAll = value;
  6878. this._markAsDirty();
  6879. },
  6880. enumerable: true,
  6881. configurable: true
  6882. });
  6883. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6884. /** Gets or sets the text hightlight color */
  6885. get: function () {
  6886. return this._textHighlightColor;
  6887. },
  6888. set: function (value) {
  6889. if (this._textHighlightColor === value) {
  6890. return;
  6891. }
  6892. this._textHighlightColor = value;
  6893. this._markAsDirty();
  6894. },
  6895. enumerable: true,
  6896. configurable: true
  6897. });
  6898. Object.defineProperty(InputText.prototype, "margin", {
  6899. /** Gets or sets control margin */
  6900. get: function () {
  6901. return this._margin.toString(this._host);
  6902. },
  6903. set: function (value) {
  6904. if (this._margin.toString(this._host) === value) {
  6905. return;
  6906. }
  6907. if (this._margin.fromString(value)) {
  6908. this._markAsDirty();
  6909. }
  6910. },
  6911. enumerable: true,
  6912. configurable: true
  6913. });
  6914. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6915. /** Gets control margin in pixels */
  6916. get: function () {
  6917. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6918. },
  6919. enumerable: true,
  6920. configurable: true
  6921. });
  6922. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6923. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6924. get: function () {
  6925. return this._autoStretchWidth;
  6926. },
  6927. set: function (value) {
  6928. if (this._autoStretchWidth === value) {
  6929. return;
  6930. }
  6931. this._autoStretchWidth = value;
  6932. this._markAsDirty();
  6933. },
  6934. enumerable: true,
  6935. configurable: true
  6936. });
  6937. Object.defineProperty(InputText.prototype, "thickness", {
  6938. /** Gets or sets border thickness */
  6939. get: function () {
  6940. return this._thickness;
  6941. },
  6942. set: function (value) {
  6943. if (this._thickness === value) {
  6944. return;
  6945. }
  6946. this._thickness = value;
  6947. this._markAsDirty();
  6948. },
  6949. enumerable: true,
  6950. configurable: true
  6951. });
  6952. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6953. /** Gets or sets the background color when focused */
  6954. get: function () {
  6955. return this._focusedBackground;
  6956. },
  6957. set: function (value) {
  6958. if (this._focusedBackground === value) {
  6959. return;
  6960. }
  6961. this._focusedBackground = value;
  6962. this._markAsDirty();
  6963. },
  6964. enumerable: true,
  6965. configurable: true
  6966. });
  6967. Object.defineProperty(InputText.prototype, "focusedColor", {
  6968. /** Gets or sets the background color when focused */
  6969. get: function () {
  6970. return this._focusedColor;
  6971. },
  6972. set: function (value) {
  6973. if (this._focusedColor === value) {
  6974. return;
  6975. }
  6976. this._focusedColor = value;
  6977. this._markAsDirty();
  6978. },
  6979. enumerable: true,
  6980. configurable: true
  6981. });
  6982. Object.defineProperty(InputText.prototype, "background", {
  6983. /** Gets or sets the background color */
  6984. get: function () {
  6985. return this._background;
  6986. },
  6987. set: function (value) {
  6988. if (this._background === value) {
  6989. return;
  6990. }
  6991. this._background = value;
  6992. this._markAsDirty();
  6993. },
  6994. enumerable: true,
  6995. configurable: true
  6996. });
  6997. Object.defineProperty(InputText.prototype, "placeholderColor", {
  6998. /** Gets or sets the placeholder color */
  6999. get: function () {
  7000. return this._placeholderColor;
  7001. },
  7002. set: function (value) {
  7003. if (this._placeholderColor === value) {
  7004. return;
  7005. }
  7006. this._placeholderColor = value;
  7007. this._markAsDirty();
  7008. },
  7009. enumerable: true,
  7010. configurable: true
  7011. });
  7012. Object.defineProperty(InputText.prototype, "placeholderText", {
  7013. /** Gets or sets the text displayed when the control is empty */
  7014. get: function () {
  7015. return this._placeholderText;
  7016. },
  7017. set: function (value) {
  7018. if (this._placeholderText === value) {
  7019. return;
  7020. }
  7021. this._placeholderText = value;
  7022. this._markAsDirty();
  7023. },
  7024. enumerable: true,
  7025. configurable: true
  7026. });
  7027. Object.defineProperty(InputText.prototype, "deadKey", {
  7028. /** Gets or sets the dead key flag */
  7029. get: function () {
  7030. return this._deadKey;
  7031. },
  7032. set: function (flag) {
  7033. this._deadKey = flag;
  7034. },
  7035. enumerable: true,
  7036. configurable: true
  7037. });
  7038. Object.defineProperty(InputText.prototype, "highlightedText", {
  7039. /** Gets or sets the highlight text */
  7040. get: function () {
  7041. return this._highlightedText;
  7042. },
  7043. set: function (text) {
  7044. if (this._highlightedText === text) {
  7045. return;
  7046. }
  7047. this._highlightedText = text;
  7048. this._markAsDirty();
  7049. },
  7050. enumerable: true,
  7051. configurable: true
  7052. });
  7053. Object.defineProperty(InputText.prototype, "addKey", {
  7054. /** Gets or sets if the current key should be added */
  7055. get: function () {
  7056. return this._addKey;
  7057. },
  7058. set: function (flag) {
  7059. this._addKey = flag;
  7060. },
  7061. enumerable: true,
  7062. configurable: true
  7063. });
  7064. Object.defineProperty(InputText.prototype, "currentKey", {
  7065. /** Gets or sets the value of the current key being entered */
  7066. get: function () {
  7067. return this._currentKey;
  7068. },
  7069. set: function (key) {
  7070. this._currentKey = key;
  7071. },
  7072. enumerable: true,
  7073. configurable: true
  7074. });
  7075. Object.defineProperty(InputText.prototype, "text", {
  7076. /** Gets or sets the text displayed in the control */
  7077. get: function () {
  7078. return this._text;
  7079. },
  7080. set: function (value) {
  7081. var valueAsString = value.toString(); // Forcing convertion
  7082. if (this._text === valueAsString) {
  7083. return;
  7084. }
  7085. this._text = valueAsString;
  7086. this._markAsDirty();
  7087. this.onTextChangedObservable.notifyObservers(this);
  7088. },
  7089. enumerable: true,
  7090. configurable: true
  7091. });
  7092. Object.defineProperty(InputText.prototype, "width", {
  7093. /** Gets or sets control width */
  7094. get: function () {
  7095. return this._width.toString(this._host);
  7096. },
  7097. set: function (value) {
  7098. if (this._width.toString(this._host) === value) {
  7099. return;
  7100. }
  7101. if (this._width.fromString(value)) {
  7102. this._markAsDirty();
  7103. }
  7104. this.autoStretchWidth = false;
  7105. },
  7106. enumerable: true,
  7107. configurable: true
  7108. });
  7109. /** @hidden */
  7110. InputText.prototype.onBlur = function () {
  7111. this._isFocused = false;
  7112. this._scrollLeft = null;
  7113. this._cursorOffset = 0;
  7114. clearTimeout(this._blinkTimeout);
  7115. this._markAsDirty();
  7116. this.onBlurObservable.notifyObservers(this);
  7117. this._host.unRegisterClipboardEvents();
  7118. if (this._onClipboardObserver) {
  7119. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7120. }
  7121. var scene = this._host.getScene();
  7122. if (this._onPointerDblTapObserver && scene) {
  7123. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7124. }
  7125. };
  7126. /** @hidden */
  7127. InputText.prototype.onFocus = function () {
  7128. var _this = this;
  7129. if (!this._isEnabled) {
  7130. return;
  7131. }
  7132. this._scrollLeft = null;
  7133. this._isFocused = true;
  7134. this._blinkIsEven = false;
  7135. this._cursorOffset = 0;
  7136. this._markAsDirty();
  7137. this.onFocusObservable.notifyObservers(this);
  7138. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7139. var value = prompt(this.promptMessage);
  7140. if (value !== null) {
  7141. this.text = value;
  7142. }
  7143. this._host.focusedControl = null;
  7144. return;
  7145. }
  7146. this._host.registerClipboardEvents();
  7147. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7148. // process clipboard event, can be configured.
  7149. switch (clipboardInfo.type) {
  7150. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7151. _this._onCopyText(clipboardInfo.event);
  7152. _this.onTextCopyObservable.notifyObservers(_this);
  7153. break;
  7154. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7155. _this._onCutText(clipboardInfo.event);
  7156. _this.onTextCutObservable.notifyObservers(_this);
  7157. break;
  7158. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7159. _this._onPasteText(clipboardInfo.event);
  7160. _this.onTextPasteObservable.notifyObservers(_this);
  7161. break;
  7162. default: return;
  7163. }
  7164. });
  7165. var scene = this._host.getScene();
  7166. if (scene) {
  7167. //register the pointer double tap event
  7168. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7169. if (!_this._isFocused) {
  7170. return;
  7171. }
  7172. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7173. _this._processDblClick(pointerInfo);
  7174. }
  7175. });
  7176. }
  7177. if (this._onFocusSelectAll) {
  7178. this._selectAllText();
  7179. }
  7180. };
  7181. InputText.prototype._getTypeName = function () {
  7182. return "InputText";
  7183. };
  7184. /**
  7185. * Function called to get the list of controls that should not steal the focus from this control
  7186. * @returns an array of controls
  7187. */
  7188. InputText.prototype.keepsFocusWith = function () {
  7189. if (!this._connectedVirtualKeyboard) {
  7190. return null;
  7191. }
  7192. return [this._connectedVirtualKeyboard];
  7193. };
  7194. /** @hidden */
  7195. InputText.prototype.processKey = function (keyCode, key, evt) {
  7196. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7197. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7198. return;
  7199. }
  7200. //select all
  7201. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7202. this._selectAllText();
  7203. evt.preventDefault();
  7204. return;
  7205. }
  7206. // Specific cases
  7207. switch (keyCode) {
  7208. case 32: //SPACE
  7209. key = " "; //ie11 key for space is "Spacebar"
  7210. break;
  7211. case 191: //SLASH
  7212. if (evt) {
  7213. evt.preventDefault();
  7214. }
  7215. break;
  7216. case 8: // BACKSPACE
  7217. if (this._text && this._text.length > 0) {
  7218. //delete the highlighted text
  7219. if (this._isTextHighlightOn) {
  7220. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7221. this._isTextHighlightOn = false;
  7222. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7223. this._blinkIsEven = false;
  7224. if (evt) {
  7225. evt.preventDefault();
  7226. }
  7227. return;
  7228. }
  7229. //delete single character
  7230. if (this._cursorOffset === 0) {
  7231. this.text = this._text.substr(0, this._text.length - 1);
  7232. }
  7233. else {
  7234. var deletePosition = this._text.length - this._cursorOffset;
  7235. if (deletePosition > 0) {
  7236. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7237. }
  7238. }
  7239. }
  7240. if (evt) {
  7241. evt.preventDefault();
  7242. }
  7243. return;
  7244. case 46: // DELETE
  7245. if (this._isTextHighlightOn) {
  7246. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7247. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7248. while (decrementor > 0 && this._cursorOffset > 0) {
  7249. this._cursorOffset--;
  7250. }
  7251. this._isTextHighlightOn = false;
  7252. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7253. if (evt) {
  7254. evt.preventDefault();
  7255. }
  7256. return;
  7257. }
  7258. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7259. var deletePosition = this._text.length - this._cursorOffset;
  7260. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7261. this._cursorOffset--;
  7262. }
  7263. if (evt) {
  7264. evt.preventDefault();
  7265. }
  7266. return;
  7267. case 13: // RETURN
  7268. this._host.focusedControl = null;
  7269. this._isTextHighlightOn = false;
  7270. return;
  7271. case 35: // END
  7272. this._cursorOffset = 0;
  7273. this._blinkIsEven = false;
  7274. this._isTextHighlightOn = false;
  7275. this._markAsDirty();
  7276. return;
  7277. case 36: // HOME
  7278. this._cursorOffset = this._text.length;
  7279. this._blinkIsEven = false;
  7280. this._isTextHighlightOn = false;
  7281. this._markAsDirty();
  7282. return;
  7283. case 37: // LEFT
  7284. this._cursorOffset++;
  7285. if (this._cursorOffset > this._text.length) {
  7286. this._cursorOffset = this._text.length;
  7287. }
  7288. if (evt && evt.shiftKey) {
  7289. // update the cursor
  7290. this._blinkIsEven = false;
  7291. // shift + ctrl/cmd + <-
  7292. if (evt.ctrlKey || evt.metaKey) {
  7293. if (!this._isTextHighlightOn) {
  7294. if (this._text.length === this._cursorOffset) {
  7295. return;
  7296. }
  7297. else {
  7298. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7299. }
  7300. }
  7301. this._startHighlightIndex = 0;
  7302. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7303. this._cursorOffset = this._text.length;
  7304. this._isTextHighlightOn = true;
  7305. this._markAsDirty();
  7306. return;
  7307. }
  7308. //store the starting point
  7309. if (!this._isTextHighlightOn) {
  7310. this._isTextHighlightOn = true;
  7311. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7312. }
  7313. //if text is already highlighted
  7314. else if (this._cursorIndex === -1) {
  7315. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7316. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7317. }
  7318. //set the highlight indexes
  7319. if (this._cursorIndex < this._cursorOffset) {
  7320. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7321. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7322. }
  7323. else if (this._cursorIndex > this._cursorOffset) {
  7324. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7325. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7326. }
  7327. else {
  7328. this._isTextHighlightOn = false;
  7329. }
  7330. this._markAsDirty();
  7331. return;
  7332. }
  7333. if (this._isTextHighlightOn) {
  7334. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7335. this._isTextHighlightOn = false;
  7336. }
  7337. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7338. this._cursorOffset = this.text.length;
  7339. evt.preventDefault();
  7340. }
  7341. this._blinkIsEven = false;
  7342. this._isTextHighlightOn = false;
  7343. this._cursorIndex = -1;
  7344. this._markAsDirty();
  7345. return;
  7346. case 39: // RIGHT
  7347. this._cursorOffset--;
  7348. if (this._cursorOffset < 0) {
  7349. this._cursorOffset = 0;
  7350. }
  7351. if (evt && evt.shiftKey) {
  7352. //update the cursor
  7353. this._blinkIsEven = false;
  7354. //shift + ctrl/cmd + ->
  7355. if (evt.ctrlKey || evt.metaKey) {
  7356. if (!this._isTextHighlightOn) {
  7357. if (this._cursorOffset === 0) {
  7358. return;
  7359. }
  7360. else {
  7361. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7362. }
  7363. }
  7364. this._endHighlightIndex = this._text.length;
  7365. this._isTextHighlightOn = true;
  7366. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7367. this._cursorOffset = 0;
  7368. this._markAsDirty();
  7369. return;
  7370. }
  7371. if (!this._isTextHighlightOn) {
  7372. this._isTextHighlightOn = true;
  7373. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7374. }
  7375. //if text is already highlighted
  7376. else if (this._cursorIndex === -1) {
  7377. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7378. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7379. }
  7380. //set the highlight indexes
  7381. if (this._cursorIndex < this._cursorOffset) {
  7382. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7383. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7384. }
  7385. else if (this._cursorIndex > this._cursorOffset) {
  7386. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7387. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7388. }
  7389. else {
  7390. this._isTextHighlightOn = false;
  7391. }
  7392. this._markAsDirty();
  7393. return;
  7394. }
  7395. if (this._isTextHighlightOn) {
  7396. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7397. this._isTextHighlightOn = false;
  7398. }
  7399. //ctr + ->
  7400. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7401. this._cursorOffset = 0;
  7402. evt.preventDefault();
  7403. }
  7404. this._blinkIsEven = false;
  7405. this._isTextHighlightOn = false;
  7406. this._cursorIndex = -1;
  7407. this._markAsDirty();
  7408. return;
  7409. case 222: // Dead
  7410. if (evt) {
  7411. evt.preventDefault();
  7412. }
  7413. this._cursorIndex = -1;
  7414. this.deadKey = true;
  7415. break;
  7416. }
  7417. // Printable characters
  7418. if (key &&
  7419. ((keyCode === -1) || // Direct access
  7420. (keyCode === 32) || // Space
  7421. (keyCode > 47 && keyCode < 64) || // Numbers
  7422. (keyCode > 64 && keyCode < 91) || // Letters
  7423. (keyCode > 159 && keyCode < 193) || // Special characters
  7424. (keyCode > 218 && keyCode < 223) || // Special characters
  7425. (keyCode > 95 && keyCode < 112))) { // Numpad
  7426. this._currentKey = key;
  7427. this.onBeforeKeyAddObservable.notifyObservers(this);
  7428. key = this._currentKey;
  7429. if (this._addKey) {
  7430. if (this._isTextHighlightOn) {
  7431. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7432. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7433. this._isTextHighlightOn = false;
  7434. this._blinkIsEven = false;
  7435. this._markAsDirty();
  7436. }
  7437. else if (this._cursorOffset === 0) {
  7438. this.text += key;
  7439. }
  7440. else {
  7441. var insertPosition = this._text.length - this._cursorOffset;
  7442. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7443. }
  7444. }
  7445. }
  7446. };
  7447. /** @hidden */
  7448. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7449. //update the cursor
  7450. this._blinkIsEven = false;
  7451. if (this._cursorIndex === -1) {
  7452. this._cursorIndex = offset;
  7453. }
  7454. else {
  7455. if (this._cursorIndex < this._cursorOffset) {
  7456. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7457. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7458. }
  7459. else if (this._cursorIndex > this._cursorOffset) {
  7460. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7461. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7462. }
  7463. else {
  7464. this._isTextHighlightOn = false;
  7465. this._markAsDirty();
  7466. return;
  7467. }
  7468. }
  7469. this._isTextHighlightOn = true;
  7470. this._markAsDirty();
  7471. };
  7472. /** @hidden */
  7473. InputText.prototype._processDblClick = function (evt) {
  7474. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7475. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7476. this._endHighlightIndex = this._startHighlightIndex;
  7477. var rWord = /\w+/g, moveLeft, moveRight;
  7478. do {
  7479. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7480. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7481. } while (moveLeft || moveRight);
  7482. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7483. this.onTextHighlightObservable.notifyObservers(this);
  7484. this._isTextHighlightOn = true;
  7485. this._clickedCoordinate = null;
  7486. this._blinkIsEven = true;
  7487. this._cursorIndex = -1;
  7488. this._markAsDirty();
  7489. };
  7490. /** @hidden */
  7491. InputText.prototype._selectAllText = function () {
  7492. this._blinkIsEven = true;
  7493. this._isTextHighlightOn = true;
  7494. this._startHighlightIndex = 0;
  7495. this._endHighlightIndex = this._text.length;
  7496. this._cursorOffset = this._text.length;
  7497. this._cursorIndex = -1;
  7498. this._markAsDirty();
  7499. };
  7500. /**
  7501. * Handles the keyboard event
  7502. * @param evt Defines the KeyboardEvent
  7503. */
  7504. InputText.prototype.processKeyboard = function (evt) {
  7505. // process pressed key
  7506. this.processKey(evt.keyCode, evt.key, evt);
  7507. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7508. };
  7509. /** @hidden */
  7510. InputText.prototype._onCopyText = function (ev) {
  7511. this._isTextHighlightOn = false;
  7512. //when write permission to clipbaord data is denied
  7513. try {
  7514. ev.clipboardData.setData("text/plain", this._highlightedText);
  7515. }
  7516. catch (_a) { } //pass
  7517. this._host.clipboardData = this._highlightedText;
  7518. };
  7519. /** @hidden */
  7520. InputText.prototype._onCutText = function (ev) {
  7521. if (!this._highlightedText) {
  7522. return;
  7523. }
  7524. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7525. this._isTextHighlightOn = false;
  7526. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7527. //when write permission to clipbaord data is denied
  7528. try {
  7529. ev.clipboardData.setData("text/plain", this._highlightedText);
  7530. }
  7531. catch (_a) { } //pass
  7532. this._host.clipboardData = this._highlightedText;
  7533. this._highlightedText = "";
  7534. };
  7535. /** @hidden */
  7536. InputText.prototype._onPasteText = function (ev) {
  7537. var data = "";
  7538. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7539. data = ev.clipboardData.getData("text/plain");
  7540. }
  7541. else {
  7542. //get the cached data; returns blank string by default
  7543. data = this._host.clipboardData;
  7544. }
  7545. var insertPosition = this._text.length - this._cursorOffset;
  7546. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7547. };
  7548. InputText.prototype._draw = function (context) {
  7549. var _this = this;
  7550. context.save();
  7551. this._applyStates(context);
  7552. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7553. context.shadowColor = this.shadowColor;
  7554. context.shadowBlur = this.shadowBlur;
  7555. context.shadowOffsetX = this.shadowOffsetX;
  7556. context.shadowOffsetY = this.shadowOffsetY;
  7557. }
  7558. // Background
  7559. if (this._isFocused) {
  7560. if (this._focusedBackground) {
  7561. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7562. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7563. }
  7564. }
  7565. else if (this._background) {
  7566. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7567. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7568. }
  7569. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7570. context.shadowBlur = 0;
  7571. context.shadowOffsetX = 0;
  7572. context.shadowOffsetY = 0;
  7573. }
  7574. if (!this._fontOffset) {
  7575. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7576. }
  7577. // Text
  7578. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7579. if (this.color) {
  7580. context.fillStyle = this.color;
  7581. }
  7582. var text = this._beforeRenderText(this._text);
  7583. if (!this._isFocused && !this._text && this._placeholderText) {
  7584. text = this._placeholderText;
  7585. if (this._placeholderColor) {
  7586. context.fillStyle = this._placeholderColor;
  7587. }
  7588. }
  7589. this._textWidth = context.measureText(text).width;
  7590. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7591. if (this._autoStretchWidth) {
  7592. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7593. }
  7594. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7595. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7596. context.save();
  7597. context.beginPath();
  7598. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7599. context.clip();
  7600. if (this._isFocused && this._textWidth > availableWidth) {
  7601. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7602. if (!this._scrollLeft) {
  7603. this._scrollLeft = textLeft;
  7604. }
  7605. }
  7606. else {
  7607. this._scrollLeft = clipTextLeft;
  7608. }
  7609. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7610. // Cursor
  7611. if (this._isFocused) {
  7612. // Need to move cursor
  7613. if (this._clickedCoordinate) {
  7614. var rightPosition = this._scrollLeft + this._textWidth;
  7615. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7616. var currentSize = 0;
  7617. this._cursorOffset = 0;
  7618. var previousDist = 0;
  7619. do {
  7620. if (this._cursorOffset) {
  7621. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7622. }
  7623. this._cursorOffset++;
  7624. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7625. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7626. // Find closest move
  7627. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7628. this._cursorOffset--;
  7629. }
  7630. this._blinkIsEven = false;
  7631. this._clickedCoordinate = null;
  7632. }
  7633. // Render cursor
  7634. if (!this._blinkIsEven) {
  7635. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7636. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7637. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7638. if (cursorLeft < clipTextLeft) {
  7639. this._scrollLeft += (clipTextLeft - cursorLeft);
  7640. cursorLeft = clipTextLeft;
  7641. this._markAsDirty();
  7642. }
  7643. else if (cursorLeft > clipTextLeft + availableWidth) {
  7644. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7645. cursorLeft = clipTextLeft + availableWidth;
  7646. this._markAsDirty();
  7647. }
  7648. if (!this._isTextHighlightOn) {
  7649. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7650. }
  7651. }
  7652. clearTimeout(this._blinkTimeout);
  7653. this._blinkTimeout = setTimeout(function () {
  7654. _this._blinkIsEven = !_this._blinkIsEven;
  7655. _this._markAsDirty();
  7656. }, 500);
  7657. //show the highlighted text
  7658. if (this._isTextHighlightOn) {
  7659. clearTimeout(this._blinkTimeout);
  7660. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7661. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7662. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7663. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7664. if (highlightCursorLeft < clipTextLeft) {
  7665. width = width - (clipTextLeft - highlightCursorLeft);
  7666. if (!width) {
  7667. // when using left arrow on text.length > availableWidth;
  7668. // assigns the width of the first letter after clipTextLeft
  7669. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7670. }
  7671. highlightCursorLeft = clipTextLeft;
  7672. }
  7673. //for transparancy
  7674. context.globalAlpha = this._highligherOpacity;
  7675. context.fillStyle = this._textHighlightColor;
  7676. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7677. context.globalAlpha = 1.0;
  7678. }
  7679. }
  7680. context.restore();
  7681. // Border
  7682. if (this._thickness) {
  7683. if (this._isFocused) {
  7684. if (this.focusedColor) {
  7685. context.strokeStyle = this.focusedColor;
  7686. }
  7687. }
  7688. else {
  7689. if (this.color) {
  7690. context.strokeStyle = this.color;
  7691. }
  7692. }
  7693. context.lineWidth = this._thickness;
  7694. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7695. }
  7696. context.restore();
  7697. };
  7698. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7699. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7700. return false;
  7701. }
  7702. this._clickedCoordinate = coordinates.x;
  7703. this._isTextHighlightOn = false;
  7704. this._highlightedText = "";
  7705. this._cursorIndex = -1;
  7706. this._isPointerDown = true;
  7707. this._host._capturingControl[pointerId] = this;
  7708. if (this._host.focusedControl === this) {
  7709. // Move cursor
  7710. clearTimeout(this._blinkTimeout);
  7711. this._markAsDirty();
  7712. return true;
  7713. }
  7714. if (!this._isEnabled) {
  7715. return false;
  7716. }
  7717. this._host.focusedControl = this;
  7718. return true;
  7719. };
  7720. InputText.prototype._onPointerMove = function (target, coordinates) {
  7721. if (this._host.focusedControl === this && this._isPointerDown) {
  7722. this._clickedCoordinate = coordinates.x;
  7723. this._markAsDirty();
  7724. this._updateValueFromCursorIndex(this._cursorOffset);
  7725. }
  7726. _super.prototype._onPointerMove.call(this, target, coordinates);
  7727. };
  7728. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7729. this._isPointerDown = false;
  7730. delete this._host._capturingControl[pointerId];
  7731. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7732. };
  7733. InputText.prototype._beforeRenderText = function (text) {
  7734. return text;
  7735. };
  7736. InputText.prototype.dispose = function () {
  7737. _super.prototype.dispose.call(this);
  7738. this.onBlurObservable.clear();
  7739. this.onFocusObservable.clear();
  7740. this.onTextChangedObservable.clear();
  7741. this.onTextCopyObservable.clear();
  7742. this.onTextCutObservable.clear();
  7743. this.onTextPasteObservable.clear();
  7744. this.onTextHighlightObservable.clear();
  7745. this.onKeyboardEventProcessedObservable.clear();
  7746. };
  7747. return InputText;
  7748. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7749. /***/ }),
  7750. /***/ "./2D/controls/line.ts":
  7751. /*!*****************************!*\
  7752. !*** ./2D/controls/line.ts ***!
  7753. \*****************************/
  7754. /*! exports provided: Line */
  7755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7756. "use strict";
  7757. __webpack_require__.r(__webpack_exports__);
  7758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7759. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7760. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  7761. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7762. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7763. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7764. /** Class used to render 2D lines */
  7765. var Line = /** @class */ (function (_super) {
  7766. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7767. /**
  7768. * Creates a new Line
  7769. * @param name defines the control name
  7770. */
  7771. function Line(name) {
  7772. var _this = _super.call(this, name) || this;
  7773. _this.name = name;
  7774. _this._lineWidth = 1;
  7775. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7776. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7777. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7778. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7779. _this._dash = new Array();
  7780. _this.isHitTestVisible = false;
  7781. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7782. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7783. return _this;
  7784. }
  7785. Object.defineProperty(Line.prototype, "dash", {
  7786. /** Gets or sets the dash pattern */
  7787. get: function () {
  7788. return this._dash;
  7789. },
  7790. set: function (value) {
  7791. if (this._dash === value) {
  7792. return;
  7793. }
  7794. this._dash = value;
  7795. this._markAsDirty();
  7796. },
  7797. enumerable: true,
  7798. configurable: true
  7799. });
  7800. Object.defineProperty(Line.prototype, "connectedControl", {
  7801. /** Gets or sets the control connected with the line end */
  7802. get: function () {
  7803. return this._connectedControl;
  7804. },
  7805. set: function (value) {
  7806. var _this = this;
  7807. if (this._connectedControl === value) {
  7808. return;
  7809. }
  7810. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7811. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7812. this._connectedControlDirtyObserver = null;
  7813. }
  7814. if (value) {
  7815. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7816. }
  7817. this._connectedControl = value;
  7818. this._markAsDirty();
  7819. },
  7820. enumerable: true,
  7821. configurable: true
  7822. });
  7823. Object.defineProperty(Line.prototype, "x1", {
  7824. /** Gets or sets start coordinates on X axis */
  7825. get: function () {
  7826. return this._x1.toString(this._host);
  7827. },
  7828. set: function (value) {
  7829. if (this._x1.toString(this._host) === value) {
  7830. return;
  7831. }
  7832. if (this._x1.fromString(value)) {
  7833. this._markAsDirty();
  7834. }
  7835. },
  7836. enumerable: true,
  7837. configurable: true
  7838. });
  7839. Object.defineProperty(Line.prototype, "y1", {
  7840. /** Gets or sets start coordinates on Y axis */
  7841. get: function () {
  7842. return this._y1.toString(this._host);
  7843. },
  7844. set: function (value) {
  7845. if (this._y1.toString(this._host) === value) {
  7846. return;
  7847. }
  7848. if (this._y1.fromString(value)) {
  7849. this._markAsDirty();
  7850. }
  7851. },
  7852. enumerable: true,
  7853. configurable: true
  7854. });
  7855. Object.defineProperty(Line.prototype, "x2", {
  7856. /** Gets or sets end coordinates on X axis */
  7857. get: function () {
  7858. return this._x2.toString(this._host);
  7859. },
  7860. set: function (value) {
  7861. if (this._x2.toString(this._host) === value) {
  7862. return;
  7863. }
  7864. if (this._x2.fromString(value)) {
  7865. this._markAsDirty();
  7866. }
  7867. },
  7868. enumerable: true,
  7869. configurable: true
  7870. });
  7871. Object.defineProperty(Line.prototype, "y2", {
  7872. /** Gets or sets end coordinates on Y axis */
  7873. get: function () {
  7874. return this._y2.toString(this._host);
  7875. },
  7876. set: function (value) {
  7877. if (this._y2.toString(this._host) === value) {
  7878. return;
  7879. }
  7880. if (this._y2.fromString(value)) {
  7881. this._markAsDirty();
  7882. }
  7883. },
  7884. enumerable: true,
  7885. configurable: true
  7886. });
  7887. Object.defineProperty(Line.prototype, "lineWidth", {
  7888. /** Gets or sets line width */
  7889. get: function () {
  7890. return this._lineWidth;
  7891. },
  7892. set: function (value) {
  7893. if (this._lineWidth === value) {
  7894. return;
  7895. }
  7896. this._lineWidth = value;
  7897. this._markAsDirty();
  7898. },
  7899. enumerable: true,
  7900. configurable: true
  7901. });
  7902. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7903. /** Gets or sets horizontal alignment */
  7904. set: function (value) {
  7905. return;
  7906. },
  7907. enumerable: true,
  7908. configurable: true
  7909. });
  7910. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7911. /** Gets or sets vertical alignment */
  7912. set: function (value) {
  7913. return;
  7914. },
  7915. enumerable: true,
  7916. configurable: true
  7917. });
  7918. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7919. get: function () {
  7920. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7921. },
  7922. enumerable: true,
  7923. configurable: true
  7924. });
  7925. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7926. get: function () {
  7927. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7928. },
  7929. enumerable: true,
  7930. configurable: true
  7931. });
  7932. Line.prototype._getTypeName = function () {
  7933. return "Line";
  7934. };
  7935. Line.prototype._draw = function (context) {
  7936. context.save();
  7937. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7938. context.shadowColor = this.shadowColor;
  7939. context.shadowBlur = this.shadowBlur;
  7940. context.shadowOffsetX = this.shadowOffsetX;
  7941. context.shadowOffsetY = this.shadowOffsetY;
  7942. }
  7943. this._applyStates(context);
  7944. context.strokeStyle = this.color;
  7945. context.lineWidth = this._lineWidth;
  7946. context.setLineDash(this._dash);
  7947. context.beginPath();
  7948. context.moveTo(this._x1.getValue(this._host), this._y1.getValue(this._host));
  7949. context.lineTo(this._effectiveX2, this._effectiveY2);
  7950. context.stroke();
  7951. context.restore();
  7952. };
  7953. Line.prototype._measure = function () {
  7954. // Width / Height
  7955. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7956. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7957. };
  7958. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7959. this._currentMeasure.left = Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7960. this._currentMeasure.top = Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7961. };
  7962. /**
  7963. * Move one end of the line given 3D cartesian coordinates.
  7964. * @param position Targeted world position
  7965. * @param scene Scene
  7966. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7967. */
  7968. Line.prototype.moveToVector3 = function (position, scene, end) {
  7969. if (end === void 0) { end = false; }
  7970. if (!this._host || this.parent !== this._host._rootContainer) {
  7971. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  7972. return;
  7973. }
  7974. var globalViewport = this._host._getGlobalViewport(scene);
  7975. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  7976. this._moveToProjectedPosition(projectedPosition, end);
  7977. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  7978. this.notRenderable = true;
  7979. return;
  7980. }
  7981. this.notRenderable = false;
  7982. };
  7983. /**
  7984. * Move one end of the line to a position in screen absolute space.
  7985. * @param projectedPosition Position in screen absolute space (X, Y)
  7986. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7987. */
  7988. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  7989. if (end === void 0) { end = false; }
  7990. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  7991. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  7992. if (end) {
  7993. this.x2 = x;
  7994. this.y2 = y;
  7995. this._x2.ignoreAdaptiveScaling = true;
  7996. this._y2.ignoreAdaptiveScaling = true;
  7997. }
  7998. else {
  7999. this.x1 = x;
  8000. this.y1 = y;
  8001. this._x1.ignoreAdaptiveScaling = true;
  8002. this._y1.ignoreAdaptiveScaling = true;
  8003. }
  8004. };
  8005. return Line;
  8006. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8007. /***/ }),
  8008. /***/ "./2D/controls/multiLine.ts":
  8009. /*!**********************************!*\
  8010. !*** ./2D/controls/multiLine.ts ***!
  8011. \**********************************/
  8012. /*! exports provided: MultiLine */
  8013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8014. "use strict";
  8015. __webpack_require__.r(__webpack_exports__);
  8016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8017. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8018. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  8019. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8020. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8021. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8022. /**
  8023. * Class used to create multi line control
  8024. */
  8025. var MultiLine = /** @class */ (function (_super) {
  8026. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8027. /**
  8028. * Creates a new MultiLine
  8029. * @param name defines the control name
  8030. */
  8031. function MultiLine(name) {
  8032. var _this = _super.call(this, name) || this;
  8033. _this.name = name;
  8034. _this._lineWidth = 1;
  8035. /** Function called when a point is updated */
  8036. _this.onPointUpdate = function () {
  8037. _this._markAsDirty();
  8038. };
  8039. _this.isHitTestVisible = false;
  8040. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8041. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8042. _this._dash = [];
  8043. _this._points = [];
  8044. return _this;
  8045. }
  8046. Object.defineProperty(MultiLine.prototype, "dash", {
  8047. /** Gets or sets dash pattern */
  8048. get: function () {
  8049. return this._dash;
  8050. },
  8051. set: function (value) {
  8052. if (this._dash === value) {
  8053. return;
  8054. }
  8055. this._dash = value;
  8056. this._markAsDirty();
  8057. },
  8058. enumerable: true,
  8059. configurable: true
  8060. });
  8061. /**
  8062. * Gets point stored at specified index
  8063. * @param index defines the index to look for
  8064. * @returns the requested point if found
  8065. */
  8066. MultiLine.prototype.getAt = function (index) {
  8067. if (!this._points[index]) {
  8068. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8069. }
  8070. return this._points[index];
  8071. };
  8072. /**
  8073. * Adds new points to the point collection
  8074. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8075. * @returns the list of created MultiLinePoint
  8076. */
  8077. MultiLine.prototype.add = function () {
  8078. var _this = this;
  8079. var items = [];
  8080. for (var _i = 0; _i < arguments.length; _i++) {
  8081. items[_i] = arguments[_i];
  8082. }
  8083. return items.map(function (item) { return _this.push(item); });
  8084. };
  8085. /**
  8086. * Adds a new point to the point collection
  8087. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8088. * @returns the created MultiLinePoint
  8089. */
  8090. MultiLine.prototype.push = function (item) {
  8091. var point = this.getAt(this._points.length);
  8092. if (item == null) {
  8093. return point;
  8094. }
  8095. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8096. point.mesh = item;
  8097. }
  8098. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8099. point.control = item;
  8100. }
  8101. else if (item.x != null && item.y != null) {
  8102. point.x = item.x;
  8103. point.y = item.y;
  8104. }
  8105. return point;
  8106. };
  8107. /**
  8108. * Remove a specific value or point from the active point collection
  8109. * @param value defines the value or point to remove
  8110. */
  8111. MultiLine.prototype.remove = function (value) {
  8112. var index;
  8113. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8114. index = this._points.indexOf(value);
  8115. if (index === -1) {
  8116. return;
  8117. }
  8118. }
  8119. else {
  8120. index = value;
  8121. }
  8122. var point = this._points[index];
  8123. if (!point) {
  8124. return;
  8125. }
  8126. point.dispose();
  8127. this._points.splice(index, 1);
  8128. };
  8129. /**
  8130. * Resets this object to initial state (no point)
  8131. */
  8132. MultiLine.prototype.reset = function () {
  8133. while (this._points.length > 0) {
  8134. this.remove(this._points.length - 1);
  8135. }
  8136. };
  8137. /**
  8138. * Resets all links
  8139. */
  8140. MultiLine.prototype.resetLinks = function () {
  8141. this._points.forEach(function (point) {
  8142. if (point != null) {
  8143. point.resetLinks();
  8144. }
  8145. });
  8146. };
  8147. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8148. /** Gets or sets line width */
  8149. get: function () {
  8150. return this._lineWidth;
  8151. },
  8152. set: function (value) {
  8153. if (this._lineWidth === value) {
  8154. return;
  8155. }
  8156. this._lineWidth = value;
  8157. this._markAsDirty();
  8158. },
  8159. enumerable: true,
  8160. configurable: true
  8161. });
  8162. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8163. set: function (value) {
  8164. return;
  8165. },
  8166. enumerable: true,
  8167. configurable: true
  8168. });
  8169. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8170. set: function (value) {
  8171. return;
  8172. },
  8173. enumerable: true,
  8174. configurable: true
  8175. });
  8176. MultiLine.prototype._getTypeName = function () {
  8177. return "MultiLine";
  8178. };
  8179. MultiLine.prototype._draw = function (context) {
  8180. context.save();
  8181. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8182. context.shadowColor = this.shadowColor;
  8183. context.shadowBlur = this.shadowBlur;
  8184. context.shadowOffsetX = this.shadowOffsetX;
  8185. context.shadowOffsetY = this.shadowOffsetY;
  8186. }
  8187. this._applyStates(context);
  8188. context.strokeStyle = this.color;
  8189. context.lineWidth = this._lineWidth;
  8190. context.setLineDash(this._dash);
  8191. context.beginPath();
  8192. var first = true; //first index is not necessarily 0
  8193. this._points.forEach(function (point) {
  8194. if (!point) {
  8195. return;
  8196. }
  8197. if (first) {
  8198. context.moveTo(point._point.x, point._point.y);
  8199. first = false;
  8200. }
  8201. else {
  8202. context.lineTo(point._point.x, point._point.y);
  8203. }
  8204. });
  8205. context.stroke();
  8206. context.restore();
  8207. };
  8208. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8209. var _this = this;
  8210. this._minX = null;
  8211. this._minY = null;
  8212. this._maxX = null;
  8213. this._maxY = null;
  8214. this._points.forEach(function (point, index) {
  8215. if (!point) {
  8216. return;
  8217. }
  8218. point.translate();
  8219. if (_this._minX == null || point._point.x < _this._minX) {
  8220. _this._minX = point._point.x;
  8221. }
  8222. if (_this._minY == null || point._point.y < _this._minY) {
  8223. _this._minY = point._point.y;
  8224. }
  8225. if (_this._maxX == null || point._point.x > _this._maxX) {
  8226. _this._maxX = point._point.x;
  8227. }
  8228. if (_this._maxY == null || point._point.y > _this._maxY) {
  8229. _this._maxY = point._point.y;
  8230. }
  8231. });
  8232. if (this._minX == null) {
  8233. this._minX = 0;
  8234. }
  8235. if (this._minY == null) {
  8236. this._minY = 0;
  8237. }
  8238. if (this._maxX == null) {
  8239. this._maxX = 0;
  8240. }
  8241. if (this._maxY == null) {
  8242. this._maxY = 0;
  8243. }
  8244. };
  8245. MultiLine.prototype._measure = function () {
  8246. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8247. return;
  8248. }
  8249. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8250. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8251. };
  8252. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8253. if (this._minX == null || this._minY == null) {
  8254. return;
  8255. }
  8256. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8257. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8258. };
  8259. MultiLine.prototype.dispose = function () {
  8260. this.reset();
  8261. _super.prototype.dispose.call(this);
  8262. };
  8263. return MultiLine;
  8264. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8265. /***/ }),
  8266. /***/ "./2D/controls/radioButton.ts":
  8267. /*!************************************!*\
  8268. !*** ./2D/controls/radioButton.ts ***!
  8269. \************************************/
  8270. /*! exports provided: RadioButton */
  8271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8272. "use strict";
  8273. __webpack_require__.r(__webpack_exports__);
  8274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8275. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8276. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8277. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8278. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8279. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8280. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8281. /**
  8282. * Class used to create radio button controls
  8283. */
  8284. var RadioButton = /** @class */ (function (_super) {
  8285. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8286. /**
  8287. * Creates a new RadioButton
  8288. * @param name defines the control name
  8289. */
  8290. function RadioButton(name) {
  8291. var _this = _super.call(this, name) || this;
  8292. _this.name = name;
  8293. _this._isChecked = false;
  8294. _this._background = "black";
  8295. _this._checkSizeRatio = 0.8;
  8296. _this._thickness = 1;
  8297. /** Gets or sets group name */
  8298. _this.group = "";
  8299. /** Observable raised when isChecked is changed */
  8300. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8301. _this.isPointerBlocker = true;
  8302. return _this;
  8303. }
  8304. Object.defineProperty(RadioButton.prototype, "thickness", {
  8305. /** Gets or sets border thickness */
  8306. get: function () {
  8307. return this._thickness;
  8308. },
  8309. set: function (value) {
  8310. if (this._thickness === value) {
  8311. return;
  8312. }
  8313. this._thickness = value;
  8314. this._markAsDirty();
  8315. },
  8316. enumerable: true,
  8317. configurable: true
  8318. });
  8319. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8320. /** Gets or sets a value indicating the ratio between overall size and check size */
  8321. get: function () {
  8322. return this._checkSizeRatio;
  8323. },
  8324. set: function (value) {
  8325. value = Math.max(Math.min(1, value), 0);
  8326. if (this._checkSizeRatio === value) {
  8327. return;
  8328. }
  8329. this._checkSizeRatio = value;
  8330. this._markAsDirty();
  8331. },
  8332. enumerable: true,
  8333. configurable: true
  8334. });
  8335. Object.defineProperty(RadioButton.prototype, "background", {
  8336. /** Gets or sets background color */
  8337. get: function () {
  8338. return this._background;
  8339. },
  8340. set: function (value) {
  8341. if (this._background === value) {
  8342. return;
  8343. }
  8344. this._background = value;
  8345. this._markAsDirty();
  8346. },
  8347. enumerable: true,
  8348. configurable: true
  8349. });
  8350. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8351. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8352. get: function () {
  8353. return this._isChecked;
  8354. },
  8355. set: function (value) {
  8356. var _this = this;
  8357. if (this._isChecked === value) {
  8358. return;
  8359. }
  8360. this._isChecked = value;
  8361. this._markAsDirty();
  8362. this.onIsCheckedChangedObservable.notifyObservers(value);
  8363. if (this._isChecked && this._host) {
  8364. // Update all controls from same group
  8365. this._host.executeOnAllControls(function (control) {
  8366. if (control === _this) {
  8367. return;
  8368. }
  8369. if (control.group === undefined) {
  8370. return;
  8371. }
  8372. var childRadio = control;
  8373. if (childRadio.group === _this.group) {
  8374. childRadio.isChecked = false;
  8375. }
  8376. });
  8377. }
  8378. },
  8379. enumerable: true,
  8380. configurable: true
  8381. });
  8382. RadioButton.prototype._getTypeName = function () {
  8383. return "RadioButton";
  8384. };
  8385. RadioButton.prototype._draw = function (context) {
  8386. context.save();
  8387. this._applyStates(context);
  8388. var actualWidth = this._currentMeasure.width - this._thickness;
  8389. var actualHeight = this._currentMeasure.height - this._thickness;
  8390. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8391. context.shadowColor = this.shadowColor;
  8392. context.shadowBlur = this.shadowBlur;
  8393. context.shadowOffsetX = this.shadowOffsetX;
  8394. context.shadowOffsetY = this.shadowOffsetY;
  8395. }
  8396. // Outer
  8397. _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);
  8398. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8399. context.fill();
  8400. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8401. context.shadowBlur = 0;
  8402. context.shadowOffsetX = 0;
  8403. context.shadowOffsetY = 0;
  8404. }
  8405. context.strokeStyle = this.color;
  8406. context.lineWidth = this._thickness;
  8407. context.stroke();
  8408. // Inner
  8409. if (this._isChecked) {
  8410. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8411. var offsetWidth = actualWidth * this._checkSizeRatio;
  8412. var offseHeight = actualHeight * this._checkSizeRatio;
  8413. _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);
  8414. context.fill();
  8415. }
  8416. context.restore();
  8417. };
  8418. // Events
  8419. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8420. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8421. return false;
  8422. }
  8423. if (!this.isChecked) {
  8424. this.isChecked = true;
  8425. }
  8426. return true;
  8427. };
  8428. /**
  8429. * Utility function to easily create a radio button with a header
  8430. * @param title defines the label to use for the header
  8431. * @param group defines the group to use for the radio button
  8432. * @param isChecked defines the initial state of the radio button
  8433. * @param onValueChanged defines the callback to call when value changes
  8434. * @returns a StackPanel containing the radio button and a textBlock
  8435. */
  8436. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8437. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8438. panel.isVertical = false;
  8439. panel.height = "30px";
  8440. var radio = new RadioButton();
  8441. radio.width = "20px";
  8442. radio.height = "20px";
  8443. radio.isChecked = isChecked;
  8444. radio.color = "green";
  8445. radio.group = group;
  8446. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8447. panel.addControl(radio);
  8448. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8449. header.text = title;
  8450. header.width = "180px";
  8451. header.paddingLeft = "5px";
  8452. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8453. header.color = "white";
  8454. panel.addControl(header);
  8455. return panel;
  8456. };
  8457. return RadioButton;
  8458. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8459. /***/ }),
  8460. /***/ "./2D/controls/rectangle.ts":
  8461. /*!**********************************!*\
  8462. !*** ./2D/controls/rectangle.ts ***!
  8463. \**********************************/
  8464. /*! exports provided: Rectangle */
  8465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8466. "use strict";
  8467. __webpack_require__.r(__webpack_exports__);
  8468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8469. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8470. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8471. /** Class used to create rectangle container */
  8472. var Rectangle = /** @class */ (function (_super) {
  8473. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8474. /**
  8475. * Creates a new Rectangle
  8476. * @param name defines the control name
  8477. */
  8478. function Rectangle(name) {
  8479. var _this = _super.call(this, name) || this;
  8480. _this.name = name;
  8481. _this._thickness = 1;
  8482. _this._cornerRadius = 0;
  8483. return _this;
  8484. }
  8485. Object.defineProperty(Rectangle.prototype, "thickness", {
  8486. /** Gets or sets border thickness */
  8487. get: function () {
  8488. return this._thickness;
  8489. },
  8490. set: function (value) {
  8491. if (this._thickness === value) {
  8492. return;
  8493. }
  8494. this._thickness = value;
  8495. this._markAsDirty();
  8496. },
  8497. enumerable: true,
  8498. configurable: true
  8499. });
  8500. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8501. /** Gets or sets the corner radius angle */
  8502. get: function () {
  8503. return this._cornerRadius;
  8504. },
  8505. set: function (value) {
  8506. if (value < 0) {
  8507. value = 0;
  8508. }
  8509. if (this._cornerRadius === value) {
  8510. return;
  8511. }
  8512. this._cornerRadius = value;
  8513. this._markAsDirty();
  8514. },
  8515. enumerable: true,
  8516. configurable: true
  8517. });
  8518. Rectangle.prototype._getTypeName = function () {
  8519. return "Rectangle";
  8520. };
  8521. Rectangle.prototype._localDraw = function (context) {
  8522. context.save();
  8523. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8524. context.shadowColor = this.shadowColor;
  8525. context.shadowBlur = this.shadowBlur;
  8526. context.shadowOffsetX = this.shadowOffsetX;
  8527. context.shadowOffsetY = this.shadowOffsetY;
  8528. }
  8529. if (this._background) {
  8530. context.fillStyle = this._background;
  8531. if (this._cornerRadius) {
  8532. this._drawRoundedRect(context, this._thickness / 2);
  8533. context.fill();
  8534. }
  8535. else {
  8536. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8537. }
  8538. }
  8539. if (this._thickness) {
  8540. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8541. context.shadowBlur = 0;
  8542. context.shadowOffsetX = 0;
  8543. context.shadowOffsetY = 0;
  8544. }
  8545. if (this.color) {
  8546. context.strokeStyle = this.color;
  8547. }
  8548. context.lineWidth = this._thickness;
  8549. if (this._cornerRadius) {
  8550. this._drawRoundedRect(context, this._thickness / 2);
  8551. context.stroke();
  8552. }
  8553. else {
  8554. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8555. }
  8556. }
  8557. context.restore();
  8558. };
  8559. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8560. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8561. this._measureForChildren.width -= 2 * this._thickness;
  8562. this._measureForChildren.height -= 2 * this._thickness;
  8563. this._measureForChildren.left += this._thickness;
  8564. this._measureForChildren.top += this._thickness;
  8565. };
  8566. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8567. if (offset === void 0) { offset = 0; }
  8568. var x = this._currentMeasure.left + offset;
  8569. var y = this._currentMeasure.top + offset;
  8570. var width = this._currentMeasure.width - offset * 2;
  8571. var height = this._currentMeasure.height - offset * 2;
  8572. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8573. context.beginPath();
  8574. context.moveTo(x + radius, y);
  8575. context.lineTo(x + width - radius, y);
  8576. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8577. context.lineTo(x + width, y + height - radius);
  8578. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8579. context.lineTo(x + radius, y + height);
  8580. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8581. context.lineTo(x, y + radius);
  8582. context.quadraticCurveTo(x, y, x + radius, y);
  8583. context.closePath();
  8584. };
  8585. Rectangle.prototype._clipForChildren = function (context) {
  8586. if (this._cornerRadius) {
  8587. this._drawRoundedRect(context, this._thickness);
  8588. context.clip();
  8589. }
  8590. };
  8591. return Rectangle;
  8592. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8593. /***/ }),
  8594. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8595. /*!***************************************************!*\
  8596. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8597. \***************************************************/
  8598. /*! exports provided: ScrollViewer */
  8599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8600. "use strict";
  8601. __webpack_require__.r(__webpack_exports__);
  8602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8603. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8604. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/observable");
  8605. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8606. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8607. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8608. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8609. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8610. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8611. /**
  8612. * Class used to hold a viewer window and sliders in a grid
  8613. */
  8614. var ScrollViewer = /** @class */ (function (_super) {
  8615. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8616. /**
  8617. * Creates a new ScrollViewer
  8618. * @param name of ScrollViewer
  8619. */
  8620. function ScrollViewer(name) {
  8621. var _this = _super.call(this, name) || this;
  8622. _this._barSize = 20;
  8623. _this._pointerIsOver = false;
  8624. _this._wheelPrecision = 0.05;
  8625. _this.onDirtyObservable.add(function () {
  8626. _this._horizontalBarSpace.color = _this.color;
  8627. _this._verticalBarSpace.color = _this.color;
  8628. _this._dragSpace.color = _this.color;
  8629. });
  8630. _this.onPointerEnterObservable.add(function () {
  8631. _this._pointerIsOver = true;
  8632. });
  8633. _this.onPointerOutObservable.add(function () {
  8634. _this._pointerIsOver = false;
  8635. });
  8636. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8637. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8638. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8639. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8640. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8641. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8642. _this._grid.addColumnDefinition(1);
  8643. _this._grid.addColumnDefinition(0, true);
  8644. _this._grid.addRowDefinition(1);
  8645. _this._grid.addRowDefinition(0, true);
  8646. _super.prototype.addControl.call(_this, _this._grid);
  8647. _this._grid.addControl(_this._window, 0, 0);
  8648. _this._verticalBar.paddingLeft = 0;
  8649. _this._verticalBar.width = "100%";
  8650. _this._verticalBar.height = "100%";
  8651. _this._verticalBar.barOffset = 0;
  8652. _this._verticalBar.value = 0;
  8653. _this._verticalBar.maximum = 1;
  8654. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8655. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8656. _this._verticalBar.isVertical = true;
  8657. _this._verticalBar.rotation = Math.PI;
  8658. _this._verticalBar.isVisible = false;
  8659. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8660. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8661. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8662. _this._verticalBarSpace.thickness = 1;
  8663. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8664. _this._verticalBarSpace.addControl(_this._verticalBar);
  8665. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8666. _this._window.top = value * _this._endTop + "px";
  8667. });
  8668. _this._horizontalBar.paddingLeft = 0;
  8669. _this._horizontalBar.width = "100%";
  8670. _this._horizontalBar.height = "100%";
  8671. _this._horizontalBar.barOffset = 0;
  8672. _this._horizontalBar.value = 0;
  8673. _this._horizontalBar.maximum = 1;
  8674. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8675. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8676. _this._horizontalBar.isVisible = false;
  8677. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8678. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8679. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8680. _this._horizontalBarSpace.thickness = 1;
  8681. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8682. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8683. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8684. _this._window.left = value * _this._endLeft + "px";
  8685. });
  8686. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8687. _this._dragSpace.thickness = 1;
  8688. _this._grid.addControl(_this._dragSpace, 1, 1);
  8689. // Colors
  8690. _this.barColor = "grey";
  8691. _this.barBackground = "transparent";
  8692. return _this;
  8693. }
  8694. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8695. /**
  8696. * Gets the horizontal scrollbar
  8697. */
  8698. get: function () {
  8699. return this._horizontalBar;
  8700. },
  8701. enumerable: true,
  8702. configurable: true
  8703. });
  8704. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8705. /**
  8706. * Gets the vertical scrollbar
  8707. */
  8708. get: function () {
  8709. return this._verticalBar;
  8710. },
  8711. enumerable: true,
  8712. configurable: true
  8713. });
  8714. /**
  8715. * Adds a new control to the current container
  8716. * @param control defines the control to add
  8717. * @returns the current container
  8718. */
  8719. ScrollViewer.prototype.addControl = function (control) {
  8720. if (!control) {
  8721. return this;
  8722. }
  8723. this._window.addControl(control);
  8724. return this;
  8725. };
  8726. /**
  8727. * Removes a control from the current container
  8728. * @param control defines the control to remove
  8729. * @returns the current container
  8730. */
  8731. ScrollViewer.prototype.removeControl = function (control) {
  8732. this._window.removeControl(control);
  8733. return this;
  8734. };
  8735. Object.defineProperty(ScrollViewer.prototype, "children", {
  8736. /** Gets the list of children */
  8737. get: function () {
  8738. return this._window.children;
  8739. },
  8740. enumerable: true,
  8741. configurable: true
  8742. });
  8743. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8744. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8745. var child = _a[_i];
  8746. child._markMatrixAsDirty();
  8747. }
  8748. };
  8749. /** Reset the scroll viewer window to initial size */
  8750. ScrollViewer.prototype.resetWindow = function () {
  8751. this._window.width = "100%";
  8752. this._window.height = "100%";
  8753. };
  8754. ScrollViewer.prototype._getTypeName = function () {
  8755. return "ScrollViewer";
  8756. };
  8757. ScrollViewer.prototype._buildClientSizes = function () {
  8758. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8759. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8760. this._clientWidth = this._window.parentClientWidth;
  8761. this._clientHeight = this._window.parentClientHeight;
  8762. };
  8763. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8764. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8765. this._buildClientSizes();
  8766. };
  8767. ScrollViewer.prototype._postMeasure = function () {
  8768. _super.prototype._postMeasure.call(this);
  8769. this._updateScroller();
  8770. };
  8771. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8772. /**
  8773. * Gets or sets the mouse wheel precision
  8774. * from 0 to 1 with a default value of 0.05
  8775. * */
  8776. get: function () {
  8777. return this._wheelPrecision;
  8778. },
  8779. set: function (value) {
  8780. if (this._wheelPrecision === value) {
  8781. return;
  8782. }
  8783. if (value < 0) {
  8784. value = 0;
  8785. }
  8786. if (value > 1) {
  8787. value = 1;
  8788. }
  8789. this._wheelPrecision = value;
  8790. },
  8791. enumerable: true,
  8792. configurable: true
  8793. });
  8794. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8795. /** Gets or sets the bar color */
  8796. get: function () {
  8797. return this._barColor;
  8798. },
  8799. set: function (color) {
  8800. if (this._barColor === color) {
  8801. return;
  8802. }
  8803. this._barColor = color;
  8804. this._horizontalBar.color = color;
  8805. this._verticalBar.color = color;
  8806. },
  8807. enumerable: true,
  8808. configurable: true
  8809. });
  8810. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8811. /** Gets or sets the size of the bar */
  8812. get: function () {
  8813. return this._barSize;
  8814. },
  8815. set: function (value) {
  8816. if (this._barSize === value) {
  8817. return;
  8818. }
  8819. this._barSize = value;
  8820. this._markAsDirty();
  8821. if (this._horizontalBar.isVisible) {
  8822. this._grid.setRowDefinition(1, this._barSize, true);
  8823. }
  8824. if (this._verticalBar.isVisible) {
  8825. this._grid.setColumnDefinition(1, this._barSize, true);
  8826. }
  8827. },
  8828. enumerable: true,
  8829. configurable: true
  8830. });
  8831. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8832. /** Gets or sets the bar background */
  8833. get: function () {
  8834. return this._barBackground;
  8835. },
  8836. set: function (color) {
  8837. if (this._barBackground === color) {
  8838. return;
  8839. }
  8840. this._barBackground = color;
  8841. this._horizontalBar.background = color;
  8842. this._verticalBar.background = color;
  8843. this._dragSpace.background = color;
  8844. },
  8845. enumerable: true,
  8846. configurable: true
  8847. });
  8848. /** @hidden */
  8849. ScrollViewer.prototype._updateScroller = function () {
  8850. var windowContentsWidth = this._window._currentMeasure.width;
  8851. var windowContentsHeight = this._window._currentMeasure.height;
  8852. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8853. this._grid.setRowDefinition(1, 0, true);
  8854. this._horizontalBar.isVisible = false;
  8855. this._horizontalBar.value = 0;
  8856. this._rebuildLayout = true;
  8857. }
  8858. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8859. this._grid.setRowDefinition(1, this._barSize, true);
  8860. this._horizontalBar.isVisible = true;
  8861. this._rebuildLayout = true;
  8862. }
  8863. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8864. this._grid.setColumnDefinition(1, 0, true);
  8865. this._verticalBar.isVisible = false;
  8866. this._verticalBar.value = 0;
  8867. this._rebuildLayout = true;
  8868. }
  8869. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8870. this._grid.setColumnDefinition(1, this._barSize, true);
  8871. this._verticalBar.isVisible = true;
  8872. this._rebuildLayout = true;
  8873. }
  8874. this._buildClientSizes();
  8875. this._endLeft = this._clientWidth - windowContentsWidth;
  8876. this._endTop = this._clientHeight - windowContentsHeight;
  8877. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8878. var newTop = this._verticalBar.value * this._endTop + "px";
  8879. if (newLeft !== this._window.left) {
  8880. this._window.left = newLeft;
  8881. this._rebuildLayout = true;
  8882. }
  8883. if (newTop !== this._window.top) {
  8884. this._window.top = newTop;
  8885. this._rebuildLayout = true;
  8886. }
  8887. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8888. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8889. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8890. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8891. };
  8892. ScrollViewer.prototype._link = function (host) {
  8893. _super.prototype._link.call(this, host);
  8894. this._attachWheel();
  8895. };
  8896. /** @hidden */
  8897. ScrollViewer.prototype._attachWheel = function () {
  8898. var _this = this;
  8899. if (this._onPointerObserver) {
  8900. return;
  8901. }
  8902. var scene = this._host.getScene();
  8903. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8904. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8905. return;
  8906. }
  8907. if (_this._verticalBar.isVisible == true) {
  8908. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8909. _this._verticalBar.value -= _this._wheelPrecision;
  8910. }
  8911. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8912. _this._verticalBar.value += _this._wheelPrecision;
  8913. }
  8914. }
  8915. if (_this._horizontalBar.isVisible == true) {
  8916. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8917. _this._horizontalBar.value += _this._wheelPrecision;
  8918. }
  8919. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8920. _this._horizontalBar.value -= _this._wheelPrecision;
  8921. }
  8922. }
  8923. });
  8924. };
  8925. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8926. if (!this.isHighlighted) {
  8927. return;
  8928. }
  8929. _super.prototype._renderHighlightSpecific.call(this, context);
  8930. this._grid._renderHighlightSpecific(context);
  8931. context.restore();
  8932. };
  8933. /** Releases associated resources */
  8934. ScrollViewer.prototype.dispose = function () {
  8935. var scene = this._host.getScene();
  8936. if (scene && this._onPointerObserver) {
  8937. scene.onPointerObservable.remove(this._onPointerObserver);
  8938. this._onPointerObserver = null;
  8939. }
  8940. _super.prototype.dispose.call(this);
  8941. };
  8942. return ScrollViewer;
  8943. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8944. /***/ }),
  8945. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8946. /*!*********************************************************!*\
  8947. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8948. \*********************************************************/
  8949. /*! exports provided: _ScrollViewerWindow */
  8950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8951. "use strict";
  8952. __webpack_require__.r(__webpack_exports__);
  8953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8954. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8955. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8956. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8957. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8958. /**
  8959. * Class used to hold a the container for ScrollViewer
  8960. * @hidden
  8961. */
  8962. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8963. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  8964. /**
  8965. * Creates a new ScrollViewerWindow
  8966. * @param name of ScrollViewerWindow
  8967. */
  8968. function _ScrollViewerWindow(name) {
  8969. return _super.call(this, name) || this;
  8970. }
  8971. _ScrollViewerWindow.prototype._getTypeName = function () {
  8972. return "ScrollViewerWindow";
  8973. };
  8974. /** @hidden */
  8975. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  8976. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8977. this._measureForChildren.left = this._currentMeasure.left;
  8978. this._measureForChildren.top = this._currentMeasure.top;
  8979. this._measureForChildren.width = parentMeasure.width;
  8980. this._measureForChildren.height = parentMeasure.height;
  8981. };
  8982. _ScrollViewerWindow.prototype._postMeasure = function () {
  8983. var maxWidth = this.parentClientWidth;
  8984. var maxHeight = this.parentClientHeight;
  8985. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  8986. var child = _a[_i];
  8987. if (!child.isVisible || child.notRenderable) {
  8988. continue;
  8989. }
  8990. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  8991. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  8992. }
  8993. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  8994. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  8995. }
  8996. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  8997. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  8998. }
  8999. if (this._currentMeasure.width !== maxWidth) {
  9000. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9001. this._currentMeasure.width = maxWidth;
  9002. this._rebuildLayout = true;
  9003. this._isDirty = true;
  9004. }
  9005. if (this._currentMeasure.height !== maxHeight) {
  9006. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9007. this._currentMeasure.height = maxHeight;
  9008. this._rebuildLayout = true;
  9009. this._isDirty = true;
  9010. }
  9011. _super.prototype._postMeasure.call(this);
  9012. };
  9013. return _ScrollViewerWindow;
  9014. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9015. /***/ }),
  9016. /***/ "./2D/controls/selector.ts":
  9017. /*!*********************************!*\
  9018. !*** ./2D/controls/selector.ts ***!
  9019. \*********************************/
  9020. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9022. "use strict";
  9023. __webpack_require__.r(__webpack_exports__);
  9024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9029. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9030. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9031. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9032. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9033. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9034. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9035. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9036. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9037. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9038. /** Class used to create a RadioGroup
  9039. * which contains groups of radio buttons
  9040. */
  9041. var SelectorGroup = /** @class */ (function () {
  9042. /**
  9043. * Creates a new SelectorGroup
  9044. * @param name of group, used as a group heading
  9045. */
  9046. function SelectorGroup(
  9047. /** name of SelectorGroup */
  9048. name) {
  9049. this.name = name;
  9050. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9051. this._selectors = new Array();
  9052. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9053. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9054. this._groupHeader = this._addGroupHeader(name);
  9055. }
  9056. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9057. /** Gets the groupPanel of the SelectorGroup */
  9058. get: function () {
  9059. return this._groupPanel;
  9060. },
  9061. enumerable: true,
  9062. configurable: true
  9063. });
  9064. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9065. /** Gets the selectors array */
  9066. get: function () {
  9067. return this._selectors;
  9068. },
  9069. enumerable: true,
  9070. configurable: true
  9071. });
  9072. Object.defineProperty(SelectorGroup.prototype, "header", {
  9073. /** Gets and sets the group header */
  9074. get: function () {
  9075. return this._groupHeader.text;
  9076. },
  9077. set: function (label) {
  9078. if (this._groupHeader.text === "label") {
  9079. return;
  9080. }
  9081. this._groupHeader.text = label;
  9082. },
  9083. enumerable: true,
  9084. configurable: true
  9085. });
  9086. /** @hidden */
  9087. SelectorGroup.prototype._addGroupHeader = function (text) {
  9088. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9089. groupHeading.width = 0.9;
  9090. groupHeading.height = "30px";
  9091. groupHeading.textWrapping = true;
  9092. groupHeading.color = "black";
  9093. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9094. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9095. groupHeading.left = "2px";
  9096. this._groupPanel.addControl(groupHeading);
  9097. return groupHeading;
  9098. };
  9099. /** @hidden*/
  9100. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9101. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9102. return;
  9103. }
  9104. return this._selectors[selectorNb];
  9105. };
  9106. /** Removes the selector at the given position
  9107. * @param selectorNb the position of the selector within the group
  9108. */
  9109. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9110. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9111. return;
  9112. }
  9113. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9114. this._selectors.splice(selectorNb, 1);
  9115. };
  9116. return SelectorGroup;
  9117. }());
  9118. /** Class used to create a CheckboxGroup
  9119. * which contains groups of checkbox buttons
  9120. */
  9121. var CheckboxGroup = /** @class */ (function (_super) {
  9122. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9123. function CheckboxGroup() {
  9124. return _super !== null && _super.apply(this, arguments) || this;
  9125. }
  9126. /** Adds a checkbox as a control
  9127. * @param text is the label for the selector
  9128. * @param func is the function called when the Selector is checked
  9129. * @param checked is true when Selector is checked
  9130. */
  9131. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9132. if (func === void 0) { func = function (s) { }; }
  9133. if (checked === void 0) { checked = false; }
  9134. var checked = checked || false;
  9135. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9136. button.width = "20px";
  9137. button.height = "20px";
  9138. button.color = "#364249";
  9139. button.background = "#CCCCCC";
  9140. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9141. button.onIsCheckedChangedObservable.add(function (state) {
  9142. func(state);
  9143. });
  9144. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9145. _selector.height = "30px";
  9146. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9147. _selector.left = "4px";
  9148. this.groupPanel.addControl(_selector);
  9149. this.selectors.push(_selector);
  9150. button.isChecked = checked;
  9151. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9152. button.color = this.groupPanel.parent.parent.buttonColor;
  9153. button.background = this.groupPanel.parent.parent.buttonBackground;
  9154. }
  9155. };
  9156. /** @hidden */
  9157. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9158. this.selectors[selectorNb].children[1].text = label;
  9159. };
  9160. /** @hidden */
  9161. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9162. this.selectors[selectorNb].children[1].color = color;
  9163. };
  9164. /** @hidden */
  9165. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9166. this.selectors[selectorNb].children[0].color = color;
  9167. };
  9168. /** @hidden */
  9169. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9170. this.selectors[selectorNb].children[0].background = color;
  9171. };
  9172. return CheckboxGroup;
  9173. }(SelectorGroup));
  9174. /** Class used to create a RadioGroup
  9175. * which contains groups of radio buttons
  9176. */
  9177. var RadioGroup = /** @class */ (function (_super) {
  9178. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9179. function RadioGroup() {
  9180. var _this = _super !== null && _super.apply(this, arguments) || this;
  9181. _this._selectNb = 0;
  9182. return _this;
  9183. }
  9184. /** Adds a radio button as a control
  9185. * @param label is the label for the selector
  9186. * @param func is the function called when the Selector is checked
  9187. * @param checked is true when Selector is checked
  9188. */
  9189. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9190. if (func === void 0) { func = function (n) { }; }
  9191. if (checked === void 0) { checked = false; }
  9192. var nb = this._selectNb++;
  9193. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9194. button.name = label;
  9195. button.width = "20px";
  9196. button.height = "20px";
  9197. button.color = "#364249";
  9198. button.background = "#CCCCCC";
  9199. button.group = this.name;
  9200. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9201. button.onIsCheckedChangedObservable.add(function (state) {
  9202. if (state) {
  9203. func(nb);
  9204. }
  9205. });
  9206. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9207. _selector.height = "30px";
  9208. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9209. _selector.left = "4px";
  9210. this.groupPanel.addControl(_selector);
  9211. this.selectors.push(_selector);
  9212. button.isChecked = checked;
  9213. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9214. button.color = this.groupPanel.parent.parent.buttonColor;
  9215. button.background = this.groupPanel.parent.parent.buttonBackground;
  9216. }
  9217. };
  9218. /** @hidden */
  9219. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9220. this.selectors[selectorNb].children[1].text = label;
  9221. };
  9222. /** @hidden */
  9223. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9224. this.selectors[selectorNb].children[1].color = color;
  9225. };
  9226. /** @hidden */
  9227. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9228. this.selectors[selectorNb].children[0].color = color;
  9229. };
  9230. /** @hidden */
  9231. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9232. this.selectors[selectorNb].children[0].background = color;
  9233. };
  9234. return RadioGroup;
  9235. }(SelectorGroup));
  9236. /** Class used to create a SliderGroup
  9237. * which contains groups of slider buttons
  9238. */
  9239. var SliderGroup = /** @class */ (function (_super) {
  9240. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9241. function SliderGroup() {
  9242. return _super !== null && _super.apply(this, arguments) || this;
  9243. }
  9244. /**
  9245. * Adds a slider to the SelectorGroup
  9246. * @param label is the label for the SliderBar
  9247. * @param func is the function called when the Slider moves
  9248. * @param unit is a string describing the units used, eg degrees or metres
  9249. * @param min is the minimum value for the Slider
  9250. * @param max is the maximum value for the Slider
  9251. * @param value is the start value for the Slider between min and max
  9252. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9253. */
  9254. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9255. if (func === void 0) { func = function (v) { }; }
  9256. if (unit === void 0) { unit = "Units"; }
  9257. if (min === void 0) { min = 0; }
  9258. if (max === void 0) { max = 0; }
  9259. if (value === void 0) { value = 0; }
  9260. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9261. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9262. button.name = unit;
  9263. button.value = value;
  9264. button.minimum = min;
  9265. button.maximum = max;
  9266. button.width = 0.9;
  9267. button.height = "20px";
  9268. button.color = "#364249";
  9269. button.background = "#CCCCCC";
  9270. button.borderColor = "black";
  9271. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9272. button.left = "4px";
  9273. button.paddingBottom = "4px";
  9274. button.onValueChangedObservable.add(function (value) {
  9275. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9276. func(value);
  9277. });
  9278. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9279. _selector.height = "60px";
  9280. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9281. _selector.left = "4px";
  9282. _selector.children[0].name = label;
  9283. this.groupPanel.addControl(_selector);
  9284. this.selectors.push(_selector);
  9285. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9286. button.color = this.groupPanel.parent.parent.buttonColor;
  9287. button.background = this.groupPanel.parent.parent.buttonBackground;
  9288. }
  9289. };
  9290. /** @hidden */
  9291. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9292. this.selectors[selectorNb].children[0].name = label;
  9293. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9294. };
  9295. /** @hidden */
  9296. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9297. this.selectors[selectorNb].children[0].color = color;
  9298. };
  9299. /** @hidden */
  9300. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9301. this.selectors[selectorNb].children[1].color = color;
  9302. };
  9303. /** @hidden */
  9304. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9305. this.selectors[selectorNb].children[1].background = color;
  9306. };
  9307. return SliderGroup;
  9308. }(SelectorGroup));
  9309. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9310. * @see http://doc.babylonjs.com/how_to/selector
  9311. */
  9312. var SelectionPanel = /** @class */ (function (_super) {
  9313. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9314. /**
  9315. * Creates a new SelectionPanel
  9316. * @param name of SelectionPanel
  9317. * @param groups is an array of SelectionGroups
  9318. */
  9319. function SelectionPanel(
  9320. /** name of SelectionPanel */
  9321. name,
  9322. /** an array of SelectionGroups */
  9323. groups) {
  9324. if (groups === void 0) { groups = []; }
  9325. var _this = _super.call(this, name) || this;
  9326. _this.name = name;
  9327. _this.groups = groups;
  9328. _this._buttonColor = "#364249";
  9329. _this._buttonBackground = "#CCCCCC";
  9330. _this._headerColor = "black";
  9331. _this._barColor = "white";
  9332. _this._barHeight = "2px";
  9333. _this._spacerHeight = "20px";
  9334. _this._bars = new Array();
  9335. _this._groups = groups;
  9336. _this.thickness = 2;
  9337. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9338. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9339. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9340. _this._panel.top = 5;
  9341. _this._panel.left = 5;
  9342. _this._panel.width = 0.95;
  9343. if (groups.length > 0) {
  9344. for (var i = 0; i < groups.length - 1; i++) {
  9345. _this._panel.addControl(groups[i].groupPanel);
  9346. _this._addSpacer();
  9347. }
  9348. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9349. }
  9350. _this.addControl(_this._panel);
  9351. return _this;
  9352. }
  9353. SelectionPanel.prototype._getTypeName = function () {
  9354. return "SelectionPanel";
  9355. };
  9356. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9357. /** Gets or sets the headerColor */
  9358. get: function () {
  9359. return this._headerColor;
  9360. },
  9361. set: function (color) {
  9362. if (this._headerColor === color) {
  9363. return;
  9364. }
  9365. this._headerColor = color;
  9366. this._setHeaderColor();
  9367. },
  9368. enumerable: true,
  9369. configurable: true
  9370. });
  9371. SelectionPanel.prototype._setHeaderColor = function () {
  9372. for (var i = 0; i < this._groups.length; i++) {
  9373. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9374. }
  9375. };
  9376. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9377. /** Gets or sets the button color */
  9378. get: function () {
  9379. return this._buttonColor;
  9380. },
  9381. set: function (color) {
  9382. if (this._buttonColor === color) {
  9383. return;
  9384. }
  9385. this._buttonColor = color;
  9386. this._setbuttonColor();
  9387. },
  9388. enumerable: true,
  9389. configurable: true
  9390. });
  9391. SelectionPanel.prototype._setbuttonColor = function () {
  9392. for (var i = 0; i < this._groups.length; i++) {
  9393. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9394. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9395. }
  9396. }
  9397. };
  9398. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9399. /** Gets or sets the label color */
  9400. get: function () {
  9401. return this._labelColor;
  9402. },
  9403. set: function (color) {
  9404. if (this._labelColor === color) {
  9405. return;
  9406. }
  9407. this._labelColor = color;
  9408. this._setLabelColor();
  9409. },
  9410. enumerable: true,
  9411. configurable: true
  9412. });
  9413. SelectionPanel.prototype._setLabelColor = function () {
  9414. for (var i = 0; i < this._groups.length; i++) {
  9415. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9416. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9417. }
  9418. }
  9419. };
  9420. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9421. /** Gets or sets the button background */
  9422. get: function () {
  9423. return this._buttonBackground;
  9424. },
  9425. set: function (color) {
  9426. if (this._buttonBackground === color) {
  9427. return;
  9428. }
  9429. this._buttonBackground = color;
  9430. this._setButtonBackground();
  9431. },
  9432. enumerable: true,
  9433. configurable: true
  9434. });
  9435. SelectionPanel.prototype._setButtonBackground = function () {
  9436. for (var i = 0; i < this._groups.length; i++) {
  9437. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9438. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9439. }
  9440. }
  9441. };
  9442. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9443. /** Gets or sets the color of separator bar */
  9444. get: function () {
  9445. return this._barColor;
  9446. },
  9447. set: function (color) {
  9448. if (this._barColor === color) {
  9449. return;
  9450. }
  9451. this._barColor = color;
  9452. this._setBarColor();
  9453. },
  9454. enumerable: true,
  9455. configurable: true
  9456. });
  9457. SelectionPanel.prototype._setBarColor = function () {
  9458. for (var i = 0; i < this._bars.length; i++) {
  9459. this._bars[i].children[0].background = this._barColor;
  9460. }
  9461. };
  9462. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9463. /** Gets or sets the height of separator bar */
  9464. get: function () {
  9465. return this._barHeight;
  9466. },
  9467. set: function (value) {
  9468. if (this._barHeight === value) {
  9469. return;
  9470. }
  9471. this._barHeight = value;
  9472. this._setBarHeight();
  9473. },
  9474. enumerable: true,
  9475. configurable: true
  9476. });
  9477. SelectionPanel.prototype._setBarHeight = function () {
  9478. for (var i = 0; i < this._bars.length; i++) {
  9479. this._bars[i].children[0].height = this._barHeight;
  9480. }
  9481. };
  9482. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9483. /** Gets or sets the height of spacers*/
  9484. get: function () {
  9485. return this._spacerHeight;
  9486. },
  9487. set: function (value) {
  9488. if (this._spacerHeight === value) {
  9489. return;
  9490. }
  9491. this._spacerHeight = value;
  9492. this._setSpacerHeight();
  9493. },
  9494. enumerable: true,
  9495. configurable: true
  9496. });
  9497. SelectionPanel.prototype._setSpacerHeight = function () {
  9498. for (var i = 0; i < this._bars.length; i++) {
  9499. this._bars[i].height = this._spacerHeight;
  9500. }
  9501. };
  9502. /** Adds a bar between groups */
  9503. SelectionPanel.prototype._addSpacer = function () {
  9504. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9505. separator.width = 1;
  9506. separator.height = this._spacerHeight;
  9507. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9508. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9509. bar.width = 1;
  9510. bar.height = this._barHeight;
  9511. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9512. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9513. bar.background = this._barColor;
  9514. bar.color = "transparent";
  9515. separator.addControl(bar);
  9516. this._panel.addControl(separator);
  9517. this._bars.push(separator);
  9518. };
  9519. /** Add a group to the selection panel
  9520. * @param group is the selector group to add
  9521. */
  9522. SelectionPanel.prototype.addGroup = function (group) {
  9523. if (this._groups.length > 0) {
  9524. this._addSpacer();
  9525. }
  9526. this._panel.addControl(group.groupPanel);
  9527. this._groups.push(group);
  9528. group.groupPanel.children[0].color = this._headerColor;
  9529. for (var j = 0; j < group.selectors.length; j++) {
  9530. group._setSelectorButtonColor(j, this._buttonColor);
  9531. group._setSelectorButtonBackground(j, this._buttonBackground);
  9532. }
  9533. };
  9534. /** Remove the group from the given position
  9535. * @param groupNb is the position of the group in the list
  9536. */
  9537. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9538. if (groupNb < 0 || groupNb >= this._groups.length) {
  9539. return;
  9540. }
  9541. var group = this._groups[groupNb];
  9542. this._panel.removeControl(group.groupPanel);
  9543. this._groups.splice(groupNb, 1);
  9544. if (groupNb < this._bars.length) {
  9545. this._panel.removeControl(this._bars[groupNb]);
  9546. this._bars.splice(groupNb, 1);
  9547. }
  9548. };
  9549. /** Change a group header label
  9550. * @param label is the new group header label
  9551. * @param groupNb is the number of the group to relabel
  9552. * */
  9553. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9554. if (groupNb < 0 || groupNb >= this._groups.length) {
  9555. return;
  9556. }
  9557. var group = this._groups[groupNb];
  9558. group.groupPanel.children[0].text = label;
  9559. };
  9560. /** Change selector label to the one given
  9561. * @param label is the new selector label
  9562. * @param groupNb is the number of the groupcontaining the selector
  9563. * @param selectorNb is the number of the selector within a group to relabel
  9564. * */
  9565. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9566. if (groupNb < 0 || groupNb >= this._groups.length) {
  9567. return;
  9568. }
  9569. var group = this._groups[groupNb];
  9570. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9571. return;
  9572. }
  9573. group._setSelectorLabel(selectorNb, label);
  9574. };
  9575. /** For a given group position remove the selector at the given position
  9576. * @param groupNb is the number of the group to remove the selector from
  9577. * @param selectorNb is the number of the selector within the group
  9578. */
  9579. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9580. if (groupNb < 0 || groupNb >= this._groups.length) {
  9581. return;
  9582. }
  9583. var group = this._groups[groupNb];
  9584. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9585. return;
  9586. }
  9587. group.removeSelector(selectorNb);
  9588. };
  9589. /** For a given group position of correct type add a checkbox button
  9590. * @param groupNb is the number of the group to remove the selector from
  9591. * @param label is the label for the selector
  9592. * @param func is the function called when the Selector is checked
  9593. * @param checked is true when Selector is checked
  9594. */
  9595. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9596. if (func === void 0) { func = function () { }; }
  9597. if (checked === void 0) { checked = false; }
  9598. if (groupNb < 0 || groupNb >= this._groups.length) {
  9599. return;
  9600. }
  9601. var group = this._groups[groupNb];
  9602. group.addCheckbox(label, func, checked);
  9603. };
  9604. /** For a given group position of correct type add a radio button
  9605. * @param groupNb is the number of the group to remove the selector from
  9606. * @param label is the label for the selector
  9607. * @param func is the function called when the Selector is checked
  9608. * @param checked is true when Selector is checked
  9609. */
  9610. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9611. if (func === void 0) { func = function () { }; }
  9612. if (checked === void 0) { checked = false; }
  9613. if (groupNb < 0 || groupNb >= this._groups.length) {
  9614. return;
  9615. }
  9616. var group = this._groups[groupNb];
  9617. group.addRadio(label, func, checked);
  9618. };
  9619. /**
  9620. * For a given slider group add a slider
  9621. * @param groupNb is the number of the group to add the slider to
  9622. * @param label is the label for the Slider
  9623. * @param func is the function called when the Slider moves
  9624. * @param unit is a string describing the units used, eg degrees or metres
  9625. * @param min is the minimum value for the Slider
  9626. * @param max is the maximum value for the Slider
  9627. * @param value is the start value for the Slider between min and max
  9628. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9629. */
  9630. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9631. if (func === void 0) { func = function () { }; }
  9632. if (unit === void 0) { unit = "Units"; }
  9633. if (min === void 0) { min = 0; }
  9634. if (max === void 0) { max = 0; }
  9635. if (value === void 0) { value = 0; }
  9636. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9637. if (groupNb < 0 || groupNb >= this._groups.length) {
  9638. return;
  9639. }
  9640. var group = this._groups[groupNb];
  9641. group.addSlider(label, func, unit, min, max, value, onVal);
  9642. };
  9643. return SelectionPanel;
  9644. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9645. /***/ }),
  9646. /***/ "./2D/controls/sliders/baseSlider.ts":
  9647. /*!*******************************************!*\
  9648. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9649. \*******************************************/
  9650. /*! exports provided: BaseSlider */
  9651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9652. "use strict";
  9653. __webpack_require__.r(__webpack_exports__);
  9654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9655. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9656. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  9657. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9658. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9659. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9660. /**
  9661. * Class used to create slider controls
  9662. */
  9663. var BaseSlider = /** @class */ (function (_super) {
  9664. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9665. /**
  9666. * Creates a new BaseSlider
  9667. * @param name defines the control name
  9668. */
  9669. function BaseSlider(name) {
  9670. var _this = _super.call(this, name) || this;
  9671. _this.name = name;
  9672. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9673. _this._minimum = 0;
  9674. _this._maximum = 100;
  9675. _this._value = 50;
  9676. _this._isVertical = false;
  9677. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9678. _this._isThumbClamped = false;
  9679. _this._displayThumb = true;
  9680. _this._step = 0;
  9681. // Shared rendering info
  9682. _this._effectiveBarOffset = 0;
  9683. /** Observable raised when the sldier value changes */
  9684. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9685. // Events
  9686. _this._pointerIsDown = false;
  9687. _this.isPointerBlocker = true;
  9688. return _this;
  9689. }
  9690. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9691. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9692. get: function () {
  9693. return this._displayThumb;
  9694. },
  9695. set: function (value) {
  9696. if (this._displayThumb === value) {
  9697. return;
  9698. }
  9699. this._displayThumb = value;
  9700. this._markAsDirty();
  9701. },
  9702. enumerable: true,
  9703. configurable: true
  9704. });
  9705. Object.defineProperty(BaseSlider.prototype, "step", {
  9706. /** Gets or sets a step to apply to values (0 by default) */
  9707. get: function () {
  9708. return this._step;
  9709. },
  9710. set: function (value) {
  9711. if (this._step === value) {
  9712. return;
  9713. }
  9714. this._step = value;
  9715. this._markAsDirty();
  9716. },
  9717. enumerable: true,
  9718. configurable: true
  9719. });
  9720. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9721. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9722. get: function () {
  9723. return this._barOffset.toString(this._host);
  9724. },
  9725. set: function (value) {
  9726. if (this._barOffset.toString(this._host) === value) {
  9727. return;
  9728. }
  9729. if (this._barOffset.fromString(value)) {
  9730. this._markAsDirty();
  9731. }
  9732. },
  9733. enumerable: true,
  9734. configurable: true
  9735. });
  9736. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9737. /** Gets main bar offset in pixels*/
  9738. get: function () {
  9739. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9740. },
  9741. enumerable: true,
  9742. configurable: true
  9743. });
  9744. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9745. /** Gets or sets thumb width */
  9746. get: function () {
  9747. return this._thumbWidth.toString(this._host);
  9748. },
  9749. set: function (value) {
  9750. if (this._thumbWidth.toString(this._host) === value) {
  9751. return;
  9752. }
  9753. if (this._thumbWidth.fromString(value)) {
  9754. this._markAsDirty();
  9755. }
  9756. },
  9757. enumerable: true,
  9758. configurable: true
  9759. });
  9760. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9761. /** Gets thumb width in pixels */
  9762. get: function () {
  9763. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9764. },
  9765. enumerable: true,
  9766. configurable: true
  9767. });
  9768. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9769. /** Gets or sets minimum value */
  9770. get: function () {
  9771. return this._minimum;
  9772. },
  9773. set: function (value) {
  9774. if (this._minimum === value) {
  9775. return;
  9776. }
  9777. this._minimum = value;
  9778. this._markAsDirty();
  9779. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9780. },
  9781. enumerable: true,
  9782. configurable: true
  9783. });
  9784. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9785. /** Gets or sets maximum value */
  9786. get: function () {
  9787. return this._maximum;
  9788. },
  9789. set: function (value) {
  9790. if (this._maximum === value) {
  9791. return;
  9792. }
  9793. this._maximum = value;
  9794. this._markAsDirty();
  9795. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9796. },
  9797. enumerable: true,
  9798. configurable: true
  9799. });
  9800. Object.defineProperty(BaseSlider.prototype, "value", {
  9801. /** Gets or sets current value */
  9802. get: function () {
  9803. return this._value;
  9804. },
  9805. set: function (value) {
  9806. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9807. if (this._value === value) {
  9808. return;
  9809. }
  9810. this._value = value;
  9811. this._markAsDirty();
  9812. this.onValueChangedObservable.notifyObservers(this._value);
  9813. },
  9814. enumerable: true,
  9815. configurable: true
  9816. });
  9817. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9818. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9819. get: function () {
  9820. return this._isVertical;
  9821. },
  9822. set: function (value) {
  9823. if (this._isVertical === value) {
  9824. return;
  9825. }
  9826. this._isVertical = value;
  9827. this._markAsDirty();
  9828. },
  9829. enumerable: true,
  9830. configurable: true
  9831. });
  9832. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9833. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9834. get: function () {
  9835. return this._isThumbClamped;
  9836. },
  9837. set: function (value) {
  9838. if (this._isThumbClamped === value) {
  9839. return;
  9840. }
  9841. this._isThumbClamped = value;
  9842. this._markAsDirty();
  9843. },
  9844. enumerable: true,
  9845. configurable: true
  9846. });
  9847. BaseSlider.prototype._getTypeName = function () {
  9848. return "BaseSlider";
  9849. };
  9850. BaseSlider.prototype._getThumbPosition = function () {
  9851. if (this.isVertical) {
  9852. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9853. }
  9854. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9855. };
  9856. BaseSlider.prototype._getThumbThickness = function (type) {
  9857. var thumbThickness = 0;
  9858. switch (type) {
  9859. case "circle":
  9860. if (this._thumbWidth.isPixel) {
  9861. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9862. }
  9863. else {
  9864. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9865. }
  9866. break;
  9867. case "rectangle":
  9868. if (this._thumbWidth.isPixel) {
  9869. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9870. }
  9871. else {
  9872. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9873. }
  9874. }
  9875. return thumbThickness;
  9876. };
  9877. BaseSlider.prototype._prepareRenderingData = function (type) {
  9878. // Main bar
  9879. this._effectiveBarOffset = 0;
  9880. this._renderLeft = this._currentMeasure.left;
  9881. this._renderTop = this._currentMeasure.top;
  9882. this._renderWidth = this._currentMeasure.width;
  9883. this._renderHeight = this._currentMeasure.height;
  9884. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9885. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9886. this._effectiveThumbThickness = this._getThumbThickness(type);
  9887. if (this.displayThumb) {
  9888. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9889. }
  9890. //throw error when height is less than width for vertical slider
  9891. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9892. console.error("Height should be greater than width");
  9893. return;
  9894. }
  9895. if (this._barOffset.isPixel) {
  9896. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9897. }
  9898. else {
  9899. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9900. }
  9901. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9902. if (this.isVertical) {
  9903. this._renderLeft += this._effectiveBarOffset;
  9904. if (!this.isThumbClamped && this.displayThumb) {
  9905. this._renderTop += (this._effectiveThumbThickness / 2);
  9906. }
  9907. this._renderHeight = this._backgroundBoxLength;
  9908. this._renderWidth = this._backgroundBoxThickness;
  9909. }
  9910. else {
  9911. this._renderTop += this._effectiveBarOffset;
  9912. if (!this.isThumbClamped && this.displayThumb) {
  9913. this._renderLeft += (this._effectiveThumbThickness / 2);
  9914. }
  9915. this._renderHeight = this._backgroundBoxThickness;
  9916. this._renderWidth = this._backgroundBoxLength;
  9917. }
  9918. };
  9919. /** @hidden */
  9920. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9921. if (this.rotation != 0) {
  9922. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9923. x = this._transformedPosition.x;
  9924. y = this._transformedPosition.y;
  9925. }
  9926. var value;
  9927. if (this._isVertical) {
  9928. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9929. }
  9930. else {
  9931. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9932. }
  9933. var mult = (1 / this._step) | 0;
  9934. this.value = this._step ? ((value * mult) | 0) / mult : value;
  9935. };
  9936. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9937. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9938. return false;
  9939. }
  9940. this._pointerIsDown = true;
  9941. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9942. this._host._capturingControl[pointerId] = this;
  9943. return true;
  9944. };
  9945. BaseSlider.prototype._onPointerMove = function (target, coordinates) {
  9946. if (this._pointerIsDown) {
  9947. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9948. }
  9949. _super.prototype._onPointerMove.call(this, target, coordinates);
  9950. };
  9951. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9952. this._pointerIsDown = false;
  9953. delete this._host._capturingControl[pointerId];
  9954. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9955. };
  9956. return BaseSlider;
  9957. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9958. /***/ }),
  9959. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  9960. /*!*************************************************!*\
  9961. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  9962. \*************************************************/
  9963. /*! exports provided: ImageBasedSlider */
  9964. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9965. "use strict";
  9966. __webpack_require__.r(__webpack_exports__);
  9967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  9968. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9969. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  9970. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9971. /**
  9972. * Class used to create slider controls based on images
  9973. */
  9974. var ImageBasedSlider = /** @class */ (function (_super) {
  9975. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  9976. /**
  9977. * Creates a new ImageBasedSlider
  9978. * @param name defines the control name
  9979. */
  9980. function ImageBasedSlider(name) {
  9981. var _this = _super.call(this, name) || this;
  9982. _this.name = name;
  9983. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  9984. return _this;
  9985. }
  9986. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  9987. get: function () {
  9988. return this._displayThumb && this.thumbImage != null;
  9989. },
  9990. set: function (value) {
  9991. if (this._displayThumb === value) {
  9992. return;
  9993. }
  9994. this._displayThumb = value;
  9995. this._markAsDirty();
  9996. },
  9997. enumerable: true,
  9998. configurable: true
  9999. });
  10000. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10001. /**
  10002. * Gets or sets the image used to render the background
  10003. */
  10004. get: function () {
  10005. return this._backgroundImage;
  10006. },
  10007. set: function (value) {
  10008. var _this = this;
  10009. if (this._backgroundImage === value) {
  10010. return;
  10011. }
  10012. this._backgroundImage = value;
  10013. if (value && !value.isLoaded) {
  10014. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10015. }
  10016. this._markAsDirty();
  10017. },
  10018. enumerable: true,
  10019. configurable: true
  10020. });
  10021. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10022. /**
  10023. * Gets or sets the image used to render the value bar
  10024. */
  10025. get: function () {
  10026. return this._valueBarImage;
  10027. },
  10028. set: function (value) {
  10029. var _this = this;
  10030. if (this._valueBarImage === value) {
  10031. return;
  10032. }
  10033. this._valueBarImage = value;
  10034. if (value && !value.isLoaded) {
  10035. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10036. }
  10037. this._markAsDirty();
  10038. },
  10039. enumerable: true,
  10040. configurable: true
  10041. });
  10042. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10043. /**
  10044. * Gets or sets the image used to render the thumb
  10045. */
  10046. get: function () {
  10047. return this._thumbImage;
  10048. },
  10049. set: function (value) {
  10050. var _this = this;
  10051. if (this._thumbImage === value) {
  10052. return;
  10053. }
  10054. this._thumbImage = value;
  10055. if (value && !value.isLoaded) {
  10056. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10057. }
  10058. this._markAsDirty();
  10059. },
  10060. enumerable: true,
  10061. configurable: true
  10062. });
  10063. ImageBasedSlider.prototype._getTypeName = function () {
  10064. return "ImageBasedSlider";
  10065. };
  10066. ImageBasedSlider.prototype._draw = function (context) {
  10067. context.save();
  10068. this._applyStates(context);
  10069. this._prepareRenderingData("rectangle");
  10070. var thumbPosition = this._getThumbPosition();
  10071. var left = this._renderLeft;
  10072. var top = this._renderTop;
  10073. var width = this._renderWidth;
  10074. var height = this._renderHeight;
  10075. // Background
  10076. if (this._backgroundImage) {
  10077. this._tempMeasure.copyFromFloats(left, top, width, height);
  10078. if (this.isThumbClamped && this.displayThumb) {
  10079. if (this.isVertical) {
  10080. this._tempMeasure.height += this._effectiveThumbThickness;
  10081. }
  10082. else {
  10083. this._tempMeasure.width += this._effectiveThumbThickness;
  10084. }
  10085. }
  10086. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10087. this._backgroundImage._draw(context);
  10088. }
  10089. // Bar
  10090. if (this._valueBarImage) {
  10091. if (this.isVertical) {
  10092. if (this.isThumbClamped && this.displayThumb) {
  10093. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10094. }
  10095. else {
  10096. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10097. }
  10098. }
  10099. else {
  10100. if (this.isThumbClamped && this.displayThumb) {
  10101. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10102. }
  10103. else {
  10104. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10105. }
  10106. }
  10107. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10108. this._valueBarImage._draw(context);
  10109. }
  10110. // Thumb
  10111. if (this.displayThumb) {
  10112. if (this.isVertical) {
  10113. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10114. }
  10115. else {
  10116. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10117. }
  10118. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10119. this._thumbImage._draw(context);
  10120. }
  10121. context.restore();
  10122. };
  10123. return ImageBasedSlider;
  10124. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10125. /***/ }),
  10126. /***/ "./2D/controls/sliders/scrollBar.ts":
  10127. /*!******************************************!*\
  10128. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10129. \******************************************/
  10130. /*! exports provided: ScrollBar */
  10131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10132. "use strict";
  10133. __webpack_require__.r(__webpack_exports__);
  10134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10135. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10136. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10137. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10138. /**
  10139. * Class used to create slider controls
  10140. */
  10141. var ScrollBar = /** @class */ (function (_super) {
  10142. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10143. /**
  10144. * Creates a new Slider
  10145. * @param name defines the control name
  10146. */
  10147. function ScrollBar(name) {
  10148. var _this = _super.call(this, name) || this;
  10149. _this.name = name;
  10150. _this._background = "black";
  10151. _this._borderColor = "white";
  10152. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10153. return _this;
  10154. }
  10155. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10156. /** Gets or sets border color */
  10157. get: function () {
  10158. return this._borderColor;
  10159. },
  10160. set: function (value) {
  10161. if (this._borderColor === value) {
  10162. return;
  10163. }
  10164. this._borderColor = value;
  10165. this._markAsDirty();
  10166. },
  10167. enumerable: true,
  10168. configurable: true
  10169. });
  10170. Object.defineProperty(ScrollBar.prototype, "background", {
  10171. /** Gets or sets background color */
  10172. get: function () {
  10173. return this._background;
  10174. },
  10175. set: function (value) {
  10176. if (this._background === value) {
  10177. return;
  10178. }
  10179. this._background = value;
  10180. this._markAsDirty();
  10181. },
  10182. enumerable: true,
  10183. configurable: true
  10184. });
  10185. ScrollBar.prototype._getTypeName = function () {
  10186. return "Scrollbar";
  10187. };
  10188. ScrollBar.prototype._getThumbThickness = function () {
  10189. var thumbThickness = 0;
  10190. if (this._thumbWidth.isPixel) {
  10191. thumbThickness = this._thumbWidth.getValue(this._host);
  10192. }
  10193. else {
  10194. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10195. }
  10196. return thumbThickness;
  10197. };
  10198. ScrollBar.prototype._draw = function (context) {
  10199. context.save();
  10200. this._applyStates(context);
  10201. this._prepareRenderingData("rectangle");
  10202. var left = this._renderLeft;
  10203. var thumbPosition = this._getThumbPosition();
  10204. context.fillStyle = this._background;
  10205. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10206. // Value bar
  10207. context.fillStyle = this.color;
  10208. // Thumb
  10209. if (this.isVertical) {
  10210. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10211. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10212. this._thumbMeasure.width = this._currentMeasure.width;
  10213. this._thumbMeasure.height = this._effectiveThumbThickness;
  10214. }
  10215. else {
  10216. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10217. this._thumbMeasure.top = this._currentMeasure.top;
  10218. this._thumbMeasure.width = this._effectiveThumbThickness;
  10219. this._thumbMeasure.height = this._currentMeasure.height;
  10220. }
  10221. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10222. context.restore();
  10223. };
  10224. /** @hidden */
  10225. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10226. if (this.rotation != 0) {
  10227. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10228. x = this._transformedPosition.x;
  10229. y = this._transformedPosition.y;
  10230. }
  10231. if (this._first) {
  10232. this._first = false;
  10233. this._originX = x;
  10234. this._originY = y;
  10235. // Check if move is required
  10236. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10237. if (this.isVertical) {
  10238. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10239. }
  10240. else {
  10241. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10242. }
  10243. }
  10244. }
  10245. // Delta mode
  10246. var delta = 0;
  10247. if (this.isVertical) {
  10248. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10249. }
  10250. else {
  10251. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10252. }
  10253. this.value += delta * (this.maximum - this.minimum);
  10254. this._originX = x;
  10255. this._originY = y;
  10256. };
  10257. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10258. this._first = true;
  10259. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10260. };
  10261. return ScrollBar;
  10262. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10263. /***/ }),
  10264. /***/ "./2D/controls/sliders/slider.ts":
  10265. /*!***************************************!*\
  10266. !*** ./2D/controls/sliders/slider.ts ***!
  10267. \***************************************/
  10268. /*! exports provided: Slider */
  10269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10270. "use strict";
  10271. __webpack_require__.r(__webpack_exports__);
  10272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10273. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10274. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10275. /**
  10276. * Class used to create slider controls
  10277. */
  10278. var Slider = /** @class */ (function (_super) {
  10279. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10280. /**
  10281. * Creates a new Slider
  10282. * @param name defines the control name
  10283. */
  10284. function Slider(name) {
  10285. var _this = _super.call(this, name) || this;
  10286. _this.name = name;
  10287. _this._background = "black";
  10288. _this._borderColor = "white";
  10289. _this._isThumbCircle = false;
  10290. _this._displayValueBar = true;
  10291. return _this;
  10292. }
  10293. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10294. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10295. get: function () {
  10296. return this._displayValueBar;
  10297. },
  10298. set: function (value) {
  10299. if (this._displayValueBar === value) {
  10300. return;
  10301. }
  10302. this._displayValueBar = value;
  10303. this._markAsDirty();
  10304. },
  10305. enumerable: true,
  10306. configurable: true
  10307. });
  10308. Object.defineProperty(Slider.prototype, "borderColor", {
  10309. /** Gets or sets border color */
  10310. get: function () {
  10311. return this._borderColor;
  10312. },
  10313. set: function (value) {
  10314. if (this._borderColor === value) {
  10315. return;
  10316. }
  10317. this._borderColor = value;
  10318. this._markAsDirty();
  10319. },
  10320. enumerable: true,
  10321. configurable: true
  10322. });
  10323. Object.defineProperty(Slider.prototype, "background", {
  10324. /** Gets or sets background color */
  10325. get: function () {
  10326. return this._background;
  10327. },
  10328. set: function (value) {
  10329. if (this._background === value) {
  10330. return;
  10331. }
  10332. this._background = value;
  10333. this._markAsDirty();
  10334. },
  10335. enumerable: true,
  10336. configurable: true
  10337. });
  10338. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10339. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10340. get: function () {
  10341. return this._isThumbCircle;
  10342. },
  10343. set: function (value) {
  10344. if (this._isThumbCircle === value) {
  10345. return;
  10346. }
  10347. this._isThumbCircle = value;
  10348. this._markAsDirty();
  10349. },
  10350. enumerable: true,
  10351. configurable: true
  10352. });
  10353. Slider.prototype._getTypeName = function () {
  10354. return "Slider";
  10355. };
  10356. Slider.prototype._draw = function (context) {
  10357. context.save();
  10358. this._applyStates(context);
  10359. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10360. var left = this._renderLeft;
  10361. var top = this._renderTop;
  10362. var width = this._renderWidth;
  10363. var height = this._renderHeight;
  10364. var radius = 0;
  10365. if (this.isThumbClamped && this.isThumbCircle) {
  10366. if (this.isVertical) {
  10367. top += (this._effectiveThumbThickness / 2);
  10368. }
  10369. else {
  10370. left += (this._effectiveThumbThickness / 2);
  10371. }
  10372. radius = this._backgroundBoxThickness / 2;
  10373. }
  10374. else {
  10375. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10376. }
  10377. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10378. context.shadowColor = this.shadowColor;
  10379. context.shadowBlur = this.shadowBlur;
  10380. context.shadowOffsetX = this.shadowOffsetX;
  10381. context.shadowOffsetY = this.shadowOffsetY;
  10382. }
  10383. var thumbPosition = this._getThumbPosition();
  10384. context.fillStyle = this._background;
  10385. if (this.isVertical) {
  10386. if (this.isThumbClamped) {
  10387. if (this.isThumbCircle) {
  10388. context.beginPath();
  10389. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10390. context.fill();
  10391. context.fillRect(left, top, width, height);
  10392. }
  10393. else {
  10394. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10395. }
  10396. }
  10397. else {
  10398. context.fillRect(left, top, width, height);
  10399. }
  10400. }
  10401. else {
  10402. if (this.isThumbClamped) {
  10403. if (this.isThumbCircle) {
  10404. context.beginPath();
  10405. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10406. context.fill();
  10407. context.fillRect(left, top, width, height);
  10408. }
  10409. else {
  10410. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10411. }
  10412. }
  10413. else {
  10414. context.fillRect(left, top, width, height);
  10415. }
  10416. }
  10417. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10418. context.shadowBlur = 0;
  10419. context.shadowOffsetX = 0;
  10420. context.shadowOffsetY = 0;
  10421. }
  10422. // Value bar
  10423. context.fillStyle = this.color;
  10424. if (this._displayValueBar) {
  10425. if (this.isVertical) {
  10426. if (this.isThumbClamped) {
  10427. if (this.isThumbCircle) {
  10428. context.beginPath();
  10429. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10430. context.fill();
  10431. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10432. }
  10433. else {
  10434. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10435. }
  10436. }
  10437. else {
  10438. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10439. }
  10440. }
  10441. else {
  10442. if (this.isThumbClamped) {
  10443. if (this.isThumbCircle) {
  10444. context.beginPath();
  10445. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10446. context.fill();
  10447. context.fillRect(left, top, thumbPosition, height);
  10448. }
  10449. else {
  10450. context.fillRect(left, top, thumbPosition, height);
  10451. }
  10452. }
  10453. else {
  10454. context.fillRect(left, top, thumbPosition, height);
  10455. }
  10456. }
  10457. }
  10458. // Thumb
  10459. if (this.displayThumb) {
  10460. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10461. context.shadowColor = this.shadowColor;
  10462. context.shadowBlur = this.shadowBlur;
  10463. context.shadowOffsetX = this.shadowOffsetX;
  10464. context.shadowOffsetY = this.shadowOffsetY;
  10465. }
  10466. if (this._isThumbCircle) {
  10467. context.beginPath();
  10468. if (this.isVertical) {
  10469. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10470. }
  10471. else {
  10472. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10473. }
  10474. context.fill();
  10475. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10476. context.shadowBlur = 0;
  10477. context.shadowOffsetX = 0;
  10478. context.shadowOffsetY = 0;
  10479. }
  10480. context.strokeStyle = this._borderColor;
  10481. context.stroke();
  10482. }
  10483. else {
  10484. if (this.isVertical) {
  10485. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10486. }
  10487. else {
  10488. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10489. }
  10490. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10491. context.shadowBlur = 0;
  10492. context.shadowOffsetX = 0;
  10493. context.shadowOffsetY = 0;
  10494. }
  10495. context.strokeStyle = this._borderColor;
  10496. if (this.isVertical) {
  10497. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10498. }
  10499. else {
  10500. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10501. }
  10502. }
  10503. }
  10504. context.restore();
  10505. };
  10506. return Slider;
  10507. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10508. /***/ }),
  10509. /***/ "./2D/controls/stackPanel.ts":
  10510. /*!***********************************!*\
  10511. !*** ./2D/controls/stackPanel.ts ***!
  10512. \***********************************/
  10513. /*! exports provided: StackPanel */
  10514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10515. "use strict";
  10516. __webpack_require__.r(__webpack_exports__);
  10517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10518. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10519. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  10520. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10521. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10522. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10523. /**
  10524. * Class used to create a 2D stack panel container
  10525. */
  10526. var StackPanel = /** @class */ (function (_super) {
  10527. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10528. /**
  10529. * Creates a new StackPanel
  10530. * @param name defines control name
  10531. */
  10532. function StackPanel(name) {
  10533. var _this = _super.call(this, name) || this;
  10534. _this.name = name;
  10535. _this._isVertical = true;
  10536. _this._manualWidth = false;
  10537. _this._manualHeight = false;
  10538. _this._doNotTrackManualChanges = false;
  10539. return _this;
  10540. }
  10541. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10542. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10543. get: function () {
  10544. return this._isVertical;
  10545. },
  10546. set: function (value) {
  10547. if (this._isVertical === value) {
  10548. return;
  10549. }
  10550. this._isVertical = value;
  10551. this._markAsDirty();
  10552. },
  10553. enumerable: true,
  10554. configurable: true
  10555. });
  10556. Object.defineProperty(StackPanel.prototype, "width", {
  10557. get: function () {
  10558. return this._width.toString(this._host);
  10559. },
  10560. /**
  10561. * Gets or sets panel width.
  10562. * This value should not be set when in horizontal mode as it will be computed automatically
  10563. */
  10564. set: function (value) {
  10565. if (!this._doNotTrackManualChanges) {
  10566. this._manualWidth = true;
  10567. }
  10568. if (this._width.toString(this._host) === value) {
  10569. return;
  10570. }
  10571. if (this._width.fromString(value)) {
  10572. this._markAsDirty();
  10573. }
  10574. },
  10575. enumerable: true,
  10576. configurable: true
  10577. });
  10578. Object.defineProperty(StackPanel.prototype, "height", {
  10579. get: function () {
  10580. return this._height.toString(this._host);
  10581. },
  10582. /**
  10583. * Gets or sets panel height.
  10584. * This value should not be set when in vertical mode as it will be computed automatically
  10585. */
  10586. set: function (value) {
  10587. if (!this._doNotTrackManualChanges) {
  10588. this._manualHeight = true;
  10589. }
  10590. if (this._height.toString(this._host) === value) {
  10591. return;
  10592. }
  10593. if (this._height.fromString(value)) {
  10594. this._markAsDirty();
  10595. }
  10596. },
  10597. enumerable: true,
  10598. configurable: true
  10599. });
  10600. StackPanel.prototype._getTypeName = function () {
  10601. return "StackPanel";
  10602. };
  10603. /** @hidden */
  10604. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10605. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10606. var child = _a[_i];
  10607. if (this._isVertical) {
  10608. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10609. }
  10610. else {
  10611. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10612. }
  10613. }
  10614. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10615. };
  10616. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10617. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10618. this._measureForChildren.copyFrom(parentMeasure);
  10619. this._measureForChildren.left = this._currentMeasure.left;
  10620. this._measureForChildren.top = this._currentMeasure.top;
  10621. if (!this.isVertical || this._manualWidth) {
  10622. this._measureForChildren.width = this._currentMeasure.width;
  10623. }
  10624. if (this.isVertical || this._manualHeight) {
  10625. this._measureForChildren.height = this._currentMeasure.height;
  10626. }
  10627. };
  10628. StackPanel.prototype._postMeasure = function () {
  10629. var stackWidth = 0;
  10630. var stackHeight = 0;
  10631. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10632. var child = _a[_i];
  10633. if (!child.isVisible || child.notRenderable) {
  10634. continue;
  10635. }
  10636. if (this._isVertical) {
  10637. if (child.top !== stackHeight + "px") {
  10638. child.top = stackHeight + "px";
  10639. this._rebuildLayout = true;
  10640. child._top.ignoreAdaptiveScaling = true;
  10641. }
  10642. if (child._height.isPercentage) {
  10643. 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");
  10644. }
  10645. else {
  10646. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10647. }
  10648. }
  10649. else {
  10650. if (child.left !== stackWidth + "px") {
  10651. child.left = stackWidth + "px";
  10652. this._rebuildLayout = true;
  10653. child._left.ignoreAdaptiveScaling = true;
  10654. }
  10655. if (child._width.isPercentage) {
  10656. 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");
  10657. }
  10658. else {
  10659. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10660. }
  10661. }
  10662. }
  10663. this._doNotTrackManualChanges = true;
  10664. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10665. // User can now define their own height and width for stack panel.
  10666. var panelWidthChanged = false;
  10667. var panelHeightChanged = false;
  10668. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10669. var previousHeight = this.height;
  10670. this.height = stackHeight + "px";
  10671. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10672. }
  10673. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10674. var previousWidth = this.width;
  10675. this.width = stackWidth + "px";
  10676. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10677. }
  10678. if (panelHeightChanged) {
  10679. this._height.ignoreAdaptiveScaling = true;
  10680. }
  10681. if (panelWidthChanged) {
  10682. this._width.ignoreAdaptiveScaling = true;
  10683. }
  10684. this._doNotTrackManualChanges = false;
  10685. if (panelWidthChanged || panelHeightChanged) {
  10686. this._rebuildLayout = true;
  10687. }
  10688. _super.prototype._postMeasure.call(this);
  10689. };
  10690. return StackPanel;
  10691. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10692. /***/ }),
  10693. /***/ "./2D/controls/statics.ts":
  10694. /*!********************************!*\
  10695. !*** ./2D/controls/statics.ts ***!
  10696. \********************************/
  10697. /*! exports provided: name */
  10698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10699. "use strict";
  10700. __webpack_require__.r(__webpack_exports__);
  10701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10702. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10703. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10704. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10705. /**
  10706. * Forcing an export so that this code will execute
  10707. * @hidden
  10708. */
  10709. var name = "Statics";
  10710. /**
  10711. * Creates a stack panel that can be used to render headers
  10712. * @param control defines the control to associate with the header
  10713. * @param text defines the text of the header
  10714. * @param size defines the size of the header
  10715. * @param options defines options used to configure the header
  10716. * @returns a new StackPanel
  10717. */
  10718. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10719. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10720. var isHorizontal = options ? options.isHorizontal : true;
  10721. var controlFirst = options ? options.controlFirst : true;
  10722. panel.isVertical = !isHorizontal;
  10723. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10724. header.text = text;
  10725. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10726. if (isHorizontal) {
  10727. header.width = size;
  10728. }
  10729. else {
  10730. header.height = size;
  10731. }
  10732. if (controlFirst) {
  10733. panel.addControl(control);
  10734. panel.addControl(header);
  10735. header.paddingLeft = "5px";
  10736. }
  10737. else {
  10738. panel.addControl(header);
  10739. panel.addControl(control);
  10740. header.paddingRight = "5px";
  10741. }
  10742. header.shadowBlur = control.shadowBlur;
  10743. header.shadowColor = control.shadowColor;
  10744. header.shadowOffsetX = control.shadowOffsetX;
  10745. header.shadowOffsetY = control.shadowOffsetY;
  10746. return panel;
  10747. };
  10748. /***/ }),
  10749. /***/ "./2D/controls/textBlock.ts":
  10750. /*!**********************************!*\
  10751. !*** ./2D/controls/textBlock.ts ***!
  10752. \**********************************/
  10753. /*! exports provided: TextWrapping, TextBlock */
  10754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10755. "use strict";
  10756. __webpack_require__.r(__webpack_exports__);
  10757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10759. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10760. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10761. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10762. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10763. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10764. /**
  10765. * Enum that determines the text-wrapping mode to use.
  10766. */
  10767. var TextWrapping;
  10768. (function (TextWrapping) {
  10769. /**
  10770. * Clip the text when it's larger than Control.width; this is the default mode.
  10771. */
  10772. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10773. /**
  10774. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10775. */
  10776. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10777. /**
  10778. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10779. */
  10780. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10781. })(TextWrapping || (TextWrapping = {}));
  10782. /**
  10783. * Class used to create text block control
  10784. */
  10785. var TextBlock = /** @class */ (function (_super) {
  10786. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10787. /**
  10788. * Creates a new TextBlock object
  10789. * @param name defines the name of the control
  10790. * @param text defines the text to display (emptry string by default)
  10791. */
  10792. function TextBlock(
  10793. /**
  10794. * Defines the name of the control
  10795. */
  10796. name, text) {
  10797. if (text === void 0) { text = ""; }
  10798. var _this = _super.call(this, name) || this;
  10799. _this.name = name;
  10800. _this._text = "";
  10801. _this._textWrapping = TextWrapping.Clip;
  10802. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10803. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10804. _this._resizeToFit = false;
  10805. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10806. _this._outlineWidth = 0;
  10807. _this._outlineColor = "white";
  10808. /**
  10809. * An event triggered after the text is changed
  10810. */
  10811. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10812. /**
  10813. * An event triggered after the text was broken up into lines
  10814. */
  10815. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10816. _this.text = text;
  10817. return _this;
  10818. }
  10819. Object.defineProperty(TextBlock.prototype, "lines", {
  10820. /**
  10821. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10822. */
  10823. get: function () {
  10824. return this._lines;
  10825. },
  10826. enumerable: true,
  10827. configurable: true
  10828. });
  10829. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10830. /**
  10831. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10832. */
  10833. get: function () {
  10834. return this._resizeToFit;
  10835. },
  10836. /**
  10837. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10838. */
  10839. set: function (value) {
  10840. if (this._resizeToFit === value) {
  10841. return;
  10842. }
  10843. this._resizeToFit = value;
  10844. if (this._resizeToFit) {
  10845. this._width.ignoreAdaptiveScaling = true;
  10846. this._height.ignoreAdaptiveScaling = true;
  10847. }
  10848. this._markAsDirty();
  10849. },
  10850. enumerable: true,
  10851. configurable: true
  10852. });
  10853. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10854. /**
  10855. * Gets or sets a boolean indicating if text must be wrapped
  10856. */
  10857. get: function () {
  10858. return this._textWrapping;
  10859. },
  10860. /**
  10861. * Gets or sets a boolean indicating if text must be wrapped
  10862. */
  10863. set: function (value) {
  10864. if (this._textWrapping === value) {
  10865. return;
  10866. }
  10867. this._textWrapping = +value;
  10868. this._markAsDirty();
  10869. },
  10870. enumerable: true,
  10871. configurable: true
  10872. });
  10873. Object.defineProperty(TextBlock.prototype, "text", {
  10874. /**
  10875. * Gets or sets text to display
  10876. */
  10877. get: function () {
  10878. return this._text;
  10879. },
  10880. /**
  10881. * Gets or sets text to display
  10882. */
  10883. set: function (value) {
  10884. if (this._text === value) {
  10885. return;
  10886. }
  10887. this._text = value;
  10888. this._markAsDirty();
  10889. this.onTextChangedObservable.notifyObservers(this);
  10890. },
  10891. enumerable: true,
  10892. configurable: true
  10893. });
  10894. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10895. /**
  10896. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10897. */
  10898. get: function () {
  10899. return this._textHorizontalAlignment;
  10900. },
  10901. /**
  10902. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10903. */
  10904. set: function (value) {
  10905. if (this._textHorizontalAlignment === value) {
  10906. return;
  10907. }
  10908. this._textHorizontalAlignment = value;
  10909. this._markAsDirty();
  10910. },
  10911. enumerable: true,
  10912. configurable: true
  10913. });
  10914. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10915. /**
  10916. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10917. */
  10918. get: function () {
  10919. return this._textVerticalAlignment;
  10920. },
  10921. /**
  10922. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10923. */
  10924. set: function (value) {
  10925. if (this._textVerticalAlignment === value) {
  10926. return;
  10927. }
  10928. this._textVerticalAlignment = value;
  10929. this._markAsDirty();
  10930. },
  10931. enumerable: true,
  10932. configurable: true
  10933. });
  10934. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10935. /**
  10936. * Gets or sets line spacing value
  10937. */
  10938. get: function () {
  10939. return this._lineSpacing.toString(this._host);
  10940. },
  10941. /**
  10942. * Gets or sets line spacing value
  10943. */
  10944. set: function (value) {
  10945. if (this._lineSpacing.fromString(value)) {
  10946. this._markAsDirty();
  10947. }
  10948. },
  10949. enumerable: true,
  10950. configurable: true
  10951. });
  10952. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10953. /**
  10954. * Gets or sets outlineWidth of the text to display
  10955. */
  10956. get: function () {
  10957. return this._outlineWidth;
  10958. },
  10959. /**
  10960. * Gets or sets outlineWidth of the text to display
  10961. */
  10962. set: function (value) {
  10963. if (this._outlineWidth === value) {
  10964. return;
  10965. }
  10966. this._outlineWidth = value;
  10967. this._markAsDirty();
  10968. },
  10969. enumerable: true,
  10970. configurable: true
  10971. });
  10972. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  10973. /**
  10974. * Gets or sets outlineColor of the text to display
  10975. */
  10976. get: function () {
  10977. return this._outlineColor;
  10978. },
  10979. /**
  10980. * Gets or sets outlineColor of the text to display
  10981. */
  10982. set: function (value) {
  10983. if (this._outlineColor === value) {
  10984. return;
  10985. }
  10986. this._outlineColor = value;
  10987. this._markAsDirty();
  10988. },
  10989. enumerable: true,
  10990. configurable: true
  10991. });
  10992. TextBlock.prototype._getTypeName = function () {
  10993. return "TextBlock";
  10994. };
  10995. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  10996. if (!this._fontOffset) {
  10997. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  10998. }
  10999. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11000. // Prepare lines
  11001. this._lines = this._breakLines(this._currentMeasure.width, context);
  11002. this.onLinesReadyObservable.notifyObservers(this);
  11003. var maxLineWidth = 0;
  11004. for (var i = 0; i < this._lines.length; i++) {
  11005. var line = this._lines[i];
  11006. if (line.width > maxLineWidth) {
  11007. maxLineWidth = line.width;
  11008. }
  11009. }
  11010. if (this._resizeToFit) {
  11011. if (this._textWrapping === TextWrapping.Clip) {
  11012. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11013. if (newWidth !== this._width.internalValue) {
  11014. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11015. this._rebuildLayout = true;
  11016. }
  11017. }
  11018. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11019. if (newHeight !== this._height.internalValue) {
  11020. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11021. this._rebuildLayout = true;
  11022. }
  11023. }
  11024. };
  11025. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11026. var width = this._currentMeasure.width;
  11027. var x = 0;
  11028. switch (this._textHorizontalAlignment) {
  11029. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11030. x = 0;
  11031. break;
  11032. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11033. x = width - textWidth;
  11034. break;
  11035. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11036. x = (width - textWidth) / 2;
  11037. break;
  11038. }
  11039. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11040. context.shadowColor = this.shadowColor;
  11041. context.shadowBlur = this.shadowBlur;
  11042. context.shadowOffsetX = this.shadowOffsetX;
  11043. context.shadowOffsetY = this.shadowOffsetY;
  11044. }
  11045. if (this.outlineWidth) {
  11046. context.strokeText(text, this._currentMeasure.left + x, y);
  11047. }
  11048. context.fillText(text, this._currentMeasure.left + x, y);
  11049. };
  11050. /** @hidden */
  11051. TextBlock.prototype._draw = function (context) {
  11052. context.save();
  11053. this._applyStates(context);
  11054. // Render lines
  11055. this._renderLines(context);
  11056. context.restore();
  11057. };
  11058. TextBlock.prototype._applyStates = function (context) {
  11059. _super.prototype._applyStates.call(this, context);
  11060. if (this.outlineWidth) {
  11061. context.lineWidth = this.outlineWidth;
  11062. context.strokeStyle = this.outlineColor;
  11063. }
  11064. };
  11065. TextBlock.prototype._breakLines = function (refWidth, context) {
  11066. var lines = [];
  11067. var _lines = this.text.split("\n");
  11068. if (this._textWrapping === TextWrapping.Ellipsis) {
  11069. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11070. var _line = _lines_1[_i];
  11071. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11072. }
  11073. }
  11074. else if (this._textWrapping === TextWrapping.WordWrap) {
  11075. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11076. var _line = _lines_2[_a];
  11077. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11078. }
  11079. }
  11080. else {
  11081. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11082. var _line = _lines_3[_b];
  11083. lines.push(this._parseLine(_line, context));
  11084. }
  11085. }
  11086. return lines;
  11087. };
  11088. TextBlock.prototype._parseLine = function (line, context) {
  11089. if (line === void 0) { line = ''; }
  11090. return { text: line, width: context.measureText(line).width };
  11091. };
  11092. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11093. if (line === void 0) { line = ''; }
  11094. var lineWidth = context.measureText(line).width;
  11095. if (lineWidth > width) {
  11096. line += '…';
  11097. }
  11098. while (line.length > 2 && lineWidth > width) {
  11099. line = line.slice(0, -2) + '…';
  11100. lineWidth = context.measureText(line).width;
  11101. }
  11102. return { text: line, width: lineWidth };
  11103. };
  11104. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11105. if (line === void 0) { line = ''; }
  11106. var lines = [];
  11107. var words = line.split(' ');
  11108. var lineWidth = 0;
  11109. for (var n = 0; n < words.length; n++) {
  11110. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11111. var metrics = context.measureText(testLine);
  11112. var testWidth = metrics.width;
  11113. if (testWidth > width && n > 0) {
  11114. lines.push({ text: line, width: lineWidth });
  11115. line = words[n];
  11116. lineWidth = context.measureText(line).width;
  11117. }
  11118. else {
  11119. lineWidth = testWidth;
  11120. line = testLine;
  11121. }
  11122. }
  11123. lines.push({ text: line, width: lineWidth });
  11124. return lines;
  11125. };
  11126. TextBlock.prototype._renderLines = function (context) {
  11127. var height = this._currentMeasure.height;
  11128. var rootY = 0;
  11129. switch (this._textVerticalAlignment) {
  11130. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11131. rootY = this._fontOffset.ascent;
  11132. break;
  11133. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11134. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11135. break;
  11136. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11137. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11138. break;
  11139. }
  11140. rootY += this._currentMeasure.top;
  11141. for (var i = 0; i < this._lines.length; i++) {
  11142. var line = this._lines[i];
  11143. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11144. if (this._lineSpacing.isPixel) {
  11145. rootY += this._lineSpacing.getValue(this._host);
  11146. }
  11147. else {
  11148. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11149. }
  11150. }
  11151. this._drawText(line.text, line.width, rootY, context);
  11152. rootY += this._fontOffset.height;
  11153. }
  11154. };
  11155. /**
  11156. * Given a width constraint applied on the text block, find the expected height
  11157. * @returns expected height
  11158. */
  11159. TextBlock.prototype.computeExpectedHeight = function () {
  11160. if (this.text && this.widthInPixels) {
  11161. var context_1 = document.createElement('canvas').getContext('2d');
  11162. if (context_1) {
  11163. this._applyStates(context_1);
  11164. if (!this._fontOffset) {
  11165. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11166. }
  11167. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11168. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11169. }
  11170. }
  11171. return 0;
  11172. };
  11173. TextBlock.prototype.dispose = function () {
  11174. _super.prototype.dispose.call(this);
  11175. this.onTextChangedObservable.clear();
  11176. };
  11177. return TextBlock;
  11178. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11179. /***/ }),
  11180. /***/ "./2D/controls/virtualKeyboard.ts":
  11181. /*!****************************************!*\
  11182. !*** ./2D/controls/virtualKeyboard.ts ***!
  11183. \****************************************/
  11184. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11186. "use strict";
  11187. __webpack_require__.r(__webpack_exports__);
  11188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11190. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11191. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11192. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11193. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11194. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11195. /**
  11196. * Class used to store key control properties
  11197. */
  11198. var KeyPropertySet = /** @class */ (function () {
  11199. function KeyPropertySet() {
  11200. }
  11201. return KeyPropertySet;
  11202. }());
  11203. /**
  11204. * Class used to create virtual keyboard
  11205. */
  11206. var VirtualKeyboard = /** @class */ (function (_super) {
  11207. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11208. function VirtualKeyboard() {
  11209. var _this = _super !== null && _super.apply(this, arguments) || this;
  11210. /** Observable raised when a key is pressed */
  11211. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11212. /** Gets or sets default key button width */
  11213. _this.defaultButtonWidth = "40px";
  11214. /** Gets or sets default key button height */
  11215. _this.defaultButtonHeight = "40px";
  11216. /** Gets or sets default key button left padding */
  11217. _this.defaultButtonPaddingLeft = "2px";
  11218. /** Gets or sets default key button right padding */
  11219. _this.defaultButtonPaddingRight = "2px";
  11220. /** Gets or sets default key button top padding */
  11221. _this.defaultButtonPaddingTop = "2px";
  11222. /** Gets or sets default key button bottom padding */
  11223. _this.defaultButtonPaddingBottom = "2px";
  11224. /** Gets or sets default key button foreground color */
  11225. _this.defaultButtonColor = "#DDD";
  11226. /** Gets or sets default key button background color */
  11227. _this.defaultButtonBackground = "#070707";
  11228. /** Gets or sets shift button foreground color */
  11229. _this.shiftButtonColor = "#7799FF";
  11230. /** Gets or sets shift button thickness*/
  11231. _this.selectedShiftThickness = 1;
  11232. /** Gets shift key state */
  11233. _this.shiftState = 0;
  11234. _this._currentlyConnectedInputText = null;
  11235. _this._connectedInputTexts = [];
  11236. _this._onKeyPressObserver = null;
  11237. return _this;
  11238. }
  11239. VirtualKeyboard.prototype._getTypeName = function () {
  11240. return "VirtualKeyboard";
  11241. };
  11242. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11243. var _this = this;
  11244. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11245. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11246. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11247. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11248. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11249. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11250. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11251. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11252. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11253. button.thickness = 0;
  11254. button.isFocusInvisible = true;
  11255. button.shadowColor = this.shadowColor;
  11256. button.shadowBlur = this.shadowBlur;
  11257. button.shadowOffsetX = this.shadowOffsetX;
  11258. button.shadowOffsetY = this.shadowOffsetY;
  11259. button.onPointerUpObservable.add(function () {
  11260. _this.onKeyPressObservable.notifyObservers(key);
  11261. });
  11262. return button;
  11263. };
  11264. /**
  11265. * Adds a new row of keys
  11266. * @param keys defines the list of keys to add
  11267. * @param propertySets defines the associated property sets
  11268. */
  11269. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11270. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11271. panel.isVertical = false;
  11272. panel.isFocusInvisible = true;
  11273. for (var i = 0; i < keys.length; i++) {
  11274. var properties = null;
  11275. if (propertySets && propertySets.length === keys.length) {
  11276. properties = propertySets[i];
  11277. }
  11278. panel.addControl(this._createKey(keys[i], properties));
  11279. }
  11280. this.addControl(panel);
  11281. };
  11282. /**
  11283. * Set the shift key to a specific state
  11284. * @param shiftState defines the new shift state
  11285. */
  11286. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11287. if (!this.children) {
  11288. return;
  11289. }
  11290. for (var i = 0; i < this.children.length; i++) {
  11291. var row = this.children[i];
  11292. if (!row || !row.children) {
  11293. continue;
  11294. }
  11295. var rowContainer = row;
  11296. for (var j = 0; j < rowContainer.children.length; j++) {
  11297. var button = rowContainer.children[j];
  11298. if (!button || !button.children[0]) {
  11299. continue;
  11300. }
  11301. var button_tblock = button.children[0];
  11302. if (button_tblock.text === "\u21E7") {
  11303. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11304. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11305. }
  11306. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11307. }
  11308. }
  11309. };
  11310. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11311. /** Gets the input text control currently attached to the keyboard */
  11312. get: function () {
  11313. return this._currentlyConnectedInputText;
  11314. },
  11315. enumerable: true,
  11316. configurable: true
  11317. });
  11318. /**
  11319. * Connects the keyboard with an input text control
  11320. *
  11321. * @param input defines the target control
  11322. */
  11323. VirtualKeyboard.prototype.connect = function (input) {
  11324. var _this = this;
  11325. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11326. if (inputTextAlreadyConnected) {
  11327. return;
  11328. }
  11329. if (this._onKeyPressObserver === null) {
  11330. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11331. if (!_this._currentlyConnectedInputText) {
  11332. return;
  11333. }
  11334. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11335. switch (key) {
  11336. case "\u21E7":
  11337. _this.shiftState++;
  11338. if (_this.shiftState > 2) {
  11339. _this.shiftState = 0;
  11340. }
  11341. _this.applyShiftState(_this.shiftState);
  11342. return;
  11343. case "\u2190":
  11344. _this._currentlyConnectedInputText.processKey(8);
  11345. return;
  11346. case "\u21B5":
  11347. _this._currentlyConnectedInputText.processKey(13);
  11348. return;
  11349. }
  11350. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11351. if (_this.shiftState === 1) {
  11352. _this.shiftState = 0;
  11353. _this.applyShiftState(_this.shiftState);
  11354. }
  11355. });
  11356. }
  11357. this.isVisible = false;
  11358. this._currentlyConnectedInputText = input;
  11359. input._connectedVirtualKeyboard = this;
  11360. // Events hooking
  11361. var onFocusObserver = input.onFocusObservable.add(function () {
  11362. _this._currentlyConnectedInputText = input;
  11363. input._connectedVirtualKeyboard = _this;
  11364. _this.isVisible = true;
  11365. });
  11366. var onBlurObserver = input.onBlurObservable.add(function () {
  11367. input._connectedVirtualKeyboard = null;
  11368. _this._currentlyConnectedInputText = null;
  11369. _this.isVisible = false;
  11370. });
  11371. this._connectedInputTexts.push({
  11372. input: input,
  11373. onBlurObserver: onBlurObserver,
  11374. onFocusObserver: onFocusObserver
  11375. });
  11376. };
  11377. /**
  11378. * Disconnects the keyboard from connected InputText controls
  11379. *
  11380. * @param input optionally defines a target control, otherwise all are disconnected
  11381. */
  11382. VirtualKeyboard.prototype.disconnect = function (input) {
  11383. var _this = this;
  11384. if (input) {
  11385. // .find not available on IE
  11386. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11387. if (filtered.length === 1) {
  11388. this._removeConnectedInputObservables(filtered[0]);
  11389. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11390. if (this._currentlyConnectedInputText === input) {
  11391. this._currentlyConnectedInputText = null;
  11392. }
  11393. }
  11394. }
  11395. else {
  11396. this._connectedInputTexts.forEach(function (connectedInputText) {
  11397. _this._removeConnectedInputObservables(connectedInputText);
  11398. });
  11399. this._connectedInputTexts = [];
  11400. }
  11401. if (this._connectedInputTexts.length === 0) {
  11402. this._currentlyConnectedInputText = null;
  11403. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11404. this._onKeyPressObserver = null;
  11405. }
  11406. };
  11407. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11408. connectedInputText.input._connectedVirtualKeyboard = null;
  11409. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11410. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11411. };
  11412. /**
  11413. * Release all resources
  11414. */
  11415. VirtualKeyboard.prototype.dispose = function () {
  11416. _super.prototype.dispose.call(this);
  11417. this.disconnect();
  11418. };
  11419. // Statics
  11420. /**
  11421. * Creates a new keyboard using a default layout
  11422. *
  11423. * @param name defines control name
  11424. * @returns a new VirtualKeyboard
  11425. */
  11426. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11427. var returnValue = new VirtualKeyboard(name);
  11428. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11429. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11430. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11431. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11432. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11433. return returnValue;
  11434. };
  11435. return VirtualKeyboard;
  11436. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11437. /***/ }),
  11438. /***/ "./2D/index.ts":
  11439. /*!*********************!*\
  11440. !*** ./2D/index.ts ***!
  11441. \*********************/
  11442. /*! 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 */
  11443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11444. "use strict";
  11445. __webpack_require__.r(__webpack_exports__);
  11446. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11478. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11480. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11482. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11485. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11487. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11489. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11491. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11493. /***/ }),
  11494. /***/ "./2D/math2D.ts":
  11495. /*!**********************!*\
  11496. !*** ./2D/math2D.ts ***!
  11497. \**********************/
  11498. /*! exports provided: Vector2WithInfo, Matrix2D */
  11499. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11500. "use strict";
  11501. __webpack_require__.r(__webpack_exports__);
  11502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11504. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11505. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11506. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11507. /**
  11508. * Class used to transport Vector2 information for pointer events
  11509. */
  11510. var Vector2WithInfo = /** @class */ (function (_super) {
  11511. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11512. /**
  11513. * Creates a new Vector2WithInfo
  11514. * @param source defines the vector2 data to transport
  11515. * @param buttonIndex defines the current mouse button index
  11516. */
  11517. function Vector2WithInfo(source,
  11518. /** defines the current mouse button index */
  11519. buttonIndex) {
  11520. if (buttonIndex === void 0) { buttonIndex = 0; }
  11521. var _this = _super.call(this, source.x, source.y) || this;
  11522. _this.buttonIndex = buttonIndex;
  11523. return _this;
  11524. }
  11525. return Vector2WithInfo;
  11526. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11527. /** Class used to provide 2D matrix features */
  11528. var Matrix2D = /** @class */ (function () {
  11529. /**
  11530. * Creates a new matrix
  11531. * @param m00 defines value for (0, 0)
  11532. * @param m01 defines value for (0, 1)
  11533. * @param m10 defines value for (1, 0)
  11534. * @param m11 defines value for (1, 1)
  11535. * @param m20 defines value for (2, 0)
  11536. * @param m21 defines value for (2, 1)
  11537. */
  11538. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11539. /** Gets the internal array of 6 floats used to store matrix data */
  11540. this.m = new Float32Array(6);
  11541. this.fromValues(m00, m01, m10, m11, m20, m21);
  11542. }
  11543. /**
  11544. * Fills the matrix from direct values
  11545. * @param m00 defines value for (0, 0)
  11546. * @param m01 defines value for (0, 1)
  11547. * @param m10 defines value for (1, 0)
  11548. * @param m11 defines value for (1, 1)
  11549. * @param m20 defines value for (2, 0)
  11550. * @param m21 defines value for (2, 1)
  11551. * @returns the current modified matrix
  11552. */
  11553. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11554. this.m[0] = m00;
  11555. this.m[1] = m01;
  11556. this.m[2] = m10;
  11557. this.m[3] = m11;
  11558. this.m[4] = m20;
  11559. this.m[5] = m21;
  11560. return this;
  11561. };
  11562. /**
  11563. * Gets matrix determinant
  11564. * @returns the determinant
  11565. */
  11566. Matrix2D.prototype.determinant = function () {
  11567. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11568. };
  11569. /**
  11570. * Inverses the matrix and stores it in a target matrix
  11571. * @param result defines the target matrix
  11572. * @returns the current matrix
  11573. */
  11574. Matrix2D.prototype.invertToRef = function (result) {
  11575. var l0 = this.m[0];
  11576. var l1 = this.m[1];
  11577. var l2 = this.m[2];
  11578. var l3 = this.m[3];
  11579. var l4 = this.m[4];
  11580. var l5 = this.m[5];
  11581. var det = this.determinant();
  11582. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11583. result.m[0] = 0;
  11584. result.m[1] = 0;
  11585. result.m[2] = 0;
  11586. result.m[3] = 0;
  11587. result.m[4] = 0;
  11588. result.m[5] = 0;
  11589. return this;
  11590. }
  11591. var detDiv = 1 / det;
  11592. var det4 = l2 * l5 - l3 * l4;
  11593. var det5 = l1 * l4 - l0 * l5;
  11594. result.m[0] = l3 * detDiv;
  11595. result.m[1] = -l1 * detDiv;
  11596. result.m[2] = -l2 * detDiv;
  11597. result.m[3] = l0 * detDiv;
  11598. result.m[4] = det4 * detDiv;
  11599. result.m[5] = det5 * detDiv;
  11600. return this;
  11601. };
  11602. /**
  11603. * Multiplies the current matrix with another one
  11604. * @param other defines the second operand
  11605. * @param result defines the target matrix
  11606. * @returns the current matrix
  11607. */
  11608. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11609. var l0 = this.m[0];
  11610. var l1 = this.m[1];
  11611. var l2 = this.m[2];
  11612. var l3 = this.m[3];
  11613. var l4 = this.m[4];
  11614. var l5 = this.m[5];
  11615. var r0 = other.m[0];
  11616. var r1 = other.m[1];
  11617. var r2 = other.m[2];
  11618. var r3 = other.m[3];
  11619. var r4 = other.m[4];
  11620. var r5 = other.m[5];
  11621. result.m[0] = l0 * r0 + l1 * r2;
  11622. result.m[1] = l0 * r1 + l1 * r3;
  11623. result.m[2] = l2 * r0 + l3 * r2;
  11624. result.m[3] = l2 * r1 + l3 * r3;
  11625. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11626. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11627. return this;
  11628. };
  11629. /**
  11630. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11631. * @param x defines the x coordinate to transform
  11632. * @param y defines the x coordinate to transform
  11633. * @param result defines the target vector2
  11634. * @returns the current matrix
  11635. */
  11636. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11637. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11638. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11639. return this;
  11640. };
  11641. // Statics
  11642. /**
  11643. * Creates an identity matrix
  11644. * @returns a new matrix
  11645. */
  11646. Matrix2D.Identity = function () {
  11647. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11648. };
  11649. /**
  11650. * Creates a translation matrix and stores it in a target matrix
  11651. * @param x defines the x coordinate of the translation
  11652. * @param y defines the y coordinate of the translation
  11653. * @param result defines the target matrix
  11654. */
  11655. Matrix2D.TranslationToRef = function (x, y, result) {
  11656. result.fromValues(1, 0, 0, 1, x, y);
  11657. };
  11658. /**
  11659. * Creates a scaling matrix and stores it in a target matrix
  11660. * @param x defines the x coordinate of the scaling
  11661. * @param y defines the y coordinate of the scaling
  11662. * @param result defines the target matrix
  11663. */
  11664. Matrix2D.ScalingToRef = function (x, y, result) {
  11665. result.fromValues(x, 0, 0, y, 0, 0);
  11666. };
  11667. /**
  11668. * Creates a rotation matrix and stores it in a target matrix
  11669. * @param angle defines the rotation angle
  11670. * @param result defines the target matrix
  11671. */
  11672. Matrix2D.RotationToRef = function (angle, result) {
  11673. var s = Math.sin(angle);
  11674. var c = Math.cos(angle);
  11675. result.fromValues(c, s, -s, c, 0, 0);
  11676. };
  11677. /**
  11678. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11679. * @param tx defines the x coordinate of the translation
  11680. * @param ty defines the y coordinate of the translation
  11681. * @param angle defines the rotation angle
  11682. * @param scaleX defines the x coordinate of the scaling
  11683. * @param scaleY defines the y coordinate of the scaling
  11684. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11685. * @param result defines the target matrix
  11686. */
  11687. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11688. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11689. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11690. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11691. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11692. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11693. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11694. if (parentMatrix) {
  11695. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11696. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11697. }
  11698. else {
  11699. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11700. }
  11701. };
  11702. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11703. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11704. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11705. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11706. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11707. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11708. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11709. return Matrix2D;
  11710. }());
  11711. /***/ }),
  11712. /***/ "./2D/measure.ts":
  11713. /*!***********************!*\
  11714. !*** ./2D/measure.ts ***!
  11715. \***********************/
  11716. /*! exports provided: Measure */
  11717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11718. "use strict";
  11719. __webpack_require__.r(__webpack_exports__);
  11720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11721. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11722. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11723. /**
  11724. * Class used to store 2D control sizes
  11725. */
  11726. var Measure = /** @class */ (function () {
  11727. /**
  11728. * Creates a new measure
  11729. * @param left defines left coordinate
  11730. * @param top defines top coordinate
  11731. * @param width defines width dimension
  11732. * @param height defines height dimension
  11733. */
  11734. function Measure(
  11735. /** defines left coordinate */
  11736. left,
  11737. /** defines top coordinate */
  11738. top,
  11739. /** defines width dimension */
  11740. width,
  11741. /** defines height dimension */
  11742. height) {
  11743. this.left = left;
  11744. this.top = top;
  11745. this.width = width;
  11746. this.height = height;
  11747. }
  11748. /**
  11749. * Copy from another measure
  11750. * @param other defines the other measure to copy from
  11751. */
  11752. Measure.prototype.copyFrom = function (other) {
  11753. this.left = other.left;
  11754. this.top = other.top;
  11755. this.width = other.width;
  11756. this.height = other.height;
  11757. };
  11758. /**
  11759. * Copy from a group of 4 floats
  11760. * @param left defines left coordinate
  11761. * @param top defines top coordinate
  11762. * @param width defines width dimension
  11763. * @param height defines height dimension
  11764. */
  11765. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11766. this.left = left;
  11767. this.top = top;
  11768. this.width = width;
  11769. this.height = height;
  11770. };
  11771. /**
  11772. * Computes the axis aligned bounding box measure for two given measures
  11773. * @param a Input measure
  11774. * @param b Input measure
  11775. * @param result the resulting bounding measure
  11776. */
  11777. Measure.CombineToRef = function (a, b, result) {
  11778. var left = Math.min(a.left, b.left);
  11779. var top = Math.min(a.top, b.top);
  11780. var right = Math.max(a.left + a.width, b.left + b.width);
  11781. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11782. result.left = left;
  11783. result.top = top;
  11784. result.width = right - left;
  11785. result.height = bottom - top;
  11786. };
  11787. /**
  11788. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11789. * @param transform the matrix to transform the measure before computing the AABB
  11790. * @param result the resulting AABB
  11791. */
  11792. Measure.prototype.transformToRef = function (transform, result) {
  11793. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11794. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11795. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11796. for (var i = 0; i < 4; i++) {
  11797. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11798. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11799. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11800. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11801. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11802. }
  11803. result.left = min.x;
  11804. result.top = min.y;
  11805. result.width = max.x - min.x;
  11806. result.height = max.y - min.y;
  11807. };
  11808. /**
  11809. * Check equality between this measure and another one
  11810. * @param other defines the other measures
  11811. * @returns true if both measures are equals
  11812. */
  11813. Measure.prototype.isEqualsTo = function (other) {
  11814. if (this.left !== other.left) {
  11815. return false;
  11816. }
  11817. if (this.top !== other.top) {
  11818. return false;
  11819. }
  11820. if (this.width !== other.width) {
  11821. return false;
  11822. }
  11823. if (this.height !== other.height) {
  11824. return false;
  11825. }
  11826. return true;
  11827. };
  11828. /**
  11829. * Creates an empty measure
  11830. * @returns a new measure
  11831. */
  11832. Measure.Empty = function () {
  11833. return new Measure(0, 0, 0, 0);
  11834. };
  11835. return Measure;
  11836. }());
  11837. /***/ }),
  11838. /***/ "./2D/multiLinePoint.ts":
  11839. /*!******************************!*\
  11840. !*** ./2D/multiLinePoint.ts ***!
  11841. \******************************/
  11842. /*! exports provided: MultiLinePoint */
  11843. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11844. "use strict";
  11845. __webpack_require__.r(__webpack_exports__);
  11846. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11847. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11848. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11849. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11850. /**
  11851. * Class used to store a point for a MultiLine object.
  11852. * The point can be pure 2D coordinates, a mesh or a control
  11853. */
  11854. var MultiLinePoint = /** @class */ (function () {
  11855. /**
  11856. * Creates a new MultiLinePoint
  11857. * @param multiLine defines the source MultiLine object
  11858. */
  11859. function MultiLinePoint(multiLine) {
  11860. this._multiLine = multiLine;
  11861. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11862. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11863. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11864. }
  11865. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11866. /** Gets or sets x coordinate */
  11867. get: function () {
  11868. return this._x.toString(this._multiLine._host);
  11869. },
  11870. set: function (value) {
  11871. if (this._x.toString(this._multiLine._host) === value) {
  11872. return;
  11873. }
  11874. if (this._x.fromString(value)) {
  11875. this._multiLine._markAsDirty();
  11876. }
  11877. },
  11878. enumerable: true,
  11879. configurable: true
  11880. });
  11881. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11882. /** Gets or sets y coordinate */
  11883. get: function () {
  11884. return this._y.toString(this._multiLine._host);
  11885. },
  11886. set: function (value) {
  11887. if (this._y.toString(this._multiLine._host) === value) {
  11888. return;
  11889. }
  11890. if (this._y.fromString(value)) {
  11891. this._multiLine._markAsDirty();
  11892. }
  11893. },
  11894. enumerable: true,
  11895. configurable: true
  11896. });
  11897. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11898. /** Gets or sets the control associated with this point */
  11899. get: function () {
  11900. return this._control;
  11901. },
  11902. set: function (value) {
  11903. if (this._control === value) {
  11904. return;
  11905. }
  11906. if (this._control && this._controlObserver) {
  11907. this._control.onDirtyObservable.remove(this._controlObserver);
  11908. this._controlObserver = null;
  11909. }
  11910. this._control = value;
  11911. if (this._control) {
  11912. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11913. }
  11914. this._multiLine._markAsDirty();
  11915. },
  11916. enumerable: true,
  11917. configurable: true
  11918. });
  11919. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11920. /** Gets or sets the mesh associated with this point */
  11921. get: function () {
  11922. return this._mesh;
  11923. },
  11924. set: function (value) {
  11925. if (this._mesh === value) {
  11926. return;
  11927. }
  11928. if (this._mesh && this._meshObserver) {
  11929. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11930. }
  11931. this._mesh = value;
  11932. if (this._mesh) {
  11933. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11934. }
  11935. this._multiLine._markAsDirty();
  11936. },
  11937. enumerable: true,
  11938. configurable: true
  11939. });
  11940. /** Resets links */
  11941. MultiLinePoint.prototype.resetLinks = function () {
  11942. this.control = null;
  11943. this.mesh = null;
  11944. };
  11945. /**
  11946. * Gets a translation vector
  11947. * @returns the translation vector
  11948. */
  11949. MultiLinePoint.prototype.translate = function () {
  11950. this._point = this._translatePoint();
  11951. return this._point;
  11952. };
  11953. MultiLinePoint.prototype._translatePoint = function () {
  11954. if (this._mesh != null) {
  11955. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  11956. }
  11957. else if (this._control != null) {
  11958. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  11959. }
  11960. else {
  11961. var host = this._multiLine._host;
  11962. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  11963. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  11964. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  11965. }
  11966. };
  11967. /** Release associated resources */
  11968. MultiLinePoint.prototype.dispose = function () {
  11969. this.resetLinks();
  11970. };
  11971. return MultiLinePoint;
  11972. }());
  11973. /***/ }),
  11974. /***/ "./2D/style.ts":
  11975. /*!*********************!*\
  11976. !*** ./2D/style.ts ***!
  11977. \*********************/
  11978. /*! exports provided: Style */
  11979. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11980. "use strict";
  11981. __webpack_require__.r(__webpack_exports__);
  11982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  11983. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11984. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  11985. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11986. /**
  11987. * Define a style used by control to automatically setup properties based on a template.
  11988. * Only support font related properties so far
  11989. */
  11990. var Style = /** @class */ (function () {
  11991. /**
  11992. * Creates a new style object
  11993. * @param host defines the AdvancedDynamicTexture which hosts this style
  11994. */
  11995. function Style(host) {
  11996. this._fontFamily = "Arial";
  11997. this._fontStyle = "";
  11998. this._fontWeight = "";
  11999. /** @hidden */
  12000. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12001. /**
  12002. * Observable raised when the style values are changed
  12003. */
  12004. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12005. this._host = host;
  12006. }
  12007. Object.defineProperty(Style.prototype, "fontSize", {
  12008. /**
  12009. * Gets or sets the font size
  12010. */
  12011. get: function () {
  12012. return this._fontSize.toString(this._host);
  12013. },
  12014. set: function (value) {
  12015. if (this._fontSize.toString(this._host) === value) {
  12016. return;
  12017. }
  12018. if (this._fontSize.fromString(value)) {
  12019. this.onChangedObservable.notifyObservers(this);
  12020. }
  12021. },
  12022. enumerable: true,
  12023. configurable: true
  12024. });
  12025. Object.defineProperty(Style.prototype, "fontFamily", {
  12026. /**
  12027. * Gets or sets the font family
  12028. */
  12029. get: function () {
  12030. return this._fontFamily;
  12031. },
  12032. set: function (value) {
  12033. if (this._fontFamily === value) {
  12034. return;
  12035. }
  12036. this._fontFamily = value;
  12037. this.onChangedObservable.notifyObservers(this);
  12038. },
  12039. enumerable: true,
  12040. configurable: true
  12041. });
  12042. Object.defineProperty(Style.prototype, "fontStyle", {
  12043. /**
  12044. * Gets or sets the font style
  12045. */
  12046. get: function () {
  12047. return this._fontStyle;
  12048. },
  12049. set: function (value) {
  12050. if (this._fontStyle === value) {
  12051. return;
  12052. }
  12053. this._fontStyle = value;
  12054. this.onChangedObservable.notifyObservers(this);
  12055. },
  12056. enumerable: true,
  12057. configurable: true
  12058. });
  12059. Object.defineProperty(Style.prototype, "fontWeight", {
  12060. /** Gets or sets font weight */
  12061. get: function () {
  12062. return this._fontWeight;
  12063. },
  12064. set: function (value) {
  12065. if (this._fontWeight === value) {
  12066. return;
  12067. }
  12068. this._fontWeight = value;
  12069. this.onChangedObservable.notifyObservers(this);
  12070. },
  12071. enumerable: true,
  12072. configurable: true
  12073. });
  12074. /** Dispose all associated resources */
  12075. Style.prototype.dispose = function () {
  12076. this.onChangedObservable.clear();
  12077. };
  12078. return Style;
  12079. }());
  12080. /***/ }),
  12081. /***/ "./2D/valueAndUnit.ts":
  12082. /*!****************************!*\
  12083. !*** ./2D/valueAndUnit.ts ***!
  12084. \****************************/
  12085. /*! exports provided: ValueAndUnit */
  12086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12087. "use strict";
  12088. __webpack_require__.r(__webpack_exports__);
  12089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12090. /**
  12091. * Class used to specific a value and its associated unit
  12092. */
  12093. var ValueAndUnit = /** @class */ (function () {
  12094. /**
  12095. * Creates a new ValueAndUnit
  12096. * @param value defines the value to store
  12097. * @param unit defines the unit to store
  12098. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12099. */
  12100. function ValueAndUnit(value,
  12101. /** defines the unit to store */
  12102. unit,
  12103. /** defines a boolean indicating if the value can be negative */
  12104. negativeValueAllowed) {
  12105. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12106. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12107. this.unit = unit;
  12108. this.negativeValueAllowed = negativeValueAllowed;
  12109. this._value = 1;
  12110. /**
  12111. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12112. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12113. */
  12114. this.ignoreAdaptiveScaling = false;
  12115. this._value = value;
  12116. this._originalUnit = unit;
  12117. }
  12118. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12119. /** Gets a boolean indicating if the value is a percentage */
  12120. get: function () {
  12121. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12122. },
  12123. enumerable: true,
  12124. configurable: true
  12125. });
  12126. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12127. /** Gets a boolean indicating if the value is store as pixel */
  12128. get: function () {
  12129. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12130. },
  12131. enumerable: true,
  12132. configurable: true
  12133. });
  12134. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12135. /** Gets direct internal value */
  12136. get: function () {
  12137. return this._value;
  12138. },
  12139. enumerable: true,
  12140. configurable: true
  12141. });
  12142. /**
  12143. * Gets value as pixel
  12144. * @param host defines the root host
  12145. * @param refValue defines the reference value for percentages
  12146. * @returns the value as pixel
  12147. */
  12148. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12149. if (this.isPixel) {
  12150. return this.getValue(host);
  12151. }
  12152. return this.getValue(host) * refValue;
  12153. };
  12154. /**
  12155. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12156. * @param value defines the value to store
  12157. * @param unit defines the unit to store
  12158. * @returns the current ValueAndUnit
  12159. */
  12160. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12161. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12162. this._value = value;
  12163. this.unit = unit;
  12164. return this;
  12165. };
  12166. /**
  12167. * Gets the value accordingly to its unit
  12168. * @param host defines the root host
  12169. * @returns the value
  12170. */
  12171. ValueAndUnit.prototype.getValue = function (host) {
  12172. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12173. var width = 0;
  12174. var height = 0;
  12175. if (host.idealWidth) {
  12176. width = (this._value * host.getSize().width) / host.idealWidth;
  12177. }
  12178. if (host.idealHeight) {
  12179. height = (this._value * host.getSize().height) / host.idealHeight;
  12180. }
  12181. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12182. return window.innerWidth < window.innerHeight ? width : height;
  12183. }
  12184. if (host.idealWidth) { // horizontal
  12185. return width;
  12186. }
  12187. if (host.idealHeight) { // vertical
  12188. return height;
  12189. }
  12190. }
  12191. return this._value;
  12192. };
  12193. /**
  12194. * Gets a string representation of the value
  12195. * @param host defines the root host
  12196. * @returns a string
  12197. */
  12198. ValueAndUnit.prototype.toString = function (host) {
  12199. switch (this.unit) {
  12200. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12201. return (this.getValue(host) * 100) + "%";
  12202. case ValueAndUnit.UNITMODE_PIXEL:
  12203. return this.getValue(host) + "px";
  12204. }
  12205. return this.unit.toString();
  12206. };
  12207. /**
  12208. * Store a value parsed from a string
  12209. * @param source defines the source string
  12210. * @returns true if the value was successfully parsed
  12211. */
  12212. ValueAndUnit.prototype.fromString = function (source) {
  12213. var match = ValueAndUnit._Regex.exec(source.toString());
  12214. if (!match || match.length === 0) {
  12215. return false;
  12216. }
  12217. var sourceValue = parseFloat(match[1]);
  12218. var sourceUnit = this._originalUnit;
  12219. if (!this.negativeValueAllowed) {
  12220. if (sourceValue < 0) {
  12221. sourceValue = 0;
  12222. }
  12223. }
  12224. if (match.length === 4) {
  12225. switch (match[3]) {
  12226. case "px":
  12227. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12228. break;
  12229. case "%":
  12230. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12231. sourceValue /= 100.0;
  12232. break;
  12233. }
  12234. }
  12235. if (sourceValue === this._value && sourceUnit === this.unit) {
  12236. return false;
  12237. }
  12238. this._value = sourceValue;
  12239. this.unit = sourceUnit;
  12240. return true;
  12241. };
  12242. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12243. /** UNITMODE_PERCENTAGE */
  12244. get: function () {
  12245. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12246. },
  12247. enumerable: true,
  12248. configurable: true
  12249. });
  12250. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12251. /** UNITMODE_PIXEL */
  12252. get: function () {
  12253. return ValueAndUnit._UNITMODE_PIXEL;
  12254. },
  12255. enumerable: true,
  12256. configurable: true
  12257. });
  12258. // Static
  12259. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12260. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12261. ValueAndUnit._UNITMODE_PIXEL = 1;
  12262. return ValueAndUnit;
  12263. }());
  12264. /***/ }),
  12265. /***/ "./3D/controls/abstractButton3D.ts":
  12266. /*!*****************************************!*\
  12267. !*** ./3D/controls/abstractButton3D.ts ***!
  12268. \*****************************************/
  12269. /*! exports provided: AbstractButton3D */
  12270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12271. "use strict";
  12272. __webpack_require__.r(__webpack_exports__);
  12273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12274. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12275. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12276. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12277. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12278. /**
  12279. * Class used as a root to all buttons
  12280. */
  12281. var AbstractButton3D = /** @class */ (function (_super) {
  12282. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12283. /**
  12284. * Creates a new button
  12285. * @param name defines the control name
  12286. */
  12287. function AbstractButton3D(name) {
  12288. return _super.call(this, name) || this;
  12289. }
  12290. AbstractButton3D.prototype._getTypeName = function () {
  12291. return "AbstractButton3D";
  12292. };
  12293. // Mesh association
  12294. AbstractButton3D.prototype._createNode = function (scene) {
  12295. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12296. };
  12297. return AbstractButton3D;
  12298. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12299. /***/ }),
  12300. /***/ "./3D/controls/button3D.ts":
  12301. /*!*********************************!*\
  12302. !*** ./3D/controls/button3D.ts ***!
  12303. \*********************************/
  12304. /*! exports provided: Button3D */
  12305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12306. "use strict";
  12307. __webpack_require__.r(__webpack_exports__);
  12308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12309. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12310. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  12311. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12312. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12313. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12314. /**
  12315. * Class used to create a button in 3D
  12316. */
  12317. var Button3D = /** @class */ (function (_super) {
  12318. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12319. /**
  12320. * Creates a new button
  12321. * @param name defines the control name
  12322. */
  12323. function Button3D(name) {
  12324. var _this = _super.call(this, name) || this;
  12325. _this._contentResolution = 512;
  12326. _this._contentScaleRatio = 2;
  12327. // Default animations
  12328. _this.pointerEnterAnimation = function () {
  12329. if (!_this.mesh) {
  12330. return;
  12331. }
  12332. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12333. };
  12334. _this.pointerOutAnimation = function () {
  12335. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12336. };
  12337. _this.pointerDownAnimation = function () {
  12338. if (!_this.mesh) {
  12339. return;
  12340. }
  12341. _this.mesh.scaling.scaleInPlace(0.95);
  12342. };
  12343. _this.pointerUpAnimation = function () {
  12344. if (!_this.mesh) {
  12345. return;
  12346. }
  12347. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12348. };
  12349. return _this;
  12350. }
  12351. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12352. /**
  12353. * Gets or sets the texture resolution used to render content (512 by default)
  12354. */
  12355. get: function () {
  12356. return this._contentResolution;
  12357. },
  12358. set: function (value) {
  12359. if (this._contentResolution === value) {
  12360. return;
  12361. }
  12362. this._contentResolution = value;
  12363. this._resetContent();
  12364. },
  12365. enumerable: true,
  12366. configurable: true
  12367. });
  12368. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12369. /**
  12370. * Gets or sets the texture scale ratio used to render content (2 by default)
  12371. */
  12372. get: function () {
  12373. return this._contentScaleRatio;
  12374. },
  12375. set: function (value) {
  12376. if (this._contentScaleRatio === value) {
  12377. return;
  12378. }
  12379. this._contentScaleRatio = value;
  12380. this._resetContent();
  12381. },
  12382. enumerable: true,
  12383. configurable: true
  12384. });
  12385. Button3D.prototype._disposeFacadeTexture = function () {
  12386. if (this._facadeTexture) {
  12387. this._facadeTexture.dispose();
  12388. this._facadeTexture = null;
  12389. }
  12390. };
  12391. Button3D.prototype._resetContent = function () {
  12392. this._disposeFacadeTexture();
  12393. this.content = this._content;
  12394. };
  12395. Object.defineProperty(Button3D.prototype, "content", {
  12396. /**
  12397. * Gets or sets the GUI 2D content used to display the button's facade
  12398. */
  12399. get: function () {
  12400. return this._content;
  12401. },
  12402. set: function (value) {
  12403. this._content = value;
  12404. if (!this._host || !this._host.utilityLayer) {
  12405. return;
  12406. }
  12407. if (!this._facadeTexture) {
  12408. 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);
  12409. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12410. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12411. this._facadeTexture.premulAlpha = true;
  12412. }
  12413. this._facadeTexture.addControl(value);
  12414. this._applyFacade(this._facadeTexture);
  12415. },
  12416. enumerable: true,
  12417. configurable: true
  12418. });
  12419. /**
  12420. * Apply the facade texture (created from the content property).
  12421. * This function can be overloaded by child classes
  12422. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12423. */
  12424. Button3D.prototype._applyFacade = function (facadeTexture) {
  12425. this._currentMaterial.emissiveTexture = facadeTexture;
  12426. };
  12427. Button3D.prototype._getTypeName = function () {
  12428. return "Button3D";
  12429. };
  12430. // Mesh association
  12431. Button3D.prototype._createNode = function (scene) {
  12432. var faceUV = new Array(6);
  12433. for (var i = 0; i < 6; i++) {
  12434. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12435. }
  12436. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12437. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12438. width: 1.0,
  12439. height: 1.0,
  12440. depth: 0.08,
  12441. faceUV: faceUV
  12442. }, scene);
  12443. return mesh;
  12444. };
  12445. Button3D.prototype._affectMaterial = function (mesh) {
  12446. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12447. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12448. mesh.material = material;
  12449. this._currentMaterial = material;
  12450. this._resetContent();
  12451. };
  12452. /**
  12453. * Releases all associated resources
  12454. */
  12455. Button3D.prototype.dispose = function () {
  12456. _super.prototype.dispose.call(this);
  12457. this._disposeFacadeTexture();
  12458. if (this._currentMaterial) {
  12459. this._currentMaterial.dispose();
  12460. }
  12461. };
  12462. return Button3D;
  12463. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12464. /***/ }),
  12465. /***/ "./3D/controls/container3D.ts":
  12466. /*!************************************!*\
  12467. !*** ./3D/controls/container3D.ts ***!
  12468. \************************************/
  12469. /*! exports provided: Container3D */
  12470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12471. "use strict";
  12472. __webpack_require__.r(__webpack_exports__);
  12473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12474. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12475. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12476. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12477. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12478. /**
  12479. * Class used to create containers for controls
  12480. */
  12481. var Container3D = /** @class */ (function (_super) {
  12482. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12483. /**
  12484. * Creates a new container
  12485. * @param name defines the container name
  12486. */
  12487. function Container3D(name) {
  12488. var _this = _super.call(this, name) || this;
  12489. _this._blockLayout = false;
  12490. /**
  12491. * Gets the list of child controls
  12492. */
  12493. _this._children = new Array();
  12494. return _this;
  12495. }
  12496. Object.defineProperty(Container3D.prototype, "children", {
  12497. /**
  12498. * Gets the list of child controls
  12499. */
  12500. get: function () {
  12501. return this._children;
  12502. },
  12503. enumerable: true,
  12504. configurable: true
  12505. });
  12506. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12507. /**
  12508. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12509. * This is helpful to optimize layout operation when adding multiple children in a row
  12510. */
  12511. get: function () {
  12512. return this._blockLayout;
  12513. },
  12514. set: function (value) {
  12515. if (this._blockLayout === value) {
  12516. return;
  12517. }
  12518. this._blockLayout = value;
  12519. if (!this._blockLayout) {
  12520. this._arrangeChildren();
  12521. }
  12522. },
  12523. enumerable: true,
  12524. configurable: true
  12525. });
  12526. /**
  12527. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12528. * @returns the current container
  12529. */
  12530. Container3D.prototype.updateLayout = function () {
  12531. this._arrangeChildren();
  12532. return this;
  12533. };
  12534. /**
  12535. * Gets a boolean indicating if the given control is in the children of this control
  12536. * @param control defines the control to check
  12537. * @returns true if the control is in the child list
  12538. */
  12539. Container3D.prototype.containsControl = function (control) {
  12540. return this._children.indexOf(control) !== -1;
  12541. };
  12542. /**
  12543. * Adds a control to the children of this control
  12544. * @param control defines the control to add
  12545. * @returns the current container
  12546. */
  12547. Container3D.prototype.addControl = function (control) {
  12548. var index = this._children.indexOf(control);
  12549. if (index !== -1) {
  12550. return this;
  12551. }
  12552. control.parent = this;
  12553. control._host = this._host;
  12554. this._children.push(control);
  12555. if (this._host.utilityLayer) {
  12556. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12557. if (control.node) {
  12558. control.node.parent = this.node;
  12559. }
  12560. if (!this.blockLayout) {
  12561. this._arrangeChildren();
  12562. }
  12563. }
  12564. return this;
  12565. };
  12566. /**
  12567. * This function will be called everytime a new control is added
  12568. */
  12569. Container3D.prototype._arrangeChildren = function () {
  12570. };
  12571. Container3D.prototype._createNode = function (scene) {
  12572. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12573. };
  12574. /**
  12575. * Removes a control from the children of this control
  12576. * @param control defines the control to remove
  12577. * @returns the current container
  12578. */
  12579. Container3D.prototype.removeControl = function (control) {
  12580. var index = this._children.indexOf(control);
  12581. if (index !== -1) {
  12582. this._children.splice(index, 1);
  12583. control.parent = null;
  12584. control._disposeNode();
  12585. }
  12586. return this;
  12587. };
  12588. Container3D.prototype._getTypeName = function () {
  12589. return "Container3D";
  12590. };
  12591. /**
  12592. * Releases all associated resources
  12593. */
  12594. Container3D.prototype.dispose = function () {
  12595. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12596. var control = _a[_i];
  12597. control.dispose();
  12598. }
  12599. this._children = [];
  12600. _super.prototype.dispose.call(this);
  12601. };
  12602. /** Control rotation will remain unchanged */
  12603. Container3D.UNSET_ORIENTATION = 0;
  12604. /** Control will rotate to make it look at sphere central axis */
  12605. Container3D.FACEORIGIN_ORIENTATION = 1;
  12606. /** Control will rotate to make it look back at sphere central axis */
  12607. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12608. /** Control will rotate to look at z axis (0, 0, 1) */
  12609. Container3D.FACEFORWARD_ORIENTATION = 3;
  12610. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12611. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12612. return Container3D;
  12613. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12614. /***/ }),
  12615. /***/ "./3D/controls/control3D.ts":
  12616. /*!**********************************!*\
  12617. !*** ./3D/controls/control3D.ts ***!
  12618. \**********************************/
  12619. /*! exports provided: Control3D */
  12620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12621. "use strict";
  12622. __webpack_require__.r(__webpack_exports__);
  12623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12624. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12625. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12626. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12627. /**
  12628. * Class used as base class for controls
  12629. */
  12630. var Control3D = /** @class */ (function () {
  12631. /**
  12632. * Creates a new control
  12633. * @param name defines the control name
  12634. */
  12635. function Control3D(
  12636. /** Defines the control name */
  12637. name) {
  12638. this.name = name;
  12639. this._downCount = 0;
  12640. this._enterCount = -1;
  12641. this._downPointerIds = {};
  12642. this._isVisible = true;
  12643. /**
  12644. * An event triggered when the pointer move over the control
  12645. */
  12646. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12647. /**
  12648. * An event triggered when the pointer move out of the control
  12649. */
  12650. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12651. /**
  12652. * An event triggered when the pointer taps the control
  12653. */
  12654. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12655. /**
  12656. * An event triggered when pointer is up
  12657. */
  12658. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12659. /**
  12660. * An event triggered when a control is clicked on (with a mouse)
  12661. */
  12662. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12663. /**
  12664. * An event triggered when pointer enters the control
  12665. */
  12666. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12667. // Behaviors
  12668. this._behaviors = new Array();
  12669. }
  12670. Object.defineProperty(Control3D.prototype, "position", {
  12671. /** Gets or sets the control position in world space */
  12672. get: function () {
  12673. if (!this._node) {
  12674. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12675. }
  12676. return this._node.position;
  12677. },
  12678. set: function (value) {
  12679. if (!this._node) {
  12680. return;
  12681. }
  12682. this._node.position = value;
  12683. },
  12684. enumerable: true,
  12685. configurable: true
  12686. });
  12687. Object.defineProperty(Control3D.prototype, "scaling", {
  12688. /** Gets or sets the control scaling in world space */
  12689. get: function () {
  12690. if (!this._node) {
  12691. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12692. }
  12693. return this._node.scaling;
  12694. },
  12695. set: function (value) {
  12696. if (!this._node) {
  12697. return;
  12698. }
  12699. this._node.scaling = value;
  12700. },
  12701. enumerable: true,
  12702. configurable: true
  12703. });
  12704. Object.defineProperty(Control3D.prototype, "behaviors", {
  12705. /**
  12706. * Gets the list of attached behaviors
  12707. * @see http://doc.babylonjs.com/features/behaviour
  12708. */
  12709. get: function () {
  12710. return this._behaviors;
  12711. },
  12712. enumerable: true,
  12713. configurable: true
  12714. });
  12715. /**
  12716. * Attach a behavior to the control
  12717. * @see http://doc.babylonjs.com/features/behaviour
  12718. * @param behavior defines the behavior to attach
  12719. * @returns the current control
  12720. */
  12721. Control3D.prototype.addBehavior = function (behavior) {
  12722. var _this = this;
  12723. var index = this._behaviors.indexOf(behavior);
  12724. if (index !== -1) {
  12725. return this;
  12726. }
  12727. behavior.init();
  12728. var scene = this._host.scene;
  12729. if (scene.isLoading) {
  12730. // We defer the attach when the scene will be loaded
  12731. scene.onDataLoadedObservable.addOnce(function () {
  12732. behavior.attach(_this);
  12733. });
  12734. }
  12735. else {
  12736. behavior.attach(this);
  12737. }
  12738. this._behaviors.push(behavior);
  12739. return this;
  12740. };
  12741. /**
  12742. * Remove an attached behavior
  12743. * @see http://doc.babylonjs.com/features/behaviour
  12744. * @param behavior defines the behavior to attach
  12745. * @returns the current control
  12746. */
  12747. Control3D.prototype.removeBehavior = function (behavior) {
  12748. var index = this._behaviors.indexOf(behavior);
  12749. if (index === -1) {
  12750. return this;
  12751. }
  12752. this._behaviors[index].detach();
  12753. this._behaviors.splice(index, 1);
  12754. return this;
  12755. };
  12756. /**
  12757. * Gets an attached behavior by name
  12758. * @param name defines the name of the behavior to look for
  12759. * @see http://doc.babylonjs.com/features/behaviour
  12760. * @returns null if behavior was not found else the requested behavior
  12761. */
  12762. Control3D.prototype.getBehaviorByName = function (name) {
  12763. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12764. var behavior = _a[_i];
  12765. if (behavior.name === name) {
  12766. return behavior;
  12767. }
  12768. }
  12769. return null;
  12770. };
  12771. Object.defineProperty(Control3D.prototype, "isVisible", {
  12772. /** Gets or sets a boolean indicating if the control is visible */
  12773. get: function () {
  12774. return this._isVisible;
  12775. },
  12776. set: function (value) {
  12777. if (this._isVisible === value) {
  12778. return;
  12779. }
  12780. this._isVisible = value;
  12781. var mesh = this.mesh;
  12782. if (mesh) {
  12783. mesh.setEnabled(value);
  12784. }
  12785. },
  12786. enumerable: true,
  12787. configurable: true
  12788. });
  12789. Object.defineProperty(Control3D.prototype, "typeName", {
  12790. /**
  12791. * Gets a string representing the class name
  12792. */
  12793. get: function () {
  12794. return this._getTypeName();
  12795. },
  12796. enumerable: true,
  12797. configurable: true
  12798. });
  12799. /**
  12800. * Get the current class name of the control.
  12801. * @returns current class name
  12802. */
  12803. Control3D.prototype.getClassName = function () {
  12804. return this._getTypeName();
  12805. };
  12806. Control3D.prototype._getTypeName = function () {
  12807. return "Control3D";
  12808. };
  12809. Object.defineProperty(Control3D.prototype, "node", {
  12810. /**
  12811. * Gets the transform node used by this control
  12812. */
  12813. get: function () {
  12814. return this._node;
  12815. },
  12816. enumerable: true,
  12817. configurable: true
  12818. });
  12819. Object.defineProperty(Control3D.prototype, "mesh", {
  12820. /**
  12821. * Gets the mesh used to render this control
  12822. */
  12823. get: function () {
  12824. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12825. return this._node;
  12826. }
  12827. return null;
  12828. },
  12829. enumerable: true,
  12830. configurable: true
  12831. });
  12832. /**
  12833. * Link the control as child of the given node
  12834. * @param node defines the node to link to. Use null to unlink the control
  12835. * @returns the current control
  12836. */
  12837. Control3D.prototype.linkToTransformNode = function (node) {
  12838. if (this._node) {
  12839. this._node.parent = node;
  12840. }
  12841. return this;
  12842. };
  12843. /** @hidden **/
  12844. Control3D.prototype._prepareNode = function (scene) {
  12845. if (!this._node) {
  12846. this._node = this._createNode(scene);
  12847. if (!this.node) {
  12848. return;
  12849. }
  12850. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12851. this._node.position = this.position;
  12852. this._node.scaling = this.scaling;
  12853. var mesh = this.mesh;
  12854. if (mesh) {
  12855. mesh.isPickable = true;
  12856. this._affectMaterial(mesh);
  12857. }
  12858. }
  12859. };
  12860. /**
  12861. * Node creation.
  12862. * Can be overriden by children
  12863. * @param scene defines the scene where the node must be attached
  12864. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12865. */
  12866. Control3D.prototype._createNode = function (scene) {
  12867. // Do nothing by default
  12868. return null;
  12869. };
  12870. /**
  12871. * Affect a material to the given mesh
  12872. * @param mesh defines the mesh which will represent the control
  12873. */
  12874. Control3D.prototype._affectMaterial = function (mesh) {
  12875. mesh.material = null;
  12876. };
  12877. // Pointers
  12878. /** @hidden */
  12879. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12880. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12881. };
  12882. /** @hidden */
  12883. Control3D.prototype._onPointerEnter = function (target) {
  12884. if (this._enterCount > 0) {
  12885. return false;
  12886. }
  12887. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12888. this._enterCount = 0;
  12889. }
  12890. this._enterCount++;
  12891. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12892. if (this.pointerEnterAnimation) {
  12893. this.pointerEnterAnimation();
  12894. }
  12895. return true;
  12896. };
  12897. /** @hidden */
  12898. Control3D.prototype._onPointerOut = function (target) {
  12899. this._enterCount = 0;
  12900. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12901. if (this.pointerOutAnimation) {
  12902. this.pointerOutAnimation();
  12903. }
  12904. };
  12905. /** @hidden */
  12906. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12907. if (this._downCount !== 0) {
  12908. return false;
  12909. }
  12910. this._downCount++;
  12911. this._downPointerIds[pointerId] = true;
  12912. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12913. if (this.pointerDownAnimation) {
  12914. this.pointerDownAnimation();
  12915. }
  12916. return true;
  12917. };
  12918. /** @hidden */
  12919. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12920. this._downCount = 0;
  12921. delete this._downPointerIds[pointerId];
  12922. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12923. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12924. }
  12925. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12926. if (this.pointerUpAnimation) {
  12927. this.pointerUpAnimation();
  12928. }
  12929. };
  12930. /** @hidden */
  12931. Control3D.prototype.forcePointerUp = function (pointerId) {
  12932. if (pointerId === void 0) { pointerId = null; }
  12933. if (pointerId !== null) {
  12934. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12935. }
  12936. else {
  12937. for (var key in this._downPointerIds) {
  12938. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12939. }
  12940. }
  12941. };
  12942. /** @hidden */
  12943. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  12944. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  12945. this._onPointerMove(this, pickedPoint);
  12946. var previousControlOver = this._host._lastControlOver[pointerId];
  12947. if (previousControlOver && previousControlOver !== this) {
  12948. previousControlOver._onPointerOut(this);
  12949. }
  12950. if (previousControlOver !== this) {
  12951. this._onPointerEnter(this);
  12952. }
  12953. this._host._lastControlOver[pointerId] = this;
  12954. return true;
  12955. }
  12956. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  12957. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  12958. this._host._lastControlDown[pointerId] = this;
  12959. this._host._lastPickedControl = this;
  12960. return true;
  12961. }
  12962. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  12963. if (this._host._lastControlDown[pointerId]) {
  12964. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  12965. }
  12966. delete this._host._lastControlDown[pointerId];
  12967. return true;
  12968. }
  12969. return false;
  12970. };
  12971. /** @hidden */
  12972. Control3D.prototype._disposeNode = function () {
  12973. if (this._node) {
  12974. this._node.dispose();
  12975. this._node = null;
  12976. }
  12977. };
  12978. /**
  12979. * Releases all associated resources
  12980. */
  12981. Control3D.prototype.dispose = function () {
  12982. this.onPointerDownObservable.clear();
  12983. this.onPointerEnterObservable.clear();
  12984. this.onPointerMoveObservable.clear();
  12985. this.onPointerOutObservable.clear();
  12986. this.onPointerUpObservable.clear();
  12987. this.onPointerClickObservable.clear();
  12988. this._disposeNode();
  12989. // Behaviors
  12990. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12991. var behavior = _a[_i];
  12992. behavior.detach();
  12993. }
  12994. };
  12995. return Control3D;
  12996. }());
  12997. /***/ }),
  12998. /***/ "./3D/controls/cylinderPanel.ts":
  12999. /*!**************************************!*\
  13000. !*** ./3D/controls/cylinderPanel.ts ***!
  13001. \**************************************/
  13002. /*! exports provided: CylinderPanel */
  13003. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13004. "use strict";
  13005. __webpack_require__.r(__webpack_exports__);
  13006. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13007. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13008. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13009. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13010. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13011. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13012. /**
  13013. * Class used to create a container panel deployed on the surface of a cylinder
  13014. */
  13015. var CylinderPanel = /** @class */ (function (_super) {
  13016. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13017. function CylinderPanel() {
  13018. var _this = _super !== null && _super.apply(this, arguments) || this;
  13019. _this._radius = 5.0;
  13020. return _this;
  13021. }
  13022. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13023. /**
  13024. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13025. */
  13026. get: function () {
  13027. return this._radius;
  13028. },
  13029. set: function (value) {
  13030. var _this = this;
  13031. if (this._radius === value) {
  13032. return;
  13033. }
  13034. this._radius = value;
  13035. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13036. _this._arrangeChildren();
  13037. });
  13038. },
  13039. enumerable: true,
  13040. configurable: true
  13041. });
  13042. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13043. var mesh = control.mesh;
  13044. if (!mesh) {
  13045. return;
  13046. }
  13047. var newPos = this._cylindricalMapping(nodePosition);
  13048. control.position = newPos;
  13049. switch (this.orientation) {
  13050. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13051. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13052. break;
  13053. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13054. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13055. break;
  13056. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13057. break;
  13058. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13059. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13060. break;
  13061. }
  13062. };
  13063. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13064. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13065. var yAngle = (source.x / this._radius);
  13066. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13067. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13068. };
  13069. return CylinderPanel;
  13070. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13071. /***/ }),
  13072. /***/ "./3D/controls/holographicButton.ts":
  13073. /*!******************************************!*\
  13074. !*** ./3D/controls/holographicButton.ts ***!
  13075. \******************************************/
  13076. /*! exports provided: HolographicButton */
  13077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13078. "use strict";
  13079. __webpack_require__.r(__webpack_exports__);
  13080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13081. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13082. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13083. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13084. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13085. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13086. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13087. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13088. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13089. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13090. /**
  13091. * Class used to create a holographic button in 3D
  13092. */
  13093. var HolographicButton = /** @class */ (function (_super) {
  13094. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13095. /**
  13096. * Creates a new button
  13097. * @param name defines the control name
  13098. */
  13099. function HolographicButton(name, shareMaterials) {
  13100. if (shareMaterials === void 0) { shareMaterials = true; }
  13101. var _this = _super.call(this, name) || this;
  13102. _this._shareMaterials = true;
  13103. _this._shareMaterials = shareMaterials;
  13104. // Default animations
  13105. _this.pointerEnterAnimation = function () {
  13106. if (!_this.mesh) {
  13107. return;
  13108. }
  13109. _this._frontPlate.setEnabled(true);
  13110. };
  13111. _this.pointerOutAnimation = function () {
  13112. if (!_this.mesh) {
  13113. return;
  13114. }
  13115. _this._frontPlate.setEnabled(false);
  13116. };
  13117. return _this;
  13118. }
  13119. HolographicButton.prototype._disposeTooltip = function () {
  13120. this._tooltipFade = null;
  13121. if (this._tooltipTextBlock) {
  13122. this._tooltipTextBlock.dispose();
  13123. }
  13124. if (this._tooltipTexture) {
  13125. this._tooltipTexture.dispose();
  13126. }
  13127. if (this._tooltipMesh) {
  13128. this._tooltipMesh.dispose();
  13129. }
  13130. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13131. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13132. };
  13133. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13134. get: function () {
  13135. if (this._tooltipTextBlock) {
  13136. return this._tooltipTextBlock.text;
  13137. }
  13138. return null;
  13139. },
  13140. /**
  13141. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13142. */
  13143. set: function (text) {
  13144. var _this = this;
  13145. if (!text) {
  13146. this._disposeTooltip();
  13147. return;
  13148. }
  13149. if (!this._tooltipFade) {
  13150. // Create tooltip with mesh and text
  13151. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13152. 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);
  13153. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13154. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13155. tooltipBackground.material = mat;
  13156. tooltipBackground.isPickable = false;
  13157. this._tooltipMesh.addChild(tooltipBackground);
  13158. tooltipBackground.position.z = 0.05;
  13159. this._tooltipMesh.scaling.y = 1 / 3;
  13160. this._tooltipMesh.position.y = 0.7;
  13161. this._tooltipMesh.position.z = -0.15;
  13162. this._tooltipMesh.isPickable = false;
  13163. this._tooltipMesh.parent = this._backPlate;
  13164. // Create text texture for the tooltip
  13165. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13166. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13167. this._tooltipTextBlock.scaleY = 3;
  13168. this._tooltipTextBlock.color = "white";
  13169. this._tooltipTextBlock.fontSize = 130;
  13170. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13171. // Add hover action to tooltip
  13172. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13173. this._tooltipFade.delay = 500;
  13174. this._tooltipMesh.addBehavior(this._tooltipFade);
  13175. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13176. if (_this._tooltipFade) {
  13177. _this._tooltipFade.fadeIn(true);
  13178. }
  13179. });
  13180. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13181. if (_this._tooltipFade) {
  13182. _this._tooltipFade.fadeIn(false);
  13183. }
  13184. });
  13185. }
  13186. if (this._tooltipTextBlock) {
  13187. this._tooltipTextBlock.text = text;
  13188. }
  13189. },
  13190. enumerable: true,
  13191. configurable: true
  13192. });
  13193. Object.defineProperty(HolographicButton.prototype, "text", {
  13194. /**
  13195. * Gets or sets text for the button
  13196. */
  13197. get: function () {
  13198. return this._text;
  13199. },
  13200. set: function (value) {
  13201. if (this._text === value) {
  13202. return;
  13203. }
  13204. this._text = value;
  13205. this._rebuildContent();
  13206. },
  13207. enumerable: true,
  13208. configurable: true
  13209. });
  13210. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13211. /**
  13212. * Gets or sets the image url for the button
  13213. */
  13214. get: function () {
  13215. return this._imageUrl;
  13216. },
  13217. set: function (value) {
  13218. if (this._imageUrl === value) {
  13219. return;
  13220. }
  13221. this._imageUrl = value;
  13222. this._rebuildContent();
  13223. },
  13224. enumerable: true,
  13225. configurable: true
  13226. });
  13227. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13228. /**
  13229. * Gets the back material used by this button
  13230. */
  13231. get: function () {
  13232. return this._backMaterial;
  13233. },
  13234. enumerable: true,
  13235. configurable: true
  13236. });
  13237. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13238. /**
  13239. * Gets the front material used by this button
  13240. */
  13241. get: function () {
  13242. return this._frontMaterial;
  13243. },
  13244. enumerable: true,
  13245. configurable: true
  13246. });
  13247. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13248. /**
  13249. * Gets the plate material used by this button
  13250. */
  13251. get: function () {
  13252. return this._plateMaterial;
  13253. },
  13254. enumerable: true,
  13255. configurable: true
  13256. });
  13257. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13258. /**
  13259. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13260. */
  13261. get: function () {
  13262. return this._shareMaterials;
  13263. },
  13264. enumerable: true,
  13265. configurable: true
  13266. });
  13267. HolographicButton.prototype._getTypeName = function () {
  13268. return "HolographicButton";
  13269. };
  13270. HolographicButton.prototype._rebuildContent = function () {
  13271. this._disposeFacadeTexture();
  13272. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13273. panel.isVertical = true;
  13274. if (this._imageUrl) {
  13275. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13276. image.source = this._imageUrl;
  13277. image.paddingTop = "40px";
  13278. image.height = "180px";
  13279. image.width = "100px";
  13280. image.paddingBottom = "40px";
  13281. panel.addControl(image);
  13282. }
  13283. if (this._text) {
  13284. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13285. text.text = this._text;
  13286. text.color = "white";
  13287. text.height = "30px";
  13288. text.fontSize = 24;
  13289. panel.addControl(text);
  13290. }
  13291. if (this._frontPlate) {
  13292. this.content = panel;
  13293. }
  13294. };
  13295. // Mesh association
  13296. HolographicButton.prototype._createNode = function (scene) {
  13297. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13298. width: 1.0,
  13299. height: 1.0,
  13300. depth: 0.08
  13301. }, scene);
  13302. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13303. width: 1.0,
  13304. height: 1.0,
  13305. depth: 0.08
  13306. }, scene);
  13307. this._frontPlate.parent = this._backPlate;
  13308. this._frontPlate.position.z = -0.08;
  13309. this._frontPlate.isPickable = false;
  13310. this._frontPlate.setEnabled(false);
  13311. this._textPlate = _super.prototype._createNode.call(this, scene);
  13312. this._textPlate.parent = this._backPlate;
  13313. this._textPlate.position.z = -0.08;
  13314. this._textPlate.isPickable = false;
  13315. return this._backPlate;
  13316. };
  13317. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13318. this._plateMaterial.emissiveTexture = facadeTexture;
  13319. this._plateMaterial.opacityTexture = facadeTexture;
  13320. };
  13321. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13322. var _this = this;
  13323. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13324. this._backMaterial.renderHoverLight = true;
  13325. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13326. if (pickedPoint) {
  13327. _this._backMaterial.hoverPosition = pickedPoint;
  13328. _this._backMaterial.hoverColor.a = 1.0;
  13329. }
  13330. else {
  13331. _this._backMaterial.hoverColor.a = 0;
  13332. }
  13333. });
  13334. };
  13335. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13336. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13337. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13338. this._frontMaterial.alpha = 0.5; // Additive
  13339. this._frontMaterial.renderBorders = true;
  13340. };
  13341. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13342. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13343. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13344. };
  13345. HolographicButton.prototype._affectMaterial = function (mesh) {
  13346. // Back
  13347. if (this._shareMaterials) {
  13348. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13349. this._createBackMaterial(mesh);
  13350. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13351. }
  13352. else {
  13353. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13354. }
  13355. // Front
  13356. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13357. this._createFrontMaterial(mesh);
  13358. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13359. }
  13360. else {
  13361. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13362. }
  13363. }
  13364. else {
  13365. this._createBackMaterial(mesh);
  13366. this._createFrontMaterial(mesh);
  13367. }
  13368. this._createPlateMaterial(mesh);
  13369. this._backPlate.material = this._backMaterial;
  13370. this._frontPlate.material = this._frontMaterial;
  13371. this._textPlate.material = this._plateMaterial;
  13372. this._rebuildContent();
  13373. };
  13374. /**
  13375. * Releases all associated resources
  13376. */
  13377. HolographicButton.prototype.dispose = function () {
  13378. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13379. this._disposeTooltip();
  13380. if (!this.shareMaterials) {
  13381. this._backMaterial.dispose();
  13382. this._frontMaterial.dispose();
  13383. this._plateMaterial.dispose();
  13384. if (this._pickedPointObserver) {
  13385. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13386. this._pickedPointObserver = null;
  13387. }
  13388. }
  13389. };
  13390. return HolographicButton;
  13391. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13392. /***/ }),
  13393. /***/ "./3D/controls/index.ts":
  13394. /*!******************************!*\
  13395. !*** ./3D/controls/index.ts ***!
  13396. \******************************/
  13397. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13399. "use strict";
  13400. __webpack_require__.r(__webpack_exports__);
  13401. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13403. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13405. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13407. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13409. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13411. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13413. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13415. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13417. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13419. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13421. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13423. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13425. /***/ }),
  13426. /***/ "./3D/controls/meshButton3D.ts":
  13427. /*!*************************************!*\
  13428. !*** ./3D/controls/meshButton3D.ts ***!
  13429. \*************************************/
  13430. /*! exports provided: MeshButton3D */
  13431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13432. "use strict";
  13433. __webpack_require__.r(__webpack_exports__);
  13434. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13435. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13436. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13437. /**
  13438. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13439. */
  13440. var MeshButton3D = /** @class */ (function (_super) {
  13441. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13442. /**
  13443. * Creates a new 3D button based on a mesh
  13444. * @param mesh mesh to become a 3D button
  13445. * @param name defines the control name
  13446. */
  13447. function MeshButton3D(mesh, name) {
  13448. var _this = _super.call(this, name) || this;
  13449. _this._currentMesh = mesh;
  13450. /**
  13451. * Provides a default behavior on hover/out & up/down
  13452. * Override those function to create your own desired behavior specific to your mesh
  13453. */
  13454. _this.pointerEnterAnimation = function () {
  13455. if (!_this.mesh) {
  13456. return;
  13457. }
  13458. _this.mesh.scaling.scaleInPlace(1.1);
  13459. };
  13460. _this.pointerOutAnimation = function () {
  13461. if (!_this.mesh) {
  13462. return;
  13463. }
  13464. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13465. };
  13466. _this.pointerDownAnimation = function () {
  13467. if (!_this.mesh) {
  13468. return;
  13469. }
  13470. _this.mesh.scaling.scaleInPlace(0.95);
  13471. };
  13472. _this.pointerUpAnimation = function () {
  13473. if (!_this.mesh) {
  13474. return;
  13475. }
  13476. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13477. };
  13478. return _this;
  13479. }
  13480. MeshButton3D.prototype._getTypeName = function () {
  13481. return "MeshButton3D";
  13482. };
  13483. // Mesh association
  13484. MeshButton3D.prototype._createNode = function (scene) {
  13485. var _this = this;
  13486. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13487. mesh.metadata = _this;
  13488. });
  13489. return this._currentMesh;
  13490. };
  13491. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13492. };
  13493. return MeshButton3D;
  13494. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13495. /***/ }),
  13496. /***/ "./3D/controls/planePanel.ts":
  13497. /*!***********************************!*\
  13498. !*** ./3D/controls/planePanel.ts ***!
  13499. \***********************************/
  13500. /*! exports provided: PlanePanel */
  13501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13502. "use strict";
  13503. __webpack_require__.r(__webpack_exports__);
  13504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13505. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13506. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13507. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13508. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13509. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13510. /**
  13511. * Class used to create a container panel deployed on the surface of a plane
  13512. */
  13513. var PlanePanel = /** @class */ (function (_super) {
  13514. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13515. function PlanePanel() {
  13516. return _super !== null && _super.apply(this, arguments) || this;
  13517. }
  13518. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13519. var mesh = control.mesh;
  13520. if (!mesh) {
  13521. return;
  13522. }
  13523. control.position = nodePosition.clone();
  13524. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13525. target.copyFrom(nodePosition);
  13526. switch (this.orientation) {
  13527. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13528. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13529. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13530. mesh.lookAt(target);
  13531. break;
  13532. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13533. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13534. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13535. mesh.lookAt(target);
  13536. break;
  13537. }
  13538. };
  13539. return PlanePanel;
  13540. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13541. /***/ }),
  13542. /***/ "./3D/controls/scatterPanel.ts":
  13543. /*!*************************************!*\
  13544. !*** ./3D/controls/scatterPanel.ts ***!
  13545. \*************************************/
  13546. /*! exports provided: ScatterPanel */
  13547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13548. "use strict";
  13549. __webpack_require__.r(__webpack_exports__);
  13550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13551. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13552. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13553. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13554. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13555. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13556. /**
  13557. * Class used to create a container panel where items get randomized planar mapping
  13558. */
  13559. var ScatterPanel = /** @class */ (function (_super) {
  13560. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13561. function ScatterPanel() {
  13562. var _this = _super !== null && _super.apply(this, arguments) || this;
  13563. _this._iteration = 100.0;
  13564. return _this;
  13565. }
  13566. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13567. /**
  13568. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13569. */
  13570. get: function () {
  13571. return this._iteration;
  13572. },
  13573. set: function (value) {
  13574. var _this = this;
  13575. if (this._iteration === value) {
  13576. return;
  13577. }
  13578. this._iteration = value;
  13579. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13580. _this._arrangeChildren();
  13581. });
  13582. },
  13583. enumerable: true,
  13584. configurable: true
  13585. });
  13586. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13587. var mesh = control.mesh;
  13588. var newPos = this._scatterMapping(nodePosition);
  13589. if (!mesh) {
  13590. return;
  13591. }
  13592. switch (this.orientation) {
  13593. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13594. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13595. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13596. break;
  13597. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13598. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13599. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13600. break;
  13601. }
  13602. control.position = newPos;
  13603. };
  13604. ScatterPanel.prototype._scatterMapping = function (source) {
  13605. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13606. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13607. return source;
  13608. };
  13609. ScatterPanel.prototype._finalProcessing = function () {
  13610. var meshes = [];
  13611. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13612. var child = _a[_i];
  13613. if (!child.mesh) {
  13614. continue;
  13615. }
  13616. meshes.push(child.mesh);
  13617. }
  13618. for (var count = 0; count < this._iteration; count++) {
  13619. meshes.sort(function (a, b) {
  13620. var distance1 = a.position.lengthSquared();
  13621. var distance2 = b.position.lengthSquared();
  13622. if (distance1 < distance2) {
  13623. return 1;
  13624. }
  13625. else if (distance1 > distance2) {
  13626. return -1;
  13627. }
  13628. return 0;
  13629. });
  13630. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13631. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13632. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13633. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13634. for (var i = 0; i < meshes.length - 1; i++) {
  13635. for (var j = i + 1; j < meshes.length; j++) {
  13636. if (i != j) {
  13637. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13638. // Ignore Z axis
  13639. difference2D.x = difference.x;
  13640. difference2D.y = difference.y;
  13641. var combinedRadius = cellSize;
  13642. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13643. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13644. distance -= minSeparation;
  13645. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13646. difference2D.normalize();
  13647. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13648. meshes[j].position.addInPlace(difference);
  13649. meshes[i].position.subtractInPlace(difference);
  13650. }
  13651. }
  13652. }
  13653. }
  13654. }
  13655. };
  13656. return ScatterPanel;
  13657. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13658. /***/ }),
  13659. /***/ "./3D/controls/spherePanel.ts":
  13660. /*!************************************!*\
  13661. !*** ./3D/controls/spherePanel.ts ***!
  13662. \************************************/
  13663. /*! exports provided: SpherePanel */
  13664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13665. "use strict";
  13666. __webpack_require__.r(__webpack_exports__);
  13667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13668. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13669. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13670. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13671. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13672. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13673. /**
  13674. * Class used to create a container panel deployed on the surface of a sphere
  13675. */
  13676. var SpherePanel = /** @class */ (function (_super) {
  13677. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13678. function SpherePanel() {
  13679. var _this = _super !== null && _super.apply(this, arguments) || this;
  13680. _this._radius = 5.0;
  13681. return _this;
  13682. }
  13683. Object.defineProperty(SpherePanel.prototype, "radius", {
  13684. /**
  13685. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13686. */
  13687. get: function () {
  13688. return this._radius;
  13689. },
  13690. set: function (value) {
  13691. var _this = this;
  13692. if (this._radius === value) {
  13693. return;
  13694. }
  13695. this._radius = value;
  13696. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13697. _this._arrangeChildren();
  13698. });
  13699. },
  13700. enumerable: true,
  13701. configurable: true
  13702. });
  13703. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13704. var mesh = control.mesh;
  13705. if (!mesh) {
  13706. return;
  13707. }
  13708. var newPos = this._sphericalMapping(nodePosition);
  13709. control.position = newPos;
  13710. switch (this.orientation) {
  13711. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13712. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13713. break;
  13714. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13715. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13716. break;
  13717. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13718. break;
  13719. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13720. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13721. break;
  13722. }
  13723. };
  13724. SpherePanel.prototype._sphericalMapping = function (source) {
  13725. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13726. var xAngle = (source.y / this._radius);
  13727. var yAngle = -(source.x / this._radius);
  13728. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13729. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13730. };
  13731. return SpherePanel;
  13732. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13733. /***/ }),
  13734. /***/ "./3D/controls/stackPanel3D.ts":
  13735. /*!*************************************!*\
  13736. !*** ./3D/controls/stackPanel3D.ts ***!
  13737. \*************************************/
  13738. /*! exports provided: StackPanel3D */
  13739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13740. "use strict";
  13741. __webpack_require__.r(__webpack_exports__);
  13742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13743. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13744. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13745. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13746. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13747. /**
  13748. * Class used to create a stack panel in 3D on XY plane
  13749. */
  13750. var StackPanel3D = /** @class */ (function (_super) {
  13751. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13752. /**
  13753. * Creates new StackPanel
  13754. * @param isVertical
  13755. */
  13756. function StackPanel3D(isVertical) {
  13757. if (isVertical === void 0) { isVertical = false; }
  13758. var _this = _super.call(this) || this;
  13759. _this._isVertical = false;
  13760. /**
  13761. * Gets or sets the distance between elements
  13762. */
  13763. _this.margin = 0.1;
  13764. _this._isVertical = isVertical;
  13765. return _this;
  13766. }
  13767. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13768. /**
  13769. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13770. */
  13771. get: function () {
  13772. return this._isVertical;
  13773. },
  13774. set: function (value) {
  13775. var _this = this;
  13776. if (this._isVertical === value) {
  13777. return;
  13778. }
  13779. this._isVertical = value;
  13780. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13781. _this._arrangeChildren();
  13782. });
  13783. },
  13784. enumerable: true,
  13785. configurable: true
  13786. });
  13787. StackPanel3D.prototype._arrangeChildren = function () {
  13788. var width = 0;
  13789. var height = 0;
  13790. var controlCount = 0;
  13791. var extendSizes = [];
  13792. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13793. // Measure
  13794. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13795. var child = _a[_i];
  13796. if (!child.mesh) {
  13797. continue;
  13798. }
  13799. controlCount++;
  13800. child.mesh.computeWorldMatrix(true);
  13801. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13802. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13803. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13804. extendSizes.push(extendSize);
  13805. if (this._isVertical) {
  13806. height += extendSize.y;
  13807. }
  13808. else {
  13809. width += extendSize.x;
  13810. }
  13811. }
  13812. if (this._isVertical) {
  13813. height += (controlCount - 1) * this.margin / 2;
  13814. }
  13815. else {
  13816. width += (controlCount - 1) * this.margin / 2;
  13817. }
  13818. // Arrange
  13819. var offset;
  13820. if (this._isVertical) {
  13821. offset = -height;
  13822. }
  13823. else {
  13824. offset = -width;
  13825. }
  13826. var index = 0;
  13827. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13828. var child = _c[_b];
  13829. if (!child.mesh) {
  13830. continue;
  13831. }
  13832. controlCount--;
  13833. var extendSize = extendSizes[index++];
  13834. if (this._isVertical) {
  13835. child.position.y = offset + extendSize.y;
  13836. child.position.x = 0;
  13837. offset += extendSize.y * 2;
  13838. }
  13839. else {
  13840. child.position.x = offset + extendSize.x;
  13841. child.position.y = 0;
  13842. offset += extendSize.x * 2;
  13843. }
  13844. offset += (controlCount > 0 ? this.margin : 0);
  13845. }
  13846. };
  13847. return StackPanel3D;
  13848. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13849. /***/ }),
  13850. /***/ "./3D/controls/volumeBasedPanel.ts":
  13851. /*!*****************************************!*\
  13852. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13853. \*****************************************/
  13854. /*! exports provided: VolumeBasedPanel */
  13855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13856. "use strict";
  13857. __webpack_require__.r(__webpack_exports__);
  13858. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13859. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13860. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13861. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13862. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13863. /**
  13864. * Abstract class used to create a container panel deployed on the surface of a volume
  13865. */
  13866. var VolumeBasedPanel = /** @class */ (function (_super) {
  13867. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13868. /**
  13869. * Creates new VolumeBasedPanel
  13870. */
  13871. function VolumeBasedPanel() {
  13872. var _this = _super.call(this) || this;
  13873. _this._columns = 10;
  13874. _this._rows = 0;
  13875. _this._rowThenColum = true;
  13876. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13877. /**
  13878. * Gets or sets the distance between elements
  13879. */
  13880. _this.margin = 0;
  13881. return _this;
  13882. }
  13883. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13884. /**
  13885. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13886. * | Value | Type | Description |
  13887. * | ----- | ----------------------------------- | ----------- |
  13888. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13889. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13890. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13891. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13892. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13893. */
  13894. get: function () {
  13895. return this._orientation;
  13896. },
  13897. set: function (value) {
  13898. var _this = this;
  13899. if (this._orientation === value) {
  13900. return;
  13901. }
  13902. this._orientation = value;
  13903. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13904. _this._arrangeChildren();
  13905. });
  13906. },
  13907. enumerable: true,
  13908. configurable: true
  13909. });
  13910. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13911. /**
  13912. * Gets or sets the number of columns requested (10 by default).
  13913. * The panel will automatically compute the number of rows based on number of child controls.
  13914. */
  13915. get: function () {
  13916. return this._columns;
  13917. },
  13918. set: function (value) {
  13919. var _this = this;
  13920. if (this._columns === value) {
  13921. return;
  13922. }
  13923. this._columns = value;
  13924. this._rowThenColum = true;
  13925. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13926. _this._arrangeChildren();
  13927. });
  13928. },
  13929. enumerable: true,
  13930. configurable: true
  13931. });
  13932. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13933. /**
  13934. * Gets or sets a the number of rows requested.
  13935. * The panel will automatically compute the number of columns based on number of child controls.
  13936. */
  13937. get: function () {
  13938. return this._rows;
  13939. },
  13940. set: function (value) {
  13941. var _this = this;
  13942. if (this._rows === value) {
  13943. return;
  13944. }
  13945. this._rows = value;
  13946. this._rowThenColum = false;
  13947. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13948. _this._arrangeChildren();
  13949. });
  13950. },
  13951. enumerable: true,
  13952. configurable: true
  13953. });
  13954. VolumeBasedPanel.prototype._arrangeChildren = function () {
  13955. this._cellWidth = 0;
  13956. this._cellHeight = 0;
  13957. var rows = 0;
  13958. var columns = 0;
  13959. var controlCount = 0;
  13960. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13961. // Measure
  13962. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13963. var child = _a[_i];
  13964. if (!child.mesh) {
  13965. continue;
  13966. }
  13967. controlCount++;
  13968. child.mesh.computeWorldMatrix(true);
  13969. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  13970. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  13971. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13972. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  13973. boundingBox.max.subtractToRef(boundingBox.min, diff);
  13974. diff.scaleInPlace(0.5);
  13975. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  13976. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  13977. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  13978. }
  13979. this._cellWidth += this.margin * 2;
  13980. this._cellHeight += this.margin * 2;
  13981. // Arrange
  13982. if (this._rowThenColum) {
  13983. columns = this._columns;
  13984. rows = Math.ceil(controlCount / this._columns);
  13985. }
  13986. else {
  13987. rows = this._rows;
  13988. columns = Math.ceil(controlCount / this._rows);
  13989. }
  13990. var startOffsetX = (columns * 0.5) * this._cellWidth;
  13991. var startOffsetY = (rows * 0.5) * this._cellHeight;
  13992. var nodeGrid = [];
  13993. var cellCounter = 0;
  13994. if (this._rowThenColum) {
  13995. for (var r = 0; r < rows; r++) {
  13996. for (var c = 0; c < columns; c++) {
  13997. 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));
  13998. cellCounter++;
  13999. if (cellCounter > controlCount) {
  14000. break;
  14001. }
  14002. }
  14003. }
  14004. }
  14005. else {
  14006. for (var c = 0; c < columns; c++) {
  14007. for (var r = 0; r < rows; r++) {
  14008. 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));
  14009. cellCounter++;
  14010. if (cellCounter > controlCount) {
  14011. break;
  14012. }
  14013. }
  14014. }
  14015. }
  14016. cellCounter = 0;
  14017. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14018. var child = _c[_b];
  14019. if (!child.mesh) {
  14020. continue;
  14021. }
  14022. this._mapGridNode(child, nodeGrid[cellCounter]);
  14023. cellCounter++;
  14024. }
  14025. this._finalProcessing();
  14026. };
  14027. /** Child classes can implement this function to provide additional processing */
  14028. VolumeBasedPanel.prototype._finalProcessing = function () {
  14029. };
  14030. return VolumeBasedPanel;
  14031. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14032. /***/ }),
  14033. /***/ "./3D/gui3DManager.ts":
  14034. /*!****************************!*\
  14035. !*** ./3D/gui3DManager.ts ***!
  14036. \****************************/
  14037. /*! exports provided: GUI3DManager */
  14038. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14039. "use strict";
  14040. __webpack_require__.r(__webpack_exports__);
  14041. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14042. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  14043. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14044. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14045. /**
  14046. * Class used to manage 3D user interface
  14047. * @see http://doc.babylonjs.com/how_to/gui3d
  14048. */
  14049. var GUI3DManager = /** @class */ (function () {
  14050. /**
  14051. * Creates a new GUI3DManager
  14052. * @param scene
  14053. */
  14054. function GUI3DManager(scene) {
  14055. var _this = this;
  14056. /** @hidden */
  14057. this._lastControlOver = {};
  14058. /** @hidden */
  14059. this._lastControlDown = {};
  14060. /**
  14061. * Observable raised when the point picked by the pointer events changed
  14062. */
  14063. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14064. // Shared resources
  14065. /** @hidden */
  14066. this._sharedMaterials = {};
  14067. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14068. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14069. _this._sceneDisposeObserver = null;
  14070. _this._utilityLayer = null;
  14071. _this.dispose();
  14072. });
  14073. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14074. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14075. this._utilityLayer.pickUtilitySceneFirst = false;
  14076. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14077. return mesh && mesh.metadata && mesh.metadata._node;
  14078. };
  14079. // Root
  14080. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14081. this._rootContainer._host = this;
  14082. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14083. // Events
  14084. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14085. _this._handlePointerOut(pointerId, true);
  14086. });
  14087. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14088. _this._doPicking(pi);
  14089. });
  14090. // Scene
  14091. this._utilityLayer.utilityLayerScene.autoClear = false;
  14092. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14093. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14094. }
  14095. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14096. /** Gets the hosting scene */
  14097. get: function () {
  14098. return this._scene;
  14099. },
  14100. enumerable: true,
  14101. configurable: true
  14102. });
  14103. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14104. /** Gets associated utility layer */
  14105. get: function () {
  14106. return this._utilityLayer;
  14107. },
  14108. enumerable: true,
  14109. configurable: true
  14110. });
  14111. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14112. var previousControlOver = this._lastControlOver[pointerId];
  14113. if (previousControlOver) {
  14114. previousControlOver._onPointerOut(previousControlOver);
  14115. delete this._lastControlOver[pointerId];
  14116. }
  14117. if (isPointerUp) {
  14118. if (this._lastControlDown[pointerId]) {
  14119. this._lastControlDown[pointerId].forcePointerUp();
  14120. delete this._lastControlDown[pointerId];
  14121. }
  14122. }
  14123. this.onPickedPointChangedObservable.notifyObservers(null);
  14124. };
  14125. GUI3DManager.prototype._doPicking = function (pi) {
  14126. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14127. return false;
  14128. }
  14129. var pointerEvent = (pi.event);
  14130. var pointerId = pointerEvent.pointerId || 0;
  14131. var buttonIndex = pointerEvent.button;
  14132. var pickingInfo = pi.pickInfo;
  14133. if (!pickingInfo || !pickingInfo.hit) {
  14134. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14135. return false;
  14136. }
  14137. var control = (pickingInfo.pickedMesh.metadata);
  14138. if (pickingInfo.pickedPoint) {
  14139. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14140. }
  14141. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14142. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14143. if (this._lastControlOver[pointerId]) {
  14144. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14145. }
  14146. delete this._lastControlOver[pointerId];
  14147. }
  14148. }
  14149. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14150. if (this._lastControlDown[pointerEvent.pointerId]) {
  14151. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14152. delete this._lastControlDown[pointerEvent.pointerId];
  14153. }
  14154. if (pointerEvent.pointerType === "touch") {
  14155. this._handlePointerOut(pointerId, false);
  14156. }
  14157. }
  14158. return true;
  14159. };
  14160. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14161. /**
  14162. * Gets the root container
  14163. */
  14164. get: function () {
  14165. return this._rootContainer;
  14166. },
  14167. enumerable: true,
  14168. configurable: true
  14169. });
  14170. /**
  14171. * Gets a boolean indicating if the given control is in the root child list
  14172. * @param control defines the control to check
  14173. * @returns true if the control is in the root child list
  14174. */
  14175. GUI3DManager.prototype.containsControl = function (control) {
  14176. return this._rootContainer.containsControl(control);
  14177. };
  14178. /**
  14179. * Adds a control to the root child list
  14180. * @param control defines the control to add
  14181. * @returns the current manager
  14182. */
  14183. GUI3DManager.prototype.addControl = function (control) {
  14184. this._rootContainer.addControl(control);
  14185. return this;
  14186. };
  14187. /**
  14188. * Removes a control from the root child list
  14189. * @param control defines the control to remove
  14190. * @returns the current container
  14191. */
  14192. GUI3DManager.prototype.removeControl = function (control) {
  14193. this._rootContainer.removeControl(control);
  14194. return this;
  14195. };
  14196. /**
  14197. * Releases all associated resources
  14198. */
  14199. GUI3DManager.prototype.dispose = function () {
  14200. this._rootContainer.dispose();
  14201. for (var materialName in this._sharedMaterials) {
  14202. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14203. continue;
  14204. }
  14205. this._sharedMaterials[materialName].dispose();
  14206. }
  14207. this._sharedMaterials = {};
  14208. if (this._pointerOutObserver && this._utilityLayer) {
  14209. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14210. this._pointerOutObserver = null;
  14211. }
  14212. this.onPickedPointChangedObservable.clear();
  14213. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14214. if (utilityLayerScene) {
  14215. if (this._pointerObserver) {
  14216. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14217. this._pointerObserver = null;
  14218. }
  14219. }
  14220. if (this._scene) {
  14221. if (this._sceneDisposeObserver) {
  14222. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14223. this._sceneDisposeObserver = null;
  14224. }
  14225. }
  14226. if (this._utilityLayer) {
  14227. this._utilityLayer.dispose();
  14228. }
  14229. };
  14230. return GUI3DManager;
  14231. }());
  14232. /***/ }),
  14233. /***/ "./3D/index.ts":
  14234. /*!*********************!*\
  14235. !*** ./3D/index.ts ***!
  14236. \*********************/
  14237. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14239. "use strict";
  14240. __webpack_require__.r(__webpack_exports__);
  14241. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14254. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14257. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14259. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14261. /***/ }),
  14262. /***/ "./3D/materials/fluentMaterial.ts":
  14263. /*!****************************************!*\
  14264. !*** ./3D/materials/fluentMaterial.ts ***!
  14265. \****************************************/
  14266. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14268. "use strict";
  14269. __webpack_require__.r(__webpack_exports__);
  14270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14272. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14273. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  14274. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14275. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14276. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14277. /** @hidden */
  14278. var FluentMaterialDefines = /** @class */ (function (_super) {
  14279. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14280. function FluentMaterialDefines() {
  14281. var _this = _super.call(this) || this;
  14282. _this.INNERGLOW = false;
  14283. _this.BORDER = false;
  14284. _this.HOVERLIGHT = false;
  14285. _this.TEXTURE = false;
  14286. _this.rebuild();
  14287. return _this;
  14288. }
  14289. return FluentMaterialDefines;
  14290. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14291. /**
  14292. * Class used to render controls with fluent desgin
  14293. */
  14294. var FluentMaterial = /** @class */ (function (_super) {
  14295. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14296. /**
  14297. * Creates a new Fluent material
  14298. * @param name defines the name of the material
  14299. * @param scene defines the hosting scene
  14300. */
  14301. function FluentMaterial(name, scene) {
  14302. var _this = _super.call(this, name, scene) || this;
  14303. /**
  14304. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14305. */
  14306. _this.innerGlowColorIntensity = 0.5;
  14307. /**
  14308. * Gets or sets the inner glow color (white by default)
  14309. */
  14310. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14311. /**
  14312. * Gets or sets alpha value (default is 1.0)
  14313. */
  14314. _this.alpha = 1.0;
  14315. /**
  14316. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14317. */
  14318. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14319. /**
  14320. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14321. */
  14322. _this.renderBorders = false;
  14323. /**
  14324. * Gets or sets border width (default is 0.5)
  14325. */
  14326. _this.borderWidth = 0.5;
  14327. /**
  14328. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14329. */
  14330. _this.edgeSmoothingValue = 0.02;
  14331. /**
  14332. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14333. */
  14334. _this.borderMinValue = 0.1;
  14335. /**
  14336. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14337. */
  14338. _this.renderHoverLight = false;
  14339. /**
  14340. * Gets or sets the radius used to render the hover light (default is 1.0)
  14341. */
  14342. _this.hoverRadius = 1.0;
  14343. /**
  14344. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14345. */
  14346. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14347. /**
  14348. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14349. */
  14350. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14351. return _this;
  14352. }
  14353. FluentMaterial.prototype.needAlphaBlending = function () {
  14354. return this.alpha !== 1.0;
  14355. };
  14356. FluentMaterial.prototype.needAlphaTesting = function () {
  14357. return false;
  14358. };
  14359. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14360. return null;
  14361. };
  14362. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14363. if (this.isFrozen) {
  14364. if (this._wasPreviouslyReady && subMesh.effect) {
  14365. return true;
  14366. }
  14367. }
  14368. if (!subMesh._materialDefines) {
  14369. subMesh._materialDefines = new FluentMaterialDefines();
  14370. }
  14371. var scene = this.getScene();
  14372. var defines = subMesh._materialDefines;
  14373. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14374. if (defines._renderId === scene.getRenderId()) {
  14375. return true;
  14376. }
  14377. }
  14378. if (defines._areTexturesDirty) {
  14379. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14380. defines.BORDER = this.renderBorders;
  14381. defines.HOVERLIGHT = this.renderHoverLight;
  14382. if (this._albedoTexture) {
  14383. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14384. return false;
  14385. }
  14386. else {
  14387. defines.TEXTURE = true;
  14388. }
  14389. }
  14390. else {
  14391. defines.TEXTURE = false;
  14392. }
  14393. }
  14394. var engine = scene.getEngine();
  14395. // Get correct effect
  14396. if (defines.isDirty) {
  14397. defines.markAsProcessed();
  14398. scene.resetCachedMaterial();
  14399. //Attributes
  14400. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14401. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14402. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14403. var shaderName = "fluent";
  14404. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14405. "hoverColor", "hoverPosition", "hoverRadius"
  14406. ];
  14407. var samplers = ["albedoSampler"];
  14408. var uniformBuffers = new Array();
  14409. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14410. uniformsNames: uniforms,
  14411. uniformBuffersNames: uniformBuffers,
  14412. samplers: samplers,
  14413. defines: defines,
  14414. maxSimultaneousLights: 4
  14415. });
  14416. var join = defines.toString();
  14417. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14418. attributes: attribs,
  14419. uniformsNames: uniforms,
  14420. uniformBuffersNames: uniformBuffers,
  14421. samplers: samplers,
  14422. defines: join,
  14423. fallbacks: null,
  14424. onCompiled: this.onCompiled,
  14425. onError: this.onError,
  14426. indexParameters: { maxSimultaneousLights: 4 }
  14427. }, engine));
  14428. }
  14429. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14430. return false;
  14431. }
  14432. defines._renderId = scene.getRenderId();
  14433. this._wasPreviouslyReady = true;
  14434. return true;
  14435. };
  14436. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14437. var scene = this.getScene();
  14438. var defines = subMesh._materialDefines;
  14439. if (!defines) {
  14440. return;
  14441. }
  14442. var effect = subMesh.effect;
  14443. if (!effect) {
  14444. return;
  14445. }
  14446. this._activeEffect = effect;
  14447. // Matrices
  14448. this.bindOnlyWorldMatrix(world);
  14449. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14450. if (this._mustRebind(scene, effect)) {
  14451. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14452. if (defines.INNERGLOW) {
  14453. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14454. }
  14455. if (defines.BORDER) {
  14456. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14457. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14458. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14459. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14460. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14461. }
  14462. if (defines.HOVERLIGHT) {
  14463. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14464. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14465. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14466. }
  14467. if (defines.TEXTURE) {
  14468. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14469. }
  14470. }
  14471. this._afterBind(mesh, this._activeEffect);
  14472. };
  14473. FluentMaterial.prototype.getActiveTextures = function () {
  14474. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14475. return activeTextures;
  14476. };
  14477. FluentMaterial.prototype.hasTexture = function (texture) {
  14478. if (_super.prototype.hasTexture.call(this, texture)) {
  14479. return true;
  14480. }
  14481. return false;
  14482. };
  14483. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14484. _super.prototype.dispose.call(this, forceDisposeEffect);
  14485. };
  14486. FluentMaterial.prototype.clone = function (name) {
  14487. var _this = this;
  14488. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14489. };
  14490. FluentMaterial.prototype.serialize = function () {
  14491. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14492. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14493. return serializationObject;
  14494. };
  14495. FluentMaterial.prototype.getClassName = function () {
  14496. return "FluentMaterial";
  14497. };
  14498. // Statics
  14499. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14500. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14501. };
  14502. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14503. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14504. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14505. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14507. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14508. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14510. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14511. ], FluentMaterial.prototype, "alpha", void 0);
  14512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14513. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14514. ], FluentMaterial.prototype, "albedoColor", void 0);
  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, "renderBorders", void 0);
  14519. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14520. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14521. ], FluentMaterial.prototype, "borderWidth", void 0);
  14522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14523. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14524. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14526. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14527. ], FluentMaterial.prototype, "borderMinValue", 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, "renderHoverLight", void 0);
  14532. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14533. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14534. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14535. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14536. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14537. ], FluentMaterial.prototype, "hoverColor", void 0);
  14538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14539. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14540. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14542. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14543. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14545. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14546. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14547. return FluentMaterial;
  14548. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14549. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14550. /***/ }),
  14551. /***/ "./3D/materials/index.ts":
  14552. /*!*******************************!*\
  14553. !*** ./3D/materials/index.ts ***!
  14554. \*******************************/
  14555. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14557. "use strict";
  14558. __webpack_require__.r(__webpack_exports__);
  14559. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14562. /***/ }),
  14563. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14564. /*!*************************************************!*\
  14565. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14566. \*************************************************/
  14567. /*! exports provided: fluentPixelShader */
  14568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14569. "use strict";
  14570. __webpack_require__.r(__webpack_exports__);
  14571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14572. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14573. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14574. var name = 'fluentPixelShader';
  14575. 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}";
  14576. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14577. /** @hidden */
  14578. var fluentPixelShader = { name: name, shader: shader };
  14579. /***/ }),
  14580. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14581. /*!***********************************************!*\
  14582. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14583. \***********************************************/
  14584. /*! exports provided: fluentVertexShader */
  14585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14586. "use strict";
  14587. __webpack_require__.r(__webpack_exports__);
  14588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14589. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14590. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14591. var name = 'fluentVertexShader';
  14592. 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";
  14593. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14594. /** @hidden */
  14595. var fluentVertexShader = { name: name, shader: shader };
  14596. /***/ }),
  14597. /***/ "./3D/vector3WithInfo.ts":
  14598. /*!*******************************!*\
  14599. !*** ./3D/vector3WithInfo.ts ***!
  14600. \*******************************/
  14601. /*! exports provided: Vector3WithInfo */
  14602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14603. "use strict";
  14604. __webpack_require__.r(__webpack_exports__);
  14605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14606. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14607. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  14608. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14609. /**
  14610. * Class used to transport Vector3 information for pointer events
  14611. */
  14612. var Vector3WithInfo = /** @class */ (function (_super) {
  14613. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14614. /**
  14615. * Creates a new Vector3WithInfo
  14616. * @param source defines the vector3 data to transport
  14617. * @param buttonIndex defines the current mouse button index
  14618. */
  14619. function Vector3WithInfo(source,
  14620. /** defines the current mouse button index */
  14621. buttonIndex) {
  14622. if (buttonIndex === void 0) { buttonIndex = 0; }
  14623. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14624. _this.buttonIndex = buttonIndex;
  14625. return _this;
  14626. }
  14627. return Vector3WithInfo;
  14628. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14629. /***/ }),
  14630. /***/ "./index.ts":
  14631. /*!******************!*\
  14632. !*** ./index.ts ***!
  14633. \******************/
  14634. /*! 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 */
  14635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14636. "use strict";
  14637. __webpack_require__.r(__webpack_exports__);
  14638. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14678. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14695. /***/ }),
  14696. /***/ "./legacy/legacy.ts":
  14697. /*!**************************!*\
  14698. !*** ./legacy/legacy.ts ***!
  14699. \**************************/
  14700. /*! 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 */
  14701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14702. "use strict";
  14703. __webpack_require__.r(__webpack_exports__);
  14704. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14760. /**
  14761. * Legacy support, defining window.BABYLON.GUI (global variable).
  14762. *
  14763. * This is the entry point for the UMD module.
  14764. * The entry point for a future ESM package should be index.ts
  14765. */
  14766. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14767. if (typeof globalObject !== "undefined") {
  14768. globalObject.BABYLON = globalObject.BABYLON || {};
  14769. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14770. }
  14771. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14772. /***/ }),
  14773. /***/ "babylonjs/Misc/observable":
  14774. /*!****************************************************************************************************!*\
  14775. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14776. \****************************************************************************************************/
  14777. /*! no static exports found */
  14778. /***/ (function(module, exports) {
  14779. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  14780. /***/ })
  14781. /******/ });
  14782. });
  14783. //# sourceMappingURL=babylon.gui.js.map