babylon.gui.js 675 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595
  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_tools__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** E:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../../node_modules/webpack/buildin/global.js":
  291. /*!***********************************!*\
  292. !*** (webpack)/buildin/global.js ***!
  293. \***********************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./2D/adtInstrumentation.ts":
  314. /*!**********************************!*\
  315. !*** ./2D/adtInstrumentation.ts ***!
  316. \**********************************/
  317. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  322. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  323. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  324. /**
  325. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  326. */
  327. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  328. /**
  329. * Instantiates a new advanced dynamic texture instrumentation.
  330. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  331. * @param texture Defines the AdvancedDynamicTexture to instrument
  332. */
  333. function AdvancedDynamicTextureInstrumentation(
  334. /**
  335. * Define the instrumented AdvancedDynamicTexture.
  336. */
  337. texture) {
  338. this.texture = texture;
  339. this._captureRenderTime = false;
  340. this._renderTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  341. this._captureLayoutTime = false;
  342. this._layoutTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  343. // Observers
  344. this._onBeginRenderObserver = null;
  345. this._onEndRenderObserver = null;
  346. this._onBeginLayoutObserver = null;
  347. this._onEndLayoutObserver = null;
  348. }
  349. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  350. // Properties
  351. /**
  352. * Gets the perf counter used to capture render time
  353. */
  354. get: function () {
  355. return this._renderTime;
  356. },
  357. enumerable: true,
  358. configurable: true
  359. });
  360. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  361. /**
  362. * Gets the perf counter used to capture layout time
  363. */
  364. get: function () {
  365. return this._layoutTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  371. /**
  372. * Enable or disable the render time capture
  373. */
  374. get: function () {
  375. return this._captureRenderTime;
  376. },
  377. set: function (value) {
  378. var _this = this;
  379. if (value === this._captureRenderTime) {
  380. return;
  381. }
  382. this._captureRenderTime = value;
  383. if (value) {
  384. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  385. _this._renderTime.beginMonitoring();
  386. });
  387. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  388. _this._renderTime.endMonitoring(true);
  389. });
  390. }
  391. else {
  392. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  393. this._onBeginRenderObserver = null;
  394. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  395. this._onEndRenderObserver = null;
  396. }
  397. },
  398. enumerable: true,
  399. configurable: true
  400. });
  401. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  402. /**
  403. * Enable or disable the layout time capture
  404. */
  405. get: function () {
  406. return this._captureLayoutTime;
  407. },
  408. set: function (value) {
  409. var _this = this;
  410. if (value === this._captureLayoutTime) {
  411. return;
  412. }
  413. this._captureLayoutTime = value;
  414. if (value) {
  415. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  416. _this._layoutTime.beginMonitoring();
  417. });
  418. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  419. _this._layoutTime.endMonitoring(true);
  420. });
  421. }
  422. else {
  423. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  424. this._onBeginLayoutObserver = null;
  425. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  426. this._onEndLayoutObserver = null;
  427. }
  428. },
  429. enumerable: true,
  430. configurable: true
  431. });
  432. /**
  433. * Dispose and release associated resources.
  434. */
  435. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  436. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  437. this._onBeginRenderObserver = null;
  438. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  439. this._onEndRenderObserver = null;
  440. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  441. this._onBeginLayoutObserver = null;
  442. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  443. this._onEndLayoutObserver = null;
  444. this.texture = null;
  445. };
  446. return AdvancedDynamicTextureInstrumentation;
  447. }());
  448. /***/ }),
  449. /***/ "./2D/advancedDynamicTexture.ts":
  450. /*!**************************************!*\
  451. !*** ./2D/advancedDynamicTexture.ts ***!
  452. \**************************************/
  453. /*! exports provided: AdvancedDynamicTexture */
  454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  455. "use strict";
  456. __webpack_require__.r(__webpack_exports__);
  457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  459. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  460. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  461. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  462. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  463. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  464. /**
  465. * Class used to create texture to support 2D GUI elements
  466. * @see http://doc.babylonjs.com/how_to/gui
  467. */
  468. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  470. /**
  471. * Creates a new AdvancedDynamicTexture
  472. * @param name defines the name of the texture
  473. * @param width defines the width of the texture
  474. * @param height defines the height of the texture
  475. * @param scene defines the hosting scene
  476. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  477. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  478. */
  479. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  480. if (width === void 0) { width = 0; }
  481. if (height === void 0) { height = 0; }
  482. if (generateMipMaps === void 0) { generateMipMaps = false; }
  483. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  484. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  485. _this._isDirty = false;
  486. /** @hidden */
  487. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  488. /** @hidden */
  489. _this._lastControlOver = {};
  490. /** @hidden */
  491. _this._lastControlDown = {};
  492. /** @hidden */
  493. _this._capturingControl = {};
  494. /** @hidden */
  495. _this._linkedControls = new Array();
  496. _this._isFullscreen = false;
  497. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  498. _this._idealWidth = 0;
  499. _this._idealHeight = 0;
  500. _this._useSmallestIdeal = false;
  501. _this._renderAtIdealSize = false;
  502. _this._blockNextFocusCheck = false;
  503. _this._renderScale = 1;
  504. /**
  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/tools");
  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/tools");
  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/tools");
  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/tools");
  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. cell._left.ignoreAdaptiveScaling = true;
  6006. cell._top.ignoreAdaptiveScaling = true;
  6007. cell._width.ignoreAdaptiveScaling = true;
  6008. cell._height.ignoreAdaptiveScaling = true;
  6009. }
  6010. });
  6011. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6012. };
  6013. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6014. for (var key in this._cells) {
  6015. if (!this._cells.hasOwnProperty(key)) {
  6016. continue;
  6017. }
  6018. var child = this._cells[key];
  6019. child._markMatrixAsDirty();
  6020. }
  6021. };
  6022. Grid.prototype._renderHighlightSpecific = function (context) {
  6023. var _this = this;
  6024. _super.prototype._renderHighlightSpecific.call(this, context);
  6025. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6026. // Columns
  6027. for (var index = 0; index < lefts.length; index++) {
  6028. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6029. context.beginPath();
  6030. context.moveTo(left, _this._currentMeasure.top);
  6031. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6032. context.stroke();
  6033. }
  6034. // Rows
  6035. for (var index = 0; index < tops.length; index++) {
  6036. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6037. context.beginPath();
  6038. context.moveTo(_this._currentMeasure.left, top_1);
  6039. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6040. context.stroke();
  6041. }
  6042. });
  6043. context.restore();
  6044. };
  6045. /** Releases associated resources */
  6046. Grid.prototype.dispose = function () {
  6047. _super.prototype.dispose.call(this);
  6048. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6049. var control = _a[_i];
  6050. control.dispose();
  6051. }
  6052. this._childControls = [];
  6053. };
  6054. return Grid;
  6055. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6056. /***/ }),
  6057. /***/ "./2D/controls/image.ts":
  6058. /*!******************************!*\
  6059. !*** ./2D/controls/image.ts ***!
  6060. \******************************/
  6061. /*! exports provided: Image */
  6062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6063. "use strict";
  6064. __webpack_require__.r(__webpack_exports__);
  6065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6066. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6067. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  6068. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6069. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6070. /**
  6071. * Class used to create 2D images
  6072. */
  6073. var Image = /** @class */ (function (_super) {
  6074. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6075. /**
  6076. * Creates a new Image
  6077. * @param name defines the control name
  6078. * @param url defines the image url
  6079. */
  6080. function Image(name, url) {
  6081. if (url === void 0) { url = null; }
  6082. var _this = _super.call(this, name) || this;
  6083. _this.name = name;
  6084. _this._loaded = false;
  6085. _this._stretch = Image.STRETCH_FILL;
  6086. _this._autoScale = false;
  6087. _this._sourceLeft = 0;
  6088. _this._sourceTop = 0;
  6089. _this._sourceWidth = 0;
  6090. _this._sourceHeight = 0;
  6091. _this._cellWidth = 0;
  6092. _this._cellHeight = 0;
  6093. _this._cellId = -1;
  6094. _this._populateNinePatchSlicesFromImage = false;
  6095. /**
  6096. * Observable notified when the content is loaded
  6097. */
  6098. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6099. _this.source = url;
  6100. return _this;
  6101. }
  6102. Object.defineProperty(Image.prototype, "isLoaded", {
  6103. /**
  6104. * Gets a boolean indicating that the content is loaded
  6105. */
  6106. get: function () {
  6107. return this._loaded;
  6108. },
  6109. enumerable: true,
  6110. configurable: true
  6111. });
  6112. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6113. /**
  6114. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6115. */
  6116. get: function () {
  6117. return this._populateNinePatchSlicesFromImage;
  6118. },
  6119. set: function (value) {
  6120. if (this._populateNinePatchSlicesFromImage === value) {
  6121. return;
  6122. }
  6123. this._populateNinePatchSlicesFromImage = value;
  6124. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6125. this._extractNinePatchSliceDataFromImage();
  6126. }
  6127. },
  6128. enumerable: true,
  6129. configurable: true
  6130. });
  6131. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6132. /**
  6133. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6134. * Beware using this as this will comsume more memory as the image has to be stored twice
  6135. */
  6136. get: function () {
  6137. return this._detectPointerOnOpaqueOnly;
  6138. },
  6139. set: function (value) {
  6140. if (this._detectPointerOnOpaqueOnly === value) {
  6141. return;
  6142. }
  6143. this._detectPointerOnOpaqueOnly = value;
  6144. },
  6145. enumerable: true,
  6146. configurable: true
  6147. });
  6148. Object.defineProperty(Image.prototype, "sliceLeft", {
  6149. /**
  6150. * Gets or sets the left value for slicing (9-patch)
  6151. */
  6152. get: function () {
  6153. return this._sliceLeft;
  6154. },
  6155. set: function (value) {
  6156. if (this._sliceLeft === value) {
  6157. return;
  6158. }
  6159. this._sliceLeft = value;
  6160. this._markAsDirty();
  6161. },
  6162. enumerable: true,
  6163. configurable: true
  6164. });
  6165. Object.defineProperty(Image.prototype, "sliceRight", {
  6166. /**
  6167. * Gets or sets the right value for slicing (9-patch)
  6168. */
  6169. get: function () {
  6170. return this._sliceRight;
  6171. },
  6172. set: function (value) {
  6173. if (this._sliceRight === value) {
  6174. return;
  6175. }
  6176. this._sliceRight = value;
  6177. this._markAsDirty();
  6178. },
  6179. enumerable: true,
  6180. configurable: true
  6181. });
  6182. Object.defineProperty(Image.prototype, "sliceTop", {
  6183. /**
  6184. * Gets or sets the top value for slicing (9-patch)
  6185. */
  6186. get: function () {
  6187. return this._sliceTop;
  6188. },
  6189. set: function (value) {
  6190. if (this._sliceTop === value) {
  6191. return;
  6192. }
  6193. this._sliceTop = value;
  6194. this._markAsDirty();
  6195. },
  6196. enumerable: true,
  6197. configurable: true
  6198. });
  6199. Object.defineProperty(Image.prototype, "sliceBottom", {
  6200. /**
  6201. * Gets or sets the bottom value for slicing (9-patch)
  6202. */
  6203. get: function () {
  6204. return this._sliceBottom;
  6205. },
  6206. set: function (value) {
  6207. if (this._sliceBottom === value) {
  6208. return;
  6209. }
  6210. this._sliceBottom = value;
  6211. this._markAsDirty();
  6212. },
  6213. enumerable: true,
  6214. configurable: true
  6215. });
  6216. Object.defineProperty(Image.prototype, "sourceLeft", {
  6217. /**
  6218. * Gets or sets the left coordinate in the source image
  6219. */
  6220. get: function () {
  6221. return this._sourceLeft;
  6222. },
  6223. set: function (value) {
  6224. if (this._sourceLeft === value) {
  6225. return;
  6226. }
  6227. this._sourceLeft = value;
  6228. this._markAsDirty();
  6229. },
  6230. enumerable: true,
  6231. configurable: true
  6232. });
  6233. Object.defineProperty(Image.prototype, "sourceTop", {
  6234. /**
  6235. * Gets or sets the top coordinate in the source image
  6236. */
  6237. get: function () {
  6238. return this._sourceTop;
  6239. },
  6240. set: function (value) {
  6241. if (this._sourceTop === value) {
  6242. return;
  6243. }
  6244. this._sourceTop = value;
  6245. this._markAsDirty();
  6246. },
  6247. enumerable: true,
  6248. configurable: true
  6249. });
  6250. Object.defineProperty(Image.prototype, "sourceWidth", {
  6251. /**
  6252. * Gets or sets the width to capture in the source image
  6253. */
  6254. get: function () {
  6255. return this._sourceWidth;
  6256. },
  6257. set: function (value) {
  6258. if (this._sourceWidth === value) {
  6259. return;
  6260. }
  6261. this._sourceWidth = value;
  6262. this._markAsDirty();
  6263. },
  6264. enumerable: true,
  6265. configurable: true
  6266. });
  6267. Object.defineProperty(Image.prototype, "sourceHeight", {
  6268. /**
  6269. * Gets or sets the height to capture in the source image
  6270. */
  6271. get: function () {
  6272. return this._sourceHeight;
  6273. },
  6274. set: function (value) {
  6275. if (this._sourceHeight === value) {
  6276. return;
  6277. }
  6278. this._sourceHeight = value;
  6279. this._markAsDirty();
  6280. },
  6281. enumerable: true,
  6282. configurable: true
  6283. });
  6284. Object.defineProperty(Image.prototype, "autoScale", {
  6285. /**
  6286. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6287. * @see http://doc.babylonjs.com/how_to/gui#image
  6288. */
  6289. get: function () {
  6290. return this._autoScale;
  6291. },
  6292. set: function (value) {
  6293. if (this._autoScale === value) {
  6294. return;
  6295. }
  6296. this._autoScale = value;
  6297. if (value && this._loaded) {
  6298. this.synchronizeSizeWithContent();
  6299. }
  6300. },
  6301. enumerable: true,
  6302. configurable: true
  6303. });
  6304. Object.defineProperty(Image.prototype, "stretch", {
  6305. /** Gets or sets the streching mode used by the image */
  6306. get: function () {
  6307. return this._stretch;
  6308. },
  6309. set: function (value) {
  6310. if (this._stretch === value) {
  6311. return;
  6312. }
  6313. this._stretch = value;
  6314. this._markAsDirty();
  6315. },
  6316. enumerable: true,
  6317. configurable: true
  6318. });
  6319. Object.defineProperty(Image.prototype, "domImage", {
  6320. get: function () {
  6321. return this._domImage;
  6322. },
  6323. /**
  6324. * Gets or sets the internal DOM image used to render the control
  6325. */
  6326. set: function (value) {
  6327. var _this = this;
  6328. this._domImage = value;
  6329. this._loaded = false;
  6330. if (this._domImage.width) {
  6331. this._onImageLoaded();
  6332. }
  6333. else {
  6334. this._domImage.onload = function () {
  6335. _this._onImageLoaded();
  6336. };
  6337. }
  6338. },
  6339. enumerable: true,
  6340. configurable: true
  6341. });
  6342. Image.prototype._onImageLoaded = function () {
  6343. this._imageWidth = this._domImage.width;
  6344. this._imageHeight = this._domImage.height;
  6345. this._loaded = true;
  6346. if (this._populateNinePatchSlicesFromImage) {
  6347. this._extractNinePatchSliceDataFromImage();
  6348. }
  6349. if (this._autoScale) {
  6350. this.synchronizeSizeWithContent();
  6351. }
  6352. this.onImageLoadedObservable.notifyObservers(this);
  6353. this._markAsDirty();
  6354. };
  6355. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6356. if (!Image._WorkingCanvas) {
  6357. Image._WorkingCanvas = document.createElement('canvas');
  6358. }
  6359. var canvas = Image._WorkingCanvas;
  6360. var context = canvas.getContext('2d');
  6361. var width = this._domImage.width;
  6362. var height = this._domImage.height;
  6363. canvas.width = width;
  6364. canvas.height = height;
  6365. context.drawImage(this._domImage, 0, 0, width, height);
  6366. var imageData = context.getImageData(0, 0, width, height);
  6367. // Left and right
  6368. this._sliceLeft = -1;
  6369. this._sliceRight = -1;
  6370. for (var x = 0; x < width; x++) {
  6371. var alpha = imageData.data[x * 4 + 3];
  6372. if (alpha > 127 && this._sliceLeft === -1) {
  6373. this._sliceLeft = x;
  6374. continue;
  6375. }
  6376. if (alpha < 127 && this._sliceLeft > -1) {
  6377. this._sliceRight = x;
  6378. break;
  6379. }
  6380. }
  6381. // top and bottom
  6382. this._sliceTop = -1;
  6383. this._sliceBottom = -1;
  6384. for (var y = 0; y < height; y++) {
  6385. var alpha = imageData.data[y * width * 4 + 3];
  6386. if (alpha > 127 && this._sliceTop === -1) {
  6387. this._sliceTop = y;
  6388. continue;
  6389. }
  6390. if (alpha < 127 && this._sliceTop > -1) {
  6391. this._sliceBottom = y;
  6392. break;
  6393. }
  6394. }
  6395. };
  6396. Object.defineProperty(Image.prototype, "source", {
  6397. /**
  6398. * Gets or sets image source url
  6399. */
  6400. set: function (value) {
  6401. var _this = this;
  6402. if (this._source === value) {
  6403. return;
  6404. }
  6405. this._loaded = false;
  6406. this._source = value;
  6407. this._domImage = document.createElement("img");
  6408. this._domImage.onload = function () {
  6409. _this._onImageLoaded();
  6410. };
  6411. if (value) {
  6412. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6413. this._domImage.src = value;
  6414. }
  6415. },
  6416. enumerable: true,
  6417. configurable: true
  6418. });
  6419. Object.defineProperty(Image.prototype, "cellWidth", {
  6420. /**
  6421. * Gets or sets the cell width to use when animation sheet is enabled
  6422. * @see http://doc.babylonjs.com/how_to/gui#image
  6423. */
  6424. get: function () {
  6425. return this._cellWidth;
  6426. },
  6427. set: function (value) {
  6428. if (this._cellWidth === value) {
  6429. return;
  6430. }
  6431. this._cellWidth = value;
  6432. this._markAsDirty();
  6433. },
  6434. enumerable: true,
  6435. configurable: true
  6436. });
  6437. Object.defineProperty(Image.prototype, "cellHeight", {
  6438. /**
  6439. * Gets or sets the cell height to use when animation sheet is enabled
  6440. * @see http://doc.babylonjs.com/how_to/gui#image
  6441. */
  6442. get: function () {
  6443. return this._cellHeight;
  6444. },
  6445. set: function (value) {
  6446. if (this._cellHeight === value) {
  6447. return;
  6448. }
  6449. this._cellHeight = value;
  6450. this._markAsDirty();
  6451. },
  6452. enumerable: true,
  6453. configurable: true
  6454. });
  6455. Object.defineProperty(Image.prototype, "cellId", {
  6456. /**
  6457. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6458. * @see http://doc.babylonjs.com/how_to/gui#image
  6459. */
  6460. get: function () {
  6461. return this._cellId;
  6462. },
  6463. set: function (value) {
  6464. if (this._cellId === value) {
  6465. return;
  6466. }
  6467. this._cellId = value;
  6468. this._markAsDirty();
  6469. },
  6470. enumerable: true,
  6471. configurable: true
  6472. });
  6473. /**
  6474. * Tests if a given coordinates belong to the current control
  6475. * @param x defines x coordinate to test
  6476. * @param y defines y coordinate to test
  6477. * @returns true if the coordinates are inside the control
  6478. */
  6479. Image.prototype.contains = function (x, y) {
  6480. if (!_super.prototype.contains.call(this, x, y)) {
  6481. return false;
  6482. }
  6483. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6484. return true;
  6485. }
  6486. var canvas = Image._WorkingCanvas;
  6487. var context = canvas.getContext("2d");
  6488. var width = this._currentMeasure.width | 0;
  6489. var height = this._currentMeasure.height | 0;
  6490. var imageData = context.getImageData(0, 0, width, height).data;
  6491. x = (x - this._currentMeasure.left) | 0;
  6492. y = (y - this._currentMeasure.top) | 0;
  6493. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6494. return pickedPixel > 0;
  6495. };
  6496. Image.prototype._getTypeName = function () {
  6497. return "Image";
  6498. };
  6499. /** Force the control to synchronize with its content */
  6500. Image.prototype.synchronizeSizeWithContent = function () {
  6501. if (!this._loaded) {
  6502. return;
  6503. }
  6504. this.width = this._domImage.width + "px";
  6505. this.height = this._domImage.height + "px";
  6506. };
  6507. Image.prototype._processMeasures = function (parentMeasure, context) {
  6508. if (this._loaded) {
  6509. switch (this._stretch) {
  6510. case Image.STRETCH_NONE:
  6511. break;
  6512. case Image.STRETCH_FILL:
  6513. break;
  6514. case Image.STRETCH_UNIFORM:
  6515. break;
  6516. case Image.STRETCH_NINE_PATCH:
  6517. break;
  6518. case Image.STRETCH_EXTEND:
  6519. if (this._autoScale) {
  6520. this.synchronizeSizeWithContent();
  6521. }
  6522. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6523. this.parent.adaptWidthToChildren = true;
  6524. this.parent.adaptHeightToChildren = true;
  6525. }
  6526. break;
  6527. }
  6528. }
  6529. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6530. };
  6531. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6532. if (!this._detectPointerOnOpaqueOnly) {
  6533. return;
  6534. }
  6535. if (!Image._WorkingCanvas) {
  6536. Image._WorkingCanvas = document.createElement('canvas');
  6537. }
  6538. var canvas = Image._WorkingCanvas;
  6539. var width = this._currentMeasure.width;
  6540. var height = this._currentMeasure.height;
  6541. var context = canvas.getContext("2d");
  6542. canvas.width = width;
  6543. canvas.height = height;
  6544. context.clearRect(0, 0, width, height);
  6545. };
  6546. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6547. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6548. if (!this._detectPointerOnOpaqueOnly) {
  6549. return;
  6550. }
  6551. var canvas = Image._WorkingCanvas;
  6552. context = canvas.getContext("2d");
  6553. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6554. };
  6555. Image.prototype._draw = function (context) {
  6556. context.save();
  6557. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6558. context.shadowColor = this.shadowColor;
  6559. context.shadowBlur = this.shadowBlur;
  6560. context.shadowOffsetX = this.shadowOffsetX;
  6561. context.shadowOffsetY = this.shadowOffsetY;
  6562. }
  6563. var x, y, width, height;
  6564. if (this.cellId == -1) {
  6565. x = this._sourceLeft;
  6566. y = this._sourceTop;
  6567. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6568. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6569. }
  6570. else {
  6571. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6572. var column = (this.cellId / rowCount) >> 0;
  6573. var row = this.cellId % rowCount;
  6574. x = this.cellWidth * row;
  6575. y = this.cellHeight * column;
  6576. width = this.cellWidth;
  6577. height = this.cellHeight;
  6578. }
  6579. this._prepareWorkingCanvasForOpaqueDetection();
  6580. this._applyStates(context);
  6581. if (this._loaded) {
  6582. switch (this._stretch) {
  6583. case Image.STRETCH_NONE:
  6584. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6585. break;
  6586. case Image.STRETCH_FILL:
  6587. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6588. break;
  6589. case Image.STRETCH_UNIFORM:
  6590. var hRatio = this._currentMeasure.width / width;
  6591. var vRatio = this._currentMeasure.height / height;
  6592. var ratio = Math.min(hRatio, vRatio);
  6593. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6594. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6595. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6596. break;
  6597. case Image.STRETCH_EXTEND:
  6598. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6599. break;
  6600. case Image.STRETCH_NINE_PATCH:
  6601. this._renderNinePatch(context);
  6602. break;
  6603. }
  6604. }
  6605. context.restore();
  6606. };
  6607. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6608. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6609. };
  6610. Image.prototype._renderNinePatch = function (context) {
  6611. var height = this._imageHeight;
  6612. var leftWidth = this._sliceLeft;
  6613. var topHeight = this._sliceTop;
  6614. var bottomHeight = this._imageHeight - this._sliceBottom;
  6615. var rightWidth = this._imageWidth - this._sliceRight;
  6616. var left = 0;
  6617. var top = 0;
  6618. if (this._populateNinePatchSlicesFromImage) {
  6619. left = 1;
  6620. top = 1;
  6621. height -= 2;
  6622. leftWidth -= 1;
  6623. topHeight -= 1;
  6624. bottomHeight -= 1;
  6625. rightWidth -= 1;
  6626. }
  6627. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6628. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6629. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6630. // Corners
  6631. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6632. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6633. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6634. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6635. // Center
  6636. 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);
  6637. // Borders
  6638. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6639. 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);
  6640. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6641. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6642. };
  6643. Image.prototype.dispose = function () {
  6644. _super.prototype.dispose.call(this);
  6645. this.onImageLoadedObservable.clear();
  6646. };
  6647. Image._WorkingCanvas = null;
  6648. // Static
  6649. /** STRETCH_NONE */
  6650. Image.STRETCH_NONE = 0;
  6651. /** STRETCH_FILL */
  6652. Image.STRETCH_FILL = 1;
  6653. /** STRETCH_UNIFORM */
  6654. Image.STRETCH_UNIFORM = 2;
  6655. /** STRETCH_EXTEND */
  6656. Image.STRETCH_EXTEND = 3;
  6657. /** NINE_PATCH */
  6658. Image.STRETCH_NINE_PATCH = 4;
  6659. return Image;
  6660. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6661. /***/ }),
  6662. /***/ "./2D/controls/index.ts":
  6663. /*!******************************!*\
  6664. !*** ./2D/controls/index.ts ***!
  6665. \******************************/
  6666. /*! 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 */
  6667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6668. "use strict";
  6669. __webpack_require__.r(__webpack_exports__);
  6670. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6672. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6674. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6676. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6678. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6680. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6682. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6684. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6686. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6688. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6690. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6692. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6694. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6696. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6698. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6704. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6706. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6709. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6712. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6714. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6716. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6718. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6720. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6722. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6724. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6726. /***/ }),
  6727. /***/ "./2D/controls/inputPassword.ts":
  6728. /*!**************************************!*\
  6729. !*** ./2D/controls/inputPassword.ts ***!
  6730. \**************************************/
  6731. /*! exports provided: InputPassword */
  6732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6733. "use strict";
  6734. __webpack_require__.r(__webpack_exports__);
  6735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6736. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6737. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6738. /**
  6739. * Class used to create a password control
  6740. */
  6741. var InputPassword = /** @class */ (function (_super) {
  6742. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6743. function InputPassword() {
  6744. return _super !== null && _super.apply(this, arguments) || this;
  6745. }
  6746. InputPassword.prototype._beforeRenderText = function (text) {
  6747. var txt = "";
  6748. for (var i = 0; i < text.length; i++) {
  6749. txt += "\u2022";
  6750. }
  6751. return txt;
  6752. };
  6753. return InputPassword;
  6754. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6755. /***/ }),
  6756. /***/ "./2D/controls/inputText.ts":
  6757. /*!**********************************!*\
  6758. !*** ./2D/controls/inputText.ts ***!
  6759. \**********************************/
  6760. /*! exports provided: InputText */
  6761. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6762. "use strict";
  6763. __webpack_require__.r(__webpack_exports__);
  6764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6765. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6766. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  6767. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6768. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6769. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6770. /**
  6771. * Class used to create input text control
  6772. */
  6773. var InputText = /** @class */ (function (_super) {
  6774. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6775. /**
  6776. * Creates a new InputText
  6777. * @param name defines the control name
  6778. * @param text defines the text of the control
  6779. */
  6780. function InputText(name, text) {
  6781. if (text === void 0) { text = ""; }
  6782. var _this = _super.call(this, name) || this;
  6783. _this.name = name;
  6784. _this._text = "";
  6785. _this._placeholderText = "";
  6786. _this._background = "#222222";
  6787. _this._focusedBackground = "#000000";
  6788. _this._focusedColor = "white";
  6789. _this._placeholderColor = "gray";
  6790. _this._thickness = 1;
  6791. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6792. _this._autoStretchWidth = true;
  6793. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6794. _this._isFocused = false;
  6795. _this._blinkIsEven = false;
  6796. _this._cursorOffset = 0;
  6797. _this._deadKey = false;
  6798. _this._addKey = true;
  6799. _this._currentKey = "";
  6800. _this._isTextHighlightOn = false;
  6801. _this._textHighlightColor = "#d5e0ff";
  6802. _this._highligherOpacity = 0.4;
  6803. _this._highlightedText = "";
  6804. _this._startHighlightIndex = 0;
  6805. _this._endHighlightIndex = 0;
  6806. _this._cursorIndex = -1;
  6807. _this._onFocusSelectAll = false;
  6808. _this._isPointerDown = false;
  6809. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6810. _this.promptMessage = "Please enter text:";
  6811. /** Observable raised when the text changes */
  6812. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6813. /** Observable raised just before an entered character is to be added */
  6814. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6815. /** Observable raised when the control gets the focus */
  6816. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6817. /** Observable raised when the control loses the focus */
  6818. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6819. /**Observable raised when the text is highlighted */
  6820. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6821. /**Observable raised when copy event is triggered */
  6822. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6823. /** Observable raised when cut event is triggered */
  6824. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6825. /** Observable raised when paste event is triggered */
  6826. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6827. /** Observable raised when a key event was processed */
  6828. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6829. _this.text = text;
  6830. _this.isPointerBlocker = true;
  6831. return _this;
  6832. }
  6833. Object.defineProperty(InputText.prototype, "maxWidth", {
  6834. /** Gets or sets the maximum width allowed by the control */
  6835. get: function () {
  6836. return this._maxWidth.toString(this._host);
  6837. },
  6838. set: function (value) {
  6839. if (this._maxWidth.toString(this._host) === value) {
  6840. return;
  6841. }
  6842. if (this._maxWidth.fromString(value)) {
  6843. this._markAsDirty();
  6844. }
  6845. },
  6846. enumerable: true,
  6847. configurable: true
  6848. });
  6849. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6850. /** Gets the maximum width allowed by the control in pixels */
  6851. get: function () {
  6852. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6853. },
  6854. enumerable: true,
  6855. configurable: true
  6856. });
  6857. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6858. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6859. get: function () {
  6860. return this._highligherOpacity;
  6861. },
  6862. set: function (value) {
  6863. if (this._highligherOpacity === value) {
  6864. return;
  6865. }
  6866. this._highligherOpacity = value;
  6867. this._markAsDirty();
  6868. },
  6869. enumerable: true,
  6870. configurable: true
  6871. });
  6872. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6873. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6874. get: function () {
  6875. return this._onFocusSelectAll;
  6876. },
  6877. set: function (value) {
  6878. if (this._onFocusSelectAll === value) {
  6879. return;
  6880. }
  6881. this._onFocusSelectAll = value;
  6882. this._markAsDirty();
  6883. },
  6884. enumerable: true,
  6885. configurable: true
  6886. });
  6887. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6888. /** Gets or sets the text hightlight color */
  6889. get: function () {
  6890. return this._textHighlightColor;
  6891. },
  6892. set: function (value) {
  6893. if (this._textHighlightColor === value) {
  6894. return;
  6895. }
  6896. this._textHighlightColor = value;
  6897. this._markAsDirty();
  6898. },
  6899. enumerable: true,
  6900. configurable: true
  6901. });
  6902. Object.defineProperty(InputText.prototype, "margin", {
  6903. /** Gets or sets control margin */
  6904. get: function () {
  6905. return this._margin.toString(this._host);
  6906. },
  6907. set: function (value) {
  6908. if (this._margin.toString(this._host) === value) {
  6909. return;
  6910. }
  6911. if (this._margin.fromString(value)) {
  6912. this._markAsDirty();
  6913. }
  6914. },
  6915. enumerable: true,
  6916. configurable: true
  6917. });
  6918. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6919. /** Gets control margin in pixels */
  6920. get: function () {
  6921. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6922. },
  6923. enumerable: true,
  6924. configurable: true
  6925. });
  6926. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6927. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6928. get: function () {
  6929. return this._autoStretchWidth;
  6930. },
  6931. set: function (value) {
  6932. if (this._autoStretchWidth === value) {
  6933. return;
  6934. }
  6935. this._autoStretchWidth = value;
  6936. this._markAsDirty();
  6937. },
  6938. enumerable: true,
  6939. configurable: true
  6940. });
  6941. Object.defineProperty(InputText.prototype, "thickness", {
  6942. /** Gets or sets border thickness */
  6943. get: function () {
  6944. return this._thickness;
  6945. },
  6946. set: function (value) {
  6947. if (this._thickness === value) {
  6948. return;
  6949. }
  6950. this._thickness = value;
  6951. this._markAsDirty();
  6952. },
  6953. enumerable: true,
  6954. configurable: true
  6955. });
  6956. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6957. /** Gets or sets the background color when focused */
  6958. get: function () {
  6959. return this._focusedBackground;
  6960. },
  6961. set: function (value) {
  6962. if (this._focusedBackground === value) {
  6963. return;
  6964. }
  6965. this._focusedBackground = value;
  6966. this._markAsDirty();
  6967. },
  6968. enumerable: true,
  6969. configurable: true
  6970. });
  6971. Object.defineProperty(InputText.prototype, "focusedColor", {
  6972. /** Gets or sets the background color when focused */
  6973. get: function () {
  6974. return this._focusedColor;
  6975. },
  6976. set: function (value) {
  6977. if (this._focusedColor === value) {
  6978. return;
  6979. }
  6980. this._focusedColor = value;
  6981. this._markAsDirty();
  6982. },
  6983. enumerable: true,
  6984. configurable: true
  6985. });
  6986. Object.defineProperty(InputText.prototype, "background", {
  6987. /** Gets or sets the background color */
  6988. get: function () {
  6989. return this._background;
  6990. },
  6991. set: function (value) {
  6992. if (this._background === value) {
  6993. return;
  6994. }
  6995. this._background = value;
  6996. this._markAsDirty();
  6997. },
  6998. enumerable: true,
  6999. configurable: true
  7000. });
  7001. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7002. /** Gets or sets the placeholder color */
  7003. get: function () {
  7004. return this._placeholderColor;
  7005. },
  7006. set: function (value) {
  7007. if (this._placeholderColor === value) {
  7008. return;
  7009. }
  7010. this._placeholderColor = value;
  7011. this._markAsDirty();
  7012. },
  7013. enumerable: true,
  7014. configurable: true
  7015. });
  7016. Object.defineProperty(InputText.prototype, "placeholderText", {
  7017. /** Gets or sets the text displayed when the control is empty */
  7018. get: function () {
  7019. return this._placeholderText;
  7020. },
  7021. set: function (value) {
  7022. if (this._placeholderText === value) {
  7023. return;
  7024. }
  7025. this._placeholderText = value;
  7026. this._markAsDirty();
  7027. },
  7028. enumerable: true,
  7029. configurable: true
  7030. });
  7031. Object.defineProperty(InputText.prototype, "deadKey", {
  7032. /** Gets or sets the dead key flag */
  7033. get: function () {
  7034. return this._deadKey;
  7035. },
  7036. set: function (flag) {
  7037. this._deadKey = flag;
  7038. },
  7039. enumerable: true,
  7040. configurable: true
  7041. });
  7042. Object.defineProperty(InputText.prototype, "highlightedText", {
  7043. /** Gets or sets the highlight text */
  7044. get: function () {
  7045. return this._highlightedText;
  7046. },
  7047. set: function (text) {
  7048. if (this._highlightedText === text) {
  7049. return;
  7050. }
  7051. this._highlightedText = text;
  7052. this._markAsDirty();
  7053. },
  7054. enumerable: true,
  7055. configurable: true
  7056. });
  7057. Object.defineProperty(InputText.prototype, "addKey", {
  7058. /** Gets or sets if the current key should be added */
  7059. get: function () {
  7060. return this._addKey;
  7061. },
  7062. set: function (flag) {
  7063. this._addKey = flag;
  7064. },
  7065. enumerable: true,
  7066. configurable: true
  7067. });
  7068. Object.defineProperty(InputText.prototype, "currentKey", {
  7069. /** Gets or sets the value of the current key being entered */
  7070. get: function () {
  7071. return this._currentKey;
  7072. },
  7073. set: function (key) {
  7074. this._currentKey = key;
  7075. },
  7076. enumerable: true,
  7077. configurable: true
  7078. });
  7079. Object.defineProperty(InputText.prototype, "text", {
  7080. /** Gets or sets the text displayed in the control */
  7081. get: function () {
  7082. return this._text;
  7083. },
  7084. set: function (value) {
  7085. var valueAsString = value.toString(); // Forcing convertion
  7086. if (this._text === valueAsString) {
  7087. return;
  7088. }
  7089. this._text = valueAsString;
  7090. this._markAsDirty();
  7091. this.onTextChangedObservable.notifyObservers(this);
  7092. },
  7093. enumerable: true,
  7094. configurable: true
  7095. });
  7096. Object.defineProperty(InputText.prototype, "width", {
  7097. /** Gets or sets control width */
  7098. get: function () {
  7099. return this._width.toString(this._host);
  7100. },
  7101. set: function (value) {
  7102. if (this._width.toString(this._host) === value) {
  7103. return;
  7104. }
  7105. if (this._width.fromString(value)) {
  7106. this._markAsDirty();
  7107. }
  7108. this.autoStretchWidth = false;
  7109. },
  7110. enumerable: true,
  7111. configurable: true
  7112. });
  7113. /** @hidden */
  7114. InputText.prototype.onBlur = function () {
  7115. this._isFocused = false;
  7116. this._scrollLeft = null;
  7117. this._cursorOffset = 0;
  7118. clearTimeout(this._blinkTimeout);
  7119. this._markAsDirty();
  7120. this.onBlurObservable.notifyObservers(this);
  7121. this._host.unRegisterClipboardEvents();
  7122. if (this._onClipboardObserver) {
  7123. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7124. }
  7125. var scene = this._host.getScene();
  7126. if (this._onPointerDblTapObserver && scene) {
  7127. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7128. }
  7129. };
  7130. /** @hidden */
  7131. InputText.prototype.onFocus = function () {
  7132. var _this = this;
  7133. if (!this._isEnabled) {
  7134. return;
  7135. }
  7136. this._scrollLeft = null;
  7137. this._isFocused = true;
  7138. this._blinkIsEven = false;
  7139. this._cursorOffset = 0;
  7140. this._markAsDirty();
  7141. this.onFocusObservable.notifyObservers(this);
  7142. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7143. var value = prompt(this.promptMessage);
  7144. if (value !== null) {
  7145. this.text = value;
  7146. }
  7147. this._host.focusedControl = null;
  7148. return;
  7149. }
  7150. this._host.registerClipboardEvents();
  7151. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7152. // process clipboard event, can be configured.
  7153. switch (clipboardInfo.type) {
  7154. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7155. _this._onCopyText(clipboardInfo.event);
  7156. _this.onTextCopyObservable.notifyObservers(_this);
  7157. break;
  7158. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7159. _this._onCutText(clipboardInfo.event);
  7160. _this.onTextCutObservable.notifyObservers(_this);
  7161. break;
  7162. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7163. _this._onPasteText(clipboardInfo.event);
  7164. _this.onTextPasteObservable.notifyObservers(_this);
  7165. break;
  7166. default: return;
  7167. }
  7168. });
  7169. var scene = this._host.getScene();
  7170. if (scene) {
  7171. //register the pointer double tap event
  7172. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7173. if (!_this._isFocused) {
  7174. return;
  7175. }
  7176. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7177. _this._processDblClick(pointerInfo);
  7178. }
  7179. });
  7180. }
  7181. if (this._onFocusSelectAll) {
  7182. this._selectAllText();
  7183. }
  7184. };
  7185. InputText.prototype._getTypeName = function () {
  7186. return "InputText";
  7187. };
  7188. /**
  7189. * Function called to get the list of controls that should not steal the focus from this control
  7190. * @returns an array of controls
  7191. */
  7192. InputText.prototype.keepsFocusWith = function () {
  7193. if (!this._connectedVirtualKeyboard) {
  7194. return null;
  7195. }
  7196. return [this._connectedVirtualKeyboard];
  7197. };
  7198. /** @hidden */
  7199. InputText.prototype.processKey = function (keyCode, key, evt) {
  7200. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7201. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7202. return;
  7203. }
  7204. //select all
  7205. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7206. this._selectAllText();
  7207. evt.preventDefault();
  7208. return;
  7209. }
  7210. // Specific cases
  7211. switch (keyCode) {
  7212. case 32: //SPACE
  7213. key = " "; //ie11 key for space is "Spacebar"
  7214. break;
  7215. case 191: //SLASH
  7216. if (evt) {
  7217. evt.preventDefault();
  7218. }
  7219. break;
  7220. case 8: // BACKSPACE
  7221. if (this._text && this._text.length > 0) {
  7222. //delete the highlighted text
  7223. if (this._isTextHighlightOn) {
  7224. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7225. this._isTextHighlightOn = false;
  7226. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7227. this._blinkIsEven = false;
  7228. if (evt) {
  7229. evt.preventDefault();
  7230. }
  7231. return;
  7232. }
  7233. //delete single character
  7234. if (this._cursorOffset === 0) {
  7235. this.text = this._text.substr(0, this._text.length - 1);
  7236. }
  7237. else {
  7238. var deletePosition = this._text.length - this._cursorOffset;
  7239. if (deletePosition > 0) {
  7240. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7241. }
  7242. }
  7243. }
  7244. if (evt) {
  7245. evt.preventDefault();
  7246. }
  7247. return;
  7248. case 46: // DELETE
  7249. if (this._isTextHighlightOn) {
  7250. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7251. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7252. while (decrementor > 0 && this._cursorOffset > 0) {
  7253. this._cursorOffset--;
  7254. }
  7255. this._isTextHighlightOn = false;
  7256. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7257. if (evt) {
  7258. evt.preventDefault();
  7259. }
  7260. return;
  7261. }
  7262. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7263. var deletePosition = this._text.length - this._cursorOffset;
  7264. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7265. this._cursorOffset--;
  7266. }
  7267. if (evt) {
  7268. evt.preventDefault();
  7269. }
  7270. return;
  7271. case 13: // RETURN
  7272. this._host.focusedControl = null;
  7273. this._isTextHighlightOn = false;
  7274. return;
  7275. case 35: // END
  7276. this._cursorOffset = 0;
  7277. this._blinkIsEven = false;
  7278. this._isTextHighlightOn = false;
  7279. this._markAsDirty();
  7280. return;
  7281. case 36: // HOME
  7282. this._cursorOffset = this._text.length;
  7283. this._blinkIsEven = false;
  7284. this._isTextHighlightOn = false;
  7285. this._markAsDirty();
  7286. return;
  7287. case 37: // LEFT
  7288. this._cursorOffset++;
  7289. if (this._cursorOffset > this._text.length) {
  7290. this._cursorOffset = this._text.length;
  7291. }
  7292. if (evt && evt.shiftKey) {
  7293. // update the cursor
  7294. this._blinkIsEven = false;
  7295. // shift + ctrl/cmd + <-
  7296. if (evt.ctrlKey || evt.metaKey) {
  7297. if (!this._isTextHighlightOn) {
  7298. if (this._text.length === this._cursorOffset) {
  7299. return;
  7300. }
  7301. else {
  7302. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7303. }
  7304. }
  7305. this._startHighlightIndex = 0;
  7306. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7307. this._cursorOffset = this._text.length;
  7308. this._isTextHighlightOn = true;
  7309. this._markAsDirty();
  7310. return;
  7311. }
  7312. //store the starting point
  7313. if (!this._isTextHighlightOn) {
  7314. this._isTextHighlightOn = true;
  7315. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7316. }
  7317. //if text is already highlighted
  7318. else if (this._cursorIndex === -1) {
  7319. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7320. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7321. }
  7322. //set the highlight indexes
  7323. if (this._cursorIndex < this._cursorOffset) {
  7324. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7325. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7326. }
  7327. else if (this._cursorIndex > this._cursorOffset) {
  7328. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7329. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7330. }
  7331. else {
  7332. this._isTextHighlightOn = false;
  7333. }
  7334. this._markAsDirty();
  7335. return;
  7336. }
  7337. if (this._isTextHighlightOn) {
  7338. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7339. this._isTextHighlightOn = false;
  7340. }
  7341. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7342. this._cursorOffset = this.text.length;
  7343. evt.preventDefault();
  7344. }
  7345. this._blinkIsEven = false;
  7346. this._isTextHighlightOn = false;
  7347. this._cursorIndex = -1;
  7348. this._markAsDirty();
  7349. return;
  7350. case 39: // RIGHT
  7351. this._cursorOffset--;
  7352. if (this._cursorOffset < 0) {
  7353. this._cursorOffset = 0;
  7354. }
  7355. if (evt && evt.shiftKey) {
  7356. //update the cursor
  7357. this._blinkIsEven = false;
  7358. //shift + ctrl/cmd + ->
  7359. if (evt.ctrlKey || evt.metaKey) {
  7360. if (!this._isTextHighlightOn) {
  7361. if (this._cursorOffset === 0) {
  7362. return;
  7363. }
  7364. else {
  7365. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7366. }
  7367. }
  7368. this._endHighlightIndex = this._text.length;
  7369. this._isTextHighlightOn = true;
  7370. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7371. this._cursorOffset = 0;
  7372. this._markAsDirty();
  7373. return;
  7374. }
  7375. if (!this._isTextHighlightOn) {
  7376. this._isTextHighlightOn = true;
  7377. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7378. }
  7379. //if text is already highlighted
  7380. else if (this._cursorIndex === -1) {
  7381. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7382. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7383. }
  7384. //set the highlight indexes
  7385. if (this._cursorIndex < this._cursorOffset) {
  7386. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7387. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7388. }
  7389. else if (this._cursorIndex > this._cursorOffset) {
  7390. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7391. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7392. }
  7393. else {
  7394. this._isTextHighlightOn = false;
  7395. }
  7396. this._markAsDirty();
  7397. return;
  7398. }
  7399. if (this._isTextHighlightOn) {
  7400. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7401. this._isTextHighlightOn = false;
  7402. }
  7403. //ctr + ->
  7404. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7405. this._cursorOffset = 0;
  7406. evt.preventDefault();
  7407. }
  7408. this._blinkIsEven = false;
  7409. this._isTextHighlightOn = false;
  7410. this._cursorIndex = -1;
  7411. this._markAsDirty();
  7412. return;
  7413. case 222: // Dead
  7414. if (evt) {
  7415. evt.preventDefault();
  7416. }
  7417. this._cursorIndex = -1;
  7418. this.deadKey = true;
  7419. break;
  7420. }
  7421. // Printable characters
  7422. if (key &&
  7423. ((keyCode === -1) || // Direct access
  7424. (keyCode === 32) || // Space
  7425. (keyCode > 47 && keyCode < 64) || // Numbers
  7426. (keyCode > 64 && keyCode < 91) || // Letters
  7427. (keyCode > 159 && keyCode < 193) || // Special characters
  7428. (keyCode > 218 && keyCode < 223) || // Special characters
  7429. (keyCode > 95 && keyCode < 112))) { // Numpad
  7430. this._currentKey = key;
  7431. this.onBeforeKeyAddObservable.notifyObservers(this);
  7432. key = this._currentKey;
  7433. if (this._addKey) {
  7434. if (this._isTextHighlightOn) {
  7435. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7436. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7437. this._isTextHighlightOn = false;
  7438. this._blinkIsEven = false;
  7439. this._markAsDirty();
  7440. }
  7441. else if (this._cursorOffset === 0) {
  7442. this.text += key;
  7443. }
  7444. else {
  7445. var insertPosition = this._text.length - this._cursorOffset;
  7446. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7447. }
  7448. }
  7449. }
  7450. };
  7451. /** @hidden */
  7452. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7453. //update the cursor
  7454. this._blinkIsEven = false;
  7455. if (this._cursorIndex === -1) {
  7456. this._cursorIndex = offset;
  7457. }
  7458. else {
  7459. if (this._cursorIndex < this._cursorOffset) {
  7460. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7461. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7462. }
  7463. else if (this._cursorIndex > this._cursorOffset) {
  7464. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7465. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7466. }
  7467. else {
  7468. this._isTextHighlightOn = false;
  7469. this._markAsDirty();
  7470. return;
  7471. }
  7472. }
  7473. this._isTextHighlightOn = true;
  7474. this._markAsDirty();
  7475. };
  7476. /** @hidden */
  7477. InputText.prototype._processDblClick = function (evt) {
  7478. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7479. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7480. this._endHighlightIndex = this._startHighlightIndex;
  7481. var rWord = /\w+/g, moveLeft, moveRight;
  7482. do {
  7483. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7484. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7485. } while (moveLeft || moveRight);
  7486. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7487. this.onTextHighlightObservable.notifyObservers(this);
  7488. this._isTextHighlightOn = true;
  7489. this._clickedCoordinate = null;
  7490. this._blinkIsEven = true;
  7491. this._cursorIndex = -1;
  7492. this._markAsDirty();
  7493. };
  7494. /** @hidden */
  7495. InputText.prototype._selectAllText = function () {
  7496. this._blinkIsEven = true;
  7497. this._isTextHighlightOn = true;
  7498. this._startHighlightIndex = 0;
  7499. this._endHighlightIndex = this._text.length;
  7500. this._cursorOffset = this._text.length;
  7501. this._cursorIndex = -1;
  7502. this._markAsDirty();
  7503. };
  7504. /**
  7505. * Handles the keyboard event
  7506. * @param evt Defines the KeyboardEvent
  7507. */
  7508. InputText.prototype.processKeyboard = function (evt) {
  7509. // process pressed key
  7510. this.processKey(evt.keyCode, evt.key, evt);
  7511. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7512. };
  7513. /** @hidden */
  7514. InputText.prototype._onCopyText = function (ev) {
  7515. this._isTextHighlightOn = false;
  7516. //when write permission to clipbaord data is denied
  7517. try {
  7518. ev.clipboardData.setData("text/plain", this._highlightedText);
  7519. }
  7520. catch (_a) { } //pass
  7521. this._host.clipboardData = this._highlightedText;
  7522. };
  7523. /** @hidden */
  7524. InputText.prototype._onCutText = function (ev) {
  7525. if (!this._highlightedText) {
  7526. return;
  7527. }
  7528. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7529. this._isTextHighlightOn = false;
  7530. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7531. //when write permission to clipbaord data is denied
  7532. try {
  7533. ev.clipboardData.setData("text/plain", this._highlightedText);
  7534. }
  7535. catch (_a) { } //pass
  7536. this._host.clipboardData = this._highlightedText;
  7537. this._highlightedText = "";
  7538. };
  7539. /** @hidden */
  7540. InputText.prototype._onPasteText = function (ev) {
  7541. var data = "";
  7542. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7543. data = ev.clipboardData.getData("text/plain");
  7544. }
  7545. else {
  7546. //get the cached data; returns blank string by default
  7547. data = this._host.clipboardData;
  7548. }
  7549. var insertPosition = this._text.length - this._cursorOffset;
  7550. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7551. };
  7552. InputText.prototype._draw = function (context) {
  7553. var _this = this;
  7554. context.save();
  7555. this._applyStates(context);
  7556. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7557. context.shadowColor = this.shadowColor;
  7558. context.shadowBlur = this.shadowBlur;
  7559. context.shadowOffsetX = this.shadowOffsetX;
  7560. context.shadowOffsetY = this.shadowOffsetY;
  7561. }
  7562. // Background
  7563. if (this._isFocused) {
  7564. if (this._focusedBackground) {
  7565. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7566. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7567. }
  7568. }
  7569. else if (this._background) {
  7570. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7571. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7572. }
  7573. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7574. context.shadowBlur = 0;
  7575. context.shadowOffsetX = 0;
  7576. context.shadowOffsetY = 0;
  7577. }
  7578. if (!this._fontOffset) {
  7579. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7580. }
  7581. // Text
  7582. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7583. if (this.color) {
  7584. context.fillStyle = this.color;
  7585. }
  7586. var text = this._beforeRenderText(this._text);
  7587. if (!this._isFocused && !this._text && this._placeholderText) {
  7588. text = this._placeholderText;
  7589. if (this._placeholderColor) {
  7590. context.fillStyle = this._placeholderColor;
  7591. }
  7592. }
  7593. this._textWidth = context.measureText(text).width;
  7594. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7595. if (this._autoStretchWidth) {
  7596. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7597. }
  7598. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7599. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7600. context.save();
  7601. context.beginPath();
  7602. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7603. context.clip();
  7604. if (this._isFocused && this._textWidth > availableWidth) {
  7605. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7606. if (!this._scrollLeft) {
  7607. this._scrollLeft = textLeft;
  7608. }
  7609. }
  7610. else {
  7611. this._scrollLeft = clipTextLeft;
  7612. }
  7613. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7614. // Cursor
  7615. if (this._isFocused) {
  7616. // Need to move cursor
  7617. if (this._clickedCoordinate) {
  7618. var rightPosition = this._scrollLeft + this._textWidth;
  7619. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7620. var currentSize = 0;
  7621. this._cursorOffset = 0;
  7622. var previousDist = 0;
  7623. do {
  7624. if (this._cursorOffset) {
  7625. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7626. }
  7627. this._cursorOffset++;
  7628. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7629. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7630. // Find closest move
  7631. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7632. this._cursorOffset--;
  7633. }
  7634. this._blinkIsEven = false;
  7635. this._clickedCoordinate = null;
  7636. }
  7637. // Render cursor
  7638. if (!this._blinkIsEven) {
  7639. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7640. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7641. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7642. if (cursorLeft < clipTextLeft) {
  7643. this._scrollLeft += (clipTextLeft - cursorLeft);
  7644. cursorLeft = clipTextLeft;
  7645. this._markAsDirty();
  7646. }
  7647. else if (cursorLeft > clipTextLeft + availableWidth) {
  7648. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7649. cursorLeft = clipTextLeft + availableWidth;
  7650. this._markAsDirty();
  7651. }
  7652. if (!this._isTextHighlightOn) {
  7653. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7654. }
  7655. }
  7656. clearTimeout(this._blinkTimeout);
  7657. this._blinkTimeout = setTimeout(function () {
  7658. _this._blinkIsEven = !_this._blinkIsEven;
  7659. _this._markAsDirty();
  7660. }, 500);
  7661. //show the highlighted text
  7662. if (this._isTextHighlightOn) {
  7663. clearTimeout(this._blinkTimeout);
  7664. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7665. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7666. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7667. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7668. if (highlightCursorLeft < clipTextLeft) {
  7669. width = width - (clipTextLeft - highlightCursorLeft);
  7670. if (!width) {
  7671. // when using left arrow on text.length > availableWidth;
  7672. // assigns the width of the first letter after clipTextLeft
  7673. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7674. }
  7675. highlightCursorLeft = clipTextLeft;
  7676. }
  7677. //for transparancy
  7678. context.globalAlpha = this._highligherOpacity;
  7679. context.fillStyle = this._textHighlightColor;
  7680. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7681. context.globalAlpha = 1.0;
  7682. }
  7683. }
  7684. context.restore();
  7685. // Border
  7686. if (this._thickness) {
  7687. if (this._isFocused) {
  7688. if (this.focusedColor) {
  7689. context.strokeStyle = this.focusedColor;
  7690. }
  7691. }
  7692. else {
  7693. if (this.color) {
  7694. context.strokeStyle = this.color;
  7695. }
  7696. }
  7697. context.lineWidth = this._thickness;
  7698. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7699. }
  7700. context.restore();
  7701. };
  7702. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7703. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7704. return false;
  7705. }
  7706. this._clickedCoordinate = coordinates.x;
  7707. this._isTextHighlightOn = false;
  7708. this._highlightedText = "";
  7709. this._cursorIndex = -1;
  7710. this._isPointerDown = true;
  7711. this._host._capturingControl[pointerId] = this;
  7712. if (this._host.focusedControl === this) {
  7713. // Move cursor
  7714. clearTimeout(this._blinkTimeout);
  7715. this._markAsDirty();
  7716. return true;
  7717. }
  7718. if (!this._isEnabled) {
  7719. return false;
  7720. }
  7721. this._host.focusedControl = this;
  7722. return true;
  7723. };
  7724. InputText.prototype._onPointerMove = function (target, coordinates) {
  7725. if (this._host.focusedControl === this && this._isPointerDown) {
  7726. this._clickedCoordinate = coordinates.x;
  7727. this._markAsDirty();
  7728. this._updateValueFromCursorIndex(this._cursorOffset);
  7729. }
  7730. _super.prototype._onPointerMove.call(this, target, coordinates);
  7731. };
  7732. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7733. this._isPointerDown = false;
  7734. delete this._host._capturingControl[pointerId];
  7735. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7736. };
  7737. InputText.prototype._beforeRenderText = function (text) {
  7738. return text;
  7739. };
  7740. InputText.prototype.dispose = function () {
  7741. _super.prototype.dispose.call(this);
  7742. this.onBlurObservable.clear();
  7743. this.onFocusObservable.clear();
  7744. this.onTextChangedObservable.clear();
  7745. this.onTextCopyObservable.clear();
  7746. this.onTextCutObservable.clear();
  7747. this.onTextPasteObservable.clear();
  7748. this.onTextHighlightObservable.clear();
  7749. this.onKeyboardEventProcessedObservable.clear();
  7750. };
  7751. return InputText;
  7752. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7753. /***/ }),
  7754. /***/ "./2D/controls/line.ts":
  7755. /*!*****************************!*\
  7756. !*** ./2D/controls/line.ts ***!
  7757. \*****************************/
  7758. /*! exports provided: Line */
  7759. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7760. "use strict";
  7761. __webpack_require__.r(__webpack_exports__);
  7762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7763. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7764. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  7765. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7766. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7767. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7768. /** Class used to render 2D lines */
  7769. var Line = /** @class */ (function (_super) {
  7770. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7771. /**
  7772. * Creates a new Line
  7773. * @param name defines the control name
  7774. */
  7775. function Line(name) {
  7776. var _this = _super.call(this, name) || this;
  7777. _this.name = name;
  7778. _this._lineWidth = 1;
  7779. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7780. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7781. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7782. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7783. _this._dash = new Array();
  7784. _this.isHitTestVisible = false;
  7785. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7786. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7787. return _this;
  7788. }
  7789. Object.defineProperty(Line.prototype, "dash", {
  7790. /** Gets or sets the dash pattern */
  7791. get: function () {
  7792. return this._dash;
  7793. },
  7794. set: function (value) {
  7795. if (this._dash === value) {
  7796. return;
  7797. }
  7798. this._dash = value;
  7799. this._markAsDirty();
  7800. },
  7801. enumerable: true,
  7802. configurable: true
  7803. });
  7804. Object.defineProperty(Line.prototype, "connectedControl", {
  7805. /** Gets or sets the control connected with the line end */
  7806. get: function () {
  7807. return this._connectedControl;
  7808. },
  7809. set: function (value) {
  7810. var _this = this;
  7811. if (this._connectedControl === value) {
  7812. return;
  7813. }
  7814. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7815. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7816. this._connectedControlDirtyObserver = null;
  7817. }
  7818. if (value) {
  7819. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7820. }
  7821. this._connectedControl = value;
  7822. this._markAsDirty();
  7823. },
  7824. enumerable: true,
  7825. configurable: true
  7826. });
  7827. Object.defineProperty(Line.prototype, "x1", {
  7828. /** Gets or sets start coordinates on X axis */
  7829. get: function () {
  7830. return this._x1.toString(this._host);
  7831. },
  7832. set: function (value) {
  7833. if (this._x1.toString(this._host) === value) {
  7834. return;
  7835. }
  7836. if (this._x1.fromString(value)) {
  7837. this._markAsDirty();
  7838. }
  7839. },
  7840. enumerable: true,
  7841. configurable: true
  7842. });
  7843. Object.defineProperty(Line.prototype, "y1", {
  7844. /** Gets or sets start coordinates on Y axis */
  7845. get: function () {
  7846. return this._y1.toString(this._host);
  7847. },
  7848. set: function (value) {
  7849. if (this._y1.toString(this._host) === value) {
  7850. return;
  7851. }
  7852. if (this._y1.fromString(value)) {
  7853. this._markAsDirty();
  7854. }
  7855. },
  7856. enumerable: true,
  7857. configurable: true
  7858. });
  7859. Object.defineProperty(Line.prototype, "x2", {
  7860. /** Gets or sets end coordinates on X axis */
  7861. get: function () {
  7862. return this._x2.toString(this._host);
  7863. },
  7864. set: function (value) {
  7865. if (this._x2.toString(this._host) === value) {
  7866. return;
  7867. }
  7868. if (this._x2.fromString(value)) {
  7869. this._markAsDirty();
  7870. }
  7871. },
  7872. enumerable: true,
  7873. configurable: true
  7874. });
  7875. Object.defineProperty(Line.prototype, "y2", {
  7876. /** Gets or sets end coordinates on Y axis */
  7877. get: function () {
  7878. return this._y2.toString(this._host);
  7879. },
  7880. set: function (value) {
  7881. if (this._y2.toString(this._host) === value) {
  7882. return;
  7883. }
  7884. if (this._y2.fromString(value)) {
  7885. this._markAsDirty();
  7886. }
  7887. },
  7888. enumerable: true,
  7889. configurable: true
  7890. });
  7891. Object.defineProperty(Line.prototype, "lineWidth", {
  7892. /** Gets or sets line width */
  7893. get: function () {
  7894. return this._lineWidth;
  7895. },
  7896. set: function (value) {
  7897. if (this._lineWidth === value) {
  7898. return;
  7899. }
  7900. this._lineWidth = value;
  7901. this._markAsDirty();
  7902. },
  7903. enumerable: true,
  7904. configurable: true
  7905. });
  7906. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7907. /** Gets or sets horizontal alignment */
  7908. set: function (value) {
  7909. return;
  7910. },
  7911. enumerable: true,
  7912. configurable: true
  7913. });
  7914. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7915. /** Gets or sets vertical alignment */
  7916. set: function (value) {
  7917. return;
  7918. },
  7919. enumerable: true,
  7920. configurable: true
  7921. });
  7922. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7923. get: function () {
  7924. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7925. },
  7926. enumerable: true,
  7927. configurable: true
  7928. });
  7929. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7930. get: function () {
  7931. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7932. },
  7933. enumerable: true,
  7934. configurable: true
  7935. });
  7936. Line.prototype._getTypeName = function () {
  7937. return "Line";
  7938. };
  7939. Line.prototype._draw = function (context) {
  7940. context.save();
  7941. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7942. context.shadowColor = this.shadowColor;
  7943. context.shadowBlur = this.shadowBlur;
  7944. context.shadowOffsetX = this.shadowOffsetX;
  7945. context.shadowOffsetY = this.shadowOffsetY;
  7946. }
  7947. this._applyStates(context);
  7948. context.strokeStyle = this.color;
  7949. context.lineWidth = this._lineWidth;
  7950. context.setLineDash(this._dash);
  7951. context.beginPath();
  7952. context.moveTo(this._currentMeasure.left, this._currentMeasure.top);
  7953. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, this._currentMeasure.top + this._currentMeasure.height);
  7954. context.stroke();
  7955. context.restore();
  7956. };
  7957. Line.prototype._measure = function () {
  7958. // Width / Height
  7959. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7960. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7961. };
  7962. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7963. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7964. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7965. };
  7966. /**
  7967. * Move one end of the line given 3D cartesian coordinates.
  7968. * @param position Targeted world position
  7969. * @param scene Scene
  7970. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7971. */
  7972. Line.prototype.moveToVector3 = function (position, scene, end) {
  7973. if (end === void 0) { end = false; }
  7974. if (!this._host || this.parent !== this._host._rootContainer) {
  7975. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  7976. return;
  7977. }
  7978. var globalViewport = this._host._getGlobalViewport(scene);
  7979. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  7980. this._moveToProjectedPosition(projectedPosition, end);
  7981. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  7982. this.notRenderable = true;
  7983. return;
  7984. }
  7985. this.notRenderable = false;
  7986. };
  7987. /**
  7988. * Move one end of the line to a position in screen absolute space.
  7989. * @param projectedPosition Position in screen absolute space (X, Y)
  7990. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7991. */
  7992. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  7993. if (end === void 0) { end = false; }
  7994. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  7995. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  7996. if (end) {
  7997. this.x2 = x;
  7998. this.y2 = y;
  7999. this._x2.ignoreAdaptiveScaling = true;
  8000. this._y2.ignoreAdaptiveScaling = true;
  8001. }
  8002. else {
  8003. this.x1 = x;
  8004. this.y1 = y;
  8005. this._x1.ignoreAdaptiveScaling = true;
  8006. this._y1.ignoreAdaptiveScaling = true;
  8007. }
  8008. };
  8009. return Line;
  8010. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8011. /***/ }),
  8012. /***/ "./2D/controls/multiLine.ts":
  8013. /*!**********************************!*\
  8014. !*** ./2D/controls/multiLine.ts ***!
  8015. \**********************************/
  8016. /*! exports provided: MultiLine */
  8017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8018. "use strict";
  8019. __webpack_require__.r(__webpack_exports__);
  8020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8021. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8022. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/tools");
  8023. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8024. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8025. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8026. /**
  8027. * Class used to create multi line control
  8028. */
  8029. var MultiLine = /** @class */ (function (_super) {
  8030. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8031. /**
  8032. * Creates a new MultiLine
  8033. * @param name defines the control name
  8034. */
  8035. function MultiLine(name) {
  8036. var _this = _super.call(this, name) || this;
  8037. _this.name = name;
  8038. _this._lineWidth = 1;
  8039. /** Function called when a point is updated */
  8040. _this.onPointUpdate = function () {
  8041. _this._markAsDirty();
  8042. };
  8043. _this.isHitTestVisible = false;
  8044. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8045. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8046. _this._dash = [];
  8047. _this._points = [];
  8048. return _this;
  8049. }
  8050. Object.defineProperty(MultiLine.prototype, "dash", {
  8051. /** Gets or sets dash pattern */
  8052. get: function () {
  8053. return this._dash;
  8054. },
  8055. set: function (value) {
  8056. if (this._dash === value) {
  8057. return;
  8058. }
  8059. this._dash = value;
  8060. this._markAsDirty();
  8061. },
  8062. enumerable: true,
  8063. configurable: true
  8064. });
  8065. /**
  8066. * Gets point stored at specified index
  8067. * @param index defines the index to look for
  8068. * @returns the requested point if found
  8069. */
  8070. MultiLine.prototype.getAt = function (index) {
  8071. if (!this._points[index]) {
  8072. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8073. }
  8074. return this._points[index];
  8075. };
  8076. /**
  8077. * Adds new points to the point collection
  8078. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8079. * @returns the list of created MultiLinePoint
  8080. */
  8081. MultiLine.prototype.add = function () {
  8082. var _this = this;
  8083. var items = [];
  8084. for (var _i = 0; _i < arguments.length; _i++) {
  8085. items[_i] = arguments[_i];
  8086. }
  8087. return items.map(function (item) { return _this.push(item); });
  8088. };
  8089. /**
  8090. * Adds a new point to the point collection
  8091. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8092. * @returns the created MultiLinePoint
  8093. */
  8094. MultiLine.prototype.push = function (item) {
  8095. var point = this.getAt(this._points.length);
  8096. if (item == null) {
  8097. return point;
  8098. }
  8099. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8100. point.mesh = item;
  8101. }
  8102. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8103. point.control = item;
  8104. }
  8105. else if (item.x != null && item.y != null) {
  8106. point.x = item.x;
  8107. point.y = item.y;
  8108. }
  8109. return point;
  8110. };
  8111. /**
  8112. * Remove a specific value or point from the active point collection
  8113. * @param value defines the value or point to remove
  8114. */
  8115. MultiLine.prototype.remove = function (value) {
  8116. var index;
  8117. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8118. index = this._points.indexOf(value);
  8119. if (index === -1) {
  8120. return;
  8121. }
  8122. }
  8123. else {
  8124. index = value;
  8125. }
  8126. var point = this._points[index];
  8127. if (!point) {
  8128. return;
  8129. }
  8130. point.dispose();
  8131. this._points.splice(index, 1);
  8132. };
  8133. /**
  8134. * Resets this object to initial state (no point)
  8135. */
  8136. MultiLine.prototype.reset = function () {
  8137. while (this._points.length > 0) {
  8138. this.remove(this._points.length - 1);
  8139. }
  8140. };
  8141. /**
  8142. * Resets all links
  8143. */
  8144. MultiLine.prototype.resetLinks = function () {
  8145. this._points.forEach(function (point) {
  8146. if (point != null) {
  8147. point.resetLinks();
  8148. }
  8149. });
  8150. };
  8151. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8152. /** Gets or sets line width */
  8153. get: function () {
  8154. return this._lineWidth;
  8155. },
  8156. set: function (value) {
  8157. if (this._lineWidth === value) {
  8158. return;
  8159. }
  8160. this._lineWidth = value;
  8161. this._markAsDirty();
  8162. },
  8163. enumerable: true,
  8164. configurable: true
  8165. });
  8166. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8167. set: function (value) {
  8168. return;
  8169. },
  8170. enumerable: true,
  8171. configurable: true
  8172. });
  8173. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8174. set: function (value) {
  8175. return;
  8176. },
  8177. enumerable: true,
  8178. configurable: true
  8179. });
  8180. MultiLine.prototype._getTypeName = function () {
  8181. return "MultiLine";
  8182. };
  8183. MultiLine.prototype._draw = function (context) {
  8184. context.save();
  8185. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8186. context.shadowColor = this.shadowColor;
  8187. context.shadowBlur = this.shadowBlur;
  8188. context.shadowOffsetX = this.shadowOffsetX;
  8189. context.shadowOffsetY = this.shadowOffsetY;
  8190. }
  8191. this._applyStates(context);
  8192. context.strokeStyle = this.color;
  8193. context.lineWidth = this._lineWidth;
  8194. context.setLineDash(this._dash);
  8195. context.beginPath();
  8196. var first = true; //first index is not necessarily 0
  8197. this._points.forEach(function (point) {
  8198. if (!point) {
  8199. return;
  8200. }
  8201. if (first) {
  8202. context.moveTo(point._point.x, point._point.y);
  8203. first = false;
  8204. }
  8205. else {
  8206. context.lineTo(point._point.x, point._point.y);
  8207. }
  8208. });
  8209. context.stroke();
  8210. context.restore();
  8211. };
  8212. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8213. var _this = this;
  8214. this._minX = null;
  8215. this._minY = null;
  8216. this._maxX = null;
  8217. this._maxY = null;
  8218. this._points.forEach(function (point, index) {
  8219. if (!point) {
  8220. return;
  8221. }
  8222. point.translate();
  8223. if (_this._minX == null || point._point.x < _this._minX) {
  8224. _this._minX = point._point.x;
  8225. }
  8226. if (_this._minY == null || point._point.y < _this._minY) {
  8227. _this._minY = point._point.y;
  8228. }
  8229. if (_this._maxX == null || point._point.x > _this._maxX) {
  8230. _this._maxX = point._point.x;
  8231. }
  8232. if (_this._maxY == null || point._point.y > _this._maxY) {
  8233. _this._maxY = point._point.y;
  8234. }
  8235. });
  8236. if (this._minX == null) {
  8237. this._minX = 0;
  8238. }
  8239. if (this._minY == null) {
  8240. this._minY = 0;
  8241. }
  8242. if (this._maxX == null) {
  8243. this._maxX = 0;
  8244. }
  8245. if (this._maxY == null) {
  8246. this._maxY = 0;
  8247. }
  8248. };
  8249. MultiLine.prototype._measure = function () {
  8250. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8251. return;
  8252. }
  8253. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8254. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8255. };
  8256. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8257. if (this._minX == null || this._minY == null) {
  8258. return;
  8259. }
  8260. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8261. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8262. };
  8263. MultiLine.prototype.dispose = function () {
  8264. this.reset();
  8265. _super.prototype.dispose.call(this);
  8266. };
  8267. return MultiLine;
  8268. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8269. /***/ }),
  8270. /***/ "./2D/controls/radioButton.ts":
  8271. /*!************************************!*\
  8272. !*** ./2D/controls/radioButton.ts ***!
  8273. \************************************/
  8274. /*! exports provided: RadioButton */
  8275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8276. "use strict";
  8277. __webpack_require__.r(__webpack_exports__);
  8278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8279. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8280. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  8281. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8282. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8283. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8284. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8285. /**
  8286. * Class used to create radio button controls
  8287. */
  8288. var RadioButton = /** @class */ (function (_super) {
  8289. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8290. /**
  8291. * Creates a new RadioButton
  8292. * @param name defines the control name
  8293. */
  8294. function RadioButton(name) {
  8295. var _this = _super.call(this, name) || this;
  8296. _this.name = name;
  8297. _this._isChecked = false;
  8298. _this._background = "black";
  8299. _this._checkSizeRatio = 0.8;
  8300. _this._thickness = 1;
  8301. /** Gets or sets group name */
  8302. _this.group = "";
  8303. /** Observable raised when isChecked is changed */
  8304. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8305. _this.isPointerBlocker = true;
  8306. return _this;
  8307. }
  8308. Object.defineProperty(RadioButton.prototype, "thickness", {
  8309. /** Gets or sets border thickness */
  8310. get: function () {
  8311. return this._thickness;
  8312. },
  8313. set: function (value) {
  8314. if (this._thickness === value) {
  8315. return;
  8316. }
  8317. this._thickness = value;
  8318. this._markAsDirty();
  8319. },
  8320. enumerable: true,
  8321. configurable: true
  8322. });
  8323. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8324. /** Gets or sets a value indicating the ratio between overall size and check size */
  8325. get: function () {
  8326. return this._checkSizeRatio;
  8327. },
  8328. set: function (value) {
  8329. value = Math.max(Math.min(1, value), 0);
  8330. if (this._checkSizeRatio === value) {
  8331. return;
  8332. }
  8333. this._checkSizeRatio = value;
  8334. this._markAsDirty();
  8335. },
  8336. enumerable: true,
  8337. configurable: true
  8338. });
  8339. Object.defineProperty(RadioButton.prototype, "background", {
  8340. /** Gets or sets background color */
  8341. get: function () {
  8342. return this._background;
  8343. },
  8344. set: function (value) {
  8345. if (this._background === value) {
  8346. return;
  8347. }
  8348. this._background = value;
  8349. this._markAsDirty();
  8350. },
  8351. enumerable: true,
  8352. configurable: true
  8353. });
  8354. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8355. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8356. get: function () {
  8357. return this._isChecked;
  8358. },
  8359. set: function (value) {
  8360. var _this = this;
  8361. if (this._isChecked === value) {
  8362. return;
  8363. }
  8364. this._isChecked = value;
  8365. this._markAsDirty();
  8366. this.onIsCheckedChangedObservable.notifyObservers(value);
  8367. if (this._isChecked && this._host) {
  8368. // Update all controls from same group
  8369. this._host.executeOnAllControls(function (control) {
  8370. if (control === _this) {
  8371. return;
  8372. }
  8373. if (control.group === undefined) {
  8374. return;
  8375. }
  8376. var childRadio = control;
  8377. if (childRadio.group === _this.group) {
  8378. childRadio.isChecked = false;
  8379. }
  8380. });
  8381. }
  8382. },
  8383. enumerable: true,
  8384. configurable: true
  8385. });
  8386. RadioButton.prototype._getTypeName = function () {
  8387. return "RadioButton";
  8388. };
  8389. RadioButton.prototype._draw = function (context) {
  8390. context.save();
  8391. this._applyStates(context);
  8392. var actualWidth = this._currentMeasure.width - this._thickness;
  8393. var actualHeight = this._currentMeasure.height - this._thickness;
  8394. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8395. context.shadowColor = this.shadowColor;
  8396. context.shadowBlur = this.shadowBlur;
  8397. context.shadowOffsetX = this.shadowOffsetX;
  8398. context.shadowOffsetY = this.shadowOffsetY;
  8399. }
  8400. // Outer
  8401. _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);
  8402. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8403. context.fill();
  8404. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8405. context.shadowBlur = 0;
  8406. context.shadowOffsetX = 0;
  8407. context.shadowOffsetY = 0;
  8408. }
  8409. context.strokeStyle = this.color;
  8410. context.lineWidth = this._thickness;
  8411. context.stroke();
  8412. // Inner
  8413. if (this._isChecked) {
  8414. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8415. var offsetWidth = actualWidth * this._checkSizeRatio;
  8416. var offseHeight = actualHeight * this._checkSizeRatio;
  8417. _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);
  8418. context.fill();
  8419. }
  8420. context.restore();
  8421. };
  8422. // Events
  8423. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8424. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8425. return false;
  8426. }
  8427. if (!this.isChecked) {
  8428. this.isChecked = true;
  8429. }
  8430. return true;
  8431. };
  8432. /**
  8433. * Utility function to easily create a radio button with a header
  8434. * @param title defines the label to use for the header
  8435. * @param group defines the group to use for the radio button
  8436. * @param isChecked defines the initial state of the radio button
  8437. * @param onValueChanged defines the callback to call when value changes
  8438. * @returns a StackPanel containing the radio button and a textBlock
  8439. */
  8440. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8441. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8442. panel.isVertical = false;
  8443. panel.height = "30px";
  8444. var radio = new RadioButton();
  8445. radio.width = "20px";
  8446. radio.height = "20px";
  8447. radio.isChecked = isChecked;
  8448. radio.color = "green";
  8449. radio.group = group;
  8450. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8451. panel.addControl(radio);
  8452. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8453. header.text = title;
  8454. header.width = "180px";
  8455. header.paddingLeft = "5px";
  8456. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8457. header.color = "white";
  8458. panel.addControl(header);
  8459. return panel;
  8460. };
  8461. return RadioButton;
  8462. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8463. /***/ }),
  8464. /***/ "./2D/controls/rectangle.ts":
  8465. /*!**********************************!*\
  8466. !*** ./2D/controls/rectangle.ts ***!
  8467. \**********************************/
  8468. /*! exports provided: Rectangle */
  8469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8470. "use strict";
  8471. __webpack_require__.r(__webpack_exports__);
  8472. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8473. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8474. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8475. /** Class used to create rectangle container */
  8476. var Rectangle = /** @class */ (function (_super) {
  8477. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8478. /**
  8479. * Creates a new Rectangle
  8480. * @param name defines the control name
  8481. */
  8482. function Rectangle(name) {
  8483. var _this = _super.call(this, name) || this;
  8484. _this.name = name;
  8485. _this._thickness = 1;
  8486. _this._cornerRadius = 0;
  8487. return _this;
  8488. }
  8489. Object.defineProperty(Rectangle.prototype, "thickness", {
  8490. /** Gets or sets border thickness */
  8491. get: function () {
  8492. return this._thickness;
  8493. },
  8494. set: function (value) {
  8495. if (this._thickness === value) {
  8496. return;
  8497. }
  8498. this._thickness = value;
  8499. this._markAsDirty();
  8500. },
  8501. enumerable: true,
  8502. configurable: true
  8503. });
  8504. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8505. /** Gets or sets the corner radius angle */
  8506. get: function () {
  8507. return this._cornerRadius;
  8508. },
  8509. set: function (value) {
  8510. if (value < 0) {
  8511. value = 0;
  8512. }
  8513. if (this._cornerRadius === value) {
  8514. return;
  8515. }
  8516. this._cornerRadius = value;
  8517. this._markAsDirty();
  8518. },
  8519. enumerable: true,
  8520. configurable: true
  8521. });
  8522. Rectangle.prototype._getTypeName = function () {
  8523. return "Rectangle";
  8524. };
  8525. Rectangle.prototype._localDraw = function (context) {
  8526. context.save();
  8527. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8528. context.shadowColor = this.shadowColor;
  8529. context.shadowBlur = this.shadowBlur;
  8530. context.shadowOffsetX = this.shadowOffsetX;
  8531. context.shadowOffsetY = this.shadowOffsetY;
  8532. }
  8533. if (this._background) {
  8534. context.fillStyle = this._background;
  8535. if (this._cornerRadius) {
  8536. this._drawRoundedRect(context, this._thickness / 2);
  8537. context.fill();
  8538. }
  8539. else {
  8540. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8541. }
  8542. }
  8543. if (this._thickness) {
  8544. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8545. context.shadowBlur = 0;
  8546. context.shadowOffsetX = 0;
  8547. context.shadowOffsetY = 0;
  8548. }
  8549. if (this.color) {
  8550. context.strokeStyle = this.color;
  8551. }
  8552. context.lineWidth = this._thickness;
  8553. if (this._cornerRadius) {
  8554. this._drawRoundedRect(context, this._thickness / 2);
  8555. context.stroke();
  8556. }
  8557. else {
  8558. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8559. }
  8560. }
  8561. context.restore();
  8562. };
  8563. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8564. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8565. this._measureForChildren.width -= 2 * this._thickness;
  8566. this._measureForChildren.height -= 2 * this._thickness;
  8567. this._measureForChildren.left += this._thickness;
  8568. this._measureForChildren.top += this._thickness;
  8569. };
  8570. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8571. if (offset === void 0) { offset = 0; }
  8572. var x = this._currentMeasure.left + offset;
  8573. var y = this._currentMeasure.top + offset;
  8574. var width = this._currentMeasure.width - offset * 2;
  8575. var height = this._currentMeasure.height - offset * 2;
  8576. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8577. context.beginPath();
  8578. context.moveTo(x + radius, y);
  8579. context.lineTo(x + width - radius, y);
  8580. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8581. context.lineTo(x + width, y + height - radius);
  8582. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8583. context.lineTo(x + radius, y + height);
  8584. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8585. context.lineTo(x, y + radius);
  8586. context.quadraticCurveTo(x, y, x + radius, y);
  8587. context.closePath();
  8588. };
  8589. Rectangle.prototype._clipForChildren = function (context) {
  8590. if (this._cornerRadius) {
  8591. this._drawRoundedRect(context, this._thickness);
  8592. context.clip();
  8593. }
  8594. };
  8595. return Rectangle;
  8596. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8597. /***/ }),
  8598. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8599. /*!***************************************************!*\
  8600. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8601. \***************************************************/
  8602. /*! exports provided: ScrollViewer */
  8603. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8604. "use strict";
  8605. __webpack_require__.r(__webpack_exports__);
  8606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8607. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8608. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/tools");
  8609. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8610. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8611. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8612. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8613. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8614. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8615. /**
  8616. * Class used to hold a viewer window and sliders in a grid
  8617. */
  8618. var ScrollViewer = /** @class */ (function (_super) {
  8619. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8620. /**
  8621. * Creates a new ScrollViewer
  8622. * @param name of ScrollViewer
  8623. */
  8624. function ScrollViewer(name) {
  8625. var _this = _super.call(this, name) || this;
  8626. _this._barSize = 20;
  8627. _this._pointerIsOver = false;
  8628. _this._wheelPrecision = 0.05;
  8629. _this.onDirtyObservable.add(function () {
  8630. _this._horizontalBarSpace.color = _this.color;
  8631. _this._verticalBarSpace.color = _this.color;
  8632. _this._dragSpace.color = _this.color;
  8633. });
  8634. _this.onPointerEnterObservable.add(function () {
  8635. _this._pointerIsOver = true;
  8636. });
  8637. _this.onPointerOutObservable.add(function () {
  8638. _this._pointerIsOver = false;
  8639. });
  8640. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8641. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8642. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8643. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8644. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8645. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8646. _this._grid.addColumnDefinition(1);
  8647. _this._grid.addColumnDefinition(0, true);
  8648. _this._grid.addRowDefinition(1);
  8649. _this._grid.addRowDefinition(0, true);
  8650. _super.prototype.addControl.call(_this, _this._grid);
  8651. _this._grid.addControl(_this._window, 0, 0);
  8652. _this._verticalBar.paddingLeft = 0;
  8653. _this._verticalBar.width = "100%";
  8654. _this._verticalBar.height = "100%";
  8655. _this._verticalBar.barOffset = 0;
  8656. _this._verticalBar.value = 0;
  8657. _this._verticalBar.maximum = 1;
  8658. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8659. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8660. _this._verticalBar.isVertical = true;
  8661. _this._verticalBar.rotation = Math.PI;
  8662. _this._verticalBar.isVisible = false;
  8663. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8664. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8665. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8666. _this._verticalBarSpace.thickness = 1;
  8667. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8668. _this._verticalBarSpace.addControl(_this._verticalBar);
  8669. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8670. _this._window.top = value * _this._endTop + "px";
  8671. });
  8672. _this._horizontalBar.paddingLeft = 0;
  8673. _this._horizontalBar.width = "100%";
  8674. _this._horizontalBar.height = "100%";
  8675. _this._horizontalBar.barOffset = 0;
  8676. _this._horizontalBar.value = 0;
  8677. _this._horizontalBar.maximum = 1;
  8678. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8679. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8680. _this._horizontalBar.isVisible = false;
  8681. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8682. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8683. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8684. _this._horizontalBarSpace.thickness = 1;
  8685. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8686. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8687. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8688. _this._window.left = value * _this._endLeft + "px";
  8689. });
  8690. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8691. _this._dragSpace.thickness = 1;
  8692. _this._grid.addControl(_this._dragSpace, 1, 1);
  8693. // Colors
  8694. _this.barColor = "grey";
  8695. _this.barBackground = "transparent";
  8696. return _this;
  8697. }
  8698. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8699. /**
  8700. * Gets the horizontal scrollbar
  8701. */
  8702. get: function () {
  8703. return this._horizontalBar;
  8704. },
  8705. enumerable: true,
  8706. configurable: true
  8707. });
  8708. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8709. /**
  8710. * Gets the vertical scrollbar
  8711. */
  8712. get: function () {
  8713. return this._verticalBar;
  8714. },
  8715. enumerable: true,
  8716. configurable: true
  8717. });
  8718. /**
  8719. * Adds a new control to the current container
  8720. * @param control defines the control to add
  8721. * @returns the current container
  8722. */
  8723. ScrollViewer.prototype.addControl = function (control) {
  8724. if (!control) {
  8725. return this;
  8726. }
  8727. this._window.addControl(control);
  8728. return this;
  8729. };
  8730. /**
  8731. * Removes a control from the current container
  8732. * @param control defines the control to remove
  8733. * @returns the current container
  8734. */
  8735. ScrollViewer.prototype.removeControl = function (control) {
  8736. this._window.removeControl(control);
  8737. return this;
  8738. };
  8739. Object.defineProperty(ScrollViewer.prototype, "children", {
  8740. /** Gets the list of children */
  8741. get: function () {
  8742. return this._window.children;
  8743. },
  8744. enumerable: true,
  8745. configurable: true
  8746. });
  8747. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8748. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8749. var child = _a[_i];
  8750. child._markMatrixAsDirty();
  8751. }
  8752. };
  8753. /** Reset the scroll viewer window to initial size */
  8754. ScrollViewer.prototype.resetWindow = function () {
  8755. this._window.width = "100%";
  8756. this._window.height = "100%";
  8757. };
  8758. ScrollViewer.prototype._getTypeName = function () {
  8759. return "ScrollViewer";
  8760. };
  8761. ScrollViewer.prototype._buildClientSizes = function () {
  8762. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8763. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8764. this._clientWidth = this._window.parentClientWidth;
  8765. this._clientHeight = this._window.parentClientHeight;
  8766. };
  8767. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8768. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8769. this._buildClientSizes();
  8770. };
  8771. ScrollViewer.prototype._postMeasure = function () {
  8772. _super.prototype._postMeasure.call(this);
  8773. this._updateScroller();
  8774. };
  8775. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8776. /**
  8777. * Gets or sets the mouse wheel precision
  8778. * from 0 to 1 with a default value of 0.05
  8779. * */
  8780. get: function () {
  8781. return this._wheelPrecision;
  8782. },
  8783. set: function (value) {
  8784. if (this._wheelPrecision === value) {
  8785. return;
  8786. }
  8787. if (value < 0) {
  8788. value = 0;
  8789. }
  8790. if (value > 1) {
  8791. value = 1;
  8792. }
  8793. this._wheelPrecision = value;
  8794. },
  8795. enumerable: true,
  8796. configurable: true
  8797. });
  8798. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8799. /** Gets or sets the bar color */
  8800. get: function () {
  8801. return this._barColor;
  8802. },
  8803. set: function (color) {
  8804. if (this._barColor === color) {
  8805. return;
  8806. }
  8807. this._barColor = color;
  8808. this._horizontalBar.color = color;
  8809. this._verticalBar.color = color;
  8810. },
  8811. enumerable: true,
  8812. configurable: true
  8813. });
  8814. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8815. /** Gets or sets the size of the bar */
  8816. get: function () {
  8817. return this._barSize;
  8818. },
  8819. set: function (value) {
  8820. if (this._barSize === value) {
  8821. return;
  8822. }
  8823. this._barSize = value;
  8824. this._markAsDirty();
  8825. if (this._horizontalBar.isVisible) {
  8826. this._grid.setRowDefinition(1, this._barSize, true);
  8827. }
  8828. if (this._verticalBar.isVisible) {
  8829. this._grid.setColumnDefinition(1, this._barSize, true);
  8830. }
  8831. },
  8832. enumerable: true,
  8833. configurable: true
  8834. });
  8835. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8836. /** Gets or sets the bar background */
  8837. get: function () {
  8838. return this._barBackground;
  8839. },
  8840. set: function (color) {
  8841. if (this._barBackground === color) {
  8842. return;
  8843. }
  8844. this._barBackground = color;
  8845. this._horizontalBar.background = color;
  8846. this._verticalBar.background = color;
  8847. this._dragSpace.background = color;
  8848. },
  8849. enumerable: true,
  8850. configurable: true
  8851. });
  8852. /** @hidden */
  8853. ScrollViewer.prototype._updateScroller = function () {
  8854. var windowContentsWidth = this._window._currentMeasure.width;
  8855. var windowContentsHeight = this._window._currentMeasure.height;
  8856. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8857. this._grid.setRowDefinition(1, 0, true);
  8858. this._horizontalBar.isVisible = false;
  8859. this._horizontalBar.value = 0;
  8860. this._rebuildLayout = true;
  8861. }
  8862. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8863. this._grid.setRowDefinition(1, this._barSize, true);
  8864. this._horizontalBar.isVisible = true;
  8865. this._rebuildLayout = true;
  8866. }
  8867. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8868. this._grid.setColumnDefinition(1, 0, true);
  8869. this._verticalBar.isVisible = false;
  8870. this._verticalBar.value = 0;
  8871. this._rebuildLayout = true;
  8872. }
  8873. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8874. this._grid.setColumnDefinition(1, this._barSize, true);
  8875. this._verticalBar.isVisible = true;
  8876. this._rebuildLayout = true;
  8877. }
  8878. this._buildClientSizes();
  8879. this._endLeft = this._clientWidth - windowContentsWidth;
  8880. this._endTop = this._clientHeight - windowContentsHeight;
  8881. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8882. var newTop = this._verticalBar.value * this._endTop + "px";
  8883. if (newLeft !== this._window.left) {
  8884. this._window.left = newLeft;
  8885. this._rebuildLayout = true;
  8886. }
  8887. if (newTop !== this._window.top) {
  8888. this._window.top = newTop;
  8889. this._rebuildLayout = true;
  8890. }
  8891. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8892. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8893. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8894. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8895. };
  8896. ScrollViewer.prototype._link = function (host) {
  8897. _super.prototype._link.call(this, host);
  8898. this._attachWheel();
  8899. };
  8900. /** @hidden */
  8901. ScrollViewer.prototype._attachWheel = function () {
  8902. var _this = this;
  8903. if (this._onPointerObserver) {
  8904. return;
  8905. }
  8906. var scene = this._host.getScene();
  8907. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8908. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8909. return;
  8910. }
  8911. if (_this._verticalBar.isVisible == true) {
  8912. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8913. _this._verticalBar.value -= _this._wheelPrecision;
  8914. }
  8915. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8916. _this._verticalBar.value += _this._wheelPrecision;
  8917. }
  8918. }
  8919. if (_this._horizontalBar.isVisible == true) {
  8920. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8921. _this._horizontalBar.value += _this._wheelPrecision;
  8922. }
  8923. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8924. _this._horizontalBar.value -= _this._wheelPrecision;
  8925. }
  8926. }
  8927. });
  8928. };
  8929. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8930. if (!this.isHighlighted) {
  8931. return;
  8932. }
  8933. _super.prototype._renderHighlightSpecific.call(this, context);
  8934. this._grid._renderHighlightSpecific(context);
  8935. context.restore();
  8936. };
  8937. /** Releases associated resources */
  8938. ScrollViewer.prototype.dispose = function () {
  8939. var scene = this._host.getScene();
  8940. if (scene && this._onPointerObserver) {
  8941. scene.onPointerObservable.remove(this._onPointerObserver);
  8942. this._onPointerObserver = null;
  8943. }
  8944. _super.prototype.dispose.call(this);
  8945. };
  8946. return ScrollViewer;
  8947. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8948. /***/ }),
  8949. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8950. /*!*********************************************************!*\
  8951. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8952. \*********************************************************/
  8953. /*! exports provided: _ScrollViewerWindow */
  8954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8955. "use strict";
  8956. __webpack_require__.r(__webpack_exports__);
  8957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8958. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8959. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8960. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8961. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8962. /**
  8963. * Class used to hold a the container for ScrollViewer
  8964. * @hidden
  8965. */
  8966. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8967. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  8968. /**
  8969. * Creates a new ScrollViewerWindow
  8970. * @param name of ScrollViewerWindow
  8971. */
  8972. function _ScrollViewerWindow(name) {
  8973. return _super.call(this, name) || this;
  8974. }
  8975. _ScrollViewerWindow.prototype._getTypeName = function () {
  8976. return "ScrollViewerWindow";
  8977. };
  8978. /** @hidden */
  8979. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  8980. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8981. this._measureForChildren.left = this._currentMeasure.left;
  8982. this._measureForChildren.top = this._currentMeasure.top;
  8983. this._measureForChildren.width = parentMeasure.width;
  8984. this._measureForChildren.height = parentMeasure.height;
  8985. };
  8986. _ScrollViewerWindow.prototype._postMeasure = function () {
  8987. var maxWidth = this.parentClientWidth;
  8988. var maxHeight = this.parentClientHeight;
  8989. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  8990. var child = _a[_i];
  8991. if (!child.isVisible || child.notRenderable) {
  8992. continue;
  8993. }
  8994. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  8995. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  8996. }
  8997. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  8998. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  8999. }
  9000. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9001. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9002. }
  9003. if (this._currentMeasure.width !== maxWidth) {
  9004. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9005. this._currentMeasure.width = maxWidth;
  9006. this._rebuildLayout = true;
  9007. this._isDirty = true;
  9008. }
  9009. if (this._currentMeasure.height !== maxHeight) {
  9010. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9011. this._currentMeasure.height = maxHeight;
  9012. this._rebuildLayout = true;
  9013. this._isDirty = true;
  9014. }
  9015. _super.prototype._postMeasure.call(this);
  9016. };
  9017. return _ScrollViewerWindow;
  9018. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9019. /***/ }),
  9020. /***/ "./2D/controls/selector.ts":
  9021. /*!*********************************!*\
  9022. !*** ./2D/controls/selector.ts ***!
  9023. \*********************************/
  9024. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9026. "use strict";
  9027. __webpack_require__.r(__webpack_exports__);
  9028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9033. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9034. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9035. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9036. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9037. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9038. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9039. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9040. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9041. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9042. /** Class used to create a RadioGroup
  9043. * which contains groups of radio buttons
  9044. */
  9045. var SelectorGroup = /** @class */ (function () {
  9046. /**
  9047. * Creates a new SelectorGroup
  9048. * @param name of group, used as a group heading
  9049. */
  9050. function SelectorGroup(
  9051. /** name of SelectorGroup */
  9052. name) {
  9053. this.name = name;
  9054. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9055. this._selectors = new Array();
  9056. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9057. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9058. this._groupHeader = this._addGroupHeader(name);
  9059. }
  9060. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9061. /** Gets the groupPanel of the SelectorGroup */
  9062. get: function () {
  9063. return this._groupPanel;
  9064. },
  9065. enumerable: true,
  9066. configurable: true
  9067. });
  9068. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9069. /** Gets the selectors array */
  9070. get: function () {
  9071. return this._selectors;
  9072. },
  9073. enumerable: true,
  9074. configurable: true
  9075. });
  9076. Object.defineProperty(SelectorGroup.prototype, "header", {
  9077. /** Gets and sets the group header */
  9078. get: function () {
  9079. return this._groupHeader.text;
  9080. },
  9081. set: function (label) {
  9082. if (this._groupHeader.text === "label") {
  9083. return;
  9084. }
  9085. this._groupHeader.text = label;
  9086. },
  9087. enumerable: true,
  9088. configurable: true
  9089. });
  9090. /** @hidden */
  9091. SelectorGroup.prototype._addGroupHeader = function (text) {
  9092. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9093. groupHeading.width = 0.9;
  9094. groupHeading.height = "30px";
  9095. groupHeading.textWrapping = true;
  9096. groupHeading.color = "black";
  9097. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9098. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9099. groupHeading.left = "2px";
  9100. this._groupPanel.addControl(groupHeading);
  9101. return groupHeading;
  9102. };
  9103. /** @hidden*/
  9104. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9105. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9106. return;
  9107. }
  9108. return this._selectors[selectorNb];
  9109. };
  9110. /** Removes the selector at the given position
  9111. * @param selectorNb the position of the selector within the group
  9112. */
  9113. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9114. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9115. return;
  9116. }
  9117. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9118. this._selectors.splice(selectorNb, 1);
  9119. };
  9120. return SelectorGroup;
  9121. }());
  9122. /** Class used to create a CheckboxGroup
  9123. * which contains groups of checkbox buttons
  9124. */
  9125. var CheckboxGroup = /** @class */ (function (_super) {
  9126. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9127. function CheckboxGroup() {
  9128. return _super !== null && _super.apply(this, arguments) || this;
  9129. }
  9130. /** Adds a checkbox as a control
  9131. * @param text is the label for the selector
  9132. * @param func is the function called when the Selector is checked
  9133. * @param checked is true when Selector is checked
  9134. */
  9135. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9136. if (func === void 0) { func = function (s) { }; }
  9137. if (checked === void 0) { checked = false; }
  9138. var checked = checked || false;
  9139. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9140. button.width = "20px";
  9141. button.height = "20px";
  9142. button.color = "#364249";
  9143. button.background = "#CCCCCC";
  9144. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9145. button.onIsCheckedChangedObservable.add(function (state) {
  9146. func(state);
  9147. });
  9148. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9149. _selector.height = "30px";
  9150. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9151. _selector.left = "4px";
  9152. this.groupPanel.addControl(_selector);
  9153. this.selectors.push(_selector);
  9154. button.isChecked = checked;
  9155. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9156. button.color = this.groupPanel.parent.parent.buttonColor;
  9157. button.background = this.groupPanel.parent.parent.buttonBackground;
  9158. }
  9159. };
  9160. /** @hidden */
  9161. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9162. this.selectors[selectorNb].children[1].text = label;
  9163. };
  9164. /** @hidden */
  9165. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9166. this.selectors[selectorNb].children[1].color = color;
  9167. };
  9168. /** @hidden */
  9169. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9170. this.selectors[selectorNb].children[0].color = color;
  9171. };
  9172. /** @hidden */
  9173. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9174. this.selectors[selectorNb].children[0].background = color;
  9175. };
  9176. return CheckboxGroup;
  9177. }(SelectorGroup));
  9178. /** Class used to create a RadioGroup
  9179. * which contains groups of radio buttons
  9180. */
  9181. var RadioGroup = /** @class */ (function (_super) {
  9182. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9183. function RadioGroup() {
  9184. var _this = _super !== null && _super.apply(this, arguments) || this;
  9185. _this._selectNb = 0;
  9186. return _this;
  9187. }
  9188. /** Adds a radio button as a control
  9189. * @param label is the label for the selector
  9190. * @param func is the function called when the Selector is checked
  9191. * @param checked is true when Selector is checked
  9192. */
  9193. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9194. if (func === void 0) { func = function (n) { }; }
  9195. if (checked === void 0) { checked = false; }
  9196. var nb = this._selectNb++;
  9197. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9198. button.name = label;
  9199. button.width = "20px";
  9200. button.height = "20px";
  9201. button.color = "#364249";
  9202. button.background = "#CCCCCC";
  9203. button.group = this.name;
  9204. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9205. button.onIsCheckedChangedObservable.add(function (state) {
  9206. if (state) {
  9207. func(nb);
  9208. }
  9209. });
  9210. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9211. _selector.height = "30px";
  9212. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9213. _selector.left = "4px";
  9214. this.groupPanel.addControl(_selector);
  9215. this.selectors.push(_selector);
  9216. button.isChecked = checked;
  9217. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9218. button.color = this.groupPanel.parent.parent.buttonColor;
  9219. button.background = this.groupPanel.parent.parent.buttonBackground;
  9220. }
  9221. };
  9222. /** @hidden */
  9223. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9224. this.selectors[selectorNb].children[1].text = label;
  9225. };
  9226. /** @hidden */
  9227. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9228. this.selectors[selectorNb].children[1].color = color;
  9229. };
  9230. /** @hidden */
  9231. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9232. this.selectors[selectorNb].children[0].color = color;
  9233. };
  9234. /** @hidden */
  9235. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9236. this.selectors[selectorNb].children[0].background = color;
  9237. };
  9238. return RadioGroup;
  9239. }(SelectorGroup));
  9240. /** Class used to create a SliderGroup
  9241. * which contains groups of slider buttons
  9242. */
  9243. var SliderGroup = /** @class */ (function (_super) {
  9244. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9245. function SliderGroup() {
  9246. return _super !== null && _super.apply(this, arguments) || this;
  9247. }
  9248. /**
  9249. * Adds a slider to the SelectorGroup
  9250. * @param label is the label for the SliderBar
  9251. * @param func is the function called when the Slider moves
  9252. * @param unit is a string describing the units used, eg degrees or metres
  9253. * @param min is the minimum value for the Slider
  9254. * @param max is the maximum value for the Slider
  9255. * @param value is the start value for the Slider between min and max
  9256. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9257. */
  9258. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9259. if (func === void 0) { func = function (v) { }; }
  9260. if (unit === void 0) { unit = "Units"; }
  9261. if (min === void 0) { min = 0; }
  9262. if (max === void 0) { max = 0; }
  9263. if (value === void 0) { value = 0; }
  9264. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9265. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9266. button.name = unit;
  9267. button.value = value;
  9268. button.minimum = min;
  9269. button.maximum = max;
  9270. button.width = 0.9;
  9271. button.height = "20px";
  9272. button.color = "#364249";
  9273. button.background = "#CCCCCC";
  9274. button.borderColor = "black";
  9275. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9276. button.left = "4px";
  9277. button.paddingBottom = "4px";
  9278. button.onValueChangedObservable.add(function (value) {
  9279. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9280. func(value);
  9281. });
  9282. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9283. _selector.height = "60px";
  9284. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9285. _selector.left = "4px";
  9286. _selector.children[0].name = label;
  9287. this.groupPanel.addControl(_selector);
  9288. this.selectors.push(_selector);
  9289. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9290. button.color = this.groupPanel.parent.parent.buttonColor;
  9291. button.background = this.groupPanel.parent.parent.buttonBackground;
  9292. }
  9293. };
  9294. /** @hidden */
  9295. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9296. this.selectors[selectorNb].children[0].name = label;
  9297. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9298. };
  9299. /** @hidden */
  9300. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9301. this.selectors[selectorNb].children[0].color = color;
  9302. };
  9303. /** @hidden */
  9304. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9305. this.selectors[selectorNb].children[1].color = color;
  9306. };
  9307. /** @hidden */
  9308. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9309. this.selectors[selectorNb].children[1].background = color;
  9310. };
  9311. return SliderGroup;
  9312. }(SelectorGroup));
  9313. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9314. * @see http://doc.babylonjs.com/how_to/selector
  9315. */
  9316. var SelectionPanel = /** @class */ (function (_super) {
  9317. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9318. /**
  9319. * Creates a new SelectionPanel
  9320. * @param name of SelectionPanel
  9321. * @param groups is an array of SelectionGroups
  9322. */
  9323. function SelectionPanel(
  9324. /** name of SelectionPanel */
  9325. name,
  9326. /** an array of SelectionGroups */
  9327. groups) {
  9328. if (groups === void 0) { groups = []; }
  9329. var _this = _super.call(this, name) || this;
  9330. _this.name = name;
  9331. _this.groups = groups;
  9332. _this._buttonColor = "#364249";
  9333. _this._buttonBackground = "#CCCCCC";
  9334. _this._headerColor = "black";
  9335. _this._barColor = "white";
  9336. _this._barHeight = "2px";
  9337. _this._spacerHeight = "20px";
  9338. _this._bars = new Array();
  9339. _this._groups = groups;
  9340. _this.thickness = 2;
  9341. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9342. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9343. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9344. _this._panel.top = 5;
  9345. _this._panel.left = 5;
  9346. _this._panel.width = 0.95;
  9347. if (groups.length > 0) {
  9348. for (var i = 0; i < groups.length - 1; i++) {
  9349. _this._panel.addControl(groups[i].groupPanel);
  9350. _this._addSpacer();
  9351. }
  9352. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9353. }
  9354. _this.addControl(_this._panel);
  9355. return _this;
  9356. }
  9357. SelectionPanel.prototype._getTypeName = function () {
  9358. return "SelectionPanel";
  9359. };
  9360. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9361. /** Gets or sets the headerColor */
  9362. get: function () {
  9363. return this._headerColor;
  9364. },
  9365. set: function (color) {
  9366. if (this._headerColor === color) {
  9367. return;
  9368. }
  9369. this._headerColor = color;
  9370. this._setHeaderColor();
  9371. },
  9372. enumerable: true,
  9373. configurable: true
  9374. });
  9375. SelectionPanel.prototype._setHeaderColor = function () {
  9376. for (var i = 0; i < this._groups.length; i++) {
  9377. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9378. }
  9379. };
  9380. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9381. /** Gets or sets the button color */
  9382. get: function () {
  9383. return this._buttonColor;
  9384. },
  9385. set: function (color) {
  9386. if (this._buttonColor === color) {
  9387. return;
  9388. }
  9389. this._buttonColor = color;
  9390. this._setbuttonColor();
  9391. },
  9392. enumerable: true,
  9393. configurable: true
  9394. });
  9395. SelectionPanel.prototype._setbuttonColor = function () {
  9396. for (var i = 0; i < this._groups.length; i++) {
  9397. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9398. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9399. }
  9400. }
  9401. };
  9402. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9403. /** Gets or sets the label color */
  9404. get: function () {
  9405. return this._labelColor;
  9406. },
  9407. set: function (color) {
  9408. if (this._labelColor === color) {
  9409. return;
  9410. }
  9411. this._labelColor = color;
  9412. this._setLabelColor();
  9413. },
  9414. enumerable: true,
  9415. configurable: true
  9416. });
  9417. SelectionPanel.prototype._setLabelColor = function () {
  9418. for (var i = 0; i < this._groups.length; i++) {
  9419. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9420. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9421. }
  9422. }
  9423. };
  9424. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9425. /** Gets or sets the button background */
  9426. get: function () {
  9427. return this._buttonBackground;
  9428. },
  9429. set: function (color) {
  9430. if (this._buttonBackground === color) {
  9431. return;
  9432. }
  9433. this._buttonBackground = color;
  9434. this._setButtonBackground();
  9435. },
  9436. enumerable: true,
  9437. configurable: true
  9438. });
  9439. SelectionPanel.prototype._setButtonBackground = function () {
  9440. for (var i = 0; i < this._groups.length; i++) {
  9441. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9442. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9443. }
  9444. }
  9445. };
  9446. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9447. /** Gets or sets the color of separator bar */
  9448. get: function () {
  9449. return this._barColor;
  9450. },
  9451. set: function (color) {
  9452. if (this._barColor === color) {
  9453. return;
  9454. }
  9455. this._barColor = color;
  9456. this._setBarColor();
  9457. },
  9458. enumerable: true,
  9459. configurable: true
  9460. });
  9461. SelectionPanel.prototype._setBarColor = function () {
  9462. for (var i = 0; i < this._bars.length; i++) {
  9463. this._bars[i].children[0].background = this._barColor;
  9464. }
  9465. };
  9466. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9467. /** Gets or sets the height of separator bar */
  9468. get: function () {
  9469. return this._barHeight;
  9470. },
  9471. set: function (value) {
  9472. if (this._barHeight === value) {
  9473. return;
  9474. }
  9475. this._barHeight = value;
  9476. this._setBarHeight();
  9477. },
  9478. enumerable: true,
  9479. configurable: true
  9480. });
  9481. SelectionPanel.prototype._setBarHeight = function () {
  9482. for (var i = 0; i < this._bars.length; i++) {
  9483. this._bars[i].children[0].height = this._barHeight;
  9484. }
  9485. };
  9486. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9487. /** Gets or sets the height of spacers*/
  9488. get: function () {
  9489. return this._spacerHeight;
  9490. },
  9491. set: function (value) {
  9492. if (this._spacerHeight === value) {
  9493. return;
  9494. }
  9495. this._spacerHeight = value;
  9496. this._setSpacerHeight();
  9497. },
  9498. enumerable: true,
  9499. configurable: true
  9500. });
  9501. SelectionPanel.prototype._setSpacerHeight = function () {
  9502. for (var i = 0; i < this._bars.length; i++) {
  9503. this._bars[i].height = this._spacerHeight;
  9504. }
  9505. };
  9506. /** Adds a bar between groups */
  9507. SelectionPanel.prototype._addSpacer = function () {
  9508. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9509. separator.width = 1;
  9510. separator.height = this._spacerHeight;
  9511. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9512. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9513. bar.width = 1;
  9514. bar.height = this._barHeight;
  9515. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9516. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9517. bar.background = this._barColor;
  9518. bar.color = "transparent";
  9519. separator.addControl(bar);
  9520. this._panel.addControl(separator);
  9521. this._bars.push(separator);
  9522. };
  9523. /** Add a group to the selection panel
  9524. * @param group is the selector group to add
  9525. */
  9526. SelectionPanel.prototype.addGroup = function (group) {
  9527. if (this._groups.length > 0) {
  9528. this._addSpacer();
  9529. }
  9530. this._panel.addControl(group.groupPanel);
  9531. this._groups.push(group);
  9532. group.groupPanel.children[0].color = this._headerColor;
  9533. for (var j = 0; j < group.selectors.length; j++) {
  9534. group._setSelectorButtonColor(j, this._buttonColor);
  9535. group._setSelectorButtonBackground(j, this._buttonBackground);
  9536. }
  9537. };
  9538. /** Remove the group from the given position
  9539. * @param groupNb is the position of the group in the list
  9540. */
  9541. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9542. if (groupNb < 0 || groupNb >= this._groups.length) {
  9543. return;
  9544. }
  9545. var group = this._groups[groupNb];
  9546. this._panel.removeControl(group.groupPanel);
  9547. this._groups.splice(groupNb, 1);
  9548. if (groupNb < this._bars.length) {
  9549. this._panel.removeControl(this._bars[groupNb]);
  9550. this._bars.splice(groupNb, 1);
  9551. }
  9552. };
  9553. /** Change a group header label
  9554. * @param label is the new group header label
  9555. * @param groupNb is the number of the group to relabel
  9556. * */
  9557. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9558. if (groupNb < 0 || groupNb >= this._groups.length) {
  9559. return;
  9560. }
  9561. var group = this._groups[groupNb];
  9562. group.groupPanel.children[0].text = label;
  9563. };
  9564. /** Change selector label to the one given
  9565. * @param label is the new selector label
  9566. * @param groupNb is the number of the groupcontaining the selector
  9567. * @param selectorNb is the number of the selector within a group to relabel
  9568. * */
  9569. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9570. if (groupNb < 0 || groupNb >= this._groups.length) {
  9571. return;
  9572. }
  9573. var group = this._groups[groupNb];
  9574. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9575. return;
  9576. }
  9577. group._setSelectorLabel(selectorNb, label);
  9578. };
  9579. /** For a given group position remove the selector at the given position
  9580. * @param groupNb is the number of the group to remove the selector from
  9581. * @param selectorNb is the number of the selector within the group
  9582. */
  9583. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9584. if (groupNb < 0 || groupNb >= this._groups.length) {
  9585. return;
  9586. }
  9587. var group = this._groups[groupNb];
  9588. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9589. return;
  9590. }
  9591. group.removeSelector(selectorNb);
  9592. };
  9593. /** For a given group position of correct type add a checkbox button
  9594. * @param groupNb is the number of the group to remove the selector from
  9595. * @param label is the label for the selector
  9596. * @param func is the function called when the Selector is checked
  9597. * @param checked is true when Selector is checked
  9598. */
  9599. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9600. if (func === void 0) { func = function () { }; }
  9601. if (checked === void 0) { checked = false; }
  9602. if (groupNb < 0 || groupNb >= this._groups.length) {
  9603. return;
  9604. }
  9605. var group = this._groups[groupNb];
  9606. group.addCheckbox(label, func, checked);
  9607. };
  9608. /** For a given group position of correct type add a radio button
  9609. * @param groupNb is the number of the group to remove the selector from
  9610. * @param label is the label for the selector
  9611. * @param func is the function called when the Selector is checked
  9612. * @param checked is true when Selector is checked
  9613. */
  9614. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9615. if (func === void 0) { func = function () { }; }
  9616. if (checked === void 0) { checked = false; }
  9617. if (groupNb < 0 || groupNb >= this._groups.length) {
  9618. return;
  9619. }
  9620. var group = this._groups[groupNb];
  9621. group.addRadio(label, func, checked);
  9622. };
  9623. /**
  9624. * For a given slider group add a slider
  9625. * @param groupNb is the number of the group to add the slider to
  9626. * @param label is the label for the Slider
  9627. * @param func is the function called when the Slider moves
  9628. * @param unit is a string describing the units used, eg degrees or metres
  9629. * @param min is the minimum value for the Slider
  9630. * @param max is the maximum value for the Slider
  9631. * @param value is the start value for the Slider between min and max
  9632. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9633. */
  9634. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9635. if (func === void 0) { func = function () { }; }
  9636. if (unit === void 0) { unit = "Units"; }
  9637. if (min === void 0) { min = 0; }
  9638. if (max === void 0) { max = 0; }
  9639. if (value === void 0) { value = 0; }
  9640. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9641. if (groupNb < 0 || groupNb >= this._groups.length) {
  9642. return;
  9643. }
  9644. var group = this._groups[groupNb];
  9645. group.addSlider(label, func, unit, min, max, value, onVal);
  9646. };
  9647. return SelectionPanel;
  9648. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9649. /***/ }),
  9650. /***/ "./2D/controls/sliders/baseSlider.ts":
  9651. /*!*******************************************!*\
  9652. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9653. \*******************************************/
  9654. /*! exports provided: BaseSlider */
  9655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9656. "use strict";
  9657. __webpack_require__.r(__webpack_exports__);
  9658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9659. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9660. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  9661. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9662. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9663. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9664. /**
  9665. * Class used to create slider controls
  9666. */
  9667. var BaseSlider = /** @class */ (function (_super) {
  9668. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9669. /**
  9670. * Creates a new BaseSlider
  9671. * @param name defines the control name
  9672. */
  9673. function BaseSlider(name) {
  9674. var _this = _super.call(this, name) || this;
  9675. _this.name = name;
  9676. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9677. _this._minimum = 0;
  9678. _this._maximum = 100;
  9679. _this._value = 50;
  9680. _this._isVertical = false;
  9681. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9682. _this._isThumbClamped = false;
  9683. _this._displayThumb = true;
  9684. _this._step = 0;
  9685. // Shared rendering info
  9686. _this._effectiveBarOffset = 0;
  9687. /** Observable raised when the sldier value changes */
  9688. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9689. // Events
  9690. _this._pointerIsDown = false;
  9691. _this.isPointerBlocker = true;
  9692. return _this;
  9693. }
  9694. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9695. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9696. get: function () {
  9697. return this._displayThumb;
  9698. },
  9699. set: function (value) {
  9700. if (this._displayThumb === value) {
  9701. return;
  9702. }
  9703. this._displayThumb = value;
  9704. this._markAsDirty();
  9705. },
  9706. enumerable: true,
  9707. configurable: true
  9708. });
  9709. Object.defineProperty(BaseSlider.prototype, "step", {
  9710. /** Gets or sets a step to apply to values (0 by default) */
  9711. get: function () {
  9712. return this._step;
  9713. },
  9714. set: function (value) {
  9715. if (this._step === value) {
  9716. return;
  9717. }
  9718. this._step = value;
  9719. this._markAsDirty();
  9720. },
  9721. enumerable: true,
  9722. configurable: true
  9723. });
  9724. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9725. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9726. get: function () {
  9727. return this._barOffset.toString(this._host);
  9728. },
  9729. set: function (value) {
  9730. if (this._barOffset.toString(this._host) === value) {
  9731. return;
  9732. }
  9733. if (this._barOffset.fromString(value)) {
  9734. this._markAsDirty();
  9735. }
  9736. },
  9737. enumerable: true,
  9738. configurable: true
  9739. });
  9740. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9741. /** Gets main bar offset in pixels*/
  9742. get: function () {
  9743. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9744. },
  9745. enumerable: true,
  9746. configurable: true
  9747. });
  9748. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9749. /** Gets or sets thumb width */
  9750. get: function () {
  9751. return this._thumbWidth.toString(this._host);
  9752. },
  9753. set: function (value) {
  9754. if (this._thumbWidth.toString(this._host) === value) {
  9755. return;
  9756. }
  9757. if (this._thumbWidth.fromString(value)) {
  9758. this._markAsDirty();
  9759. }
  9760. },
  9761. enumerable: true,
  9762. configurable: true
  9763. });
  9764. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9765. /** Gets thumb width in pixels */
  9766. get: function () {
  9767. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9768. },
  9769. enumerable: true,
  9770. configurable: true
  9771. });
  9772. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9773. /** Gets or sets minimum value */
  9774. get: function () {
  9775. return this._minimum;
  9776. },
  9777. set: function (value) {
  9778. if (this._minimum === value) {
  9779. return;
  9780. }
  9781. this._minimum = value;
  9782. this._markAsDirty();
  9783. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9784. },
  9785. enumerable: true,
  9786. configurable: true
  9787. });
  9788. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9789. /** Gets or sets maximum value */
  9790. get: function () {
  9791. return this._maximum;
  9792. },
  9793. set: function (value) {
  9794. if (this._maximum === value) {
  9795. return;
  9796. }
  9797. this._maximum = value;
  9798. this._markAsDirty();
  9799. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9800. },
  9801. enumerable: true,
  9802. configurable: true
  9803. });
  9804. Object.defineProperty(BaseSlider.prototype, "value", {
  9805. /** Gets or sets current value */
  9806. get: function () {
  9807. return this._value;
  9808. },
  9809. set: function (value) {
  9810. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9811. if (this._value === value) {
  9812. return;
  9813. }
  9814. this._value = value;
  9815. this._markAsDirty();
  9816. this.onValueChangedObservable.notifyObservers(this._value);
  9817. },
  9818. enumerable: true,
  9819. configurable: true
  9820. });
  9821. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9822. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9823. get: function () {
  9824. return this._isVertical;
  9825. },
  9826. set: function (value) {
  9827. if (this._isVertical === value) {
  9828. return;
  9829. }
  9830. this._isVertical = value;
  9831. this._markAsDirty();
  9832. },
  9833. enumerable: true,
  9834. configurable: true
  9835. });
  9836. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9837. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9838. get: function () {
  9839. return this._isThumbClamped;
  9840. },
  9841. set: function (value) {
  9842. if (this._isThumbClamped === value) {
  9843. return;
  9844. }
  9845. this._isThumbClamped = value;
  9846. this._markAsDirty();
  9847. },
  9848. enumerable: true,
  9849. configurable: true
  9850. });
  9851. BaseSlider.prototype._getTypeName = function () {
  9852. return "BaseSlider";
  9853. };
  9854. BaseSlider.prototype._getThumbPosition = function () {
  9855. if (this.isVertical) {
  9856. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9857. }
  9858. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9859. };
  9860. BaseSlider.prototype._getThumbThickness = function (type) {
  9861. var thumbThickness = 0;
  9862. switch (type) {
  9863. case "circle":
  9864. if (this._thumbWidth.isPixel) {
  9865. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9866. }
  9867. else {
  9868. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9869. }
  9870. break;
  9871. case "rectangle":
  9872. if (this._thumbWidth.isPixel) {
  9873. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9874. }
  9875. else {
  9876. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9877. }
  9878. }
  9879. return thumbThickness;
  9880. };
  9881. BaseSlider.prototype._prepareRenderingData = function (type) {
  9882. // Main bar
  9883. this._effectiveBarOffset = 0;
  9884. this._renderLeft = this._currentMeasure.left;
  9885. this._renderTop = this._currentMeasure.top;
  9886. this._renderWidth = this._currentMeasure.width;
  9887. this._renderHeight = this._currentMeasure.height;
  9888. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9889. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9890. this._effectiveThumbThickness = this._getThumbThickness(type);
  9891. if (this.displayThumb) {
  9892. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9893. }
  9894. //throw error when height is less than width for vertical slider
  9895. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9896. console.error("Height should be greater than width");
  9897. return;
  9898. }
  9899. if (this._barOffset.isPixel) {
  9900. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9901. }
  9902. else {
  9903. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9904. }
  9905. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9906. if (this.isVertical) {
  9907. this._renderLeft += this._effectiveBarOffset;
  9908. if (!this.isThumbClamped && this.displayThumb) {
  9909. this._renderTop += (this._effectiveThumbThickness / 2);
  9910. }
  9911. this._renderHeight = this._backgroundBoxLength;
  9912. this._renderWidth = this._backgroundBoxThickness;
  9913. }
  9914. else {
  9915. this._renderTop += this._effectiveBarOffset;
  9916. if (!this.isThumbClamped && this.displayThumb) {
  9917. this._renderLeft += (this._effectiveThumbThickness / 2);
  9918. }
  9919. this._renderHeight = this._backgroundBoxThickness;
  9920. this._renderWidth = this._backgroundBoxLength;
  9921. }
  9922. };
  9923. /** @hidden */
  9924. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9925. if (this.rotation != 0) {
  9926. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9927. x = this._transformedPosition.x;
  9928. y = this._transformedPosition.y;
  9929. }
  9930. var value;
  9931. if (this._isVertical) {
  9932. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9933. }
  9934. else {
  9935. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9936. }
  9937. var mult = (1 / this._step) | 0;
  9938. this.value = this._step ? ((value * mult) | 0) / mult : value;
  9939. };
  9940. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9941. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9942. return false;
  9943. }
  9944. this._pointerIsDown = true;
  9945. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9946. this._host._capturingControl[pointerId] = this;
  9947. return true;
  9948. };
  9949. BaseSlider.prototype._onPointerMove = function (target, coordinates) {
  9950. if (this._pointerIsDown) {
  9951. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9952. }
  9953. _super.prototype._onPointerMove.call(this, target, coordinates);
  9954. };
  9955. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9956. this._pointerIsDown = false;
  9957. delete this._host._capturingControl[pointerId];
  9958. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9959. };
  9960. return BaseSlider;
  9961. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9962. /***/ }),
  9963. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  9964. /*!*************************************************!*\
  9965. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  9966. \*************************************************/
  9967. /*! exports provided: ImageBasedSlider */
  9968. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9969. "use strict";
  9970. __webpack_require__.r(__webpack_exports__);
  9971. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  9972. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9973. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  9974. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9975. /**
  9976. * Class used to create slider controls based on images
  9977. */
  9978. var ImageBasedSlider = /** @class */ (function (_super) {
  9979. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  9980. /**
  9981. * Creates a new ImageBasedSlider
  9982. * @param name defines the control name
  9983. */
  9984. function ImageBasedSlider(name) {
  9985. var _this = _super.call(this, name) || this;
  9986. _this.name = name;
  9987. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  9988. return _this;
  9989. }
  9990. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  9991. get: function () {
  9992. return this._displayThumb && this.thumbImage != null;
  9993. },
  9994. set: function (value) {
  9995. if (this._displayThumb === value) {
  9996. return;
  9997. }
  9998. this._displayThumb = value;
  9999. this._markAsDirty();
  10000. },
  10001. enumerable: true,
  10002. configurable: true
  10003. });
  10004. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10005. /**
  10006. * Gets or sets the image used to render the background
  10007. */
  10008. get: function () {
  10009. return this._backgroundImage;
  10010. },
  10011. set: function (value) {
  10012. var _this = this;
  10013. if (this._backgroundImage === value) {
  10014. return;
  10015. }
  10016. this._backgroundImage = value;
  10017. if (value && !value.isLoaded) {
  10018. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10019. }
  10020. this._markAsDirty();
  10021. },
  10022. enumerable: true,
  10023. configurable: true
  10024. });
  10025. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10026. /**
  10027. * Gets or sets the image used to render the value bar
  10028. */
  10029. get: function () {
  10030. return this._valueBarImage;
  10031. },
  10032. set: function (value) {
  10033. var _this = this;
  10034. if (this._valueBarImage === value) {
  10035. return;
  10036. }
  10037. this._valueBarImage = value;
  10038. if (value && !value.isLoaded) {
  10039. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10040. }
  10041. this._markAsDirty();
  10042. },
  10043. enumerable: true,
  10044. configurable: true
  10045. });
  10046. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10047. /**
  10048. * Gets or sets the image used to render the thumb
  10049. */
  10050. get: function () {
  10051. return this._thumbImage;
  10052. },
  10053. set: function (value) {
  10054. var _this = this;
  10055. if (this._thumbImage === value) {
  10056. return;
  10057. }
  10058. this._thumbImage = value;
  10059. if (value && !value.isLoaded) {
  10060. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10061. }
  10062. this._markAsDirty();
  10063. },
  10064. enumerable: true,
  10065. configurable: true
  10066. });
  10067. ImageBasedSlider.prototype._getTypeName = function () {
  10068. return "ImageBasedSlider";
  10069. };
  10070. ImageBasedSlider.prototype._draw = function (context) {
  10071. context.save();
  10072. this._applyStates(context);
  10073. this._prepareRenderingData("rectangle");
  10074. var thumbPosition = this._getThumbPosition();
  10075. var left = this._renderLeft;
  10076. var top = this._renderTop;
  10077. var width = this._renderWidth;
  10078. var height = this._renderHeight;
  10079. // Background
  10080. if (this._backgroundImage) {
  10081. this._tempMeasure.copyFromFloats(left, top, width, height);
  10082. if (this.isThumbClamped && this.displayThumb) {
  10083. if (this.isVertical) {
  10084. this._tempMeasure.height += this._effectiveThumbThickness;
  10085. }
  10086. else {
  10087. this._tempMeasure.width += this._effectiveThumbThickness;
  10088. }
  10089. }
  10090. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10091. this._backgroundImage._draw(context);
  10092. }
  10093. // Bar
  10094. if (this._valueBarImage) {
  10095. if (this.isVertical) {
  10096. if (this.isThumbClamped && this.displayThumb) {
  10097. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10098. }
  10099. else {
  10100. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10101. }
  10102. }
  10103. else {
  10104. if (this.isThumbClamped && this.displayThumb) {
  10105. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10106. }
  10107. else {
  10108. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10109. }
  10110. }
  10111. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10112. this._valueBarImage._draw(context);
  10113. }
  10114. // Thumb
  10115. if (this.displayThumb) {
  10116. if (this.isVertical) {
  10117. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10118. }
  10119. else {
  10120. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10121. }
  10122. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10123. this._thumbImage._draw(context);
  10124. }
  10125. context.restore();
  10126. };
  10127. return ImageBasedSlider;
  10128. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10129. /***/ }),
  10130. /***/ "./2D/controls/sliders/scrollBar.ts":
  10131. /*!******************************************!*\
  10132. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10133. \******************************************/
  10134. /*! exports provided: ScrollBar */
  10135. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10136. "use strict";
  10137. __webpack_require__.r(__webpack_exports__);
  10138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10139. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10140. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10141. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10142. /**
  10143. * Class used to create slider controls
  10144. */
  10145. var ScrollBar = /** @class */ (function (_super) {
  10146. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10147. /**
  10148. * Creates a new Slider
  10149. * @param name defines the control name
  10150. */
  10151. function ScrollBar(name) {
  10152. var _this = _super.call(this, name) || this;
  10153. _this.name = name;
  10154. _this._background = "black";
  10155. _this._borderColor = "white";
  10156. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10157. return _this;
  10158. }
  10159. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10160. /** Gets or sets border color */
  10161. get: function () {
  10162. return this._borderColor;
  10163. },
  10164. set: function (value) {
  10165. if (this._borderColor === value) {
  10166. return;
  10167. }
  10168. this._borderColor = value;
  10169. this._markAsDirty();
  10170. },
  10171. enumerable: true,
  10172. configurable: true
  10173. });
  10174. Object.defineProperty(ScrollBar.prototype, "background", {
  10175. /** Gets or sets background color */
  10176. get: function () {
  10177. return this._background;
  10178. },
  10179. set: function (value) {
  10180. if (this._background === value) {
  10181. return;
  10182. }
  10183. this._background = value;
  10184. this._markAsDirty();
  10185. },
  10186. enumerable: true,
  10187. configurable: true
  10188. });
  10189. ScrollBar.prototype._getTypeName = function () {
  10190. return "Scrollbar";
  10191. };
  10192. ScrollBar.prototype._getThumbThickness = function () {
  10193. var thumbThickness = 0;
  10194. if (this._thumbWidth.isPixel) {
  10195. thumbThickness = this._thumbWidth.getValue(this._host);
  10196. }
  10197. else {
  10198. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10199. }
  10200. return thumbThickness;
  10201. };
  10202. ScrollBar.prototype._draw = function (context) {
  10203. context.save();
  10204. this._applyStates(context);
  10205. this._prepareRenderingData("rectangle");
  10206. var left = this._renderLeft;
  10207. var thumbPosition = this._getThumbPosition();
  10208. context.fillStyle = this._background;
  10209. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10210. // Value bar
  10211. context.fillStyle = this.color;
  10212. // Thumb
  10213. if (this.isVertical) {
  10214. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10215. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10216. this._thumbMeasure.width = this._currentMeasure.width;
  10217. this._thumbMeasure.height = this._effectiveThumbThickness;
  10218. }
  10219. else {
  10220. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10221. this._thumbMeasure.top = this._currentMeasure.top;
  10222. this._thumbMeasure.width = this._effectiveThumbThickness;
  10223. this._thumbMeasure.height = this._currentMeasure.height;
  10224. }
  10225. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10226. context.restore();
  10227. };
  10228. /** @hidden */
  10229. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10230. if (this.rotation != 0) {
  10231. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10232. x = this._transformedPosition.x;
  10233. y = this._transformedPosition.y;
  10234. }
  10235. if (this._first) {
  10236. this._first = false;
  10237. this._originX = x;
  10238. this._originY = y;
  10239. // Check if move is required
  10240. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10241. if (this.isVertical) {
  10242. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10243. }
  10244. else {
  10245. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10246. }
  10247. }
  10248. }
  10249. // Delta mode
  10250. var delta = 0;
  10251. if (this.isVertical) {
  10252. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10253. }
  10254. else {
  10255. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10256. }
  10257. this.value += delta * (this.maximum - this.minimum);
  10258. this._originX = x;
  10259. this._originY = y;
  10260. };
  10261. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10262. this._first = true;
  10263. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10264. };
  10265. return ScrollBar;
  10266. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10267. /***/ }),
  10268. /***/ "./2D/controls/sliders/slider.ts":
  10269. /*!***************************************!*\
  10270. !*** ./2D/controls/sliders/slider.ts ***!
  10271. \***************************************/
  10272. /*! exports provided: Slider */
  10273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10274. "use strict";
  10275. __webpack_require__.r(__webpack_exports__);
  10276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10277. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10278. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10279. /**
  10280. * Class used to create slider controls
  10281. */
  10282. var Slider = /** @class */ (function (_super) {
  10283. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10284. /**
  10285. * Creates a new Slider
  10286. * @param name defines the control name
  10287. */
  10288. function Slider(name) {
  10289. var _this = _super.call(this, name) || this;
  10290. _this.name = name;
  10291. _this._background = "black";
  10292. _this._borderColor = "white";
  10293. _this._isThumbCircle = false;
  10294. _this._displayValueBar = true;
  10295. return _this;
  10296. }
  10297. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10298. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10299. get: function () {
  10300. return this._displayValueBar;
  10301. },
  10302. set: function (value) {
  10303. if (this._displayValueBar === value) {
  10304. return;
  10305. }
  10306. this._displayValueBar = value;
  10307. this._markAsDirty();
  10308. },
  10309. enumerable: true,
  10310. configurable: true
  10311. });
  10312. Object.defineProperty(Slider.prototype, "borderColor", {
  10313. /** Gets or sets border color */
  10314. get: function () {
  10315. return this._borderColor;
  10316. },
  10317. set: function (value) {
  10318. if (this._borderColor === value) {
  10319. return;
  10320. }
  10321. this._borderColor = value;
  10322. this._markAsDirty();
  10323. },
  10324. enumerable: true,
  10325. configurable: true
  10326. });
  10327. Object.defineProperty(Slider.prototype, "background", {
  10328. /** Gets or sets background color */
  10329. get: function () {
  10330. return this._background;
  10331. },
  10332. set: function (value) {
  10333. if (this._background === value) {
  10334. return;
  10335. }
  10336. this._background = value;
  10337. this._markAsDirty();
  10338. },
  10339. enumerable: true,
  10340. configurable: true
  10341. });
  10342. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10343. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10344. get: function () {
  10345. return this._isThumbCircle;
  10346. },
  10347. set: function (value) {
  10348. if (this._isThumbCircle === value) {
  10349. return;
  10350. }
  10351. this._isThumbCircle = value;
  10352. this._markAsDirty();
  10353. },
  10354. enumerable: true,
  10355. configurable: true
  10356. });
  10357. Slider.prototype._getTypeName = function () {
  10358. return "Slider";
  10359. };
  10360. Slider.prototype._draw = function (context) {
  10361. context.save();
  10362. this._applyStates(context);
  10363. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10364. var left = this._renderLeft;
  10365. var top = this._renderTop;
  10366. var width = this._renderWidth;
  10367. var height = this._renderHeight;
  10368. var radius = 0;
  10369. if (this.isThumbClamped && this.isThumbCircle) {
  10370. if (this.isVertical) {
  10371. top += (this._effectiveThumbThickness / 2);
  10372. }
  10373. else {
  10374. left += (this._effectiveThumbThickness / 2);
  10375. }
  10376. radius = this._backgroundBoxThickness / 2;
  10377. }
  10378. else {
  10379. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10380. }
  10381. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10382. context.shadowColor = this.shadowColor;
  10383. context.shadowBlur = this.shadowBlur;
  10384. context.shadowOffsetX = this.shadowOffsetX;
  10385. context.shadowOffsetY = this.shadowOffsetY;
  10386. }
  10387. var thumbPosition = this._getThumbPosition();
  10388. context.fillStyle = this._background;
  10389. if (this.isVertical) {
  10390. if (this.isThumbClamped) {
  10391. if (this.isThumbCircle) {
  10392. context.beginPath();
  10393. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10394. context.fill();
  10395. context.fillRect(left, top, width, height);
  10396. }
  10397. else {
  10398. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10399. }
  10400. }
  10401. else {
  10402. context.fillRect(left, top, width, height);
  10403. }
  10404. }
  10405. else {
  10406. if (this.isThumbClamped) {
  10407. if (this.isThumbCircle) {
  10408. context.beginPath();
  10409. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10410. context.fill();
  10411. context.fillRect(left, top, width, height);
  10412. }
  10413. else {
  10414. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10415. }
  10416. }
  10417. else {
  10418. context.fillRect(left, top, width, height);
  10419. }
  10420. }
  10421. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10422. context.shadowBlur = 0;
  10423. context.shadowOffsetX = 0;
  10424. context.shadowOffsetY = 0;
  10425. }
  10426. // Value bar
  10427. context.fillStyle = this.color;
  10428. if (this._displayValueBar) {
  10429. if (this.isVertical) {
  10430. if (this.isThumbClamped) {
  10431. if (this.isThumbCircle) {
  10432. context.beginPath();
  10433. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10434. context.fill();
  10435. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10436. }
  10437. else {
  10438. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10439. }
  10440. }
  10441. else {
  10442. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10443. }
  10444. }
  10445. else {
  10446. if (this.isThumbClamped) {
  10447. if (this.isThumbCircle) {
  10448. context.beginPath();
  10449. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10450. context.fill();
  10451. context.fillRect(left, top, thumbPosition, height);
  10452. }
  10453. else {
  10454. context.fillRect(left, top, thumbPosition, height);
  10455. }
  10456. }
  10457. else {
  10458. context.fillRect(left, top, thumbPosition, height);
  10459. }
  10460. }
  10461. }
  10462. // Thumb
  10463. if (this.displayThumb) {
  10464. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10465. context.shadowColor = this.shadowColor;
  10466. context.shadowBlur = this.shadowBlur;
  10467. context.shadowOffsetX = this.shadowOffsetX;
  10468. context.shadowOffsetY = this.shadowOffsetY;
  10469. }
  10470. if (this._isThumbCircle) {
  10471. context.beginPath();
  10472. if (this.isVertical) {
  10473. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10474. }
  10475. else {
  10476. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10477. }
  10478. context.fill();
  10479. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10480. context.shadowBlur = 0;
  10481. context.shadowOffsetX = 0;
  10482. context.shadowOffsetY = 0;
  10483. }
  10484. context.strokeStyle = this._borderColor;
  10485. context.stroke();
  10486. }
  10487. else {
  10488. if (this.isVertical) {
  10489. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10490. }
  10491. else {
  10492. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10493. }
  10494. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10495. context.shadowBlur = 0;
  10496. context.shadowOffsetX = 0;
  10497. context.shadowOffsetY = 0;
  10498. }
  10499. context.strokeStyle = this._borderColor;
  10500. if (this.isVertical) {
  10501. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10502. }
  10503. else {
  10504. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10505. }
  10506. }
  10507. }
  10508. context.restore();
  10509. };
  10510. return Slider;
  10511. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10512. /***/ }),
  10513. /***/ "./2D/controls/stackPanel.ts":
  10514. /*!***********************************!*\
  10515. !*** ./2D/controls/stackPanel.ts ***!
  10516. \***********************************/
  10517. /*! exports provided: StackPanel */
  10518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10519. "use strict";
  10520. __webpack_require__.r(__webpack_exports__);
  10521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10522. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10523. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  10524. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10525. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10526. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10527. /**
  10528. * Class used to create a 2D stack panel container
  10529. */
  10530. var StackPanel = /** @class */ (function (_super) {
  10531. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10532. /**
  10533. * Creates a new StackPanel
  10534. * @param name defines control name
  10535. */
  10536. function StackPanel(name) {
  10537. var _this = _super.call(this, name) || this;
  10538. _this.name = name;
  10539. _this._isVertical = true;
  10540. _this._manualWidth = false;
  10541. _this._manualHeight = false;
  10542. _this._doNotTrackManualChanges = false;
  10543. return _this;
  10544. }
  10545. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10546. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10547. get: function () {
  10548. return this._isVertical;
  10549. },
  10550. set: function (value) {
  10551. if (this._isVertical === value) {
  10552. return;
  10553. }
  10554. this._isVertical = value;
  10555. this._markAsDirty();
  10556. },
  10557. enumerable: true,
  10558. configurable: true
  10559. });
  10560. Object.defineProperty(StackPanel.prototype, "width", {
  10561. get: function () {
  10562. return this._width.toString(this._host);
  10563. },
  10564. /**
  10565. * Gets or sets panel width.
  10566. * This value should not be set when in horizontal mode as it will be computed automatically
  10567. */
  10568. set: function (value) {
  10569. if (!this._doNotTrackManualChanges) {
  10570. this._manualWidth = true;
  10571. }
  10572. if (this._width.toString(this._host) === value) {
  10573. return;
  10574. }
  10575. if (this._width.fromString(value)) {
  10576. this._markAsDirty();
  10577. }
  10578. },
  10579. enumerable: true,
  10580. configurable: true
  10581. });
  10582. Object.defineProperty(StackPanel.prototype, "height", {
  10583. get: function () {
  10584. return this._height.toString(this._host);
  10585. },
  10586. /**
  10587. * Gets or sets panel height.
  10588. * This value should not be set when in vertical mode as it will be computed automatically
  10589. */
  10590. set: function (value) {
  10591. if (!this._doNotTrackManualChanges) {
  10592. this._manualHeight = true;
  10593. }
  10594. if (this._height.toString(this._host) === value) {
  10595. return;
  10596. }
  10597. if (this._height.fromString(value)) {
  10598. this._markAsDirty();
  10599. }
  10600. },
  10601. enumerable: true,
  10602. configurable: true
  10603. });
  10604. StackPanel.prototype._getTypeName = function () {
  10605. return "StackPanel";
  10606. };
  10607. /** @hidden */
  10608. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10609. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10610. var child = _a[_i];
  10611. if (this._isVertical) {
  10612. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10613. }
  10614. else {
  10615. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10616. }
  10617. }
  10618. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10619. };
  10620. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10621. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10622. this._measureForChildren.copyFrom(parentMeasure);
  10623. this._measureForChildren.left = this._currentMeasure.left;
  10624. this._measureForChildren.top = this._currentMeasure.top;
  10625. if (!this.isVertical || this._manualWidth) {
  10626. this._measureForChildren.width = this._currentMeasure.width;
  10627. }
  10628. if (this.isVertical || this._manualHeight) {
  10629. this._measureForChildren.height = this._currentMeasure.height;
  10630. }
  10631. };
  10632. StackPanel.prototype._postMeasure = function () {
  10633. var stackWidth = 0;
  10634. var stackHeight = 0;
  10635. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10636. var child = _a[_i];
  10637. if (!child.isVisible || child.notRenderable) {
  10638. continue;
  10639. }
  10640. if (this._isVertical) {
  10641. if (child.top !== stackHeight + "px") {
  10642. child.top = stackHeight + "px";
  10643. this._rebuildLayout = true;
  10644. child._top.ignoreAdaptiveScaling = true;
  10645. }
  10646. if (child._height.isPercentage) {
  10647. 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");
  10648. }
  10649. else {
  10650. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10651. }
  10652. }
  10653. else {
  10654. if (child.left !== stackWidth + "px") {
  10655. child.left = stackWidth + "px";
  10656. this._rebuildLayout = true;
  10657. child._left.ignoreAdaptiveScaling = true;
  10658. }
  10659. if (child._width.isPercentage) {
  10660. 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");
  10661. }
  10662. else {
  10663. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10664. }
  10665. }
  10666. }
  10667. this._doNotTrackManualChanges = true;
  10668. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10669. // User can now define their own height and width for stack panel.
  10670. var panelWidthChanged = false;
  10671. var panelHeightChanged = false;
  10672. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10673. var previousHeight = this.height;
  10674. this.height = stackHeight + "px";
  10675. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10676. }
  10677. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10678. var previousWidth = this.width;
  10679. this.width = stackWidth + "px";
  10680. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10681. }
  10682. if (panelHeightChanged) {
  10683. this._height.ignoreAdaptiveScaling = true;
  10684. }
  10685. if (panelWidthChanged) {
  10686. this._width.ignoreAdaptiveScaling = true;
  10687. }
  10688. this._doNotTrackManualChanges = false;
  10689. if (panelWidthChanged || panelHeightChanged) {
  10690. this._rebuildLayout = true;
  10691. }
  10692. _super.prototype._postMeasure.call(this);
  10693. };
  10694. return StackPanel;
  10695. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10696. /***/ }),
  10697. /***/ "./2D/controls/statics.ts":
  10698. /*!********************************!*\
  10699. !*** ./2D/controls/statics.ts ***!
  10700. \********************************/
  10701. /*! exports provided: name */
  10702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10703. "use strict";
  10704. __webpack_require__.r(__webpack_exports__);
  10705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10706. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10707. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10708. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10709. /**
  10710. * Forcing an export so that this code will execute
  10711. * @hidden
  10712. */
  10713. var name = "Statics";
  10714. /**
  10715. * Creates a stack panel that can be used to render headers
  10716. * @param control defines the control to associate with the header
  10717. * @param text defines the text of the header
  10718. * @param size defines the size of the header
  10719. * @param options defines options used to configure the header
  10720. * @returns a new StackPanel
  10721. */
  10722. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10723. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10724. var isHorizontal = options ? options.isHorizontal : true;
  10725. var controlFirst = options ? options.controlFirst : true;
  10726. panel.isVertical = !isHorizontal;
  10727. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10728. header.text = text;
  10729. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10730. if (isHorizontal) {
  10731. header.width = size;
  10732. }
  10733. else {
  10734. header.height = size;
  10735. }
  10736. if (controlFirst) {
  10737. panel.addControl(control);
  10738. panel.addControl(header);
  10739. header.paddingLeft = "5px";
  10740. }
  10741. else {
  10742. panel.addControl(header);
  10743. panel.addControl(control);
  10744. header.paddingRight = "5px";
  10745. }
  10746. header.shadowBlur = control.shadowBlur;
  10747. header.shadowColor = control.shadowColor;
  10748. header.shadowOffsetX = control.shadowOffsetX;
  10749. header.shadowOffsetY = control.shadowOffsetY;
  10750. return panel;
  10751. };
  10752. /***/ }),
  10753. /***/ "./2D/controls/textBlock.ts":
  10754. /*!**********************************!*\
  10755. !*** ./2D/controls/textBlock.ts ***!
  10756. \**********************************/
  10757. /*! exports provided: TextWrapping, TextBlock */
  10758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10759. "use strict";
  10760. __webpack_require__.r(__webpack_exports__);
  10761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10763. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10764. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  10765. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10766. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10767. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10768. /**
  10769. * Enum that determines the text-wrapping mode to use.
  10770. */
  10771. var TextWrapping;
  10772. (function (TextWrapping) {
  10773. /**
  10774. * Clip the text when it's larger than Control.width; this is the default mode.
  10775. */
  10776. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10777. /**
  10778. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10779. */
  10780. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10781. /**
  10782. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10783. */
  10784. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10785. })(TextWrapping || (TextWrapping = {}));
  10786. /**
  10787. * Class used to create text block control
  10788. */
  10789. var TextBlock = /** @class */ (function (_super) {
  10790. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10791. /**
  10792. * Creates a new TextBlock object
  10793. * @param name defines the name of the control
  10794. * @param text defines the text to display (emptry string by default)
  10795. */
  10796. function TextBlock(
  10797. /**
  10798. * Defines the name of the control
  10799. */
  10800. name, text) {
  10801. if (text === void 0) { text = ""; }
  10802. var _this = _super.call(this, name) || this;
  10803. _this.name = name;
  10804. _this._text = "";
  10805. _this._textWrapping = TextWrapping.Clip;
  10806. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10807. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10808. _this._resizeToFit = false;
  10809. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10810. _this._outlineWidth = 0;
  10811. _this._outlineColor = "white";
  10812. /**
  10813. * An event triggered after the text is changed
  10814. */
  10815. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10816. /**
  10817. * An event triggered after the text was broken up into lines
  10818. */
  10819. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10820. _this.text = text;
  10821. return _this;
  10822. }
  10823. Object.defineProperty(TextBlock.prototype, "lines", {
  10824. /**
  10825. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10826. */
  10827. get: function () {
  10828. return this._lines;
  10829. },
  10830. enumerable: true,
  10831. configurable: true
  10832. });
  10833. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10834. /**
  10835. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10836. */
  10837. get: function () {
  10838. return this._resizeToFit;
  10839. },
  10840. /**
  10841. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10842. */
  10843. set: function (value) {
  10844. if (this._resizeToFit === value) {
  10845. return;
  10846. }
  10847. this._resizeToFit = value;
  10848. if (this._resizeToFit) {
  10849. this._width.ignoreAdaptiveScaling = true;
  10850. this._height.ignoreAdaptiveScaling = true;
  10851. }
  10852. this._markAsDirty();
  10853. },
  10854. enumerable: true,
  10855. configurable: true
  10856. });
  10857. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10858. /**
  10859. * Gets or sets a boolean indicating if text must be wrapped
  10860. */
  10861. get: function () {
  10862. return this._textWrapping;
  10863. },
  10864. /**
  10865. * Gets or sets a boolean indicating if text must be wrapped
  10866. */
  10867. set: function (value) {
  10868. if (this._textWrapping === value) {
  10869. return;
  10870. }
  10871. this._textWrapping = +value;
  10872. this._markAsDirty();
  10873. },
  10874. enumerable: true,
  10875. configurable: true
  10876. });
  10877. Object.defineProperty(TextBlock.prototype, "text", {
  10878. /**
  10879. * Gets or sets text to display
  10880. */
  10881. get: function () {
  10882. return this._text;
  10883. },
  10884. /**
  10885. * Gets or sets text to display
  10886. */
  10887. set: function (value) {
  10888. if (this._text === value) {
  10889. return;
  10890. }
  10891. this._text = value;
  10892. this._markAsDirty();
  10893. this.onTextChangedObservable.notifyObservers(this);
  10894. },
  10895. enumerable: true,
  10896. configurable: true
  10897. });
  10898. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10899. /**
  10900. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10901. */
  10902. get: function () {
  10903. return this._textHorizontalAlignment;
  10904. },
  10905. /**
  10906. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10907. */
  10908. set: function (value) {
  10909. if (this._textHorizontalAlignment === value) {
  10910. return;
  10911. }
  10912. this._textHorizontalAlignment = value;
  10913. this._markAsDirty();
  10914. },
  10915. enumerable: true,
  10916. configurable: true
  10917. });
  10918. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10919. /**
  10920. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10921. */
  10922. get: function () {
  10923. return this._textVerticalAlignment;
  10924. },
  10925. /**
  10926. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10927. */
  10928. set: function (value) {
  10929. if (this._textVerticalAlignment === value) {
  10930. return;
  10931. }
  10932. this._textVerticalAlignment = value;
  10933. this._markAsDirty();
  10934. },
  10935. enumerable: true,
  10936. configurable: true
  10937. });
  10938. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10939. /**
  10940. * Gets or sets line spacing value
  10941. */
  10942. get: function () {
  10943. return this._lineSpacing.toString(this._host);
  10944. },
  10945. /**
  10946. * Gets or sets line spacing value
  10947. */
  10948. set: function (value) {
  10949. if (this._lineSpacing.fromString(value)) {
  10950. this._markAsDirty();
  10951. }
  10952. },
  10953. enumerable: true,
  10954. configurable: true
  10955. });
  10956. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10957. /**
  10958. * Gets or sets outlineWidth of the text to display
  10959. */
  10960. get: function () {
  10961. return this._outlineWidth;
  10962. },
  10963. /**
  10964. * Gets or sets outlineWidth of the text to display
  10965. */
  10966. set: function (value) {
  10967. if (this._outlineWidth === value) {
  10968. return;
  10969. }
  10970. this._outlineWidth = value;
  10971. this._markAsDirty();
  10972. },
  10973. enumerable: true,
  10974. configurable: true
  10975. });
  10976. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  10977. /**
  10978. * Gets or sets outlineColor of the text to display
  10979. */
  10980. get: function () {
  10981. return this._outlineColor;
  10982. },
  10983. /**
  10984. * Gets or sets outlineColor of the text to display
  10985. */
  10986. set: function (value) {
  10987. if (this._outlineColor === value) {
  10988. return;
  10989. }
  10990. this._outlineColor = value;
  10991. this._markAsDirty();
  10992. },
  10993. enumerable: true,
  10994. configurable: true
  10995. });
  10996. TextBlock.prototype._getTypeName = function () {
  10997. return "TextBlock";
  10998. };
  10999. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11000. if (!this._fontOffset) {
  11001. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11002. }
  11003. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11004. // Prepare lines
  11005. this._lines = this._breakLines(this._currentMeasure.width, context);
  11006. this.onLinesReadyObservable.notifyObservers(this);
  11007. var maxLineWidth = 0;
  11008. for (var i = 0; i < this._lines.length; i++) {
  11009. var line = this._lines[i];
  11010. if (line.width > maxLineWidth) {
  11011. maxLineWidth = line.width;
  11012. }
  11013. }
  11014. if (this._resizeToFit) {
  11015. if (this._textWrapping === TextWrapping.Clip) {
  11016. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11017. if (newWidth !== this._width.internalValue) {
  11018. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11019. this._rebuildLayout = true;
  11020. }
  11021. }
  11022. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11023. if (newHeight !== this._height.internalValue) {
  11024. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11025. this._rebuildLayout = true;
  11026. }
  11027. }
  11028. };
  11029. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11030. var width = this._currentMeasure.width;
  11031. var x = 0;
  11032. switch (this._textHorizontalAlignment) {
  11033. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11034. x = 0;
  11035. break;
  11036. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11037. x = width - textWidth;
  11038. break;
  11039. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11040. x = (width - textWidth) / 2;
  11041. break;
  11042. }
  11043. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11044. context.shadowColor = this.shadowColor;
  11045. context.shadowBlur = this.shadowBlur;
  11046. context.shadowOffsetX = this.shadowOffsetX;
  11047. context.shadowOffsetY = this.shadowOffsetY;
  11048. }
  11049. if (this.outlineWidth) {
  11050. context.strokeText(text, this._currentMeasure.left + x, y);
  11051. }
  11052. context.fillText(text, this._currentMeasure.left + x, y);
  11053. };
  11054. /** @hidden */
  11055. TextBlock.prototype._draw = function (context) {
  11056. context.save();
  11057. this._applyStates(context);
  11058. // Render lines
  11059. this._renderLines(context);
  11060. context.restore();
  11061. };
  11062. TextBlock.prototype._applyStates = function (context) {
  11063. _super.prototype._applyStates.call(this, context);
  11064. if (this.outlineWidth) {
  11065. context.lineWidth = this.outlineWidth;
  11066. context.strokeStyle = this.outlineColor;
  11067. }
  11068. };
  11069. TextBlock.prototype._breakLines = function (refWidth, context) {
  11070. var lines = [];
  11071. var _lines = this.text.split("\n");
  11072. if (this._textWrapping === TextWrapping.Ellipsis) {
  11073. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11074. var _line = _lines_1[_i];
  11075. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11076. }
  11077. }
  11078. else if (this._textWrapping === TextWrapping.WordWrap) {
  11079. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11080. var _line = _lines_2[_a];
  11081. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11082. }
  11083. }
  11084. else {
  11085. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11086. var _line = _lines_3[_b];
  11087. lines.push(this._parseLine(_line, context));
  11088. }
  11089. }
  11090. return lines;
  11091. };
  11092. TextBlock.prototype._parseLine = function (line, context) {
  11093. if (line === void 0) { line = ''; }
  11094. return { text: line, width: context.measureText(line).width };
  11095. };
  11096. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11097. if (line === void 0) { line = ''; }
  11098. var lineWidth = context.measureText(line).width;
  11099. if (lineWidth > width) {
  11100. line += '…';
  11101. }
  11102. while (line.length > 2 && lineWidth > width) {
  11103. line = line.slice(0, -2) + '…';
  11104. lineWidth = context.measureText(line).width;
  11105. }
  11106. return { text: line, width: lineWidth };
  11107. };
  11108. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11109. if (line === void 0) { line = ''; }
  11110. var lines = [];
  11111. var words = line.split(' ');
  11112. var lineWidth = 0;
  11113. for (var n = 0; n < words.length; n++) {
  11114. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11115. var metrics = context.measureText(testLine);
  11116. var testWidth = metrics.width;
  11117. if (testWidth > width && n > 0) {
  11118. lines.push({ text: line, width: lineWidth });
  11119. line = words[n];
  11120. lineWidth = context.measureText(line).width;
  11121. }
  11122. else {
  11123. lineWidth = testWidth;
  11124. line = testLine;
  11125. }
  11126. }
  11127. lines.push({ text: line, width: lineWidth });
  11128. return lines;
  11129. };
  11130. TextBlock.prototype._renderLines = function (context) {
  11131. var height = this._currentMeasure.height;
  11132. var rootY = 0;
  11133. switch (this._textVerticalAlignment) {
  11134. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11135. rootY = this._fontOffset.ascent;
  11136. break;
  11137. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11138. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11139. break;
  11140. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11141. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11142. break;
  11143. }
  11144. rootY += this._currentMeasure.top;
  11145. for (var i = 0; i < this._lines.length; i++) {
  11146. var line = this._lines[i];
  11147. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11148. if (this._lineSpacing.isPixel) {
  11149. rootY += this._lineSpacing.getValue(this._host);
  11150. }
  11151. else {
  11152. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11153. }
  11154. }
  11155. this._drawText(line.text, line.width, rootY, context);
  11156. rootY += this._fontOffset.height;
  11157. }
  11158. };
  11159. /**
  11160. * Given a width constraint applied on the text block, find the expected height
  11161. * @returns expected height
  11162. */
  11163. TextBlock.prototype.computeExpectedHeight = function () {
  11164. if (this.text && this.widthInPixels) {
  11165. var context_1 = document.createElement('canvas').getContext('2d');
  11166. if (context_1) {
  11167. this._applyStates(context_1);
  11168. if (!this._fontOffset) {
  11169. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11170. }
  11171. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11172. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11173. }
  11174. }
  11175. return 0;
  11176. };
  11177. TextBlock.prototype.dispose = function () {
  11178. _super.prototype.dispose.call(this);
  11179. this.onTextChangedObservable.clear();
  11180. };
  11181. return TextBlock;
  11182. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11183. /***/ }),
  11184. /***/ "./2D/controls/virtualKeyboard.ts":
  11185. /*!****************************************!*\
  11186. !*** ./2D/controls/virtualKeyboard.ts ***!
  11187. \****************************************/
  11188. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11190. "use strict";
  11191. __webpack_require__.r(__webpack_exports__);
  11192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11194. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11195. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  11196. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11197. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11198. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11199. /**
  11200. * Class used to store key control properties
  11201. */
  11202. var KeyPropertySet = /** @class */ (function () {
  11203. function KeyPropertySet() {
  11204. }
  11205. return KeyPropertySet;
  11206. }());
  11207. /**
  11208. * Class used to create virtual keyboard
  11209. */
  11210. var VirtualKeyboard = /** @class */ (function (_super) {
  11211. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11212. function VirtualKeyboard() {
  11213. var _this = _super !== null && _super.apply(this, arguments) || this;
  11214. /** Observable raised when a key is pressed */
  11215. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11216. /** Gets or sets default key button width */
  11217. _this.defaultButtonWidth = "40px";
  11218. /** Gets or sets default key button height */
  11219. _this.defaultButtonHeight = "40px";
  11220. /** Gets or sets default key button left padding */
  11221. _this.defaultButtonPaddingLeft = "2px";
  11222. /** Gets or sets default key button right padding */
  11223. _this.defaultButtonPaddingRight = "2px";
  11224. /** Gets or sets default key button top padding */
  11225. _this.defaultButtonPaddingTop = "2px";
  11226. /** Gets or sets default key button bottom padding */
  11227. _this.defaultButtonPaddingBottom = "2px";
  11228. /** Gets or sets default key button foreground color */
  11229. _this.defaultButtonColor = "#DDD";
  11230. /** Gets or sets default key button background color */
  11231. _this.defaultButtonBackground = "#070707";
  11232. /** Gets or sets shift button foreground color */
  11233. _this.shiftButtonColor = "#7799FF";
  11234. /** Gets or sets shift button thickness*/
  11235. _this.selectedShiftThickness = 1;
  11236. /** Gets shift key state */
  11237. _this.shiftState = 0;
  11238. _this._currentlyConnectedInputText = null;
  11239. _this._connectedInputTexts = [];
  11240. _this._onKeyPressObserver = null;
  11241. return _this;
  11242. }
  11243. VirtualKeyboard.prototype._getTypeName = function () {
  11244. return "VirtualKeyboard";
  11245. };
  11246. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11247. var _this = this;
  11248. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11249. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11250. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11251. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11252. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11253. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11254. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11255. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11256. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11257. button.thickness = 0;
  11258. button.isFocusInvisible = true;
  11259. button.shadowColor = this.shadowColor;
  11260. button.shadowBlur = this.shadowBlur;
  11261. button.shadowOffsetX = this.shadowOffsetX;
  11262. button.shadowOffsetY = this.shadowOffsetY;
  11263. button.onPointerUpObservable.add(function () {
  11264. _this.onKeyPressObservable.notifyObservers(key);
  11265. });
  11266. return button;
  11267. };
  11268. /**
  11269. * Adds a new row of keys
  11270. * @param keys defines the list of keys to add
  11271. * @param propertySets defines the associated property sets
  11272. */
  11273. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11274. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11275. panel.isVertical = false;
  11276. panel.isFocusInvisible = true;
  11277. for (var i = 0; i < keys.length; i++) {
  11278. var properties = null;
  11279. if (propertySets && propertySets.length === keys.length) {
  11280. properties = propertySets[i];
  11281. }
  11282. panel.addControl(this._createKey(keys[i], properties));
  11283. }
  11284. this.addControl(panel);
  11285. };
  11286. /**
  11287. * Set the shift key to a specific state
  11288. * @param shiftState defines the new shift state
  11289. */
  11290. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11291. if (!this.children) {
  11292. return;
  11293. }
  11294. for (var i = 0; i < this.children.length; i++) {
  11295. var row = this.children[i];
  11296. if (!row || !row.children) {
  11297. continue;
  11298. }
  11299. var rowContainer = row;
  11300. for (var j = 0; j < rowContainer.children.length; j++) {
  11301. var button = rowContainer.children[j];
  11302. if (!button || !button.children[0]) {
  11303. continue;
  11304. }
  11305. var button_tblock = button.children[0];
  11306. if (button_tblock.text === "\u21E7") {
  11307. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11308. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11309. }
  11310. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11311. }
  11312. }
  11313. };
  11314. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11315. /** Gets the input text control currently attached to the keyboard */
  11316. get: function () {
  11317. return this._currentlyConnectedInputText;
  11318. },
  11319. enumerable: true,
  11320. configurable: true
  11321. });
  11322. /**
  11323. * Connects the keyboard with an input text control
  11324. *
  11325. * @param input defines the target control
  11326. */
  11327. VirtualKeyboard.prototype.connect = function (input) {
  11328. var _this = this;
  11329. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11330. if (inputTextAlreadyConnected) {
  11331. return;
  11332. }
  11333. if (this._onKeyPressObserver === null) {
  11334. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11335. if (!_this._currentlyConnectedInputText) {
  11336. return;
  11337. }
  11338. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11339. switch (key) {
  11340. case "\u21E7":
  11341. _this.shiftState++;
  11342. if (_this.shiftState > 2) {
  11343. _this.shiftState = 0;
  11344. }
  11345. _this.applyShiftState(_this.shiftState);
  11346. return;
  11347. case "\u2190":
  11348. _this._currentlyConnectedInputText.processKey(8);
  11349. return;
  11350. case "\u21B5":
  11351. _this._currentlyConnectedInputText.processKey(13);
  11352. return;
  11353. }
  11354. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11355. if (_this.shiftState === 1) {
  11356. _this.shiftState = 0;
  11357. _this.applyShiftState(_this.shiftState);
  11358. }
  11359. });
  11360. }
  11361. this.isVisible = false;
  11362. this._currentlyConnectedInputText = input;
  11363. input._connectedVirtualKeyboard = this;
  11364. // Events hooking
  11365. var onFocusObserver = input.onFocusObservable.add(function () {
  11366. _this._currentlyConnectedInputText = input;
  11367. input._connectedVirtualKeyboard = _this;
  11368. _this.isVisible = true;
  11369. });
  11370. var onBlurObserver = input.onBlurObservable.add(function () {
  11371. input._connectedVirtualKeyboard = null;
  11372. _this._currentlyConnectedInputText = null;
  11373. _this.isVisible = false;
  11374. });
  11375. this._connectedInputTexts.push({
  11376. input: input,
  11377. onBlurObserver: onBlurObserver,
  11378. onFocusObserver: onFocusObserver
  11379. });
  11380. };
  11381. /**
  11382. * Disconnects the keyboard from connected InputText controls
  11383. *
  11384. * @param input optionally defines a target control, otherwise all are disconnected
  11385. */
  11386. VirtualKeyboard.prototype.disconnect = function (input) {
  11387. var _this = this;
  11388. if (input) {
  11389. // .find not available on IE
  11390. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11391. if (filtered.length === 1) {
  11392. this._removeConnectedInputObservables(filtered[0]);
  11393. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11394. if (this._currentlyConnectedInputText === input) {
  11395. this._currentlyConnectedInputText = null;
  11396. }
  11397. }
  11398. }
  11399. else {
  11400. this._connectedInputTexts.forEach(function (connectedInputText) {
  11401. _this._removeConnectedInputObservables(connectedInputText);
  11402. });
  11403. this._connectedInputTexts = [];
  11404. }
  11405. if (this._connectedInputTexts.length === 0) {
  11406. this._currentlyConnectedInputText = null;
  11407. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11408. this._onKeyPressObserver = null;
  11409. }
  11410. };
  11411. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11412. connectedInputText.input._connectedVirtualKeyboard = null;
  11413. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11414. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11415. };
  11416. /**
  11417. * Release all resources
  11418. */
  11419. VirtualKeyboard.prototype.dispose = function () {
  11420. _super.prototype.dispose.call(this);
  11421. this.disconnect();
  11422. };
  11423. // Statics
  11424. /**
  11425. * Creates a new keyboard using a default layout
  11426. *
  11427. * @param name defines control name
  11428. * @returns a new VirtualKeyboard
  11429. */
  11430. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11431. var returnValue = new VirtualKeyboard(name);
  11432. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11433. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11434. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11435. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11436. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11437. return returnValue;
  11438. };
  11439. return VirtualKeyboard;
  11440. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11441. /***/ }),
  11442. /***/ "./2D/index.ts":
  11443. /*!*********************!*\
  11444. !*** ./2D/index.ts ***!
  11445. \*********************/
  11446. /*! 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 */
  11447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11448. "use strict";
  11449. __webpack_require__.r(__webpack_exports__);
  11450. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11482. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11484. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11486. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11489. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11491. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11493. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11495. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11497. /***/ }),
  11498. /***/ "./2D/math2D.ts":
  11499. /*!**********************!*\
  11500. !*** ./2D/math2D.ts ***!
  11501. \**********************/
  11502. /*! exports provided: Vector2WithInfo, Matrix2D */
  11503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11504. "use strict";
  11505. __webpack_require__.r(__webpack_exports__);
  11506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11508. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11509. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11510. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11511. /**
  11512. * Class used to transport Vector2 information for pointer events
  11513. */
  11514. var Vector2WithInfo = /** @class */ (function (_super) {
  11515. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11516. /**
  11517. * Creates a new Vector2WithInfo
  11518. * @param source defines the vector2 data to transport
  11519. * @param buttonIndex defines the current mouse button index
  11520. */
  11521. function Vector2WithInfo(source,
  11522. /** defines the current mouse button index */
  11523. buttonIndex) {
  11524. if (buttonIndex === void 0) { buttonIndex = 0; }
  11525. var _this = _super.call(this, source.x, source.y) || this;
  11526. _this.buttonIndex = buttonIndex;
  11527. return _this;
  11528. }
  11529. return Vector2WithInfo;
  11530. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11531. /** Class used to provide 2D matrix features */
  11532. var Matrix2D = /** @class */ (function () {
  11533. /**
  11534. * Creates a new matrix
  11535. * @param m00 defines value for (0, 0)
  11536. * @param m01 defines value for (0, 1)
  11537. * @param m10 defines value for (1, 0)
  11538. * @param m11 defines value for (1, 1)
  11539. * @param m20 defines value for (2, 0)
  11540. * @param m21 defines value for (2, 1)
  11541. */
  11542. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11543. /** Gets the internal array of 6 floats used to store matrix data */
  11544. this.m = new Float32Array(6);
  11545. this.fromValues(m00, m01, m10, m11, m20, m21);
  11546. }
  11547. /**
  11548. * Fills the matrix from direct values
  11549. * @param m00 defines value for (0, 0)
  11550. * @param m01 defines value for (0, 1)
  11551. * @param m10 defines value for (1, 0)
  11552. * @param m11 defines value for (1, 1)
  11553. * @param m20 defines value for (2, 0)
  11554. * @param m21 defines value for (2, 1)
  11555. * @returns the current modified matrix
  11556. */
  11557. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11558. this.m[0] = m00;
  11559. this.m[1] = m01;
  11560. this.m[2] = m10;
  11561. this.m[3] = m11;
  11562. this.m[4] = m20;
  11563. this.m[5] = m21;
  11564. return this;
  11565. };
  11566. /**
  11567. * Gets matrix determinant
  11568. * @returns the determinant
  11569. */
  11570. Matrix2D.prototype.determinant = function () {
  11571. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11572. };
  11573. /**
  11574. * Inverses the matrix and stores it in a target matrix
  11575. * @param result defines the target matrix
  11576. * @returns the current matrix
  11577. */
  11578. Matrix2D.prototype.invertToRef = function (result) {
  11579. var l0 = this.m[0];
  11580. var l1 = this.m[1];
  11581. var l2 = this.m[2];
  11582. var l3 = this.m[3];
  11583. var l4 = this.m[4];
  11584. var l5 = this.m[5];
  11585. var det = this.determinant();
  11586. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11587. result.m[0] = 0;
  11588. result.m[1] = 0;
  11589. result.m[2] = 0;
  11590. result.m[3] = 0;
  11591. result.m[4] = 0;
  11592. result.m[5] = 0;
  11593. return this;
  11594. }
  11595. var detDiv = 1 / det;
  11596. var det4 = l2 * l5 - l3 * l4;
  11597. var det5 = l1 * l4 - l0 * l5;
  11598. result.m[0] = l3 * detDiv;
  11599. result.m[1] = -l1 * detDiv;
  11600. result.m[2] = -l2 * detDiv;
  11601. result.m[3] = l0 * detDiv;
  11602. result.m[4] = det4 * detDiv;
  11603. result.m[5] = det5 * detDiv;
  11604. return this;
  11605. };
  11606. /**
  11607. * Multiplies the current matrix with another one
  11608. * @param other defines the second operand
  11609. * @param result defines the target matrix
  11610. * @returns the current matrix
  11611. */
  11612. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11613. var l0 = this.m[0];
  11614. var l1 = this.m[1];
  11615. var l2 = this.m[2];
  11616. var l3 = this.m[3];
  11617. var l4 = this.m[4];
  11618. var l5 = this.m[5];
  11619. var r0 = other.m[0];
  11620. var r1 = other.m[1];
  11621. var r2 = other.m[2];
  11622. var r3 = other.m[3];
  11623. var r4 = other.m[4];
  11624. var r5 = other.m[5];
  11625. result.m[0] = l0 * r0 + l1 * r2;
  11626. result.m[1] = l0 * r1 + l1 * r3;
  11627. result.m[2] = l2 * r0 + l3 * r2;
  11628. result.m[3] = l2 * r1 + l3 * r3;
  11629. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11630. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11631. return this;
  11632. };
  11633. /**
  11634. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11635. * @param x defines the x coordinate to transform
  11636. * @param y defines the x coordinate to transform
  11637. * @param result defines the target vector2
  11638. * @returns the current matrix
  11639. */
  11640. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11641. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11642. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11643. return this;
  11644. };
  11645. // Statics
  11646. /**
  11647. * Creates an identity matrix
  11648. * @returns a new matrix
  11649. */
  11650. Matrix2D.Identity = function () {
  11651. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11652. };
  11653. /**
  11654. * Creates a translation matrix and stores it in a target matrix
  11655. * @param x defines the x coordinate of the translation
  11656. * @param y defines the y coordinate of the translation
  11657. * @param result defines the target matrix
  11658. */
  11659. Matrix2D.TranslationToRef = function (x, y, result) {
  11660. result.fromValues(1, 0, 0, 1, x, y);
  11661. };
  11662. /**
  11663. * Creates a scaling matrix and stores it in a target matrix
  11664. * @param x defines the x coordinate of the scaling
  11665. * @param y defines the y coordinate of the scaling
  11666. * @param result defines the target matrix
  11667. */
  11668. Matrix2D.ScalingToRef = function (x, y, result) {
  11669. result.fromValues(x, 0, 0, y, 0, 0);
  11670. };
  11671. /**
  11672. * Creates a rotation matrix and stores it in a target matrix
  11673. * @param angle defines the rotation angle
  11674. * @param result defines the target matrix
  11675. */
  11676. Matrix2D.RotationToRef = function (angle, result) {
  11677. var s = Math.sin(angle);
  11678. var c = Math.cos(angle);
  11679. result.fromValues(c, s, -s, c, 0, 0);
  11680. };
  11681. /**
  11682. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11683. * @param tx defines the x coordinate of the translation
  11684. * @param ty defines the y coordinate of the translation
  11685. * @param angle defines the rotation angle
  11686. * @param scaleX defines the x coordinate of the scaling
  11687. * @param scaleY defines the y coordinate of the scaling
  11688. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11689. * @param result defines the target matrix
  11690. */
  11691. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11692. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11693. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11694. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11695. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11696. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11697. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11698. if (parentMatrix) {
  11699. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11700. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11701. }
  11702. else {
  11703. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11704. }
  11705. };
  11706. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11707. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11708. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11709. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11710. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11711. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11712. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11713. return Matrix2D;
  11714. }());
  11715. /***/ }),
  11716. /***/ "./2D/measure.ts":
  11717. /*!***********************!*\
  11718. !*** ./2D/measure.ts ***!
  11719. \***********************/
  11720. /*! exports provided: Measure */
  11721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11722. "use strict";
  11723. __webpack_require__.r(__webpack_exports__);
  11724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11725. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11726. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11727. /**
  11728. * Class used to store 2D control sizes
  11729. */
  11730. var Measure = /** @class */ (function () {
  11731. /**
  11732. * Creates a new measure
  11733. * @param left defines left coordinate
  11734. * @param top defines top coordinate
  11735. * @param width defines width dimension
  11736. * @param height defines height dimension
  11737. */
  11738. function Measure(
  11739. /** defines left coordinate */
  11740. left,
  11741. /** defines top coordinate */
  11742. top,
  11743. /** defines width dimension */
  11744. width,
  11745. /** defines height dimension */
  11746. height) {
  11747. this.left = left;
  11748. this.top = top;
  11749. this.width = width;
  11750. this.height = height;
  11751. }
  11752. /**
  11753. * Copy from another measure
  11754. * @param other defines the other measure to copy from
  11755. */
  11756. Measure.prototype.copyFrom = function (other) {
  11757. this.left = other.left;
  11758. this.top = other.top;
  11759. this.width = other.width;
  11760. this.height = other.height;
  11761. };
  11762. /**
  11763. * Copy from a group of 4 floats
  11764. * @param left defines left coordinate
  11765. * @param top defines top coordinate
  11766. * @param width defines width dimension
  11767. * @param height defines height dimension
  11768. */
  11769. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11770. this.left = left;
  11771. this.top = top;
  11772. this.width = width;
  11773. this.height = height;
  11774. };
  11775. /**
  11776. * Computes the axis aligned bounding box measure for two given measures
  11777. * @param a Input measure
  11778. * @param b Input measure
  11779. * @param result the resulting bounding measure
  11780. */
  11781. Measure.CombineToRef = function (a, b, result) {
  11782. var left = Math.min(a.left, b.left);
  11783. var top = Math.min(a.top, b.top);
  11784. var right = Math.max(a.left + a.width, b.left + b.width);
  11785. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11786. result.left = left;
  11787. result.top = top;
  11788. result.width = right - left;
  11789. result.height = bottom - top;
  11790. };
  11791. /**
  11792. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11793. * @param transform the matrix to transform the measure before computing the AABB
  11794. * @param result the resulting AABB
  11795. */
  11796. Measure.prototype.transformToRef = function (transform, result) {
  11797. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11798. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11799. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11800. for (var i = 0; i < 4; i++) {
  11801. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11802. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11803. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11804. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11805. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11806. }
  11807. result.left = min.x;
  11808. result.top = min.y;
  11809. result.width = max.x - min.x;
  11810. result.height = max.y - min.y;
  11811. };
  11812. /**
  11813. * Check equality between this measure and another one
  11814. * @param other defines the other measures
  11815. * @returns true if both measures are equals
  11816. */
  11817. Measure.prototype.isEqualsTo = function (other) {
  11818. if (this.left !== other.left) {
  11819. return false;
  11820. }
  11821. if (this.top !== other.top) {
  11822. return false;
  11823. }
  11824. if (this.width !== other.width) {
  11825. return false;
  11826. }
  11827. if (this.height !== other.height) {
  11828. return false;
  11829. }
  11830. return true;
  11831. };
  11832. /**
  11833. * Creates an empty measure
  11834. * @returns a new measure
  11835. */
  11836. Measure.Empty = function () {
  11837. return new Measure(0, 0, 0, 0);
  11838. };
  11839. return Measure;
  11840. }());
  11841. /***/ }),
  11842. /***/ "./2D/multiLinePoint.ts":
  11843. /*!******************************!*\
  11844. !*** ./2D/multiLinePoint.ts ***!
  11845. \******************************/
  11846. /*! exports provided: MultiLinePoint */
  11847. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11848. "use strict";
  11849. __webpack_require__.r(__webpack_exports__);
  11850. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11851. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11852. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11853. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11854. /**
  11855. * Class used to store a point for a MultiLine object.
  11856. * The point can be pure 2D coordinates, a mesh or a control
  11857. */
  11858. var MultiLinePoint = /** @class */ (function () {
  11859. /**
  11860. * Creates a new MultiLinePoint
  11861. * @param multiLine defines the source MultiLine object
  11862. */
  11863. function MultiLinePoint(multiLine) {
  11864. this._multiLine = multiLine;
  11865. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11866. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11867. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11868. }
  11869. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11870. /** Gets or sets x coordinate */
  11871. get: function () {
  11872. return this._x.toString(this._multiLine._host);
  11873. },
  11874. set: function (value) {
  11875. if (this._x.toString(this._multiLine._host) === value) {
  11876. return;
  11877. }
  11878. if (this._x.fromString(value)) {
  11879. this._multiLine._markAsDirty();
  11880. }
  11881. },
  11882. enumerable: true,
  11883. configurable: true
  11884. });
  11885. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11886. /** Gets or sets y coordinate */
  11887. get: function () {
  11888. return this._y.toString(this._multiLine._host);
  11889. },
  11890. set: function (value) {
  11891. if (this._y.toString(this._multiLine._host) === value) {
  11892. return;
  11893. }
  11894. if (this._y.fromString(value)) {
  11895. this._multiLine._markAsDirty();
  11896. }
  11897. },
  11898. enumerable: true,
  11899. configurable: true
  11900. });
  11901. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11902. /** Gets or sets the control associated with this point */
  11903. get: function () {
  11904. return this._control;
  11905. },
  11906. set: function (value) {
  11907. if (this._control === value) {
  11908. return;
  11909. }
  11910. if (this._control && this._controlObserver) {
  11911. this._control.onDirtyObservable.remove(this._controlObserver);
  11912. this._controlObserver = null;
  11913. }
  11914. this._control = value;
  11915. if (this._control) {
  11916. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11917. }
  11918. this._multiLine._markAsDirty();
  11919. },
  11920. enumerable: true,
  11921. configurable: true
  11922. });
  11923. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11924. /** Gets or sets the mesh associated with this point */
  11925. get: function () {
  11926. return this._mesh;
  11927. },
  11928. set: function (value) {
  11929. if (this._mesh === value) {
  11930. return;
  11931. }
  11932. if (this._mesh && this._meshObserver) {
  11933. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11934. }
  11935. this._mesh = value;
  11936. if (this._mesh) {
  11937. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11938. }
  11939. this._multiLine._markAsDirty();
  11940. },
  11941. enumerable: true,
  11942. configurable: true
  11943. });
  11944. /** Resets links */
  11945. MultiLinePoint.prototype.resetLinks = function () {
  11946. this.control = null;
  11947. this.mesh = null;
  11948. };
  11949. /**
  11950. * Gets a translation vector
  11951. * @returns the translation vector
  11952. */
  11953. MultiLinePoint.prototype.translate = function () {
  11954. this._point = this._translatePoint();
  11955. return this._point;
  11956. };
  11957. MultiLinePoint.prototype._translatePoint = function () {
  11958. if (this._mesh != null) {
  11959. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  11960. }
  11961. else if (this._control != null) {
  11962. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  11963. }
  11964. else {
  11965. var host = this._multiLine._host;
  11966. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  11967. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  11968. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  11969. }
  11970. };
  11971. /** Release associated resources */
  11972. MultiLinePoint.prototype.dispose = function () {
  11973. this.resetLinks();
  11974. };
  11975. return MultiLinePoint;
  11976. }());
  11977. /***/ }),
  11978. /***/ "./2D/style.ts":
  11979. /*!*********************!*\
  11980. !*** ./2D/style.ts ***!
  11981. \*********************/
  11982. /*! exports provided: Style */
  11983. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11984. "use strict";
  11985. __webpack_require__.r(__webpack_exports__);
  11986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  11987. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  11988. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  11989. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11990. /**
  11991. * Define a style used by control to automatically setup properties based on a template.
  11992. * Only support font related properties so far
  11993. */
  11994. var Style = /** @class */ (function () {
  11995. /**
  11996. * Creates a new style object
  11997. * @param host defines the AdvancedDynamicTexture which hosts this style
  11998. */
  11999. function Style(host) {
  12000. this._fontFamily = "Arial";
  12001. this._fontStyle = "";
  12002. this._fontWeight = "";
  12003. /** @hidden */
  12004. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12005. /**
  12006. * Observable raised when the style values are changed
  12007. */
  12008. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12009. this._host = host;
  12010. }
  12011. Object.defineProperty(Style.prototype, "fontSize", {
  12012. /**
  12013. * Gets or sets the font size
  12014. */
  12015. get: function () {
  12016. return this._fontSize.toString(this._host);
  12017. },
  12018. set: function (value) {
  12019. if (this._fontSize.toString(this._host) === value) {
  12020. return;
  12021. }
  12022. if (this._fontSize.fromString(value)) {
  12023. this.onChangedObservable.notifyObservers(this);
  12024. }
  12025. },
  12026. enumerable: true,
  12027. configurable: true
  12028. });
  12029. Object.defineProperty(Style.prototype, "fontFamily", {
  12030. /**
  12031. * Gets or sets the font family
  12032. */
  12033. get: function () {
  12034. return this._fontFamily;
  12035. },
  12036. set: function (value) {
  12037. if (this._fontFamily === value) {
  12038. return;
  12039. }
  12040. this._fontFamily = value;
  12041. this.onChangedObservable.notifyObservers(this);
  12042. },
  12043. enumerable: true,
  12044. configurable: true
  12045. });
  12046. Object.defineProperty(Style.prototype, "fontStyle", {
  12047. /**
  12048. * Gets or sets the font style
  12049. */
  12050. get: function () {
  12051. return this._fontStyle;
  12052. },
  12053. set: function (value) {
  12054. if (this._fontStyle === value) {
  12055. return;
  12056. }
  12057. this._fontStyle = value;
  12058. this.onChangedObservable.notifyObservers(this);
  12059. },
  12060. enumerable: true,
  12061. configurable: true
  12062. });
  12063. Object.defineProperty(Style.prototype, "fontWeight", {
  12064. /** Gets or sets font weight */
  12065. get: function () {
  12066. return this._fontWeight;
  12067. },
  12068. set: function (value) {
  12069. if (this._fontWeight === value) {
  12070. return;
  12071. }
  12072. this._fontWeight = value;
  12073. this.onChangedObservable.notifyObservers(this);
  12074. },
  12075. enumerable: true,
  12076. configurable: true
  12077. });
  12078. /** Dispose all associated resources */
  12079. Style.prototype.dispose = function () {
  12080. this.onChangedObservable.clear();
  12081. };
  12082. return Style;
  12083. }());
  12084. /***/ }),
  12085. /***/ "./2D/valueAndUnit.ts":
  12086. /*!****************************!*\
  12087. !*** ./2D/valueAndUnit.ts ***!
  12088. \****************************/
  12089. /*! exports provided: ValueAndUnit */
  12090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12091. "use strict";
  12092. __webpack_require__.r(__webpack_exports__);
  12093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12094. /**
  12095. * Class used to specific a value and its associated unit
  12096. */
  12097. var ValueAndUnit = /** @class */ (function () {
  12098. /**
  12099. * Creates a new ValueAndUnit
  12100. * @param value defines the value to store
  12101. * @param unit defines the unit to store
  12102. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12103. */
  12104. function ValueAndUnit(value,
  12105. /** defines the unit to store */
  12106. unit,
  12107. /** defines a boolean indicating if the value can be negative */
  12108. negativeValueAllowed) {
  12109. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12110. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12111. this.unit = unit;
  12112. this.negativeValueAllowed = negativeValueAllowed;
  12113. this._value = 1;
  12114. /**
  12115. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12116. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12117. */
  12118. this.ignoreAdaptiveScaling = false;
  12119. this._value = value;
  12120. this._originalUnit = unit;
  12121. }
  12122. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12123. /** Gets a boolean indicating if the value is a percentage */
  12124. get: function () {
  12125. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12126. },
  12127. enumerable: true,
  12128. configurable: true
  12129. });
  12130. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12131. /** Gets a boolean indicating if the value is store as pixel */
  12132. get: function () {
  12133. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12134. },
  12135. enumerable: true,
  12136. configurable: true
  12137. });
  12138. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12139. /** Gets direct internal value */
  12140. get: function () {
  12141. return this._value;
  12142. },
  12143. enumerable: true,
  12144. configurable: true
  12145. });
  12146. /**
  12147. * Gets value as pixel
  12148. * @param host defines the root host
  12149. * @param refValue defines the reference value for percentages
  12150. * @returns the value as pixel
  12151. */
  12152. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12153. if (this.isPixel) {
  12154. return this.getValue(host);
  12155. }
  12156. return this.getValue(host) * refValue;
  12157. };
  12158. /**
  12159. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12160. * @param value defines the value to store
  12161. * @param unit defines the unit to store
  12162. * @returns the current ValueAndUnit
  12163. */
  12164. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12165. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12166. this._value = value;
  12167. this.unit = unit;
  12168. return this;
  12169. };
  12170. /**
  12171. * Gets the value accordingly to its unit
  12172. * @param host defines the root host
  12173. * @returns the value
  12174. */
  12175. ValueAndUnit.prototype.getValue = function (host) {
  12176. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12177. var width = 0;
  12178. var height = 0;
  12179. if (host.idealWidth) {
  12180. width = (this._value * host.getSize().width) / host.idealWidth;
  12181. }
  12182. if (host.idealHeight) {
  12183. height = (this._value * host.getSize().height) / host.idealHeight;
  12184. }
  12185. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12186. return window.innerWidth < window.innerHeight ? width : height;
  12187. }
  12188. if (host.idealWidth) { // horizontal
  12189. return width;
  12190. }
  12191. if (host.idealHeight) { // vertical
  12192. return height;
  12193. }
  12194. }
  12195. return this._value;
  12196. };
  12197. /**
  12198. * Gets a string representation of the value
  12199. * @param host defines the root host
  12200. * @param decimals defines an optional number of decimals to display
  12201. * @returns a string
  12202. */
  12203. ValueAndUnit.prototype.toString = function (host, decimals) {
  12204. switch (this.unit) {
  12205. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12206. var percentage = this.getValue(host) * 100;
  12207. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12208. case ValueAndUnit.UNITMODE_PIXEL:
  12209. var pixels = this.getValue(host);
  12210. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12211. }
  12212. return this.unit.toString();
  12213. };
  12214. /**
  12215. * Store a value parsed from a string
  12216. * @param source defines the source string
  12217. * @returns true if the value was successfully parsed
  12218. */
  12219. ValueAndUnit.prototype.fromString = function (source) {
  12220. var match = ValueAndUnit._Regex.exec(source.toString());
  12221. if (!match || match.length === 0) {
  12222. return false;
  12223. }
  12224. var sourceValue = parseFloat(match[1]);
  12225. var sourceUnit = this._originalUnit;
  12226. if (!this.negativeValueAllowed) {
  12227. if (sourceValue < 0) {
  12228. sourceValue = 0;
  12229. }
  12230. }
  12231. if (match.length === 4) {
  12232. switch (match[3]) {
  12233. case "px":
  12234. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12235. break;
  12236. case "%":
  12237. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12238. sourceValue /= 100.0;
  12239. break;
  12240. }
  12241. }
  12242. if (sourceValue === this._value && sourceUnit === this.unit) {
  12243. return false;
  12244. }
  12245. this._value = sourceValue;
  12246. this.unit = sourceUnit;
  12247. return true;
  12248. };
  12249. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12250. /** UNITMODE_PERCENTAGE */
  12251. get: function () {
  12252. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12253. },
  12254. enumerable: true,
  12255. configurable: true
  12256. });
  12257. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12258. /** UNITMODE_PIXEL */
  12259. get: function () {
  12260. return ValueAndUnit._UNITMODE_PIXEL;
  12261. },
  12262. enumerable: true,
  12263. configurable: true
  12264. });
  12265. // Static
  12266. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12267. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12268. ValueAndUnit._UNITMODE_PIXEL = 1;
  12269. return ValueAndUnit;
  12270. }());
  12271. /***/ }),
  12272. /***/ "./3D/controls/abstractButton3D.ts":
  12273. /*!*****************************************!*\
  12274. !*** ./3D/controls/abstractButton3D.ts ***!
  12275. \*****************************************/
  12276. /*! exports provided: AbstractButton3D */
  12277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12278. "use strict";
  12279. __webpack_require__.r(__webpack_exports__);
  12280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12281. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12282. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/tools");
  12283. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12284. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12285. /**
  12286. * Class used as a root to all buttons
  12287. */
  12288. var AbstractButton3D = /** @class */ (function (_super) {
  12289. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12290. /**
  12291. * Creates a new button
  12292. * @param name defines the control name
  12293. */
  12294. function AbstractButton3D(name) {
  12295. return _super.call(this, name) || this;
  12296. }
  12297. AbstractButton3D.prototype._getTypeName = function () {
  12298. return "AbstractButton3D";
  12299. };
  12300. // Mesh association
  12301. AbstractButton3D.prototype._createNode = function (scene) {
  12302. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12303. };
  12304. return AbstractButton3D;
  12305. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12306. /***/ }),
  12307. /***/ "./3D/controls/button3D.ts":
  12308. /*!*********************************!*\
  12309. !*** ./3D/controls/button3D.ts ***!
  12310. \*********************************/
  12311. /*! exports provided: Button3D */
  12312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12313. "use strict";
  12314. __webpack_require__.r(__webpack_exports__);
  12315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12316. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12317. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  12318. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12319. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12320. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12321. /**
  12322. * Class used to create a button in 3D
  12323. */
  12324. var Button3D = /** @class */ (function (_super) {
  12325. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12326. /**
  12327. * Creates a new button
  12328. * @param name defines the control name
  12329. */
  12330. function Button3D(name) {
  12331. var _this = _super.call(this, name) || this;
  12332. _this._contentResolution = 512;
  12333. _this._contentScaleRatio = 2;
  12334. // Default animations
  12335. _this.pointerEnterAnimation = function () {
  12336. if (!_this.mesh) {
  12337. return;
  12338. }
  12339. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12340. };
  12341. _this.pointerOutAnimation = function () {
  12342. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12343. };
  12344. _this.pointerDownAnimation = function () {
  12345. if (!_this.mesh) {
  12346. return;
  12347. }
  12348. _this.mesh.scaling.scaleInPlace(0.95);
  12349. };
  12350. _this.pointerUpAnimation = function () {
  12351. if (!_this.mesh) {
  12352. return;
  12353. }
  12354. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12355. };
  12356. return _this;
  12357. }
  12358. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12359. /**
  12360. * Gets or sets the texture resolution used to render content (512 by default)
  12361. */
  12362. get: function () {
  12363. return this._contentResolution;
  12364. },
  12365. set: function (value) {
  12366. if (this._contentResolution === value) {
  12367. return;
  12368. }
  12369. this._contentResolution = value;
  12370. this._resetContent();
  12371. },
  12372. enumerable: true,
  12373. configurable: true
  12374. });
  12375. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12376. /**
  12377. * Gets or sets the texture scale ratio used to render content (2 by default)
  12378. */
  12379. get: function () {
  12380. return this._contentScaleRatio;
  12381. },
  12382. set: function (value) {
  12383. if (this._contentScaleRatio === value) {
  12384. return;
  12385. }
  12386. this._contentScaleRatio = value;
  12387. this._resetContent();
  12388. },
  12389. enumerable: true,
  12390. configurable: true
  12391. });
  12392. Button3D.prototype._disposeFacadeTexture = function () {
  12393. if (this._facadeTexture) {
  12394. this._facadeTexture.dispose();
  12395. this._facadeTexture = null;
  12396. }
  12397. };
  12398. Button3D.prototype._resetContent = function () {
  12399. this._disposeFacadeTexture();
  12400. this.content = this._content;
  12401. };
  12402. Object.defineProperty(Button3D.prototype, "content", {
  12403. /**
  12404. * Gets or sets the GUI 2D content used to display the button's facade
  12405. */
  12406. get: function () {
  12407. return this._content;
  12408. },
  12409. set: function (value) {
  12410. this._content = value;
  12411. if (!this._host || !this._host.utilityLayer) {
  12412. return;
  12413. }
  12414. if (!this._facadeTexture) {
  12415. 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);
  12416. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12417. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12418. this._facadeTexture.premulAlpha = true;
  12419. }
  12420. this._facadeTexture.addControl(value);
  12421. this._applyFacade(this._facadeTexture);
  12422. },
  12423. enumerable: true,
  12424. configurable: true
  12425. });
  12426. /**
  12427. * Apply the facade texture (created from the content property).
  12428. * This function can be overloaded by child classes
  12429. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12430. */
  12431. Button3D.prototype._applyFacade = function (facadeTexture) {
  12432. this._currentMaterial.emissiveTexture = facadeTexture;
  12433. };
  12434. Button3D.prototype._getTypeName = function () {
  12435. return "Button3D";
  12436. };
  12437. // Mesh association
  12438. Button3D.prototype._createNode = function (scene) {
  12439. var faceUV = new Array(6);
  12440. for (var i = 0; i < 6; i++) {
  12441. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12442. }
  12443. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12444. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12445. width: 1.0,
  12446. height: 1.0,
  12447. depth: 0.08,
  12448. faceUV: faceUV
  12449. }, scene);
  12450. return mesh;
  12451. };
  12452. Button3D.prototype._affectMaterial = function (mesh) {
  12453. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12454. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12455. mesh.material = material;
  12456. this._currentMaterial = material;
  12457. this._resetContent();
  12458. };
  12459. /**
  12460. * Releases all associated resources
  12461. */
  12462. Button3D.prototype.dispose = function () {
  12463. _super.prototype.dispose.call(this);
  12464. this._disposeFacadeTexture();
  12465. if (this._currentMaterial) {
  12466. this._currentMaterial.dispose();
  12467. }
  12468. };
  12469. return Button3D;
  12470. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12471. /***/ }),
  12472. /***/ "./3D/controls/container3D.ts":
  12473. /*!************************************!*\
  12474. !*** ./3D/controls/container3D.ts ***!
  12475. \************************************/
  12476. /*! exports provided: Container3D */
  12477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12478. "use strict";
  12479. __webpack_require__.r(__webpack_exports__);
  12480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12481. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12482. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/tools");
  12483. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12484. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12485. /**
  12486. * Class used to create containers for controls
  12487. */
  12488. var Container3D = /** @class */ (function (_super) {
  12489. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12490. /**
  12491. * Creates a new container
  12492. * @param name defines the container name
  12493. */
  12494. function Container3D(name) {
  12495. var _this = _super.call(this, name) || this;
  12496. _this._blockLayout = false;
  12497. /**
  12498. * Gets the list of child controls
  12499. */
  12500. _this._children = new Array();
  12501. return _this;
  12502. }
  12503. Object.defineProperty(Container3D.prototype, "children", {
  12504. /**
  12505. * Gets the list of child controls
  12506. */
  12507. get: function () {
  12508. return this._children;
  12509. },
  12510. enumerable: true,
  12511. configurable: true
  12512. });
  12513. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12514. /**
  12515. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12516. * This is helpful to optimize layout operation when adding multiple children in a row
  12517. */
  12518. get: function () {
  12519. return this._blockLayout;
  12520. },
  12521. set: function (value) {
  12522. if (this._blockLayout === value) {
  12523. return;
  12524. }
  12525. this._blockLayout = value;
  12526. if (!this._blockLayout) {
  12527. this._arrangeChildren();
  12528. }
  12529. },
  12530. enumerable: true,
  12531. configurable: true
  12532. });
  12533. /**
  12534. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12535. * @returns the current container
  12536. */
  12537. Container3D.prototype.updateLayout = function () {
  12538. this._arrangeChildren();
  12539. return this;
  12540. };
  12541. /**
  12542. * Gets a boolean indicating if the given control is in the children of this control
  12543. * @param control defines the control to check
  12544. * @returns true if the control is in the child list
  12545. */
  12546. Container3D.prototype.containsControl = function (control) {
  12547. return this._children.indexOf(control) !== -1;
  12548. };
  12549. /**
  12550. * Adds a control to the children of this control
  12551. * @param control defines the control to add
  12552. * @returns the current container
  12553. */
  12554. Container3D.prototype.addControl = function (control) {
  12555. var index = this._children.indexOf(control);
  12556. if (index !== -1) {
  12557. return this;
  12558. }
  12559. control.parent = this;
  12560. control._host = this._host;
  12561. this._children.push(control);
  12562. if (this._host.utilityLayer) {
  12563. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12564. if (control.node) {
  12565. control.node.parent = this.node;
  12566. }
  12567. if (!this.blockLayout) {
  12568. this._arrangeChildren();
  12569. }
  12570. }
  12571. return this;
  12572. };
  12573. /**
  12574. * This function will be called everytime a new control is added
  12575. */
  12576. Container3D.prototype._arrangeChildren = function () {
  12577. };
  12578. Container3D.prototype._createNode = function (scene) {
  12579. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12580. };
  12581. /**
  12582. * Removes a control from the children of this control
  12583. * @param control defines the control to remove
  12584. * @returns the current container
  12585. */
  12586. Container3D.prototype.removeControl = function (control) {
  12587. var index = this._children.indexOf(control);
  12588. if (index !== -1) {
  12589. this._children.splice(index, 1);
  12590. control.parent = null;
  12591. control._disposeNode();
  12592. }
  12593. return this;
  12594. };
  12595. Container3D.prototype._getTypeName = function () {
  12596. return "Container3D";
  12597. };
  12598. /**
  12599. * Releases all associated resources
  12600. */
  12601. Container3D.prototype.dispose = function () {
  12602. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12603. var control = _a[_i];
  12604. control.dispose();
  12605. }
  12606. this._children = [];
  12607. _super.prototype.dispose.call(this);
  12608. };
  12609. /** Control rotation will remain unchanged */
  12610. Container3D.UNSET_ORIENTATION = 0;
  12611. /** Control will rotate to make it look at sphere central axis */
  12612. Container3D.FACEORIGIN_ORIENTATION = 1;
  12613. /** Control will rotate to make it look back at sphere central axis */
  12614. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12615. /** Control will rotate to look at z axis (0, 0, 1) */
  12616. Container3D.FACEFORWARD_ORIENTATION = 3;
  12617. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12618. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12619. return Container3D;
  12620. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12621. /***/ }),
  12622. /***/ "./3D/controls/control3D.ts":
  12623. /*!**********************************!*\
  12624. !*** ./3D/controls/control3D.ts ***!
  12625. \**********************************/
  12626. /*! exports provided: Control3D */
  12627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12628. "use strict";
  12629. __webpack_require__.r(__webpack_exports__);
  12630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12631. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  12632. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12633. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12634. /**
  12635. * Class used as base class for controls
  12636. */
  12637. var Control3D = /** @class */ (function () {
  12638. /**
  12639. * Creates a new control
  12640. * @param name defines the control name
  12641. */
  12642. function Control3D(
  12643. /** Defines the control name */
  12644. name) {
  12645. this.name = name;
  12646. this._downCount = 0;
  12647. this._enterCount = -1;
  12648. this._downPointerIds = {};
  12649. this._isVisible = true;
  12650. /**
  12651. * An event triggered when the pointer move over the control
  12652. */
  12653. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12654. /**
  12655. * An event triggered when the pointer move out of the control
  12656. */
  12657. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12658. /**
  12659. * An event triggered when the pointer taps the control
  12660. */
  12661. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12662. /**
  12663. * An event triggered when pointer is up
  12664. */
  12665. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12666. /**
  12667. * An event triggered when a control is clicked on (with a mouse)
  12668. */
  12669. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12670. /**
  12671. * An event triggered when pointer enters the control
  12672. */
  12673. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12674. // Behaviors
  12675. this._behaviors = new Array();
  12676. }
  12677. Object.defineProperty(Control3D.prototype, "position", {
  12678. /** Gets or sets the control position in world space */
  12679. get: function () {
  12680. if (!this._node) {
  12681. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12682. }
  12683. return this._node.position;
  12684. },
  12685. set: function (value) {
  12686. if (!this._node) {
  12687. return;
  12688. }
  12689. this._node.position = value;
  12690. },
  12691. enumerable: true,
  12692. configurable: true
  12693. });
  12694. Object.defineProperty(Control3D.prototype, "scaling", {
  12695. /** Gets or sets the control scaling in world space */
  12696. get: function () {
  12697. if (!this._node) {
  12698. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12699. }
  12700. return this._node.scaling;
  12701. },
  12702. set: function (value) {
  12703. if (!this._node) {
  12704. return;
  12705. }
  12706. this._node.scaling = value;
  12707. },
  12708. enumerable: true,
  12709. configurable: true
  12710. });
  12711. Object.defineProperty(Control3D.prototype, "behaviors", {
  12712. /**
  12713. * Gets the list of attached behaviors
  12714. * @see http://doc.babylonjs.com/features/behaviour
  12715. */
  12716. get: function () {
  12717. return this._behaviors;
  12718. },
  12719. enumerable: true,
  12720. configurable: true
  12721. });
  12722. /**
  12723. * Attach a behavior to the control
  12724. * @see http://doc.babylonjs.com/features/behaviour
  12725. * @param behavior defines the behavior to attach
  12726. * @returns the current control
  12727. */
  12728. Control3D.prototype.addBehavior = function (behavior) {
  12729. var _this = this;
  12730. var index = this._behaviors.indexOf(behavior);
  12731. if (index !== -1) {
  12732. return this;
  12733. }
  12734. behavior.init();
  12735. var scene = this._host.scene;
  12736. if (scene.isLoading) {
  12737. // We defer the attach when the scene will be loaded
  12738. scene.onDataLoadedObservable.addOnce(function () {
  12739. behavior.attach(_this);
  12740. });
  12741. }
  12742. else {
  12743. behavior.attach(this);
  12744. }
  12745. this._behaviors.push(behavior);
  12746. return this;
  12747. };
  12748. /**
  12749. * Remove an attached behavior
  12750. * @see http://doc.babylonjs.com/features/behaviour
  12751. * @param behavior defines the behavior to attach
  12752. * @returns the current control
  12753. */
  12754. Control3D.prototype.removeBehavior = function (behavior) {
  12755. var index = this._behaviors.indexOf(behavior);
  12756. if (index === -1) {
  12757. return this;
  12758. }
  12759. this._behaviors[index].detach();
  12760. this._behaviors.splice(index, 1);
  12761. return this;
  12762. };
  12763. /**
  12764. * Gets an attached behavior by name
  12765. * @param name defines the name of the behavior to look for
  12766. * @see http://doc.babylonjs.com/features/behaviour
  12767. * @returns null if behavior was not found else the requested behavior
  12768. */
  12769. Control3D.prototype.getBehaviorByName = function (name) {
  12770. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12771. var behavior = _a[_i];
  12772. if (behavior.name === name) {
  12773. return behavior;
  12774. }
  12775. }
  12776. return null;
  12777. };
  12778. Object.defineProperty(Control3D.prototype, "isVisible", {
  12779. /** Gets or sets a boolean indicating if the control is visible */
  12780. get: function () {
  12781. return this._isVisible;
  12782. },
  12783. set: function (value) {
  12784. if (this._isVisible === value) {
  12785. return;
  12786. }
  12787. this._isVisible = value;
  12788. var mesh = this.mesh;
  12789. if (mesh) {
  12790. mesh.setEnabled(value);
  12791. }
  12792. },
  12793. enumerable: true,
  12794. configurable: true
  12795. });
  12796. Object.defineProperty(Control3D.prototype, "typeName", {
  12797. /**
  12798. * Gets a string representing the class name
  12799. */
  12800. get: function () {
  12801. return this._getTypeName();
  12802. },
  12803. enumerable: true,
  12804. configurable: true
  12805. });
  12806. /**
  12807. * Get the current class name of the control.
  12808. * @returns current class name
  12809. */
  12810. Control3D.prototype.getClassName = function () {
  12811. return this._getTypeName();
  12812. };
  12813. Control3D.prototype._getTypeName = function () {
  12814. return "Control3D";
  12815. };
  12816. Object.defineProperty(Control3D.prototype, "node", {
  12817. /**
  12818. * Gets the transform node used by this control
  12819. */
  12820. get: function () {
  12821. return this._node;
  12822. },
  12823. enumerable: true,
  12824. configurable: true
  12825. });
  12826. Object.defineProperty(Control3D.prototype, "mesh", {
  12827. /**
  12828. * Gets the mesh used to render this control
  12829. */
  12830. get: function () {
  12831. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12832. return this._node;
  12833. }
  12834. return null;
  12835. },
  12836. enumerable: true,
  12837. configurable: true
  12838. });
  12839. /**
  12840. * Link the control as child of the given node
  12841. * @param node defines the node to link to. Use null to unlink the control
  12842. * @returns the current control
  12843. */
  12844. Control3D.prototype.linkToTransformNode = function (node) {
  12845. if (this._node) {
  12846. this._node.parent = node;
  12847. }
  12848. return this;
  12849. };
  12850. /** @hidden **/
  12851. Control3D.prototype._prepareNode = function (scene) {
  12852. if (!this._node) {
  12853. this._node = this._createNode(scene);
  12854. if (!this.node) {
  12855. return;
  12856. }
  12857. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12858. this._node.position = this.position;
  12859. this._node.scaling = this.scaling;
  12860. var mesh = this.mesh;
  12861. if (mesh) {
  12862. mesh.isPickable = true;
  12863. this._affectMaterial(mesh);
  12864. }
  12865. }
  12866. };
  12867. /**
  12868. * Node creation.
  12869. * Can be overriden by children
  12870. * @param scene defines the scene where the node must be attached
  12871. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12872. */
  12873. Control3D.prototype._createNode = function (scene) {
  12874. // Do nothing by default
  12875. return null;
  12876. };
  12877. /**
  12878. * Affect a material to the given mesh
  12879. * @param mesh defines the mesh which will represent the control
  12880. */
  12881. Control3D.prototype._affectMaterial = function (mesh) {
  12882. mesh.material = null;
  12883. };
  12884. // Pointers
  12885. /** @hidden */
  12886. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12887. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12888. };
  12889. /** @hidden */
  12890. Control3D.prototype._onPointerEnter = function (target) {
  12891. if (this._enterCount > 0) {
  12892. return false;
  12893. }
  12894. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12895. this._enterCount = 0;
  12896. }
  12897. this._enterCount++;
  12898. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12899. if (this.pointerEnterAnimation) {
  12900. this.pointerEnterAnimation();
  12901. }
  12902. return true;
  12903. };
  12904. /** @hidden */
  12905. Control3D.prototype._onPointerOut = function (target) {
  12906. this._enterCount = 0;
  12907. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12908. if (this.pointerOutAnimation) {
  12909. this.pointerOutAnimation();
  12910. }
  12911. };
  12912. /** @hidden */
  12913. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12914. if (this._downCount !== 0) {
  12915. return false;
  12916. }
  12917. this._downCount++;
  12918. this._downPointerIds[pointerId] = true;
  12919. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12920. if (this.pointerDownAnimation) {
  12921. this.pointerDownAnimation();
  12922. }
  12923. return true;
  12924. };
  12925. /** @hidden */
  12926. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12927. this._downCount = 0;
  12928. delete this._downPointerIds[pointerId];
  12929. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12930. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12931. }
  12932. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12933. if (this.pointerUpAnimation) {
  12934. this.pointerUpAnimation();
  12935. }
  12936. };
  12937. /** @hidden */
  12938. Control3D.prototype.forcePointerUp = function (pointerId) {
  12939. if (pointerId === void 0) { pointerId = null; }
  12940. if (pointerId !== null) {
  12941. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12942. }
  12943. else {
  12944. for (var key in this._downPointerIds) {
  12945. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12946. }
  12947. }
  12948. };
  12949. /** @hidden */
  12950. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  12951. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  12952. this._onPointerMove(this, pickedPoint);
  12953. var previousControlOver = this._host._lastControlOver[pointerId];
  12954. if (previousControlOver && previousControlOver !== this) {
  12955. previousControlOver._onPointerOut(this);
  12956. }
  12957. if (previousControlOver !== this) {
  12958. this._onPointerEnter(this);
  12959. }
  12960. this._host._lastControlOver[pointerId] = this;
  12961. return true;
  12962. }
  12963. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  12964. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  12965. this._host._lastControlDown[pointerId] = this;
  12966. this._host._lastPickedControl = this;
  12967. return true;
  12968. }
  12969. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  12970. if (this._host._lastControlDown[pointerId]) {
  12971. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  12972. }
  12973. delete this._host._lastControlDown[pointerId];
  12974. return true;
  12975. }
  12976. return false;
  12977. };
  12978. /** @hidden */
  12979. Control3D.prototype._disposeNode = function () {
  12980. if (this._node) {
  12981. this._node.dispose();
  12982. this._node = null;
  12983. }
  12984. };
  12985. /**
  12986. * Releases all associated resources
  12987. */
  12988. Control3D.prototype.dispose = function () {
  12989. this.onPointerDownObservable.clear();
  12990. this.onPointerEnterObservable.clear();
  12991. this.onPointerMoveObservable.clear();
  12992. this.onPointerOutObservable.clear();
  12993. this.onPointerUpObservable.clear();
  12994. this.onPointerClickObservable.clear();
  12995. this._disposeNode();
  12996. // Behaviors
  12997. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12998. var behavior = _a[_i];
  12999. behavior.detach();
  13000. }
  13001. };
  13002. return Control3D;
  13003. }());
  13004. /***/ }),
  13005. /***/ "./3D/controls/cylinderPanel.ts":
  13006. /*!**************************************!*\
  13007. !*** ./3D/controls/cylinderPanel.ts ***!
  13008. \**************************************/
  13009. /*! exports provided: CylinderPanel */
  13010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13011. "use strict";
  13012. __webpack_require__.r(__webpack_exports__);
  13013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13014. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13015. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13016. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13017. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13018. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13019. /**
  13020. * Class used to create a container panel deployed on the surface of a cylinder
  13021. */
  13022. var CylinderPanel = /** @class */ (function (_super) {
  13023. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13024. function CylinderPanel() {
  13025. var _this = _super !== null && _super.apply(this, arguments) || this;
  13026. _this._radius = 5.0;
  13027. return _this;
  13028. }
  13029. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13030. /**
  13031. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13032. */
  13033. get: function () {
  13034. return this._radius;
  13035. },
  13036. set: function (value) {
  13037. var _this = this;
  13038. if (this._radius === value) {
  13039. return;
  13040. }
  13041. this._radius = value;
  13042. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13043. _this._arrangeChildren();
  13044. });
  13045. },
  13046. enumerable: true,
  13047. configurable: true
  13048. });
  13049. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13050. var mesh = control.mesh;
  13051. if (!mesh) {
  13052. return;
  13053. }
  13054. var newPos = this._cylindricalMapping(nodePosition);
  13055. control.position = newPos;
  13056. switch (this.orientation) {
  13057. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13058. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13059. break;
  13060. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13061. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13062. break;
  13063. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13064. break;
  13065. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13066. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13067. break;
  13068. }
  13069. };
  13070. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13071. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13072. var yAngle = (source.x / this._radius);
  13073. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13074. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13075. };
  13076. return CylinderPanel;
  13077. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13078. /***/ }),
  13079. /***/ "./3D/controls/holographicButton.ts":
  13080. /*!******************************************!*\
  13081. !*** ./3D/controls/holographicButton.ts ***!
  13082. \******************************************/
  13083. /*! exports provided: HolographicButton */
  13084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13085. "use strict";
  13086. __webpack_require__.r(__webpack_exports__);
  13087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13088. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13089. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13090. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  13091. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13092. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13093. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13094. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13095. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13096. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13097. /**
  13098. * Class used to create a holographic button in 3D
  13099. */
  13100. var HolographicButton = /** @class */ (function (_super) {
  13101. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13102. /**
  13103. * Creates a new button
  13104. * @param name defines the control name
  13105. */
  13106. function HolographicButton(name, shareMaterials) {
  13107. if (shareMaterials === void 0) { shareMaterials = true; }
  13108. var _this = _super.call(this, name) || this;
  13109. _this._shareMaterials = true;
  13110. _this._shareMaterials = shareMaterials;
  13111. // Default animations
  13112. _this.pointerEnterAnimation = function () {
  13113. if (!_this.mesh) {
  13114. return;
  13115. }
  13116. _this._frontPlate.setEnabled(true);
  13117. };
  13118. _this.pointerOutAnimation = function () {
  13119. if (!_this.mesh) {
  13120. return;
  13121. }
  13122. _this._frontPlate.setEnabled(false);
  13123. };
  13124. return _this;
  13125. }
  13126. HolographicButton.prototype._disposeTooltip = function () {
  13127. this._tooltipFade = null;
  13128. if (this._tooltipTextBlock) {
  13129. this._tooltipTextBlock.dispose();
  13130. }
  13131. if (this._tooltipTexture) {
  13132. this._tooltipTexture.dispose();
  13133. }
  13134. if (this._tooltipMesh) {
  13135. this._tooltipMesh.dispose();
  13136. }
  13137. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13138. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13139. };
  13140. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13141. get: function () {
  13142. if (this._tooltipTextBlock) {
  13143. return this._tooltipTextBlock.text;
  13144. }
  13145. return null;
  13146. },
  13147. /**
  13148. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13149. */
  13150. set: function (text) {
  13151. var _this = this;
  13152. if (!text) {
  13153. this._disposeTooltip();
  13154. return;
  13155. }
  13156. if (!this._tooltipFade) {
  13157. // Create tooltip with mesh and text
  13158. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13159. 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);
  13160. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13161. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13162. tooltipBackground.material = mat;
  13163. tooltipBackground.isPickable = false;
  13164. this._tooltipMesh.addChild(tooltipBackground);
  13165. tooltipBackground.position.z = 0.05;
  13166. this._tooltipMesh.scaling.y = 1 / 3;
  13167. this._tooltipMesh.position.y = 0.7;
  13168. this._tooltipMesh.position.z = -0.15;
  13169. this._tooltipMesh.isPickable = false;
  13170. this._tooltipMesh.parent = this._backPlate;
  13171. // Create text texture for the tooltip
  13172. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13173. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13174. this._tooltipTextBlock.scaleY = 3;
  13175. this._tooltipTextBlock.color = "white";
  13176. this._tooltipTextBlock.fontSize = 130;
  13177. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13178. // Add hover action to tooltip
  13179. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13180. this._tooltipFade.delay = 500;
  13181. this._tooltipMesh.addBehavior(this._tooltipFade);
  13182. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13183. if (_this._tooltipFade) {
  13184. _this._tooltipFade.fadeIn(true);
  13185. }
  13186. });
  13187. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13188. if (_this._tooltipFade) {
  13189. _this._tooltipFade.fadeIn(false);
  13190. }
  13191. });
  13192. }
  13193. if (this._tooltipTextBlock) {
  13194. this._tooltipTextBlock.text = text;
  13195. }
  13196. },
  13197. enumerable: true,
  13198. configurable: true
  13199. });
  13200. Object.defineProperty(HolographicButton.prototype, "text", {
  13201. /**
  13202. * Gets or sets text for the button
  13203. */
  13204. get: function () {
  13205. return this._text;
  13206. },
  13207. set: function (value) {
  13208. if (this._text === value) {
  13209. return;
  13210. }
  13211. this._text = value;
  13212. this._rebuildContent();
  13213. },
  13214. enumerable: true,
  13215. configurable: true
  13216. });
  13217. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13218. /**
  13219. * Gets or sets the image url for the button
  13220. */
  13221. get: function () {
  13222. return this._imageUrl;
  13223. },
  13224. set: function (value) {
  13225. if (this._imageUrl === value) {
  13226. return;
  13227. }
  13228. this._imageUrl = value;
  13229. this._rebuildContent();
  13230. },
  13231. enumerable: true,
  13232. configurable: true
  13233. });
  13234. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13235. /**
  13236. * Gets the back material used by this button
  13237. */
  13238. get: function () {
  13239. return this._backMaterial;
  13240. },
  13241. enumerable: true,
  13242. configurable: true
  13243. });
  13244. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13245. /**
  13246. * Gets the front material used by this button
  13247. */
  13248. get: function () {
  13249. return this._frontMaterial;
  13250. },
  13251. enumerable: true,
  13252. configurable: true
  13253. });
  13254. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13255. /**
  13256. * Gets the plate material used by this button
  13257. */
  13258. get: function () {
  13259. return this._plateMaterial;
  13260. },
  13261. enumerable: true,
  13262. configurable: true
  13263. });
  13264. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13265. /**
  13266. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13267. */
  13268. get: function () {
  13269. return this._shareMaterials;
  13270. },
  13271. enumerable: true,
  13272. configurable: true
  13273. });
  13274. HolographicButton.prototype._getTypeName = function () {
  13275. return "HolographicButton";
  13276. };
  13277. HolographicButton.prototype._rebuildContent = function () {
  13278. this._disposeFacadeTexture();
  13279. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13280. panel.isVertical = true;
  13281. if (this._imageUrl) {
  13282. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13283. image.source = this._imageUrl;
  13284. image.paddingTop = "40px";
  13285. image.height = "180px";
  13286. image.width = "100px";
  13287. image.paddingBottom = "40px";
  13288. panel.addControl(image);
  13289. }
  13290. if (this._text) {
  13291. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13292. text.text = this._text;
  13293. text.color = "white";
  13294. text.height = "30px";
  13295. text.fontSize = 24;
  13296. panel.addControl(text);
  13297. }
  13298. if (this._frontPlate) {
  13299. this.content = panel;
  13300. }
  13301. };
  13302. // Mesh association
  13303. HolographicButton.prototype._createNode = function (scene) {
  13304. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13305. width: 1.0,
  13306. height: 1.0,
  13307. depth: 0.08
  13308. }, scene);
  13309. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13310. width: 1.0,
  13311. height: 1.0,
  13312. depth: 0.08
  13313. }, scene);
  13314. this._frontPlate.parent = this._backPlate;
  13315. this._frontPlate.position.z = -0.08;
  13316. this._frontPlate.isPickable = false;
  13317. this._frontPlate.setEnabled(false);
  13318. this._textPlate = _super.prototype._createNode.call(this, scene);
  13319. this._textPlate.parent = this._backPlate;
  13320. this._textPlate.position.z = -0.08;
  13321. this._textPlate.isPickable = false;
  13322. return this._backPlate;
  13323. };
  13324. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13325. this._plateMaterial.emissiveTexture = facadeTexture;
  13326. this._plateMaterial.opacityTexture = facadeTexture;
  13327. };
  13328. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13329. var _this = this;
  13330. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13331. this._backMaterial.renderHoverLight = true;
  13332. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13333. if (pickedPoint) {
  13334. _this._backMaterial.hoverPosition = pickedPoint;
  13335. _this._backMaterial.hoverColor.a = 1.0;
  13336. }
  13337. else {
  13338. _this._backMaterial.hoverColor.a = 0;
  13339. }
  13340. });
  13341. };
  13342. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13343. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13344. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13345. this._frontMaterial.alpha = 0.5; // Additive
  13346. this._frontMaterial.renderBorders = true;
  13347. };
  13348. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13349. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13350. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13351. };
  13352. HolographicButton.prototype._affectMaterial = function (mesh) {
  13353. // Back
  13354. if (this._shareMaterials) {
  13355. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13356. this._createBackMaterial(mesh);
  13357. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13358. }
  13359. else {
  13360. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13361. }
  13362. // Front
  13363. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13364. this._createFrontMaterial(mesh);
  13365. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13366. }
  13367. else {
  13368. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13369. }
  13370. }
  13371. else {
  13372. this._createBackMaterial(mesh);
  13373. this._createFrontMaterial(mesh);
  13374. }
  13375. this._createPlateMaterial(mesh);
  13376. this._backPlate.material = this._backMaterial;
  13377. this._frontPlate.material = this._frontMaterial;
  13378. this._textPlate.material = this._plateMaterial;
  13379. this._rebuildContent();
  13380. };
  13381. /**
  13382. * Releases all associated resources
  13383. */
  13384. HolographicButton.prototype.dispose = function () {
  13385. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13386. this._disposeTooltip();
  13387. if (!this.shareMaterials) {
  13388. this._backMaterial.dispose();
  13389. this._frontMaterial.dispose();
  13390. this._plateMaterial.dispose();
  13391. if (this._pickedPointObserver) {
  13392. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13393. this._pickedPointObserver = null;
  13394. }
  13395. }
  13396. };
  13397. return HolographicButton;
  13398. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13399. /***/ }),
  13400. /***/ "./3D/controls/index.ts":
  13401. /*!******************************!*\
  13402. !*** ./3D/controls/index.ts ***!
  13403. \******************************/
  13404. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13406. "use strict";
  13407. __webpack_require__.r(__webpack_exports__);
  13408. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13410. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13412. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13414. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13416. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13418. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13420. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13422. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13424. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13426. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13428. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13430. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13432. /***/ }),
  13433. /***/ "./3D/controls/meshButton3D.ts":
  13434. /*!*************************************!*\
  13435. !*** ./3D/controls/meshButton3D.ts ***!
  13436. \*************************************/
  13437. /*! exports provided: MeshButton3D */
  13438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13439. "use strict";
  13440. __webpack_require__.r(__webpack_exports__);
  13441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13442. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13443. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13444. /**
  13445. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13446. */
  13447. var MeshButton3D = /** @class */ (function (_super) {
  13448. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13449. /**
  13450. * Creates a new 3D button based on a mesh
  13451. * @param mesh mesh to become a 3D button
  13452. * @param name defines the control name
  13453. */
  13454. function MeshButton3D(mesh, name) {
  13455. var _this = _super.call(this, name) || this;
  13456. _this._currentMesh = mesh;
  13457. /**
  13458. * Provides a default behavior on hover/out & up/down
  13459. * Override those function to create your own desired behavior specific to your mesh
  13460. */
  13461. _this.pointerEnterAnimation = function () {
  13462. if (!_this.mesh) {
  13463. return;
  13464. }
  13465. _this.mesh.scaling.scaleInPlace(1.1);
  13466. };
  13467. _this.pointerOutAnimation = function () {
  13468. if (!_this.mesh) {
  13469. return;
  13470. }
  13471. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13472. };
  13473. _this.pointerDownAnimation = function () {
  13474. if (!_this.mesh) {
  13475. return;
  13476. }
  13477. _this.mesh.scaling.scaleInPlace(0.95);
  13478. };
  13479. _this.pointerUpAnimation = function () {
  13480. if (!_this.mesh) {
  13481. return;
  13482. }
  13483. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13484. };
  13485. return _this;
  13486. }
  13487. MeshButton3D.prototype._getTypeName = function () {
  13488. return "MeshButton3D";
  13489. };
  13490. // Mesh association
  13491. MeshButton3D.prototype._createNode = function (scene) {
  13492. var _this = this;
  13493. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13494. mesh.metadata = _this;
  13495. });
  13496. return this._currentMesh;
  13497. };
  13498. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13499. };
  13500. return MeshButton3D;
  13501. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13502. /***/ }),
  13503. /***/ "./3D/controls/planePanel.ts":
  13504. /*!***********************************!*\
  13505. !*** ./3D/controls/planePanel.ts ***!
  13506. \***********************************/
  13507. /*! exports provided: PlanePanel */
  13508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13509. "use strict";
  13510. __webpack_require__.r(__webpack_exports__);
  13511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13512. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13513. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  13514. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13515. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13516. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13517. /**
  13518. * Class used to create a container panel deployed on the surface of a plane
  13519. */
  13520. var PlanePanel = /** @class */ (function (_super) {
  13521. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13522. function PlanePanel() {
  13523. return _super !== null && _super.apply(this, arguments) || this;
  13524. }
  13525. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13526. var mesh = control.mesh;
  13527. if (!mesh) {
  13528. return;
  13529. }
  13530. control.position = nodePosition.clone();
  13531. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13532. target.copyFrom(nodePosition);
  13533. switch (this.orientation) {
  13534. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13535. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13536. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13537. mesh.lookAt(target);
  13538. break;
  13539. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13540. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13541. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13542. mesh.lookAt(target);
  13543. break;
  13544. }
  13545. };
  13546. return PlanePanel;
  13547. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13548. /***/ }),
  13549. /***/ "./3D/controls/scatterPanel.ts":
  13550. /*!*************************************!*\
  13551. !*** ./3D/controls/scatterPanel.ts ***!
  13552. \*************************************/
  13553. /*! exports provided: ScatterPanel */
  13554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13555. "use strict";
  13556. __webpack_require__.r(__webpack_exports__);
  13557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13558. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13559. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13560. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13561. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13562. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13563. /**
  13564. * Class used to create a container panel where items get randomized planar mapping
  13565. */
  13566. var ScatterPanel = /** @class */ (function (_super) {
  13567. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13568. function ScatterPanel() {
  13569. var _this = _super !== null && _super.apply(this, arguments) || this;
  13570. _this._iteration = 100.0;
  13571. return _this;
  13572. }
  13573. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13574. /**
  13575. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13576. */
  13577. get: function () {
  13578. return this._iteration;
  13579. },
  13580. set: function (value) {
  13581. var _this = this;
  13582. if (this._iteration === value) {
  13583. return;
  13584. }
  13585. this._iteration = value;
  13586. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13587. _this._arrangeChildren();
  13588. });
  13589. },
  13590. enumerable: true,
  13591. configurable: true
  13592. });
  13593. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13594. var mesh = control.mesh;
  13595. var newPos = this._scatterMapping(nodePosition);
  13596. if (!mesh) {
  13597. return;
  13598. }
  13599. switch (this.orientation) {
  13600. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13601. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13602. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13603. break;
  13604. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13605. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13606. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13607. break;
  13608. }
  13609. control.position = newPos;
  13610. };
  13611. ScatterPanel.prototype._scatterMapping = function (source) {
  13612. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13613. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13614. return source;
  13615. };
  13616. ScatterPanel.prototype._finalProcessing = function () {
  13617. var meshes = [];
  13618. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13619. var child = _a[_i];
  13620. if (!child.mesh) {
  13621. continue;
  13622. }
  13623. meshes.push(child.mesh);
  13624. }
  13625. for (var count = 0; count < this._iteration; count++) {
  13626. meshes.sort(function (a, b) {
  13627. var distance1 = a.position.lengthSquared();
  13628. var distance2 = b.position.lengthSquared();
  13629. if (distance1 < distance2) {
  13630. return 1;
  13631. }
  13632. else if (distance1 > distance2) {
  13633. return -1;
  13634. }
  13635. return 0;
  13636. });
  13637. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13638. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13639. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13640. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13641. for (var i = 0; i < meshes.length - 1; i++) {
  13642. for (var j = i + 1; j < meshes.length; j++) {
  13643. if (i != j) {
  13644. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13645. // Ignore Z axis
  13646. difference2D.x = difference.x;
  13647. difference2D.y = difference.y;
  13648. var combinedRadius = cellSize;
  13649. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13650. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13651. distance -= minSeparation;
  13652. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13653. difference2D.normalize();
  13654. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13655. meshes[j].position.addInPlace(difference);
  13656. meshes[i].position.subtractInPlace(difference);
  13657. }
  13658. }
  13659. }
  13660. }
  13661. }
  13662. };
  13663. return ScatterPanel;
  13664. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13665. /***/ }),
  13666. /***/ "./3D/controls/spherePanel.ts":
  13667. /*!************************************!*\
  13668. !*** ./3D/controls/spherePanel.ts ***!
  13669. \************************************/
  13670. /*! exports provided: SpherePanel */
  13671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13672. "use strict";
  13673. __webpack_require__.r(__webpack_exports__);
  13674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13675. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13676. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13677. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13678. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13679. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13680. /**
  13681. * Class used to create a container panel deployed on the surface of a sphere
  13682. */
  13683. var SpherePanel = /** @class */ (function (_super) {
  13684. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13685. function SpherePanel() {
  13686. var _this = _super !== null && _super.apply(this, arguments) || this;
  13687. _this._radius = 5.0;
  13688. return _this;
  13689. }
  13690. Object.defineProperty(SpherePanel.prototype, "radius", {
  13691. /**
  13692. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13693. */
  13694. get: function () {
  13695. return this._radius;
  13696. },
  13697. set: function (value) {
  13698. var _this = this;
  13699. if (this._radius === value) {
  13700. return;
  13701. }
  13702. this._radius = value;
  13703. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13704. _this._arrangeChildren();
  13705. });
  13706. },
  13707. enumerable: true,
  13708. configurable: true
  13709. });
  13710. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13711. var mesh = control.mesh;
  13712. if (!mesh) {
  13713. return;
  13714. }
  13715. var newPos = this._sphericalMapping(nodePosition);
  13716. control.position = newPos;
  13717. switch (this.orientation) {
  13718. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13719. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13720. break;
  13721. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13722. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13723. break;
  13724. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13725. break;
  13726. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13727. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13728. break;
  13729. }
  13730. };
  13731. SpherePanel.prototype._sphericalMapping = function (source) {
  13732. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13733. var xAngle = (source.y / this._radius);
  13734. var yAngle = -(source.x / this._radius);
  13735. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13736. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13737. };
  13738. return SpherePanel;
  13739. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13740. /***/ }),
  13741. /***/ "./3D/controls/stackPanel3D.ts":
  13742. /*!*************************************!*\
  13743. !*** ./3D/controls/stackPanel3D.ts ***!
  13744. \*************************************/
  13745. /*! exports provided: StackPanel3D */
  13746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13747. "use strict";
  13748. __webpack_require__.r(__webpack_exports__);
  13749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13751. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13752. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13753. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13754. /**
  13755. * Class used to create a stack panel in 3D on XY plane
  13756. */
  13757. var StackPanel3D = /** @class */ (function (_super) {
  13758. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13759. /**
  13760. * Creates new StackPanel
  13761. * @param isVertical
  13762. */
  13763. function StackPanel3D(isVertical) {
  13764. if (isVertical === void 0) { isVertical = false; }
  13765. var _this = _super.call(this) || this;
  13766. _this._isVertical = false;
  13767. /**
  13768. * Gets or sets the distance between elements
  13769. */
  13770. _this.margin = 0.1;
  13771. _this._isVertical = isVertical;
  13772. return _this;
  13773. }
  13774. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13775. /**
  13776. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13777. */
  13778. get: function () {
  13779. return this._isVertical;
  13780. },
  13781. set: function (value) {
  13782. var _this = this;
  13783. if (this._isVertical === value) {
  13784. return;
  13785. }
  13786. this._isVertical = value;
  13787. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13788. _this._arrangeChildren();
  13789. });
  13790. },
  13791. enumerable: true,
  13792. configurable: true
  13793. });
  13794. StackPanel3D.prototype._arrangeChildren = function () {
  13795. var width = 0;
  13796. var height = 0;
  13797. var controlCount = 0;
  13798. var extendSizes = [];
  13799. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13800. // Measure
  13801. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13802. var child = _a[_i];
  13803. if (!child.mesh) {
  13804. continue;
  13805. }
  13806. controlCount++;
  13807. child.mesh.computeWorldMatrix(true);
  13808. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13809. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13810. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13811. extendSizes.push(extendSize);
  13812. if (this._isVertical) {
  13813. height += extendSize.y;
  13814. }
  13815. else {
  13816. width += extendSize.x;
  13817. }
  13818. }
  13819. if (this._isVertical) {
  13820. height += (controlCount - 1) * this.margin / 2;
  13821. }
  13822. else {
  13823. width += (controlCount - 1) * this.margin / 2;
  13824. }
  13825. // Arrange
  13826. var offset;
  13827. if (this._isVertical) {
  13828. offset = -height;
  13829. }
  13830. else {
  13831. offset = -width;
  13832. }
  13833. var index = 0;
  13834. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13835. var child = _c[_b];
  13836. if (!child.mesh) {
  13837. continue;
  13838. }
  13839. controlCount--;
  13840. var extendSize = extendSizes[index++];
  13841. if (this._isVertical) {
  13842. child.position.y = offset + extendSize.y;
  13843. child.position.x = 0;
  13844. offset += extendSize.y * 2;
  13845. }
  13846. else {
  13847. child.position.x = offset + extendSize.x;
  13848. child.position.y = 0;
  13849. offset += extendSize.x * 2;
  13850. }
  13851. offset += (controlCount > 0 ? this.margin : 0);
  13852. }
  13853. };
  13854. return StackPanel3D;
  13855. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13856. /***/ }),
  13857. /***/ "./3D/controls/volumeBasedPanel.ts":
  13858. /*!*****************************************!*\
  13859. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13860. \*****************************************/
  13861. /*! exports provided: VolumeBasedPanel */
  13862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13863. "use strict";
  13864. __webpack_require__.r(__webpack_exports__);
  13865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13866. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13867. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13868. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13869. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13870. /**
  13871. * Abstract class used to create a container panel deployed on the surface of a volume
  13872. */
  13873. var VolumeBasedPanel = /** @class */ (function (_super) {
  13874. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13875. /**
  13876. * Creates new VolumeBasedPanel
  13877. */
  13878. function VolumeBasedPanel() {
  13879. var _this = _super.call(this) || this;
  13880. _this._columns = 10;
  13881. _this._rows = 0;
  13882. _this._rowThenColum = true;
  13883. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13884. /**
  13885. * Gets or sets the distance between elements
  13886. */
  13887. _this.margin = 0;
  13888. return _this;
  13889. }
  13890. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13891. /**
  13892. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13893. * | Value | Type | Description |
  13894. * | ----- | ----------------------------------- | ----------- |
  13895. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13896. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13897. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13898. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13899. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13900. */
  13901. get: function () {
  13902. return this._orientation;
  13903. },
  13904. set: function (value) {
  13905. var _this = this;
  13906. if (this._orientation === value) {
  13907. return;
  13908. }
  13909. this._orientation = value;
  13910. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13911. _this._arrangeChildren();
  13912. });
  13913. },
  13914. enumerable: true,
  13915. configurable: true
  13916. });
  13917. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13918. /**
  13919. * Gets or sets the number of columns requested (10 by default).
  13920. * The panel will automatically compute the number of rows based on number of child controls.
  13921. */
  13922. get: function () {
  13923. return this._columns;
  13924. },
  13925. set: function (value) {
  13926. var _this = this;
  13927. if (this._columns === value) {
  13928. return;
  13929. }
  13930. this._columns = value;
  13931. this._rowThenColum = true;
  13932. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13933. _this._arrangeChildren();
  13934. });
  13935. },
  13936. enumerable: true,
  13937. configurable: true
  13938. });
  13939. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13940. /**
  13941. * Gets or sets a the number of rows requested.
  13942. * The panel will automatically compute the number of columns based on number of child controls.
  13943. */
  13944. get: function () {
  13945. return this._rows;
  13946. },
  13947. set: function (value) {
  13948. var _this = this;
  13949. if (this._rows === value) {
  13950. return;
  13951. }
  13952. this._rows = value;
  13953. this._rowThenColum = false;
  13954. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13955. _this._arrangeChildren();
  13956. });
  13957. },
  13958. enumerable: true,
  13959. configurable: true
  13960. });
  13961. VolumeBasedPanel.prototype._arrangeChildren = function () {
  13962. this._cellWidth = 0;
  13963. this._cellHeight = 0;
  13964. var rows = 0;
  13965. var columns = 0;
  13966. var controlCount = 0;
  13967. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13968. // Measure
  13969. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13970. var child = _a[_i];
  13971. if (!child.mesh) {
  13972. continue;
  13973. }
  13974. controlCount++;
  13975. child.mesh.computeWorldMatrix(true);
  13976. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  13977. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  13978. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13979. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  13980. boundingBox.max.subtractToRef(boundingBox.min, diff);
  13981. diff.scaleInPlace(0.5);
  13982. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  13983. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  13984. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  13985. }
  13986. this._cellWidth += this.margin * 2;
  13987. this._cellHeight += this.margin * 2;
  13988. // Arrange
  13989. if (this._rowThenColum) {
  13990. columns = this._columns;
  13991. rows = Math.ceil(controlCount / this._columns);
  13992. }
  13993. else {
  13994. rows = this._rows;
  13995. columns = Math.ceil(controlCount / this._rows);
  13996. }
  13997. var startOffsetX = (columns * 0.5) * this._cellWidth;
  13998. var startOffsetY = (rows * 0.5) * this._cellHeight;
  13999. var nodeGrid = [];
  14000. var cellCounter = 0;
  14001. if (this._rowThenColum) {
  14002. for (var r = 0; r < rows; r++) {
  14003. for (var c = 0; c < columns; c++) {
  14004. 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));
  14005. cellCounter++;
  14006. if (cellCounter > controlCount) {
  14007. break;
  14008. }
  14009. }
  14010. }
  14011. }
  14012. else {
  14013. for (var c = 0; c < columns; c++) {
  14014. for (var r = 0; r < rows; r++) {
  14015. 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));
  14016. cellCounter++;
  14017. if (cellCounter > controlCount) {
  14018. break;
  14019. }
  14020. }
  14021. }
  14022. }
  14023. cellCounter = 0;
  14024. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14025. var child = _c[_b];
  14026. if (!child.mesh) {
  14027. continue;
  14028. }
  14029. this._mapGridNode(child, nodeGrid[cellCounter]);
  14030. cellCounter++;
  14031. }
  14032. this._finalProcessing();
  14033. };
  14034. /** Child classes can implement this function to provide additional processing */
  14035. VolumeBasedPanel.prototype._finalProcessing = function () {
  14036. };
  14037. return VolumeBasedPanel;
  14038. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14039. /***/ }),
  14040. /***/ "./3D/gui3DManager.ts":
  14041. /*!****************************!*\
  14042. !*** ./3D/gui3DManager.ts ***!
  14043. \****************************/
  14044. /*! exports provided: GUI3DManager */
  14045. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14046. "use strict";
  14047. __webpack_require__.r(__webpack_exports__);
  14048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14049. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  14050. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14051. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14052. /**
  14053. * Class used to manage 3D user interface
  14054. * @see http://doc.babylonjs.com/how_to/gui3d
  14055. */
  14056. var GUI3DManager = /** @class */ (function () {
  14057. /**
  14058. * Creates a new GUI3DManager
  14059. * @param scene
  14060. */
  14061. function GUI3DManager(scene) {
  14062. var _this = this;
  14063. /** @hidden */
  14064. this._lastControlOver = {};
  14065. /** @hidden */
  14066. this._lastControlDown = {};
  14067. /**
  14068. * Observable raised when the point picked by the pointer events changed
  14069. */
  14070. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14071. // Shared resources
  14072. /** @hidden */
  14073. this._sharedMaterials = {};
  14074. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14075. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14076. _this._sceneDisposeObserver = null;
  14077. _this._utilityLayer = null;
  14078. _this.dispose();
  14079. });
  14080. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14081. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14082. this._utilityLayer.pickUtilitySceneFirst = false;
  14083. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14084. return mesh && mesh.metadata && mesh.metadata._node;
  14085. };
  14086. // Root
  14087. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14088. this._rootContainer._host = this;
  14089. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14090. // Events
  14091. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14092. _this._handlePointerOut(pointerId, true);
  14093. });
  14094. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14095. _this._doPicking(pi);
  14096. });
  14097. // Scene
  14098. this._utilityLayer.utilityLayerScene.autoClear = false;
  14099. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14100. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14101. }
  14102. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14103. /** Gets the hosting scene */
  14104. get: function () {
  14105. return this._scene;
  14106. },
  14107. enumerable: true,
  14108. configurable: true
  14109. });
  14110. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14111. /** Gets associated utility layer */
  14112. get: function () {
  14113. return this._utilityLayer;
  14114. },
  14115. enumerable: true,
  14116. configurable: true
  14117. });
  14118. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14119. var previousControlOver = this._lastControlOver[pointerId];
  14120. if (previousControlOver) {
  14121. previousControlOver._onPointerOut(previousControlOver);
  14122. delete this._lastControlOver[pointerId];
  14123. }
  14124. if (isPointerUp) {
  14125. if (this._lastControlDown[pointerId]) {
  14126. this._lastControlDown[pointerId].forcePointerUp();
  14127. delete this._lastControlDown[pointerId];
  14128. }
  14129. }
  14130. this.onPickedPointChangedObservable.notifyObservers(null);
  14131. };
  14132. GUI3DManager.prototype._doPicking = function (pi) {
  14133. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14134. return false;
  14135. }
  14136. var pointerEvent = (pi.event);
  14137. var pointerId = pointerEvent.pointerId || 0;
  14138. var buttonIndex = pointerEvent.button;
  14139. var pickingInfo = pi.pickInfo;
  14140. if (!pickingInfo || !pickingInfo.hit) {
  14141. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14142. return false;
  14143. }
  14144. var control = (pickingInfo.pickedMesh.metadata);
  14145. if (pickingInfo.pickedPoint) {
  14146. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14147. }
  14148. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14149. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14150. if (this._lastControlOver[pointerId]) {
  14151. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14152. }
  14153. delete this._lastControlOver[pointerId];
  14154. }
  14155. }
  14156. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14157. if (this._lastControlDown[pointerEvent.pointerId]) {
  14158. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14159. delete this._lastControlDown[pointerEvent.pointerId];
  14160. }
  14161. if (pointerEvent.pointerType === "touch") {
  14162. this._handlePointerOut(pointerId, false);
  14163. }
  14164. }
  14165. return true;
  14166. };
  14167. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14168. /**
  14169. * Gets the root container
  14170. */
  14171. get: function () {
  14172. return this._rootContainer;
  14173. },
  14174. enumerable: true,
  14175. configurable: true
  14176. });
  14177. /**
  14178. * Gets a boolean indicating if the given control is in the root child list
  14179. * @param control defines the control to check
  14180. * @returns true if the control is in the root child list
  14181. */
  14182. GUI3DManager.prototype.containsControl = function (control) {
  14183. return this._rootContainer.containsControl(control);
  14184. };
  14185. /**
  14186. * Adds a control to the root child list
  14187. * @param control defines the control to add
  14188. * @returns the current manager
  14189. */
  14190. GUI3DManager.prototype.addControl = function (control) {
  14191. this._rootContainer.addControl(control);
  14192. return this;
  14193. };
  14194. /**
  14195. * Removes a control from the root child list
  14196. * @param control defines the control to remove
  14197. * @returns the current container
  14198. */
  14199. GUI3DManager.prototype.removeControl = function (control) {
  14200. this._rootContainer.removeControl(control);
  14201. return this;
  14202. };
  14203. /**
  14204. * Releases all associated resources
  14205. */
  14206. GUI3DManager.prototype.dispose = function () {
  14207. this._rootContainer.dispose();
  14208. for (var materialName in this._sharedMaterials) {
  14209. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14210. continue;
  14211. }
  14212. this._sharedMaterials[materialName].dispose();
  14213. }
  14214. this._sharedMaterials = {};
  14215. if (this._pointerOutObserver && this._utilityLayer) {
  14216. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14217. this._pointerOutObserver = null;
  14218. }
  14219. this.onPickedPointChangedObservable.clear();
  14220. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14221. if (utilityLayerScene) {
  14222. if (this._pointerObserver) {
  14223. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14224. this._pointerObserver = null;
  14225. }
  14226. }
  14227. if (this._scene) {
  14228. if (this._sceneDisposeObserver) {
  14229. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14230. this._sceneDisposeObserver = null;
  14231. }
  14232. }
  14233. if (this._utilityLayer) {
  14234. this._utilityLayer.dispose();
  14235. }
  14236. };
  14237. return GUI3DManager;
  14238. }());
  14239. /***/ }),
  14240. /***/ "./3D/index.ts":
  14241. /*!*********************!*\
  14242. !*** ./3D/index.ts ***!
  14243. \*********************/
  14244. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14246. "use strict";
  14247. __webpack_require__.r(__webpack_exports__);
  14248. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14261. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14264. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14266. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14268. /***/ }),
  14269. /***/ "./3D/materials/fluentMaterial.ts":
  14270. /*!****************************************!*\
  14271. !*** ./3D/materials/fluentMaterial.ts ***!
  14272. \****************************************/
  14273. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14275. "use strict";
  14276. __webpack_require__.r(__webpack_exports__);
  14277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14279. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14280. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/tools");
  14281. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14282. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14283. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14284. /** @hidden */
  14285. var FluentMaterialDefines = /** @class */ (function (_super) {
  14286. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14287. function FluentMaterialDefines() {
  14288. var _this = _super.call(this) || this;
  14289. _this.INNERGLOW = false;
  14290. _this.BORDER = false;
  14291. _this.HOVERLIGHT = false;
  14292. _this.TEXTURE = false;
  14293. _this.rebuild();
  14294. return _this;
  14295. }
  14296. return FluentMaterialDefines;
  14297. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14298. /**
  14299. * Class used to render controls with fluent desgin
  14300. */
  14301. var FluentMaterial = /** @class */ (function (_super) {
  14302. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14303. /**
  14304. * Creates a new Fluent material
  14305. * @param name defines the name of the material
  14306. * @param scene defines the hosting scene
  14307. */
  14308. function FluentMaterial(name, scene) {
  14309. var _this = _super.call(this, name, scene) || this;
  14310. /**
  14311. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14312. */
  14313. _this.innerGlowColorIntensity = 0.5;
  14314. /**
  14315. * Gets or sets the inner glow color (white by default)
  14316. */
  14317. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14318. /**
  14319. * Gets or sets alpha value (default is 1.0)
  14320. */
  14321. _this.alpha = 1.0;
  14322. /**
  14323. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14324. */
  14325. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14326. /**
  14327. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14328. */
  14329. _this.renderBorders = false;
  14330. /**
  14331. * Gets or sets border width (default is 0.5)
  14332. */
  14333. _this.borderWidth = 0.5;
  14334. /**
  14335. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14336. */
  14337. _this.edgeSmoothingValue = 0.02;
  14338. /**
  14339. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14340. */
  14341. _this.borderMinValue = 0.1;
  14342. /**
  14343. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14344. */
  14345. _this.renderHoverLight = false;
  14346. /**
  14347. * Gets or sets the radius used to render the hover light (default is 1.0)
  14348. */
  14349. _this.hoverRadius = 1.0;
  14350. /**
  14351. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14352. */
  14353. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14354. /**
  14355. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14356. */
  14357. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14358. return _this;
  14359. }
  14360. FluentMaterial.prototype.needAlphaBlending = function () {
  14361. return this.alpha !== 1.0;
  14362. };
  14363. FluentMaterial.prototype.needAlphaTesting = function () {
  14364. return false;
  14365. };
  14366. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14367. return null;
  14368. };
  14369. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14370. if (this.isFrozen) {
  14371. if (this._wasPreviouslyReady && subMesh.effect) {
  14372. return true;
  14373. }
  14374. }
  14375. if (!subMesh._materialDefines) {
  14376. subMesh._materialDefines = new FluentMaterialDefines();
  14377. }
  14378. var scene = this.getScene();
  14379. var defines = subMesh._materialDefines;
  14380. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14381. if (defines._renderId === scene.getRenderId()) {
  14382. return true;
  14383. }
  14384. }
  14385. if (defines._areTexturesDirty) {
  14386. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14387. defines.BORDER = this.renderBorders;
  14388. defines.HOVERLIGHT = this.renderHoverLight;
  14389. if (this._albedoTexture) {
  14390. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14391. return false;
  14392. }
  14393. else {
  14394. defines.TEXTURE = true;
  14395. }
  14396. }
  14397. else {
  14398. defines.TEXTURE = false;
  14399. }
  14400. }
  14401. var engine = scene.getEngine();
  14402. // Get correct effect
  14403. if (defines.isDirty) {
  14404. defines.markAsProcessed();
  14405. scene.resetCachedMaterial();
  14406. //Attributes
  14407. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14408. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14409. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14410. var shaderName = "fluent";
  14411. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14412. "hoverColor", "hoverPosition", "hoverRadius"
  14413. ];
  14414. var samplers = ["albedoSampler"];
  14415. var uniformBuffers = new Array();
  14416. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14417. uniformsNames: uniforms,
  14418. uniformBuffersNames: uniformBuffers,
  14419. samplers: samplers,
  14420. defines: defines,
  14421. maxSimultaneousLights: 4
  14422. });
  14423. var join = defines.toString();
  14424. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14425. attributes: attribs,
  14426. uniformsNames: uniforms,
  14427. uniformBuffersNames: uniformBuffers,
  14428. samplers: samplers,
  14429. defines: join,
  14430. fallbacks: null,
  14431. onCompiled: this.onCompiled,
  14432. onError: this.onError,
  14433. indexParameters: { maxSimultaneousLights: 4 }
  14434. }, engine));
  14435. }
  14436. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14437. return false;
  14438. }
  14439. defines._renderId = scene.getRenderId();
  14440. this._wasPreviouslyReady = true;
  14441. return true;
  14442. };
  14443. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14444. var scene = this.getScene();
  14445. var defines = subMesh._materialDefines;
  14446. if (!defines) {
  14447. return;
  14448. }
  14449. var effect = subMesh.effect;
  14450. if (!effect) {
  14451. return;
  14452. }
  14453. this._activeEffect = effect;
  14454. // Matrices
  14455. this.bindOnlyWorldMatrix(world);
  14456. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14457. if (this._mustRebind(scene, effect)) {
  14458. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14459. if (defines.INNERGLOW) {
  14460. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14461. }
  14462. if (defines.BORDER) {
  14463. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14464. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14465. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14466. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14467. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14468. }
  14469. if (defines.HOVERLIGHT) {
  14470. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14471. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14472. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14473. }
  14474. if (defines.TEXTURE) {
  14475. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14476. }
  14477. }
  14478. this._afterBind(mesh, this._activeEffect);
  14479. };
  14480. FluentMaterial.prototype.getActiveTextures = function () {
  14481. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14482. return activeTextures;
  14483. };
  14484. FluentMaterial.prototype.hasTexture = function (texture) {
  14485. if (_super.prototype.hasTexture.call(this, texture)) {
  14486. return true;
  14487. }
  14488. return false;
  14489. };
  14490. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14491. _super.prototype.dispose.call(this, forceDisposeEffect);
  14492. };
  14493. FluentMaterial.prototype.clone = function (name) {
  14494. var _this = this;
  14495. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14496. };
  14497. FluentMaterial.prototype.serialize = function () {
  14498. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14499. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14500. return serializationObject;
  14501. };
  14502. FluentMaterial.prototype.getClassName = function () {
  14503. return "FluentMaterial";
  14504. };
  14505. // Statics
  14506. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14507. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14508. };
  14509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14510. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14511. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14512. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14513. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14514. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14515. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14516. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14517. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14518. ], FluentMaterial.prototype, "alpha", void 0);
  14519. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14520. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14521. ], FluentMaterial.prototype, "albedoColor", void 0);
  14522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14523. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14524. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14525. ], FluentMaterial.prototype, "renderBorders", void 0);
  14526. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14527. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14528. ], FluentMaterial.prototype, "borderWidth", void 0);
  14529. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14530. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14531. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14532. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14533. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14534. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14535. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14536. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14537. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14538. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14540. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14541. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14543. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14544. ], FluentMaterial.prototype, "hoverColor", void 0);
  14545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14546. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14547. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14549. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14550. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14552. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14553. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14554. return FluentMaterial;
  14555. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14556. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14557. /***/ }),
  14558. /***/ "./3D/materials/index.ts":
  14559. /*!*******************************!*\
  14560. !*** ./3D/materials/index.ts ***!
  14561. \*******************************/
  14562. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14564. "use strict";
  14565. __webpack_require__.r(__webpack_exports__);
  14566. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14569. /***/ }),
  14570. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14571. /*!*************************************************!*\
  14572. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14573. \*************************************************/
  14574. /*! exports provided: fluentPixelShader */
  14575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14576. "use strict";
  14577. __webpack_require__.r(__webpack_exports__);
  14578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14579. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/tools");
  14580. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14581. var name = 'fluentPixelShader';
  14582. 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}";
  14583. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14584. /** @hidden */
  14585. var fluentPixelShader = { name: name, shader: shader };
  14586. /***/ }),
  14587. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14588. /*!***********************************************!*\
  14589. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14590. \***********************************************/
  14591. /*! exports provided: fluentVertexShader */
  14592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14593. "use strict";
  14594. __webpack_require__.r(__webpack_exports__);
  14595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14596. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/tools");
  14597. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14598. var name = 'fluentVertexShader';
  14599. 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";
  14600. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14601. /** @hidden */
  14602. var fluentVertexShader = { name: name, shader: shader };
  14603. /***/ }),
  14604. /***/ "./3D/vector3WithInfo.ts":
  14605. /*!*******************************!*\
  14606. !*** ./3D/vector3WithInfo.ts ***!
  14607. \*******************************/
  14608. /*! exports provided: Vector3WithInfo */
  14609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14610. "use strict";
  14611. __webpack_require__.r(__webpack_exports__);
  14612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14613. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14614. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  14615. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14616. /**
  14617. * Class used to transport Vector3 information for pointer events
  14618. */
  14619. var Vector3WithInfo = /** @class */ (function (_super) {
  14620. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14621. /**
  14622. * Creates a new Vector3WithInfo
  14623. * @param source defines the vector3 data to transport
  14624. * @param buttonIndex defines the current mouse button index
  14625. */
  14626. function Vector3WithInfo(source,
  14627. /** defines the current mouse button index */
  14628. buttonIndex) {
  14629. if (buttonIndex === void 0) { buttonIndex = 0; }
  14630. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14631. _this.buttonIndex = buttonIndex;
  14632. return _this;
  14633. }
  14634. return Vector3WithInfo;
  14635. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14636. /***/ }),
  14637. /***/ "./index.ts":
  14638. /*!******************!*\
  14639. !*** ./index.ts ***!
  14640. \******************/
  14641. /*! 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 */
  14642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14643. "use strict";
  14644. __webpack_require__.r(__webpack_exports__);
  14645. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14685. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14702. /***/ }),
  14703. /***/ "./legacy/legacy.ts":
  14704. /*!**************************!*\
  14705. !*** ./legacy/legacy.ts ***!
  14706. \**************************/
  14707. /*! 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 */
  14708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14709. "use strict";
  14710. __webpack_require__.r(__webpack_exports__);
  14711. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14767. /**
  14768. * Legacy support, defining window.BABYLON.GUI (global variable).
  14769. *
  14770. * This is the entry point for the UMD module.
  14771. * The entry point for a future ESM package should be index.ts
  14772. */
  14773. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14774. if (typeof globalObject !== "undefined") {
  14775. globalObject.BABYLON = globalObject.BABYLON || {};
  14776. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14777. }
  14778. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14779. /***/ }),
  14780. /***/ "babylonjs/Misc/tools":
  14781. /*!****************************************************************************************************!*\
  14782. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14783. \****************************************************************************************************/
  14784. /*! no static exports found */
  14785. /***/ (function(module, exports) {
  14786. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_tools__;
  14787. /***/ })
  14788. /******/ });
  14789. });
  14790. //# sourceMappingURL=babylon.gui.js.map