babylon.gui.js 674 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568
  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. !*** C:/Dev/Babylon/LibToModule/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. }
  6006. });
  6007. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6008. };
  6009. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6010. for (var key in this._cells) {
  6011. if (!this._cells.hasOwnProperty(key)) {
  6012. continue;
  6013. }
  6014. var child = this._cells[key];
  6015. child._markMatrixAsDirty();
  6016. }
  6017. };
  6018. Grid.prototype._renderHighlightSpecific = function (context) {
  6019. var _this = this;
  6020. _super.prototype._renderHighlightSpecific.call(this, context);
  6021. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6022. // Columns
  6023. for (var index = 0; index < lefts.length; index++) {
  6024. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6025. context.beginPath();
  6026. context.moveTo(left, _this._currentMeasure.top);
  6027. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6028. context.stroke();
  6029. }
  6030. // Rows
  6031. for (var index = 0; index < tops.length; index++) {
  6032. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6033. context.beginPath();
  6034. context.moveTo(_this._currentMeasure.left, top_1);
  6035. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6036. context.stroke();
  6037. }
  6038. });
  6039. context.restore();
  6040. };
  6041. /** Releases associated resources */
  6042. Grid.prototype.dispose = function () {
  6043. _super.prototype.dispose.call(this);
  6044. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6045. var control = _a[_i];
  6046. control.dispose();
  6047. }
  6048. this._childControls = [];
  6049. };
  6050. return Grid;
  6051. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6052. /***/ }),
  6053. /***/ "./2D/controls/image.ts":
  6054. /*!******************************!*\
  6055. !*** ./2D/controls/image.ts ***!
  6056. \******************************/
  6057. /*! exports provided: Image */
  6058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6059. "use strict";
  6060. __webpack_require__.r(__webpack_exports__);
  6061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6062. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6063. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  6064. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6065. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6066. /**
  6067. * Class used to create 2D images
  6068. */
  6069. var Image = /** @class */ (function (_super) {
  6070. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6071. /**
  6072. * Creates a new Image
  6073. * @param name defines the control name
  6074. * @param url defines the image url
  6075. */
  6076. function Image(name, url) {
  6077. if (url === void 0) { url = null; }
  6078. var _this = _super.call(this, name) || this;
  6079. _this.name = name;
  6080. _this._loaded = false;
  6081. _this._stretch = Image.STRETCH_FILL;
  6082. _this._autoScale = false;
  6083. _this._sourceLeft = 0;
  6084. _this._sourceTop = 0;
  6085. _this._sourceWidth = 0;
  6086. _this._sourceHeight = 0;
  6087. _this._cellWidth = 0;
  6088. _this._cellHeight = 0;
  6089. _this._cellId = -1;
  6090. _this._populateNinePatchSlicesFromImage = false;
  6091. /**
  6092. * Observable notified when the content is loaded
  6093. */
  6094. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6095. _this.source = url;
  6096. return _this;
  6097. }
  6098. Object.defineProperty(Image.prototype, "isLoaded", {
  6099. /**
  6100. * Gets a boolean indicating that the content is loaded
  6101. */
  6102. get: function () {
  6103. return this._loaded;
  6104. },
  6105. enumerable: true,
  6106. configurable: true
  6107. });
  6108. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6109. /**
  6110. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6111. */
  6112. get: function () {
  6113. return this._populateNinePatchSlicesFromImage;
  6114. },
  6115. set: function (value) {
  6116. if (this._populateNinePatchSlicesFromImage === value) {
  6117. return;
  6118. }
  6119. this._populateNinePatchSlicesFromImage = value;
  6120. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6121. this._extractNinePatchSliceDataFromImage();
  6122. }
  6123. },
  6124. enumerable: true,
  6125. configurable: true
  6126. });
  6127. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6128. /**
  6129. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6130. * Beware using this as this will comsume more memory as the image has to be stored twice
  6131. */
  6132. get: function () {
  6133. return this._detectPointerOnOpaqueOnly;
  6134. },
  6135. set: function (value) {
  6136. if (this._detectPointerOnOpaqueOnly === value) {
  6137. return;
  6138. }
  6139. this._detectPointerOnOpaqueOnly = value;
  6140. },
  6141. enumerable: true,
  6142. configurable: true
  6143. });
  6144. Object.defineProperty(Image.prototype, "sliceLeft", {
  6145. /**
  6146. * Gets or sets the left value for slicing (9-patch)
  6147. */
  6148. get: function () {
  6149. return this._sliceLeft;
  6150. },
  6151. set: function (value) {
  6152. if (this._sliceLeft === value) {
  6153. return;
  6154. }
  6155. this._sliceLeft = value;
  6156. this._markAsDirty();
  6157. },
  6158. enumerable: true,
  6159. configurable: true
  6160. });
  6161. Object.defineProperty(Image.prototype, "sliceRight", {
  6162. /**
  6163. * Gets or sets the right value for slicing (9-patch)
  6164. */
  6165. get: function () {
  6166. return this._sliceRight;
  6167. },
  6168. set: function (value) {
  6169. if (this._sliceRight === value) {
  6170. return;
  6171. }
  6172. this._sliceRight = value;
  6173. this._markAsDirty();
  6174. },
  6175. enumerable: true,
  6176. configurable: true
  6177. });
  6178. Object.defineProperty(Image.prototype, "sliceTop", {
  6179. /**
  6180. * Gets or sets the top value for slicing (9-patch)
  6181. */
  6182. get: function () {
  6183. return this._sliceTop;
  6184. },
  6185. set: function (value) {
  6186. if (this._sliceTop === value) {
  6187. return;
  6188. }
  6189. this._sliceTop = value;
  6190. this._markAsDirty();
  6191. },
  6192. enumerable: true,
  6193. configurable: true
  6194. });
  6195. Object.defineProperty(Image.prototype, "sliceBottom", {
  6196. /**
  6197. * Gets or sets the bottom value for slicing (9-patch)
  6198. */
  6199. get: function () {
  6200. return this._sliceBottom;
  6201. },
  6202. set: function (value) {
  6203. if (this._sliceBottom === value) {
  6204. return;
  6205. }
  6206. this._sliceBottom = value;
  6207. this._markAsDirty();
  6208. },
  6209. enumerable: true,
  6210. configurable: true
  6211. });
  6212. Object.defineProperty(Image.prototype, "sourceLeft", {
  6213. /**
  6214. * Gets or sets the left coordinate in the source image
  6215. */
  6216. get: function () {
  6217. return this._sourceLeft;
  6218. },
  6219. set: function (value) {
  6220. if (this._sourceLeft === value) {
  6221. return;
  6222. }
  6223. this._sourceLeft = value;
  6224. this._markAsDirty();
  6225. },
  6226. enumerable: true,
  6227. configurable: true
  6228. });
  6229. Object.defineProperty(Image.prototype, "sourceTop", {
  6230. /**
  6231. * Gets or sets the top coordinate in the source image
  6232. */
  6233. get: function () {
  6234. return this._sourceTop;
  6235. },
  6236. set: function (value) {
  6237. if (this._sourceTop === value) {
  6238. return;
  6239. }
  6240. this._sourceTop = value;
  6241. this._markAsDirty();
  6242. },
  6243. enumerable: true,
  6244. configurable: true
  6245. });
  6246. Object.defineProperty(Image.prototype, "sourceWidth", {
  6247. /**
  6248. * Gets or sets the width to capture in the source image
  6249. */
  6250. get: function () {
  6251. return this._sourceWidth;
  6252. },
  6253. set: function (value) {
  6254. if (this._sourceWidth === value) {
  6255. return;
  6256. }
  6257. this._sourceWidth = value;
  6258. this._markAsDirty();
  6259. },
  6260. enumerable: true,
  6261. configurable: true
  6262. });
  6263. Object.defineProperty(Image.prototype, "sourceHeight", {
  6264. /**
  6265. * Gets or sets the height to capture in the source image
  6266. */
  6267. get: function () {
  6268. return this._sourceHeight;
  6269. },
  6270. set: function (value) {
  6271. if (this._sourceHeight === value) {
  6272. return;
  6273. }
  6274. this._sourceHeight = value;
  6275. this._markAsDirty();
  6276. },
  6277. enumerable: true,
  6278. configurable: true
  6279. });
  6280. Object.defineProperty(Image.prototype, "autoScale", {
  6281. /**
  6282. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6283. * @see http://doc.babylonjs.com/how_to/gui#image
  6284. */
  6285. get: function () {
  6286. return this._autoScale;
  6287. },
  6288. set: function (value) {
  6289. if (this._autoScale === value) {
  6290. return;
  6291. }
  6292. this._autoScale = value;
  6293. if (value && this._loaded) {
  6294. this.synchronizeSizeWithContent();
  6295. }
  6296. },
  6297. enumerable: true,
  6298. configurable: true
  6299. });
  6300. Object.defineProperty(Image.prototype, "stretch", {
  6301. /** Gets or sets the streching mode used by the image */
  6302. get: function () {
  6303. return this._stretch;
  6304. },
  6305. set: function (value) {
  6306. if (this._stretch === value) {
  6307. return;
  6308. }
  6309. this._stretch = value;
  6310. this._markAsDirty();
  6311. },
  6312. enumerable: true,
  6313. configurable: true
  6314. });
  6315. Object.defineProperty(Image.prototype, "domImage", {
  6316. get: function () {
  6317. return this._domImage;
  6318. },
  6319. /**
  6320. * Gets or sets the internal DOM image used to render the control
  6321. */
  6322. set: function (value) {
  6323. var _this = this;
  6324. this._domImage = value;
  6325. this._loaded = false;
  6326. if (this._domImage.width) {
  6327. this._onImageLoaded();
  6328. }
  6329. else {
  6330. this._domImage.onload = function () {
  6331. _this._onImageLoaded();
  6332. };
  6333. }
  6334. },
  6335. enumerable: true,
  6336. configurable: true
  6337. });
  6338. Image.prototype._onImageLoaded = function () {
  6339. this._imageWidth = this._domImage.width;
  6340. this._imageHeight = this._domImage.height;
  6341. this._loaded = true;
  6342. if (this._populateNinePatchSlicesFromImage) {
  6343. this._extractNinePatchSliceDataFromImage();
  6344. }
  6345. if (this._autoScale) {
  6346. this.synchronizeSizeWithContent();
  6347. }
  6348. this.onImageLoadedObservable.notifyObservers(this);
  6349. this._markAsDirty();
  6350. };
  6351. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6352. if (!Image._WorkingCanvas) {
  6353. Image._WorkingCanvas = document.createElement('canvas');
  6354. }
  6355. var canvas = Image._WorkingCanvas;
  6356. var context = canvas.getContext('2d');
  6357. var width = this._domImage.width;
  6358. var height = this._domImage.height;
  6359. canvas.width = width;
  6360. canvas.height = height;
  6361. context.drawImage(this._domImage, 0, 0, width, height);
  6362. var imageData = context.getImageData(0, 0, width, height);
  6363. // Left and right
  6364. this._sliceLeft = -1;
  6365. this._sliceRight = -1;
  6366. for (var x = 0; x < width; x++) {
  6367. var alpha = imageData.data[x * 4 + 3];
  6368. if (alpha > 127 && this._sliceLeft === -1) {
  6369. this._sliceLeft = x;
  6370. continue;
  6371. }
  6372. if (alpha < 127 && this._sliceLeft > -1) {
  6373. this._sliceRight = x;
  6374. break;
  6375. }
  6376. }
  6377. // top and bottom
  6378. this._sliceTop = -1;
  6379. this._sliceBottom = -1;
  6380. for (var y = 0; y < height; y++) {
  6381. var alpha = imageData.data[y * width * 4 + 3];
  6382. if (alpha > 127 && this._sliceTop === -1) {
  6383. this._sliceTop = y;
  6384. continue;
  6385. }
  6386. if (alpha < 127 && this._sliceTop > -1) {
  6387. this._sliceBottom = y;
  6388. break;
  6389. }
  6390. }
  6391. };
  6392. Object.defineProperty(Image.prototype, "source", {
  6393. /**
  6394. * Gets or sets image source url
  6395. */
  6396. set: function (value) {
  6397. var _this = this;
  6398. if (this._source === value) {
  6399. return;
  6400. }
  6401. this._loaded = false;
  6402. this._source = value;
  6403. this._domImage = document.createElement("img");
  6404. this._domImage.onload = function () {
  6405. _this._onImageLoaded();
  6406. };
  6407. if (value) {
  6408. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6409. this._domImage.src = value;
  6410. }
  6411. },
  6412. enumerable: true,
  6413. configurable: true
  6414. });
  6415. Object.defineProperty(Image.prototype, "cellWidth", {
  6416. /**
  6417. * Gets or sets the cell width to use when animation sheet is enabled
  6418. * @see http://doc.babylonjs.com/how_to/gui#image
  6419. */
  6420. get: function () {
  6421. return this._cellWidth;
  6422. },
  6423. set: function (value) {
  6424. if (this._cellWidth === value) {
  6425. return;
  6426. }
  6427. this._cellWidth = value;
  6428. this._markAsDirty();
  6429. },
  6430. enumerable: true,
  6431. configurable: true
  6432. });
  6433. Object.defineProperty(Image.prototype, "cellHeight", {
  6434. /**
  6435. * Gets or sets the cell height to use when animation sheet is enabled
  6436. * @see http://doc.babylonjs.com/how_to/gui#image
  6437. */
  6438. get: function () {
  6439. return this._cellHeight;
  6440. },
  6441. set: function (value) {
  6442. if (this._cellHeight === value) {
  6443. return;
  6444. }
  6445. this._cellHeight = value;
  6446. this._markAsDirty();
  6447. },
  6448. enumerable: true,
  6449. configurable: true
  6450. });
  6451. Object.defineProperty(Image.prototype, "cellId", {
  6452. /**
  6453. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6454. * @see http://doc.babylonjs.com/how_to/gui#image
  6455. */
  6456. get: function () {
  6457. return this._cellId;
  6458. },
  6459. set: function (value) {
  6460. if (this._cellId === value) {
  6461. return;
  6462. }
  6463. this._cellId = value;
  6464. this._markAsDirty();
  6465. },
  6466. enumerable: true,
  6467. configurable: true
  6468. });
  6469. /**
  6470. * Tests if a given coordinates belong to the current control
  6471. * @param x defines x coordinate to test
  6472. * @param y defines y coordinate to test
  6473. * @returns true if the coordinates are inside the control
  6474. */
  6475. Image.prototype.contains = function (x, y) {
  6476. if (!_super.prototype.contains.call(this, x, y)) {
  6477. return false;
  6478. }
  6479. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6480. return true;
  6481. }
  6482. var canvas = Image._WorkingCanvas;
  6483. var context = canvas.getContext("2d");
  6484. var width = this._currentMeasure.width | 0;
  6485. var height = this._currentMeasure.height | 0;
  6486. var imageData = context.getImageData(0, 0, width, height).data;
  6487. x = (x - this._currentMeasure.left) | 0;
  6488. y = (y - this._currentMeasure.top) | 0;
  6489. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6490. return pickedPixel > 0;
  6491. };
  6492. Image.prototype._getTypeName = function () {
  6493. return "Image";
  6494. };
  6495. /** Force the control to synchronize with its content */
  6496. Image.prototype.synchronizeSizeWithContent = function () {
  6497. if (!this._loaded) {
  6498. return;
  6499. }
  6500. this.width = this._domImage.width + "px";
  6501. this.height = this._domImage.height + "px";
  6502. };
  6503. Image.prototype._processMeasures = function (parentMeasure, context) {
  6504. if (this._loaded) {
  6505. switch (this._stretch) {
  6506. case Image.STRETCH_NONE:
  6507. break;
  6508. case Image.STRETCH_FILL:
  6509. break;
  6510. case Image.STRETCH_UNIFORM:
  6511. break;
  6512. case Image.STRETCH_NINE_PATCH:
  6513. break;
  6514. case Image.STRETCH_EXTEND:
  6515. if (this._autoScale) {
  6516. this.synchronizeSizeWithContent();
  6517. }
  6518. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6519. this.parent.adaptWidthToChildren = true;
  6520. this.parent.adaptHeightToChildren = true;
  6521. }
  6522. break;
  6523. }
  6524. }
  6525. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6526. };
  6527. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6528. if (!this._detectPointerOnOpaqueOnly) {
  6529. return;
  6530. }
  6531. if (!Image._WorkingCanvas) {
  6532. Image._WorkingCanvas = document.createElement('canvas');
  6533. }
  6534. var canvas = Image._WorkingCanvas;
  6535. var width = this._currentMeasure.width;
  6536. var height = this._currentMeasure.height;
  6537. var context = canvas.getContext("2d");
  6538. canvas.width = width;
  6539. canvas.height = height;
  6540. context.clearRect(0, 0, width, height);
  6541. };
  6542. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6543. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6544. if (!this._detectPointerOnOpaqueOnly) {
  6545. return;
  6546. }
  6547. var canvas = Image._WorkingCanvas;
  6548. context = canvas.getContext("2d");
  6549. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6550. };
  6551. Image.prototype._draw = function (context) {
  6552. context.save();
  6553. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6554. context.shadowColor = this.shadowColor;
  6555. context.shadowBlur = this.shadowBlur;
  6556. context.shadowOffsetX = this.shadowOffsetX;
  6557. context.shadowOffsetY = this.shadowOffsetY;
  6558. }
  6559. var x, y, width, height;
  6560. if (this.cellId == -1) {
  6561. x = this._sourceLeft;
  6562. y = this._sourceTop;
  6563. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6564. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6565. }
  6566. else {
  6567. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6568. var column = (this.cellId / rowCount) >> 0;
  6569. var row = this.cellId % rowCount;
  6570. x = this.cellWidth * row;
  6571. y = this.cellHeight * column;
  6572. width = this.cellWidth;
  6573. height = this.cellHeight;
  6574. }
  6575. this._prepareWorkingCanvasForOpaqueDetection();
  6576. this._applyStates(context);
  6577. if (this._loaded) {
  6578. switch (this._stretch) {
  6579. case Image.STRETCH_NONE:
  6580. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6581. break;
  6582. case Image.STRETCH_FILL:
  6583. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6584. break;
  6585. case Image.STRETCH_UNIFORM:
  6586. var hRatio = this._currentMeasure.width / width;
  6587. var vRatio = this._currentMeasure.height / height;
  6588. var ratio = Math.min(hRatio, vRatio);
  6589. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6590. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6591. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6592. break;
  6593. case Image.STRETCH_EXTEND:
  6594. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6595. break;
  6596. case Image.STRETCH_NINE_PATCH:
  6597. this._renderNinePatch(context);
  6598. break;
  6599. }
  6600. }
  6601. context.restore();
  6602. };
  6603. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6604. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6605. };
  6606. Image.prototype._renderNinePatch = function (context) {
  6607. var height = this._imageHeight;
  6608. var leftWidth = this._sliceLeft;
  6609. var topHeight = this._sliceTop;
  6610. var bottomHeight = this._imageHeight - this._sliceBottom;
  6611. var rightWidth = this._imageWidth - this._sliceRight;
  6612. var left = 0;
  6613. var top = 0;
  6614. if (this._populateNinePatchSlicesFromImage) {
  6615. left = 1;
  6616. top = 1;
  6617. height -= 2;
  6618. leftWidth -= 1;
  6619. topHeight -= 1;
  6620. bottomHeight -= 1;
  6621. rightWidth -= 1;
  6622. }
  6623. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6624. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6625. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6626. // Corners
  6627. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6628. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6629. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6630. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6631. // Center
  6632. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop + 1, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight + 1);
  6633. // Borders
  6634. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6635. this._drawImage(context, this._sliceRight, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + this._currentMeasure.width - rightWidth, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6636. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6637. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6638. };
  6639. Image.prototype.dispose = function () {
  6640. _super.prototype.dispose.call(this);
  6641. this.onImageLoadedObservable.clear();
  6642. };
  6643. Image._WorkingCanvas = null;
  6644. // Static
  6645. /** STRETCH_NONE */
  6646. Image.STRETCH_NONE = 0;
  6647. /** STRETCH_FILL */
  6648. Image.STRETCH_FILL = 1;
  6649. /** STRETCH_UNIFORM */
  6650. Image.STRETCH_UNIFORM = 2;
  6651. /** STRETCH_EXTEND */
  6652. Image.STRETCH_EXTEND = 3;
  6653. /** NINE_PATCH */
  6654. Image.STRETCH_NINE_PATCH = 4;
  6655. return Image;
  6656. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6657. /***/ }),
  6658. /***/ "./2D/controls/index.ts":
  6659. /*!******************************!*\
  6660. !*** ./2D/controls/index.ts ***!
  6661. \******************************/
  6662. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, name */
  6663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6664. "use strict";
  6665. __webpack_require__.r(__webpack_exports__);
  6666. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6668. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6670. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6672. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6674. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6676. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6678. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6680. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6682. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6684. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6686. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6688. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6690. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6692. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6694. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6700. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6702. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6705. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6708. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6710. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6712. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6714. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6716. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6718. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6720. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6722. /***/ }),
  6723. /***/ "./2D/controls/inputPassword.ts":
  6724. /*!**************************************!*\
  6725. !*** ./2D/controls/inputPassword.ts ***!
  6726. \**************************************/
  6727. /*! exports provided: InputPassword */
  6728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6729. "use strict";
  6730. __webpack_require__.r(__webpack_exports__);
  6731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6732. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6733. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6734. /**
  6735. * Class used to create a password control
  6736. */
  6737. var InputPassword = /** @class */ (function (_super) {
  6738. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6739. function InputPassword() {
  6740. return _super !== null && _super.apply(this, arguments) || this;
  6741. }
  6742. InputPassword.prototype._beforeRenderText = function (text) {
  6743. var txt = "";
  6744. for (var i = 0; i < text.length; i++) {
  6745. txt += "\u2022";
  6746. }
  6747. return txt;
  6748. };
  6749. return InputPassword;
  6750. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6751. /***/ }),
  6752. /***/ "./2D/controls/inputText.ts":
  6753. /*!**********************************!*\
  6754. !*** ./2D/controls/inputText.ts ***!
  6755. \**********************************/
  6756. /*! exports provided: InputText */
  6757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6758. "use strict";
  6759. __webpack_require__.r(__webpack_exports__);
  6760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6762. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  6763. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6764. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6765. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6766. /**
  6767. * Class used to create input text control
  6768. */
  6769. var InputText = /** @class */ (function (_super) {
  6770. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6771. /**
  6772. * Creates a new InputText
  6773. * @param name defines the control name
  6774. * @param text defines the text of the control
  6775. */
  6776. function InputText(name, text) {
  6777. if (text === void 0) { text = ""; }
  6778. var _this = _super.call(this, name) || this;
  6779. _this.name = name;
  6780. _this._text = "";
  6781. _this._placeholderText = "";
  6782. _this._background = "#222222";
  6783. _this._focusedBackground = "#000000";
  6784. _this._focusedColor = "white";
  6785. _this._placeholderColor = "gray";
  6786. _this._thickness = 1;
  6787. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6788. _this._autoStretchWidth = true;
  6789. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6790. _this._isFocused = false;
  6791. _this._blinkIsEven = false;
  6792. _this._cursorOffset = 0;
  6793. _this._deadKey = false;
  6794. _this._addKey = true;
  6795. _this._currentKey = "";
  6796. _this._isTextHighlightOn = false;
  6797. _this._textHighlightColor = "#d5e0ff";
  6798. _this._highligherOpacity = 0.4;
  6799. _this._highlightedText = "";
  6800. _this._startHighlightIndex = 0;
  6801. _this._endHighlightIndex = 0;
  6802. _this._cursorIndex = -1;
  6803. _this._onFocusSelectAll = false;
  6804. _this._isPointerDown = false;
  6805. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6806. _this.promptMessage = "Please enter text:";
  6807. /** Observable raised when the text changes */
  6808. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6809. /** Observable raised just before an entered character is to be added */
  6810. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6811. /** Observable raised when the control gets the focus */
  6812. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6813. /** Observable raised when the control loses the focus */
  6814. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6815. /**Observable raised when the text is highlighted */
  6816. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6817. /**Observable raised when copy event is triggered */
  6818. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6819. /** Observable raised when cut event is triggered */
  6820. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6821. /** Observable raised when paste event is triggered */
  6822. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6823. /** Observable raised when a key event was processed */
  6824. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6825. _this.text = text;
  6826. _this.isPointerBlocker = true;
  6827. return _this;
  6828. }
  6829. Object.defineProperty(InputText.prototype, "maxWidth", {
  6830. /** Gets or sets the maximum width allowed by the control */
  6831. get: function () {
  6832. return this._maxWidth.toString(this._host);
  6833. },
  6834. set: function (value) {
  6835. if (this._maxWidth.toString(this._host) === value) {
  6836. return;
  6837. }
  6838. if (this._maxWidth.fromString(value)) {
  6839. this._markAsDirty();
  6840. }
  6841. },
  6842. enumerable: true,
  6843. configurable: true
  6844. });
  6845. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6846. /** Gets the maximum width allowed by the control in pixels */
  6847. get: function () {
  6848. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6849. },
  6850. enumerable: true,
  6851. configurable: true
  6852. });
  6853. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6854. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6855. get: function () {
  6856. return this._highligherOpacity;
  6857. },
  6858. set: function (value) {
  6859. if (this._highligherOpacity === value) {
  6860. return;
  6861. }
  6862. this._highligherOpacity = value;
  6863. this._markAsDirty();
  6864. },
  6865. enumerable: true,
  6866. configurable: true
  6867. });
  6868. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6869. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6870. get: function () {
  6871. return this._onFocusSelectAll;
  6872. },
  6873. set: function (value) {
  6874. if (this._onFocusSelectAll === value) {
  6875. return;
  6876. }
  6877. this._onFocusSelectAll = value;
  6878. this._markAsDirty();
  6879. },
  6880. enumerable: true,
  6881. configurable: true
  6882. });
  6883. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6884. /** Gets or sets the text hightlight color */
  6885. get: function () {
  6886. return this._textHighlightColor;
  6887. },
  6888. set: function (value) {
  6889. if (this._textHighlightColor === value) {
  6890. return;
  6891. }
  6892. this._textHighlightColor = value;
  6893. this._markAsDirty();
  6894. },
  6895. enumerable: true,
  6896. configurable: true
  6897. });
  6898. Object.defineProperty(InputText.prototype, "margin", {
  6899. /** Gets or sets control margin */
  6900. get: function () {
  6901. return this._margin.toString(this._host);
  6902. },
  6903. set: function (value) {
  6904. if (this._margin.toString(this._host) === value) {
  6905. return;
  6906. }
  6907. if (this._margin.fromString(value)) {
  6908. this._markAsDirty();
  6909. }
  6910. },
  6911. enumerable: true,
  6912. configurable: true
  6913. });
  6914. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6915. /** Gets control margin in pixels */
  6916. get: function () {
  6917. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6918. },
  6919. enumerable: true,
  6920. configurable: true
  6921. });
  6922. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6923. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6924. get: function () {
  6925. return this._autoStretchWidth;
  6926. },
  6927. set: function (value) {
  6928. if (this._autoStretchWidth === value) {
  6929. return;
  6930. }
  6931. this._autoStretchWidth = value;
  6932. this._markAsDirty();
  6933. },
  6934. enumerable: true,
  6935. configurable: true
  6936. });
  6937. Object.defineProperty(InputText.prototype, "thickness", {
  6938. /** Gets or sets border thickness */
  6939. get: function () {
  6940. return this._thickness;
  6941. },
  6942. set: function (value) {
  6943. if (this._thickness === value) {
  6944. return;
  6945. }
  6946. this._thickness = value;
  6947. this._markAsDirty();
  6948. },
  6949. enumerable: true,
  6950. configurable: true
  6951. });
  6952. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6953. /** Gets or sets the background color when focused */
  6954. get: function () {
  6955. return this._focusedBackground;
  6956. },
  6957. set: function (value) {
  6958. if (this._focusedBackground === value) {
  6959. return;
  6960. }
  6961. this._focusedBackground = value;
  6962. this._markAsDirty();
  6963. },
  6964. enumerable: true,
  6965. configurable: true
  6966. });
  6967. Object.defineProperty(InputText.prototype, "focusedColor", {
  6968. /** Gets or sets the background color when focused */
  6969. get: function () {
  6970. return this._focusedColor;
  6971. },
  6972. set: function (value) {
  6973. if (this._focusedColor === value) {
  6974. return;
  6975. }
  6976. this._focusedColor = value;
  6977. this._markAsDirty();
  6978. },
  6979. enumerable: true,
  6980. configurable: true
  6981. });
  6982. Object.defineProperty(InputText.prototype, "background", {
  6983. /** Gets or sets the background color */
  6984. get: function () {
  6985. return this._background;
  6986. },
  6987. set: function (value) {
  6988. if (this._background === value) {
  6989. return;
  6990. }
  6991. this._background = value;
  6992. this._markAsDirty();
  6993. },
  6994. enumerable: true,
  6995. configurable: true
  6996. });
  6997. Object.defineProperty(InputText.prototype, "placeholderColor", {
  6998. /** Gets or sets the placeholder color */
  6999. get: function () {
  7000. return this._placeholderColor;
  7001. },
  7002. set: function (value) {
  7003. if (this._placeholderColor === value) {
  7004. return;
  7005. }
  7006. this._placeholderColor = value;
  7007. this._markAsDirty();
  7008. },
  7009. enumerable: true,
  7010. configurable: true
  7011. });
  7012. Object.defineProperty(InputText.prototype, "placeholderText", {
  7013. /** Gets or sets the text displayed when the control is empty */
  7014. get: function () {
  7015. return this._placeholderText;
  7016. },
  7017. set: function (value) {
  7018. if (this._placeholderText === value) {
  7019. return;
  7020. }
  7021. this._placeholderText = value;
  7022. this._markAsDirty();
  7023. },
  7024. enumerable: true,
  7025. configurable: true
  7026. });
  7027. Object.defineProperty(InputText.prototype, "deadKey", {
  7028. /** Gets or sets the dead key flag */
  7029. get: function () {
  7030. return this._deadKey;
  7031. },
  7032. set: function (flag) {
  7033. this._deadKey = flag;
  7034. },
  7035. enumerable: true,
  7036. configurable: true
  7037. });
  7038. Object.defineProperty(InputText.prototype, "highlightedText", {
  7039. /** Gets or sets the highlight text */
  7040. get: function () {
  7041. return this._highlightedText;
  7042. },
  7043. set: function (text) {
  7044. if (this._highlightedText === text) {
  7045. return;
  7046. }
  7047. this._highlightedText = text;
  7048. this._markAsDirty();
  7049. },
  7050. enumerable: true,
  7051. configurable: true
  7052. });
  7053. Object.defineProperty(InputText.prototype, "addKey", {
  7054. /** Gets or sets if the current key should be added */
  7055. get: function () {
  7056. return this._addKey;
  7057. },
  7058. set: function (flag) {
  7059. this._addKey = flag;
  7060. },
  7061. enumerable: true,
  7062. configurable: true
  7063. });
  7064. Object.defineProperty(InputText.prototype, "currentKey", {
  7065. /** Gets or sets the value of the current key being entered */
  7066. get: function () {
  7067. return this._currentKey;
  7068. },
  7069. set: function (key) {
  7070. this._currentKey = key;
  7071. },
  7072. enumerable: true,
  7073. configurable: true
  7074. });
  7075. Object.defineProperty(InputText.prototype, "text", {
  7076. /** Gets or sets the text displayed in the control */
  7077. get: function () {
  7078. return this._text;
  7079. },
  7080. set: function (value) {
  7081. var valueAsString = value.toString(); // Forcing convertion
  7082. if (this._text === valueAsString) {
  7083. return;
  7084. }
  7085. this._text = valueAsString;
  7086. this._markAsDirty();
  7087. this.onTextChangedObservable.notifyObservers(this);
  7088. },
  7089. enumerable: true,
  7090. configurable: true
  7091. });
  7092. Object.defineProperty(InputText.prototype, "width", {
  7093. /** Gets or sets control width */
  7094. get: function () {
  7095. return this._width.toString(this._host);
  7096. },
  7097. set: function (value) {
  7098. if (this._width.toString(this._host) === value) {
  7099. return;
  7100. }
  7101. if (this._width.fromString(value)) {
  7102. this._markAsDirty();
  7103. }
  7104. this.autoStretchWidth = false;
  7105. },
  7106. enumerable: true,
  7107. configurable: true
  7108. });
  7109. /** @hidden */
  7110. InputText.prototype.onBlur = function () {
  7111. this._isFocused = false;
  7112. this._scrollLeft = null;
  7113. this._cursorOffset = 0;
  7114. clearTimeout(this._blinkTimeout);
  7115. this._markAsDirty();
  7116. this.onBlurObservable.notifyObservers(this);
  7117. this._host.unRegisterClipboardEvents();
  7118. if (this._onClipboardObserver) {
  7119. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7120. }
  7121. var scene = this._host.getScene();
  7122. if (this._onPointerDblTapObserver && scene) {
  7123. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7124. }
  7125. };
  7126. /** @hidden */
  7127. InputText.prototype.onFocus = function () {
  7128. var _this = this;
  7129. if (!this._isEnabled) {
  7130. return;
  7131. }
  7132. this._scrollLeft = null;
  7133. this._isFocused = true;
  7134. this._blinkIsEven = false;
  7135. this._cursorOffset = 0;
  7136. this._markAsDirty();
  7137. this.onFocusObservable.notifyObservers(this);
  7138. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7139. var value = prompt(this.promptMessage);
  7140. if (value !== null) {
  7141. this.text = value;
  7142. }
  7143. this._host.focusedControl = null;
  7144. return;
  7145. }
  7146. this._host.registerClipboardEvents();
  7147. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7148. // process clipboard event, can be configured.
  7149. switch (clipboardInfo.type) {
  7150. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7151. _this._onCopyText(clipboardInfo.event);
  7152. _this.onTextCopyObservable.notifyObservers(_this);
  7153. break;
  7154. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7155. _this._onCutText(clipboardInfo.event);
  7156. _this.onTextCutObservable.notifyObservers(_this);
  7157. break;
  7158. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7159. _this._onPasteText(clipboardInfo.event);
  7160. _this.onTextPasteObservable.notifyObservers(_this);
  7161. break;
  7162. default: return;
  7163. }
  7164. });
  7165. var scene = this._host.getScene();
  7166. if (scene) {
  7167. //register the pointer double tap event
  7168. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7169. if (!_this._isFocused) {
  7170. return;
  7171. }
  7172. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7173. _this._processDblClick(pointerInfo);
  7174. }
  7175. });
  7176. }
  7177. if (this._onFocusSelectAll) {
  7178. this._selectAllText();
  7179. }
  7180. };
  7181. InputText.prototype._getTypeName = function () {
  7182. return "InputText";
  7183. };
  7184. /**
  7185. * Function called to get the list of controls that should not steal the focus from this control
  7186. * @returns an array of controls
  7187. */
  7188. InputText.prototype.keepsFocusWith = function () {
  7189. if (!this._connectedVirtualKeyboard) {
  7190. return null;
  7191. }
  7192. return [this._connectedVirtualKeyboard];
  7193. };
  7194. /** @hidden */
  7195. InputText.prototype.processKey = function (keyCode, key, evt) {
  7196. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7197. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7198. return;
  7199. }
  7200. //select all
  7201. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7202. this._selectAllText();
  7203. evt.preventDefault();
  7204. return;
  7205. }
  7206. // Specific cases
  7207. switch (keyCode) {
  7208. case 32: //SPACE
  7209. key = " "; //ie11 key for space is "Spacebar"
  7210. break;
  7211. case 191: //SLASH
  7212. if (evt) {
  7213. evt.preventDefault();
  7214. }
  7215. break;
  7216. case 8: // BACKSPACE
  7217. if (this._text && this._text.length > 0) {
  7218. //delete the highlighted text
  7219. if (this._isTextHighlightOn) {
  7220. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7221. this._isTextHighlightOn = false;
  7222. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7223. this._blinkIsEven = false;
  7224. if (evt) {
  7225. evt.preventDefault();
  7226. }
  7227. return;
  7228. }
  7229. //delete single character
  7230. if (this._cursorOffset === 0) {
  7231. this.text = this._text.substr(0, this._text.length - 1);
  7232. }
  7233. else {
  7234. var deletePosition = this._text.length - this._cursorOffset;
  7235. if (deletePosition > 0) {
  7236. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7237. }
  7238. }
  7239. }
  7240. if (evt) {
  7241. evt.preventDefault();
  7242. }
  7243. return;
  7244. case 46: // DELETE
  7245. if (this._isTextHighlightOn) {
  7246. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7247. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7248. while (decrementor > 0 && this._cursorOffset > 0) {
  7249. this._cursorOffset--;
  7250. }
  7251. this._isTextHighlightOn = false;
  7252. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7253. if (evt) {
  7254. evt.preventDefault();
  7255. }
  7256. return;
  7257. }
  7258. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7259. var deletePosition = this._text.length - this._cursorOffset;
  7260. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7261. this._cursorOffset--;
  7262. }
  7263. if (evt) {
  7264. evt.preventDefault();
  7265. }
  7266. return;
  7267. case 13: // RETURN
  7268. this._host.focusedControl = null;
  7269. this._isTextHighlightOn = false;
  7270. return;
  7271. case 35: // END
  7272. this._cursorOffset = 0;
  7273. this._blinkIsEven = false;
  7274. this._isTextHighlightOn = false;
  7275. this._markAsDirty();
  7276. return;
  7277. case 36: // HOME
  7278. this._cursorOffset = this._text.length;
  7279. this._blinkIsEven = false;
  7280. this._isTextHighlightOn = false;
  7281. this._markAsDirty();
  7282. return;
  7283. case 37: // LEFT
  7284. this._cursorOffset++;
  7285. if (this._cursorOffset > this._text.length) {
  7286. this._cursorOffset = this._text.length;
  7287. }
  7288. if (evt && evt.shiftKey) {
  7289. // update the cursor
  7290. this._blinkIsEven = false;
  7291. // shift + ctrl/cmd + <-
  7292. if (evt.ctrlKey || evt.metaKey) {
  7293. if (!this._isTextHighlightOn) {
  7294. if (this._text.length === this._cursorOffset) {
  7295. return;
  7296. }
  7297. else {
  7298. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7299. }
  7300. }
  7301. this._startHighlightIndex = 0;
  7302. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7303. this._cursorOffset = this._text.length;
  7304. this._isTextHighlightOn = true;
  7305. this._markAsDirty();
  7306. return;
  7307. }
  7308. //store the starting point
  7309. if (!this._isTextHighlightOn) {
  7310. this._isTextHighlightOn = true;
  7311. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7312. }
  7313. //if text is already highlighted
  7314. else if (this._cursorIndex === -1) {
  7315. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7316. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7317. }
  7318. //set the highlight indexes
  7319. if (this._cursorIndex < this._cursorOffset) {
  7320. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7321. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7322. }
  7323. else if (this._cursorIndex > this._cursorOffset) {
  7324. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7325. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7326. }
  7327. else {
  7328. this._isTextHighlightOn = false;
  7329. }
  7330. this._markAsDirty();
  7331. return;
  7332. }
  7333. if (this._isTextHighlightOn) {
  7334. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7335. this._isTextHighlightOn = false;
  7336. }
  7337. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7338. this._cursorOffset = this.text.length;
  7339. evt.preventDefault();
  7340. }
  7341. this._blinkIsEven = false;
  7342. this._isTextHighlightOn = false;
  7343. this._cursorIndex = -1;
  7344. this._markAsDirty();
  7345. return;
  7346. case 39: // RIGHT
  7347. this._cursorOffset--;
  7348. if (this._cursorOffset < 0) {
  7349. this._cursorOffset = 0;
  7350. }
  7351. if (evt && evt.shiftKey) {
  7352. //update the cursor
  7353. this._blinkIsEven = false;
  7354. //shift + ctrl/cmd + ->
  7355. if (evt.ctrlKey || evt.metaKey) {
  7356. if (!this._isTextHighlightOn) {
  7357. if (this._cursorOffset === 0) {
  7358. return;
  7359. }
  7360. else {
  7361. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7362. }
  7363. }
  7364. this._endHighlightIndex = this._text.length;
  7365. this._isTextHighlightOn = true;
  7366. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7367. this._cursorOffset = 0;
  7368. this._markAsDirty();
  7369. return;
  7370. }
  7371. if (!this._isTextHighlightOn) {
  7372. this._isTextHighlightOn = true;
  7373. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7374. }
  7375. //if text is already highlighted
  7376. else if (this._cursorIndex === -1) {
  7377. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7378. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7379. }
  7380. //set the highlight indexes
  7381. if (this._cursorIndex < this._cursorOffset) {
  7382. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7383. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7384. }
  7385. else if (this._cursorIndex > this._cursorOffset) {
  7386. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7387. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7388. }
  7389. else {
  7390. this._isTextHighlightOn = false;
  7391. }
  7392. this._markAsDirty();
  7393. return;
  7394. }
  7395. if (this._isTextHighlightOn) {
  7396. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7397. this._isTextHighlightOn = false;
  7398. }
  7399. //ctr + ->
  7400. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7401. this._cursorOffset = 0;
  7402. evt.preventDefault();
  7403. }
  7404. this._blinkIsEven = false;
  7405. this._isTextHighlightOn = false;
  7406. this._cursorIndex = -1;
  7407. this._markAsDirty();
  7408. return;
  7409. case 222: // Dead
  7410. if (evt) {
  7411. evt.preventDefault();
  7412. }
  7413. this._cursorIndex = -1;
  7414. this.deadKey = true;
  7415. break;
  7416. }
  7417. // Printable characters
  7418. if (key &&
  7419. ((keyCode === -1) || // Direct access
  7420. (keyCode === 32) || // Space
  7421. (keyCode > 47 && keyCode < 64) || // Numbers
  7422. (keyCode > 64 && keyCode < 91) || // Letters
  7423. (keyCode > 159 && keyCode < 193) || // Special characters
  7424. (keyCode > 218 && keyCode < 223) || // Special characters
  7425. (keyCode > 95 && keyCode < 112))) { // Numpad
  7426. this._currentKey = key;
  7427. this.onBeforeKeyAddObservable.notifyObservers(this);
  7428. key = this._currentKey;
  7429. if (this._addKey) {
  7430. if (this._isTextHighlightOn) {
  7431. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7432. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7433. this._isTextHighlightOn = false;
  7434. this._blinkIsEven = false;
  7435. this._markAsDirty();
  7436. }
  7437. else if (this._cursorOffset === 0) {
  7438. this.text += key;
  7439. }
  7440. else {
  7441. var insertPosition = this._text.length - this._cursorOffset;
  7442. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7443. }
  7444. }
  7445. }
  7446. };
  7447. /** @hidden */
  7448. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7449. //update the cursor
  7450. this._blinkIsEven = false;
  7451. if (this._cursorIndex === -1) {
  7452. this._cursorIndex = offset;
  7453. }
  7454. else {
  7455. if (this._cursorIndex < this._cursorOffset) {
  7456. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7457. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7458. }
  7459. else if (this._cursorIndex > this._cursorOffset) {
  7460. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7461. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7462. }
  7463. else {
  7464. this._isTextHighlightOn = false;
  7465. this._markAsDirty();
  7466. return;
  7467. }
  7468. }
  7469. this._isTextHighlightOn = true;
  7470. this._markAsDirty();
  7471. };
  7472. /** @hidden */
  7473. InputText.prototype._processDblClick = function (evt) {
  7474. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7475. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7476. this._endHighlightIndex = this._startHighlightIndex;
  7477. var rWord = /\w+/g, moveLeft, moveRight;
  7478. do {
  7479. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7480. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7481. } while (moveLeft || moveRight);
  7482. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7483. this.onTextHighlightObservable.notifyObservers(this);
  7484. this._isTextHighlightOn = true;
  7485. this._clickedCoordinate = null;
  7486. this._blinkIsEven = true;
  7487. this._cursorIndex = -1;
  7488. this._markAsDirty();
  7489. };
  7490. /** @hidden */
  7491. InputText.prototype._selectAllText = function () {
  7492. this._blinkIsEven = true;
  7493. this._isTextHighlightOn = true;
  7494. this._startHighlightIndex = 0;
  7495. this._endHighlightIndex = this._text.length;
  7496. this._cursorOffset = this._text.length;
  7497. this._cursorIndex = -1;
  7498. this._markAsDirty();
  7499. };
  7500. /**
  7501. * Handles the keyboard event
  7502. * @param evt Defines the KeyboardEvent
  7503. */
  7504. InputText.prototype.processKeyboard = function (evt) {
  7505. // process pressed key
  7506. this.processKey(evt.keyCode, evt.key, evt);
  7507. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7508. };
  7509. /** @hidden */
  7510. InputText.prototype._onCopyText = function (ev) {
  7511. this._isTextHighlightOn = false;
  7512. //when write permission to clipbaord data is denied
  7513. try {
  7514. ev.clipboardData.setData("text/plain", this._highlightedText);
  7515. }
  7516. catch (_a) { } //pass
  7517. this._host.clipboardData = this._highlightedText;
  7518. };
  7519. /** @hidden */
  7520. InputText.prototype._onCutText = function (ev) {
  7521. if (!this._highlightedText) {
  7522. return;
  7523. }
  7524. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7525. this._isTextHighlightOn = false;
  7526. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7527. //when write permission to clipbaord data is denied
  7528. try {
  7529. ev.clipboardData.setData("text/plain", this._highlightedText);
  7530. }
  7531. catch (_a) { } //pass
  7532. this._host.clipboardData = this._highlightedText;
  7533. this._highlightedText = "";
  7534. };
  7535. /** @hidden */
  7536. InputText.prototype._onPasteText = function (ev) {
  7537. var data = "";
  7538. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7539. data = ev.clipboardData.getData("text/plain");
  7540. }
  7541. else {
  7542. //get the cached data; returns blank string by default
  7543. data = this._host.clipboardData;
  7544. }
  7545. var insertPosition = this._text.length - this._cursorOffset;
  7546. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7547. };
  7548. InputText.prototype._draw = function (context) {
  7549. var _this = this;
  7550. context.save();
  7551. this._applyStates(context);
  7552. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7553. context.shadowColor = this.shadowColor;
  7554. context.shadowBlur = this.shadowBlur;
  7555. context.shadowOffsetX = this.shadowOffsetX;
  7556. context.shadowOffsetY = this.shadowOffsetY;
  7557. }
  7558. // Background
  7559. if (this._isFocused) {
  7560. if (this._focusedBackground) {
  7561. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7562. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7563. }
  7564. }
  7565. else if (this._background) {
  7566. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7567. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7568. }
  7569. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7570. context.shadowBlur = 0;
  7571. context.shadowOffsetX = 0;
  7572. context.shadowOffsetY = 0;
  7573. }
  7574. if (!this._fontOffset) {
  7575. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7576. }
  7577. // Text
  7578. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7579. if (this.color) {
  7580. context.fillStyle = this.color;
  7581. }
  7582. var text = this._beforeRenderText(this._text);
  7583. if (!this._isFocused && !this._text && this._placeholderText) {
  7584. text = this._placeholderText;
  7585. if (this._placeholderColor) {
  7586. context.fillStyle = this._placeholderColor;
  7587. }
  7588. }
  7589. this._textWidth = context.measureText(text).width;
  7590. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7591. if (this._autoStretchWidth) {
  7592. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7593. }
  7594. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7595. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7596. context.save();
  7597. context.beginPath();
  7598. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7599. context.clip();
  7600. if (this._isFocused && this._textWidth > availableWidth) {
  7601. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7602. if (!this._scrollLeft) {
  7603. this._scrollLeft = textLeft;
  7604. }
  7605. }
  7606. else {
  7607. this._scrollLeft = clipTextLeft;
  7608. }
  7609. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7610. // Cursor
  7611. if (this._isFocused) {
  7612. // Need to move cursor
  7613. if (this._clickedCoordinate) {
  7614. var rightPosition = this._scrollLeft + this._textWidth;
  7615. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7616. var currentSize = 0;
  7617. this._cursorOffset = 0;
  7618. var previousDist = 0;
  7619. do {
  7620. if (this._cursorOffset) {
  7621. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7622. }
  7623. this._cursorOffset++;
  7624. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7625. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7626. // Find closest move
  7627. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7628. this._cursorOffset--;
  7629. }
  7630. this._blinkIsEven = false;
  7631. this._clickedCoordinate = null;
  7632. }
  7633. // Render cursor
  7634. if (!this._blinkIsEven) {
  7635. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7636. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7637. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7638. if (cursorLeft < clipTextLeft) {
  7639. this._scrollLeft += (clipTextLeft - cursorLeft);
  7640. cursorLeft = clipTextLeft;
  7641. this._markAsDirty();
  7642. }
  7643. else if (cursorLeft > clipTextLeft + availableWidth) {
  7644. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7645. cursorLeft = clipTextLeft + availableWidth;
  7646. this._markAsDirty();
  7647. }
  7648. if (!this._isTextHighlightOn) {
  7649. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7650. }
  7651. }
  7652. clearTimeout(this._blinkTimeout);
  7653. this._blinkTimeout = setTimeout(function () {
  7654. _this._blinkIsEven = !_this._blinkIsEven;
  7655. _this._markAsDirty();
  7656. }, 500);
  7657. //show the highlighted text
  7658. if (this._isTextHighlightOn) {
  7659. clearTimeout(this._blinkTimeout);
  7660. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7661. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7662. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7663. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7664. if (highlightCursorLeft < clipTextLeft) {
  7665. width = width - (clipTextLeft - highlightCursorLeft);
  7666. if (!width) {
  7667. // when using left arrow on text.length > availableWidth;
  7668. // assigns the width of the first letter after clipTextLeft
  7669. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7670. }
  7671. highlightCursorLeft = clipTextLeft;
  7672. }
  7673. //for transparancy
  7674. context.globalAlpha = this._highligherOpacity;
  7675. context.fillStyle = this._textHighlightColor;
  7676. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7677. context.globalAlpha = 1.0;
  7678. }
  7679. }
  7680. context.restore();
  7681. // Border
  7682. if (this._thickness) {
  7683. if (this._isFocused) {
  7684. if (this.focusedColor) {
  7685. context.strokeStyle = this.focusedColor;
  7686. }
  7687. }
  7688. else {
  7689. if (this.color) {
  7690. context.strokeStyle = this.color;
  7691. }
  7692. }
  7693. context.lineWidth = this._thickness;
  7694. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7695. }
  7696. context.restore();
  7697. };
  7698. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7699. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7700. return false;
  7701. }
  7702. this._clickedCoordinate = coordinates.x;
  7703. this._isTextHighlightOn = false;
  7704. this._highlightedText = "";
  7705. this._cursorIndex = -1;
  7706. this._isPointerDown = true;
  7707. this._host._capturingControl[pointerId] = this;
  7708. if (this._host.focusedControl === this) {
  7709. // Move cursor
  7710. clearTimeout(this._blinkTimeout);
  7711. this._markAsDirty();
  7712. return true;
  7713. }
  7714. if (!this._isEnabled) {
  7715. return false;
  7716. }
  7717. this._host.focusedControl = this;
  7718. return true;
  7719. };
  7720. InputText.prototype._onPointerMove = function (target, coordinates) {
  7721. if (this._host.focusedControl === this && this._isPointerDown) {
  7722. this._clickedCoordinate = coordinates.x;
  7723. this._markAsDirty();
  7724. this._updateValueFromCursorIndex(this._cursorOffset);
  7725. }
  7726. _super.prototype._onPointerMove.call(this, target, coordinates);
  7727. };
  7728. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7729. this._isPointerDown = false;
  7730. delete this._host._capturingControl[pointerId];
  7731. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7732. };
  7733. InputText.prototype._beforeRenderText = function (text) {
  7734. return text;
  7735. };
  7736. InputText.prototype.dispose = function () {
  7737. _super.prototype.dispose.call(this);
  7738. this.onBlurObservable.clear();
  7739. this.onFocusObservable.clear();
  7740. this.onTextChangedObservable.clear();
  7741. this.onTextCopyObservable.clear();
  7742. this.onTextCutObservable.clear();
  7743. this.onTextPasteObservable.clear();
  7744. this.onTextHighlightObservable.clear();
  7745. this.onKeyboardEventProcessedObservable.clear();
  7746. };
  7747. return InputText;
  7748. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7749. /***/ }),
  7750. /***/ "./2D/controls/line.ts":
  7751. /*!*****************************!*\
  7752. !*** ./2D/controls/line.ts ***!
  7753. \*****************************/
  7754. /*! exports provided: Line */
  7755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7756. "use strict";
  7757. __webpack_require__.r(__webpack_exports__);
  7758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7759. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7760. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  7761. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7762. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7763. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7764. /** Class used to render 2D lines */
  7765. var Line = /** @class */ (function (_super) {
  7766. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7767. /**
  7768. * Creates a new Line
  7769. * @param name defines the control name
  7770. */
  7771. function Line(name) {
  7772. var _this = _super.call(this, name) || this;
  7773. _this.name = name;
  7774. _this._lineWidth = 1;
  7775. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7776. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7777. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7778. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7779. _this._dash = new Array();
  7780. _this.isHitTestVisible = false;
  7781. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7782. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7783. return _this;
  7784. }
  7785. Object.defineProperty(Line.prototype, "dash", {
  7786. /** Gets or sets the dash pattern */
  7787. get: function () {
  7788. return this._dash;
  7789. },
  7790. set: function (value) {
  7791. if (this._dash === value) {
  7792. return;
  7793. }
  7794. this._dash = value;
  7795. this._markAsDirty();
  7796. },
  7797. enumerable: true,
  7798. configurable: true
  7799. });
  7800. Object.defineProperty(Line.prototype, "connectedControl", {
  7801. /** Gets or sets the control connected with the line end */
  7802. get: function () {
  7803. return this._connectedControl;
  7804. },
  7805. set: function (value) {
  7806. var _this = this;
  7807. if (this._connectedControl === value) {
  7808. return;
  7809. }
  7810. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7811. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7812. this._connectedControlDirtyObserver = null;
  7813. }
  7814. if (value) {
  7815. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7816. }
  7817. this._connectedControl = value;
  7818. this._markAsDirty();
  7819. },
  7820. enumerable: true,
  7821. configurable: true
  7822. });
  7823. Object.defineProperty(Line.prototype, "x1", {
  7824. /** Gets or sets start coordinates on X axis */
  7825. get: function () {
  7826. return this._x1.toString(this._host);
  7827. },
  7828. set: function (value) {
  7829. if (this._x1.toString(this._host) === value) {
  7830. return;
  7831. }
  7832. if (this._x1.fromString(value)) {
  7833. this._markAsDirty();
  7834. }
  7835. },
  7836. enumerable: true,
  7837. configurable: true
  7838. });
  7839. Object.defineProperty(Line.prototype, "y1", {
  7840. /** Gets or sets start coordinates on Y axis */
  7841. get: function () {
  7842. return this._y1.toString(this._host);
  7843. },
  7844. set: function (value) {
  7845. if (this._y1.toString(this._host) === value) {
  7846. return;
  7847. }
  7848. if (this._y1.fromString(value)) {
  7849. this._markAsDirty();
  7850. }
  7851. },
  7852. enumerable: true,
  7853. configurable: true
  7854. });
  7855. Object.defineProperty(Line.prototype, "x2", {
  7856. /** Gets or sets end coordinates on X axis */
  7857. get: function () {
  7858. return this._x2.toString(this._host);
  7859. },
  7860. set: function (value) {
  7861. if (this._x2.toString(this._host) === value) {
  7862. return;
  7863. }
  7864. if (this._x2.fromString(value)) {
  7865. this._markAsDirty();
  7866. }
  7867. },
  7868. enumerable: true,
  7869. configurable: true
  7870. });
  7871. Object.defineProperty(Line.prototype, "y2", {
  7872. /** Gets or sets end coordinates on Y axis */
  7873. get: function () {
  7874. return this._y2.toString(this._host);
  7875. },
  7876. set: function (value) {
  7877. if (this._y2.toString(this._host) === value) {
  7878. return;
  7879. }
  7880. if (this._y2.fromString(value)) {
  7881. this._markAsDirty();
  7882. }
  7883. },
  7884. enumerable: true,
  7885. configurable: true
  7886. });
  7887. Object.defineProperty(Line.prototype, "lineWidth", {
  7888. /** Gets or sets line width */
  7889. get: function () {
  7890. return this._lineWidth;
  7891. },
  7892. set: function (value) {
  7893. if (this._lineWidth === value) {
  7894. return;
  7895. }
  7896. this._lineWidth = value;
  7897. this._markAsDirty();
  7898. },
  7899. enumerable: true,
  7900. configurable: true
  7901. });
  7902. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7903. /** Gets or sets horizontal alignment */
  7904. set: function (value) {
  7905. return;
  7906. },
  7907. enumerable: true,
  7908. configurable: true
  7909. });
  7910. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7911. /** Gets or sets vertical alignment */
  7912. set: function (value) {
  7913. return;
  7914. },
  7915. enumerable: true,
  7916. configurable: true
  7917. });
  7918. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7919. get: function () {
  7920. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7921. },
  7922. enumerable: true,
  7923. configurable: true
  7924. });
  7925. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7926. get: function () {
  7927. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7928. },
  7929. enumerable: true,
  7930. configurable: true
  7931. });
  7932. Line.prototype._getTypeName = function () {
  7933. return "Line";
  7934. };
  7935. Line.prototype._draw = function (context) {
  7936. context.save();
  7937. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7938. context.shadowColor = this.shadowColor;
  7939. context.shadowBlur = this.shadowBlur;
  7940. context.shadowOffsetX = this.shadowOffsetX;
  7941. context.shadowOffsetY = this.shadowOffsetY;
  7942. }
  7943. this._applyStates(context);
  7944. context.strokeStyle = this.color;
  7945. context.lineWidth = this._lineWidth;
  7946. context.setLineDash(this._dash);
  7947. context.beginPath();
  7948. context.moveTo(this._x1.getValue(this._host), this._y1.getValue(this._host));
  7949. context.lineTo(this._effectiveX2, this._effectiveY2);
  7950. context.stroke();
  7951. context.restore();
  7952. };
  7953. Line.prototype._measure = function () {
  7954. // Width / Height
  7955. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7956. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7957. };
  7958. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7959. this._currentMeasure.left = Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7960. this._currentMeasure.top = Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7961. };
  7962. /**
  7963. * Move one end of the line given 3D cartesian coordinates.
  7964. * @param position Targeted world position
  7965. * @param scene Scene
  7966. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7967. */
  7968. Line.prototype.moveToVector3 = function (position, scene, end) {
  7969. if (end === void 0) { end = false; }
  7970. if (!this._host || this.parent !== this._host._rootContainer) {
  7971. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  7972. return;
  7973. }
  7974. var globalViewport = this._host._getGlobalViewport(scene);
  7975. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  7976. this._moveToProjectedPosition(projectedPosition, end);
  7977. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  7978. this.notRenderable = true;
  7979. return;
  7980. }
  7981. this.notRenderable = false;
  7982. };
  7983. /**
  7984. * Move one end of the line to a position in screen absolute space.
  7985. * @param projectedPosition Position in screen absolute space (X, Y)
  7986. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7987. */
  7988. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  7989. if (end === void 0) { end = false; }
  7990. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  7991. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  7992. if (end) {
  7993. this.x2 = x;
  7994. this.y2 = y;
  7995. this._x2.ignoreAdaptiveScaling = true;
  7996. this._y2.ignoreAdaptiveScaling = true;
  7997. }
  7998. else {
  7999. this.x1 = x;
  8000. this.y1 = y;
  8001. this._x1.ignoreAdaptiveScaling = true;
  8002. this._y1.ignoreAdaptiveScaling = true;
  8003. }
  8004. };
  8005. return Line;
  8006. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8007. /***/ }),
  8008. /***/ "./2D/controls/multiLine.ts":
  8009. /*!**********************************!*\
  8010. !*** ./2D/controls/multiLine.ts ***!
  8011. \**********************************/
  8012. /*! exports provided: MultiLine */
  8013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8014. "use strict";
  8015. __webpack_require__.r(__webpack_exports__);
  8016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8017. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8018. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/tools");
  8019. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8020. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8021. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8022. /**
  8023. * Class used to create multi line control
  8024. */
  8025. var MultiLine = /** @class */ (function (_super) {
  8026. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8027. /**
  8028. * Creates a new MultiLine
  8029. * @param name defines the control name
  8030. */
  8031. function MultiLine(name) {
  8032. var _this = _super.call(this, name) || this;
  8033. _this.name = name;
  8034. _this._lineWidth = 1;
  8035. /** Function called when a point is updated */
  8036. _this.onPointUpdate = function () {
  8037. _this._markAsDirty();
  8038. };
  8039. _this.isHitTestVisible = false;
  8040. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8041. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8042. _this._dash = [];
  8043. _this._points = [];
  8044. return _this;
  8045. }
  8046. Object.defineProperty(MultiLine.prototype, "dash", {
  8047. /** Gets or sets dash pattern */
  8048. get: function () {
  8049. return this._dash;
  8050. },
  8051. set: function (value) {
  8052. if (this._dash === value) {
  8053. return;
  8054. }
  8055. this._dash = value;
  8056. this._markAsDirty();
  8057. },
  8058. enumerable: true,
  8059. configurable: true
  8060. });
  8061. /**
  8062. * Gets point stored at specified index
  8063. * @param index defines the index to look for
  8064. * @returns the requested point if found
  8065. */
  8066. MultiLine.prototype.getAt = function (index) {
  8067. if (!this._points[index]) {
  8068. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8069. }
  8070. return this._points[index];
  8071. };
  8072. /**
  8073. * Adds new points to the point collection
  8074. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8075. * @returns the list of created MultiLinePoint
  8076. */
  8077. MultiLine.prototype.add = function () {
  8078. var _this = this;
  8079. var items = [];
  8080. for (var _i = 0; _i < arguments.length; _i++) {
  8081. items[_i] = arguments[_i];
  8082. }
  8083. return items.map(function (item) { return _this.push(item); });
  8084. };
  8085. /**
  8086. * Adds a new point to the point collection
  8087. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8088. * @returns the created MultiLinePoint
  8089. */
  8090. MultiLine.prototype.push = function (item) {
  8091. var point = this.getAt(this._points.length);
  8092. if (item == null) {
  8093. return point;
  8094. }
  8095. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8096. point.mesh = item;
  8097. }
  8098. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8099. point.control = item;
  8100. }
  8101. else if (item.x != null && item.y != null) {
  8102. point.x = item.x;
  8103. point.y = item.y;
  8104. }
  8105. return point;
  8106. };
  8107. /**
  8108. * Remove a specific value or point from the active point collection
  8109. * @param value defines the value or point to remove
  8110. */
  8111. MultiLine.prototype.remove = function (value) {
  8112. var index;
  8113. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8114. index = this._points.indexOf(value);
  8115. if (index === -1) {
  8116. return;
  8117. }
  8118. }
  8119. else {
  8120. index = value;
  8121. }
  8122. var point = this._points[index];
  8123. if (!point) {
  8124. return;
  8125. }
  8126. point.dispose();
  8127. this._points.splice(index, 1);
  8128. };
  8129. /**
  8130. * Resets this object to initial state (no point)
  8131. */
  8132. MultiLine.prototype.reset = function () {
  8133. while (this._points.length > 0) {
  8134. this.remove(this._points.length - 1);
  8135. }
  8136. };
  8137. /**
  8138. * Resets all links
  8139. */
  8140. MultiLine.prototype.resetLinks = function () {
  8141. this._points.forEach(function (point) {
  8142. if (point != null) {
  8143. point.resetLinks();
  8144. }
  8145. });
  8146. };
  8147. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8148. /** Gets or sets line width */
  8149. get: function () {
  8150. return this._lineWidth;
  8151. },
  8152. set: function (value) {
  8153. if (this._lineWidth === value) {
  8154. return;
  8155. }
  8156. this._lineWidth = value;
  8157. this._markAsDirty();
  8158. },
  8159. enumerable: true,
  8160. configurable: true
  8161. });
  8162. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8163. set: function (value) {
  8164. return;
  8165. },
  8166. enumerable: true,
  8167. configurable: true
  8168. });
  8169. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8170. set: function (value) {
  8171. return;
  8172. },
  8173. enumerable: true,
  8174. configurable: true
  8175. });
  8176. MultiLine.prototype._getTypeName = function () {
  8177. return "MultiLine";
  8178. };
  8179. MultiLine.prototype._draw = function (context) {
  8180. context.save();
  8181. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8182. context.shadowColor = this.shadowColor;
  8183. context.shadowBlur = this.shadowBlur;
  8184. context.shadowOffsetX = this.shadowOffsetX;
  8185. context.shadowOffsetY = this.shadowOffsetY;
  8186. }
  8187. this._applyStates(context);
  8188. context.strokeStyle = this.color;
  8189. context.lineWidth = this._lineWidth;
  8190. context.setLineDash(this._dash);
  8191. context.beginPath();
  8192. var first = true; //first index is not necessarily 0
  8193. this._points.forEach(function (point) {
  8194. if (!point) {
  8195. return;
  8196. }
  8197. if (first) {
  8198. context.moveTo(point._point.x, point._point.y);
  8199. first = false;
  8200. }
  8201. else {
  8202. context.lineTo(point._point.x, point._point.y);
  8203. }
  8204. });
  8205. context.stroke();
  8206. context.restore();
  8207. };
  8208. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8209. var _this = this;
  8210. this._minX = null;
  8211. this._minY = null;
  8212. this._maxX = null;
  8213. this._maxY = null;
  8214. this._points.forEach(function (point, index) {
  8215. if (!point) {
  8216. return;
  8217. }
  8218. point.translate();
  8219. if (_this._minX == null || point._point.x < _this._minX) {
  8220. _this._minX = point._point.x;
  8221. }
  8222. if (_this._minY == null || point._point.y < _this._minY) {
  8223. _this._minY = point._point.y;
  8224. }
  8225. if (_this._maxX == null || point._point.x > _this._maxX) {
  8226. _this._maxX = point._point.x;
  8227. }
  8228. if (_this._maxY == null || point._point.y > _this._maxY) {
  8229. _this._maxY = point._point.y;
  8230. }
  8231. });
  8232. if (this._minX == null) {
  8233. this._minX = 0;
  8234. }
  8235. if (this._minY == null) {
  8236. this._minY = 0;
  8237. }
  8238. if (this._maxX == null) {
  8239. this._maxX = 0;
  8240. }
  8241. if (this._maxY == null) {
  8242. this._maxY = 0;
  8243. }
  8244. };
  8245. MultiLine.prototype._measure = function () {
  8246. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8247. return;
  8248. }
  8249. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8250. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8251. };
  8252. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8253. if (this._minX == null || this._minY == null) {
  8254. return;
  8255. }
  8256. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8257. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8258. };
  8259. MultiLine.prototype.dispose = function () {
  8260. this.reset();
  8261. _super.prototype.dispose.call(this);
  8262. };
  8263. return MultiLine;
  8264. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8265. /***/ }),
  8266. /***/ "./2D/controls/radioButton.ts":
  8267. /*!************************************!*\
  8268. !*** ./2D/controls/radioButton.ts ***!
  8269. \************************************/
  8270. /*! exports provided: RadioButton */
  8271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8272. "use strict";
  8273. __webpack_require__.r(__webpack_exports__);
  8274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8275. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8276. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  8277. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8278. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8279. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8280. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8281. /**
  8282. * Class used to create radio button controls
  8283. */
  8284. var RadioButton = /** @class */ (function (_super) {
  8285. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8286. /**
  8287. * Creates a new RadioButton
  8288. * @param name defines the control name
  8289. */
  8290. function RadioButton(name) {
  8291. var _this = _super.call(this, name) || this;
  8292. _this.name = name;
  8293. _this._isChecked = false;
  8294. _this._background = "black";
  8295. _this._checkSizeRatio = 0.8;
  8296. _this._thickness = 1;
  8297. /** Gets or sets group name */
  8298. _this.group = "";
  8299. /** Observable raised when isChecked is changed */
  8300. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8301. _this.isPointerBlocker = true;
  8302. return _this;
  8303. }
  8304. Object.defineProperty(RadioButton.prototype, "thickness", {
  8305. /** Gets or sets border thickness */
  8306. get: function () {
  8307. return this._thickness;
  8308. },
  8309. set: function (value) {
  8310. if (this._thickness === value) {
  8311. return;
  8312. }
  8313. this._thickness = value;
  8314. this._markAsDirty();
  8315. },
  8316. enumerable: true,
  8317. configurable: true
  8318. });
  8319. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8320. /** Gets or sets a value indicating the ratio between overall size and check size */
  8321. get: function () {
  8322. return this._checkSizeRatio;
  8323. },
  8324. set: function (value) {
  8325. value = Math.max(Math.min(1, value), 0);
  8326. if (this._checkSizeRatio === value) {
  8327. return;
  8328. }
  8329. this._checkSizeRatio = value;
  8330. this._markAsDirty();
  8331. },
  8332. enumerable: true,
  8333. configurable: true
  8334. });
  8335. Object.defineProperty(RadioButton.prototype, "background", {
  8336. /** Gets or sets background color */
  8337. get: function () {
  8338. return this._background;
  8339. },
  8340. set: function (value) {
  8341. if (this._background === value) {
  8342. return;
  8343. }
  8344. this._background = value;
  8345. this._markAsDirty();
  8346. },
  8347. enumerable: true,
  8348. configurable: true
  8349. });
  8350. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8351. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8352. get: function () {
  8353. return this._isChecked;
  8354. },
  8355. set: function (value) {
  8356. var _this = this;
  8357. if (this._isChecked === value) {
  8358. return;
  8359. }
  8360. this._isChecked = value;
  8361. this._markAsDirty();
  8362. this.onIsCheckedChangedObservable.notifyObservers(value);
  8363. if (this._isChecked && this._host) {
  8364. // Update all controls from same group
  8365. this._host.executeOnAllControls(function (control) {
  8366. if (control === _this) {
  8367. return;
  8368. }
  8369. if (control.group === undefined) {
  8370. return;
  8371. }
  8372. var childRadio = control;
  8373. if (childRadio.group === _this.group) {
  8374. childRadio.isChecked = false;
  8375. }
  8376. });
  8377. }
  8378. },
  8379. enumerable: true,
  8380. configurable: true
  8381. });
  8382. RadioButton.prototype._getTypeName = function () {
  8383. return "RadioButton";
  8384. };
  8385. RadioButton.prototype._draw = function (context) {
  8386. context.save();
  8387. this._applyStates(context);
  8388. var actualWidth = this._currentMeasure.width - this._thickness;
  8389. var actualHeight = this._currentMeasure.height - this._thickness;
  8390. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8391. context.shadowColor = this.shadowColor;
  8392. context.shadowBlur = this.shadowBlur;
  8393. context.shadowOffsetX = this.shadowOffsetX;
  8394. context.shadowOffsetY = this.shadowOffsetY;
  8395. }
  8396. // Outer
  8397. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  8398. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8399. context.fill();
  8400. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8401. context.shadowBlur = 0;
  8402. context.shadowOffsetX = 0;
  8403. context.shadowOffsetY = 0;
  8404. }
  8405. context.strokeStyle = this.color;
  8406. context.lineWidth = this._thickness;
  8407. context.stroke();
  8408. // Inner
  8409. if (this._isChecked) {
  8410. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8411. var offsetWidth = actualWidth * this._checkSizeRatio;
  8412. var offseHeight = actualHeight * this._checkSizeRatio;
  8413. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, offsetWidth / 2 - this._thickness / 2, offseHeight / 2 - this._thickness / 2, context);
  8414. context.fill();
  8415. }
  8416. context.restore();
  8417. };
  8418. // Events
  8419. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8420. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8421. return false;
  8422. }
  8423. if (!this.isChecked) {
  8424. this.isChecked = true;
  8425. }
  8426. return true;
  8427. };
  8428. /**
  8429. * Utility function to easily create a radio button with a header
  8430. * @param title defines the label to use for the header
  8431. * @param group defines the group to use for the radio button
  8432. * @param isChecked defines the initial state of the radio button
  8433. * @param onValueChanged defines the callback to call when value changes
  8434. * @returns a StackPanel containing the radio button and a textBlock
  8435. */
  8436. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8437. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8438. panel.isVertical = false;
  8439. panel.height = "30px";
  8440. var radio = new RadioButton();
  8441. radio.width = "20px";
  8442. radio.height = "20px";
  8443. radio.isChecked = isChecked;
  8444. radio.color = "green";
  8445. radio.group = group;
  8446. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8447. panel.addControl(radio);
  8448. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8449. header.text = title;
  8450. header.width = "180px";
  8451. header.paddingLeft = "5px";
  8452. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8453. header.color = "white";
  8454. panel.addControl(header);
  8455. return panel;
  8456. };
  8457. return RadioButton;
  8458. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8459. /***/ }),
  8460. /***/ "./2D/controls/rectangle.ts":
  8461. /*!**********************************!*\
  8462. !*** ./2D/controls/rectangle.ts ***!
  8463. \**********************************/
  8464. /*! exports provided: Rectangle */
  8465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8466. "use strict";
  8467. __webpack_require__.r(__webpack_exports__);
  8468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8469. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8470. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8471. /** Class used to create rectangle container */
  8472. var Rectangle = /** @class */ (function (_super) {
  8473. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8474. /**
  8475. * Creates a new Rectangle
  8476. * @param name defines the control name
  8477. */
  8478. function Rectangle(name) {
  8479. var _this = _super.call(this, name) || this;
  8480. _this.name = name;
  8481. _this._thickness = 1;
  8482. _this._cornerRadius = 0;
  8483. return _this;
  8484. }
  8485. Object.defineProperty(Rectangle.prototype, "thickness", {
  8486. /** Gets or sets border thickness */
  8487. get: function () {
  8488. return this._thickness;
  8489. },
  8490. set: function (value) {
  8491. if (this._thickness === value) {
  8492. return;
  8493. }
  8494. this._thickness = value;
  8495. this._markAsDirty();
  8496. },
  8497. enumerable: true,
  8498. configurable: true
  8499. });
  8500. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8501. /** Gets or sets the corner radius angle */
  8502. get: function () {
  8503. return this._cornerRadius;
  8504. },
  8505. set: function (value) {
  8506. if (value < 0) {
  8507. value = 0;
  8508. }
  8509. if (this._cornerRadius === value) {
  8510. return;
  8511. }
  8512. this._cornerRadius = value;
  8513. this._markAsDirty();
  8514. },
  8515. enumerable: true,
  8516. configurable: true
  8517. });
  8518. Rectangle.prototype._getTypeName = function () {
  8519. return "Rectangle";
  8520. };
  8521. Rectangle.prototype._localDraw = function (context) {
  8522. context.save();
  8523. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8524. context.shadowColor = this.shadowColor;
  8525. context.shadowBlur = this.shadowBlur;
  8526. context.shadowOffsetX = this.shadowOffsetX;
  8527. context.shadowOffsetY = this.shadowOffsetY;
  8528. }
  8529. if (this._background) {
  8530. context.fillStyle = this._background;
  8531. if (this._cornerRadius) {
  8532. this._drawRoundedRect(context, this._thickness / 2);
  8533. context.fill();
  8534. }
  8535. else {
  8536. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8537. }
  8538. }
  8539. if (this._thickness) {
  8540. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8541. context.shadowBlur = 0;
  8542. context.shadowOffsetX = 0;
  8543. context.shadowOffsetY = 0;
  8544. }
  8545. if (this.color) {
  8546. context.strokeStyle = this.color;
  8547. }
  8548. context.lineWidth = this._thickness;
  8549. if (this._cornerRadius) {
  8550. this._drawRoundedRect(context, this._thickness / 2);
  8551. context.stroke();
  8552. }
  8553. else {
  8554. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8555. }
  8556. }
  8557. context.restore();
  8558. };
  8559. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8560. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8561. this._measureForChildren.width -= 2 * this._thickness;
  8562. this._measureForChildren.height -= 2 * this._thickness;
  8563. this._measureForChildren.left += this._thickness;
  8564. this._measureForChildren.top += this._thickness;
  8565. };
  8566. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8567. if (offset === void 0) { offset = 0; }
  8568. var x = this._currentMeasure.left + offset;
  8569. var y = this._currentMeasure.top + offset;
  8570. var width = this._currentMeasure.width - offset * 2;
  8571. var height = this._currentMeasure.height - offset * 2;
  8572. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8573. context.beginPath();
  8574. context.moveTo(x + radius, y);
  8575. context.lineTo(x + width - radius, y);
  8576. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8577. context.lineTo(x + width, y + height - radius);
  8578. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8579. context.lineTo(x + radius, y + height);
  8580. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8581. context.lineTo(x, y + radius);
  8582. context.quadraticCurveTo(x, y, x + radius, y);
  8583. context.closePath();
  8584. };
  8585. Rectangle.prototype._clipForChildren = function (context) {
  8586. if (this._cornerRadius) {
  8587. this._drawRoundedRect(context, this._thickness);
  8588. context.clip();
  8589. }
  8590. };
  8591. return Rectangle;
  8592. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8593. /***/ }),
  8594. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8595. /*!***************************************************!*\
  8596. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8597. \***************************************************/
  8598. /*! exports provided: ScrollViewer */
  8599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8600. "use strict";
  8601. __webpack_require__.r(__webpack_exports__);
  8602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8603. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8604. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/tools");
  8605. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8606. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8607. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8608. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8609. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8610. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8611. /**
  8612. * Class used to hold a viewer window and sliders in a grid
  8613. */
  8614. var ScrollViewer = /** @class */ (function (_super) {
  8615. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8616. /**
  8617. * Creates a new ScrollViewer
  8618. * @param name of ScrollViewer
  8619. */
  8620. function ScrollViewer(name) {
  8621. var _this = _super.call(this, name) || this;
  8622. _this._barSize = 20;
  8623. _this._pointerIsOver = false;
  8624. _this._wheelPrecision = 0.05;
  8625. _this.onDirtyObservable.add(function () {
  8626. _this._horizontalBarSpace.color = _this.color;
  8627. _this._verticalBarSpace.color = _this.color;
  8628. _this._dragSpace.color = _this.color;
  8629. });
  8630. _this.onPointerEnterObservable.add(function () {
  8631. _this._pointerIsOver = true;
  8632. });
  8633. _this.onPointerOutObservable.add(function () {
  8634. _this._pointerIsOver = false;
  8635. });
  8636. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8637. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8638. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8639. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8640. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8641. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8642. _this._grid.addColumnDefinition(1);
  8643. _this._grid.addColumnDefinition(0, true);
  8644. _this._grid.addRowDefinition(1);
  8645. _this._grid.addRowDefinition(0, true);
  8646. _super.prototype.addControl.call(_this, _this._grid);
  8647. _this._grid.addControl(_this._window, 0, 0);
  8648. _this._verticalBar.paddingLeft = 0;
  8649. _this._verticalBar.width = "100%";
  8650. _this._verticalBar.height = "100%";
  8651. _this._verticalBar.barOffset = 0;
  8652. _this._verticalBar.value = 0;
  8653. _this._verticalBar.maximum = 1;
  8654. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8655. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8656. _this._verticalBar.isVertical = true;
  8657. _this._verticalBar.rotation = Math.PI;
  8658. _this._verticalBar.isVisible = false;
  8659. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8660. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8661. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8662. _this._verticalBarSpace.thickness = 1;
  8663. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8664. _this._verticalBarSpace.addControl(_this._verticalBar);
  8665. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8666. _this._window.top = value * _this._endTop + "px";
  8667. });
  8668. _this._horizontalBar.paddingLeft = 0;
  8669. _this._horizontalBar.width = "100%";
  8670. _this._horizontalBar.height = "100%";
  8671. _this._horizontalBar.barOffset = 0;
  8672. _this._horizontalBar.value = 0;
  8673. _this._horizontalBar.maximum = 1;
  8674. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8675. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8676. _this._horizontalBar.isVisible = false;
  8677. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8678. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8679. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8680. _this._horizontalBarSpace.thickness = 1;
  8681. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8682. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8683. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8684. _this._window.left = value * _this._endLeft + "px";
  8685. });
  8686. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8687. _this._dragSpace.thickness = 1;
  8688. _this._grid.addControl(_this._dragSpace, 1, 1);
  8689. // Colors
  8690. _this.barColor = "grey";
  8691. _this.barBackground = "transparent";
  8692. return _this;
  8693. }
  8694. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8695. /**
  8696. * Gets the horizontal scrollbar
  8697. */
  8698. get: function () {
  8699. return this._horizontalBar;
  8700. },
  8701. enumerable: true,
  8702. configurable: true
  8703. });
  8704. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8705. /**
  8706. * Gets the vertical scrollbar
  8707. */
  8708. get: function () {
  8709. return this._verticalBar;
  8710. },
  8711. enumerable: true,
  8712. configurable: true
  8713. });
  8714. /**
  8715. * Adds a new control to the current container
  8716. * @param control defines the control to add
  8717. * @returns the current container
  8718. */
  8719. ScrollViewer.prototype.addControl = function (control) {
  8720. if (!control) {
  8721. return this;
  8722. }
  8723. this._window.addControl(control);
  8724. return this;
  8725. };
  8726. /**
  8727. * Removes a control from the current container
  8728. * @param control defines the control to remove
  8729. * @returns the current container
  8730. */
  8731. ScrollViewer.prototype.removeControl = function (control) {
  8732. this._window.removeControl(control);
  8733. return this;
  8734. };
  8735. Object.defineProperty(ScrollViewer.prototype, "children", {
  8736. /** Gets the list of children */
  8737. get: function () {
  8738. return this._window.children;
  8739. },
  8740. enumerable: true,
  8741. configurable: true
  8742. });
  8743. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8744. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8745. var child = _a[_i];
  8746. child._markMatrixAsDirty();
  8747. }
  8748. };
  8749. /** Reset the scroll viewer window to initial size */
  8750. ScrollViewer.prototype.resetWindow = function () {
  8751. this._window.width = "100%";
  8752. this._window.height = "100%";
  8753. };
  8754. ScrollViewer.prototype._getTypeName = function () {
  8755. return "ScrollViewer";
  8756. };
  8757. ScrollViewer.prototype._buildClientSizes = function () {
  8758. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8759. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8760. this._clientWidth = this._window.parentClientWidth;
  8761. this._clientHeight = this._window.parentClientHeight;
  8762. };
  8763. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8764. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8765. this._buildClientSizes();
  8766. };
  8767. ScrollViewer.prototype._postMeasure = function () {
  8768. _super.prototype._postMeasure.call(this);
  8769. this._updateScroller();
  8770. };
  8771. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8772. /**
  8773. * Gets or sets the mouse wheel precision
  8774. * from 0 to 1 with a default value of 0.05
  8775. * */
  8776. get: function () {
  8777. return this._wheelPrecision;
  8778. },
  8779. set: function (value) {
  8780. if (this._wheelPrecision === value) {
  8781. return;
  8782. }
  8783. if (value < 0) {
  8784. value = 0;
  8785. }
  8786. if (value > 1) {
  8787. value = 1;
  8788. }
  8789. this._wheelPrecision = value;
  8790. },
  8791. enumerable: true,
  8792. configurable: true
  8793. });
  8794. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8795. /** Gets or sets the bar color */
  8796. get: function () {
  8797. return this._barColor;
  8798. },
  8799. set: function (color) {
  8800. if (this._barColor === color) {
  8801. return;
  8802. }
  8803. this._barColor = color;
  8804. this._horizontalBar.color = color;
  8805. this._verticalBar.color = color;
  8806. },
  8807. enumerable: true,
  8808. configurable: true
  8809. });
  8810. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8811. /** Gets or sets the size of the bar */
  8812. get: function () {
  8813. return this._barSize;
  8814. },
  8815. set: function (value) {
  8816. if (this._barSize === value) {
  8817. return;
  8818. }
  8819. this._barSize = value;
  8820. this._markAsDirty();
  8821. if (this._horizontalBar.isVisible) {
  8822. this._grid.setRowDefinition(1, this._barSize, true);
  8823. }
  8824. if (this._verticalBar.isVisible) {
  8825. this._grid.setColumnDefinition(1, this._barSize, true);
  8826. }
  8827. },
  8828. enumerable: true,
  8829. configurable: true
  8830. });
  8831. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8832. /** Gets or sets the bar background */
  8833. get: function () {
  8834. return this._barBackground;
  8835. },
  8836. set: function (color) {
  8837. if (this._barBackground === color) {
  8838. return;
  8839. }
  8840. this._barBackground = color;
  8841. this._horizontalBar.background = color;
  8842. this._verticalBar.background = color;
  8843. this._dragSpace.background = color;
  8844. },
  8845. enumerable: true,
  8846. configurable: true
  8847. });
  8848. /** @hidden */
  8849. ScrollViewer.prototype._updateScroller = function () {
  8850. var windowContentsWidth = this._window._currentMeasure.width;
  8851. var windowContentsHeight = this._window._currentMeasure.height;
  8852. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8853. this._grid.setRowDefinition(1, 0, true);
  8854. this._horizontalBar.isVisible = false;
  8855. this._horizontalBar.value = 0;
  8856. this._rebuildLayout = true;
  8857. }
  8858. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8859. this._grid.setRowDefinition(1, this._barSize, true);
  8860. this._horizontalBar.isVisible = true;
  8861. this._rebuildLayout = true;
  8862. }
  8863. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8864. this._grid.setColumnDefinition(1, 0, true);
  8865. this._verticalBar.isVisible = false;
  8866. this._verticalBar.value = 0;
  8867. this._rebuildLayout = true;
  8868. }
  8869. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8870. this._grid.setColumnDefinition(1, this._barSize, true);
  8871. this._verticalBar.isVisible = true;
  8872. this._rebuildLayout = true;
  8873. }
  8874. this._buildClientSizes();
  8875. this._endLeft = this._clientWidth - windowContentsWidth;
  8876. this._endTop = this._clientHeight - windowContentsHeight;
  8877. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8878. var newTop = this._verticalBar.value * this._endTop + "px";
  8879. if (newLeft !== this._window.left) {
  8880. this._window.left = newLeft;
  8881. this._rebuildLayout = true;
  8882. }
  8883. if (newTop !== this._window.top) {
  8884. this._window.top = newTop;
  8885. this._rebuildLayout = true;
  8886. }
  8887. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8888. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8889. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8890. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8891. };
  8892. ScrollViewer.prototype._link = function (host) {
  8893. _super.prototype._link.call(this, host);
  8894. this._attachWheel();
  8895. };
  8896. /** @hidden */
  8897. ScrollViewer.prototype._attachWheel = function () {
  8898. var _this = this;
  8899. if (this._onPointerObserver) {
  8900. return;
  8901. }
  8902. var scene = this._host.getScene();
  8903. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8904. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8905. return;
  8906. }
  8907. if (_this._verticalBar.isVisible == true) {
  8908. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8909. _this._verticalBar.value -= _this._wheelPrecision;
  8910. }
  8911. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8912. _this._verticalBar.value += _this._wheelPrecision;
  8913. }
  8914. }
  8915. if (_this._horizontalBar.isVisible == true) {
  8916. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8917. _this._horizontalBar.value += _this._wheelPrecision;
  8918. }
  8919. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8920. _this._horizontalBar.value -= _this._wheelPrecision;
  8921. }
  8922. }
  8923. });
  8924. };
  8925. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8926. if (!this.isHighlighted) {
  8927. return;
  8928. }
  8929. _super.prototype._renderHighlightSpecific.call(this, context);
  8930. this._grid._renderHighlightSpecific(context);
  8931. context.restore();
  8932. };
  8933. /** Releases associated resources */
  8934. ScrollViewer.prototype.dispose = function () {
  8935. var scene = this._host.getScene();
  8936. if (scene && this._onPointerObserver) {
  8937. scene.onPointerObservable.remove(this._onPointerObserver);
  8938. this._onPointerObserver = null;
  8939. }
  8940. _super.prototype.dispose.call(this);
  8941. };
  8942. return ScrollViewer;
  8943. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8944. /***/ }),
  8945. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8946. /*!*********************************************************!*\
  8947. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8948. \*********************************************************/
  8949. /*! exports provided: _ScrollViewerWindow */
  8950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8951. "use strict";
  8952. __webpack_require__.r(__webpack_exports__);
  8953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8954. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8955. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8956. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8957. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8958. /**
  8959. * Class used to hold a the container for ScrollViewer
  8960. * @hidden
  8961. */
  8962. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8963. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  8964. /**
  8965. * Creates a new ScrollViewerWindow
  8966. * @param name of ScrollViewerWindow
  8967. */
  8968. function _ScrollViewerWindow(name) {
  8969. return _super.call(this, name) || this;
  8970. }
  8971. _ScrollViewerWindow.prototype._getTypeName = function () {
  8972. return "ScrollViewerWindow";
  8973. };
  8974. /** @hidden */
  8975. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  8976. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8977. this._measureForChildren.left = this._currentMeasure.left;
  8978. this._measureForChildren.top = this._currentMeasure.top;
  8979. this._measureForChildren.width = parentMeasure.width;
  8980. this._measureForChildren.height = parentMeasure.height;
  8981. };
  8982. _ScrollViewerWindow.prototype._postMeasure = function () {
  8983. var maxWidth = this.parentClientWidth;
  8984. var maxHeight = this.parentClientHeight;
  8985. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  8986. var child = _a[_i];
  8987. if (!child.isVisible || child.notRenderable) {
  8988. continue;
  8989. }
  8990. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  8991. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  8992. }
  8993. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  8994. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  8995. }
  8996. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  8997. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  8998. }
  8999. if (this._currentMeasure.width !== maxWidth) {
  9000. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9001. this._currentMeasure.width = maxWidth;
  9002. this._rebuildLayout = true;
  9003. this._isDirty = true;
  9004. }
  9005. if (this._currentMeasure.height !== maxHeight) {
  9006. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9007. this._currentMeasure.height = maxHeight;
  9008. this._rebuildLayout = true;
  9009. this._isDirty = true;
  9010. }
  9011. _super.prototype._postMeasure.call(this);
  9012. };
  9013. return _ScrollViewerWindow;
  9014. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9015. /***/ }),
  9016. /***/ "./2D/controls/selector.ts":
  9017. /*!*********************************!*\
  9018. !*** ./2D/controls/selector.ts ***!
  9019. \*********************************/
  9020. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9022. "use strict";
  9023. __webpack_require__.r(__webpack_exports__);
  9024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9029. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9030. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9031. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9032. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9033. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9034. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9035. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9036. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9037. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9038. /** Class used to create a RadioGroup
  9039. * which contains groups of radio buttons
  9040. */
  9041. var SelectorGroup = /** @class */ (function () {
  9042. /**
  9043. * Creates a new SelectorGroup
  9044. * @param name of group, used as a group heading
  9045. */
  9046. function SelectorGroup(
  9047. /** name of SelectorGroup */
  9048. name) {
  9049. this.name = name;
  9050. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9051. this._selectors = new Array();
  9052. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9053. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9054. this._groupHeader = this._addGroupHeader(name);
  9055. }
  9056. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9057. /** Gets the groupPanel of the SelectorGroup */
  9058. get: function () {
  9059. return this._groupPanel;
  9060. },
  9061. enumerable: true,
  9062. configurable: true
  9063. });
  9064. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9065. /** Gets the selectors array */
  9066. get: function () {
  9067. return this._selectors;
  9068. },
  9069. enumerable: true,
  9070. configurable: true
  9071. });
  9072. Object.defineProperty(SelectorGroup.prototype, "header", {
  9073. /** Gets and sets the group header */
  9074. get: function () {
  9075. return this._groupHeader.text;
  9076. },
  9077. set: function (label) {
  9078. if (this._groupHeader.text === "label") {
  9079. return;
  9080. }
  9081. this._groupHeader.text = label;
  9082. },
  9083. enumerable: true,
  9084. configurable: true
  9085. });
  9086. /** @hidden */
  9087. SelectorGroup.prototype._addGroupHeader = function (text) {
  9088. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9089. groupHeading.width = 0.9;
  9090. groupHeading.height = "30px";
  9091. groupHeading.textWrapping = true;
  9092. groupHeading.color = "black";
  9093. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9094. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9095. groupHeading.left = "2px";
  9096. this._groupPanel.addControl(groupHeading);
  9097. return groupHeading;
  9098. };
  9099. /** @hidden*/
  9100. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9101. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9102. return;
  9103. }
  9104. return this._selectors[selectorNb];
  9105. };
  9106. /** Removes the selector at the given position
  9107. * @param selectorNb the position of the selector within the group
  9108. */
  9109. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9110. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9111. return;
  9112. }
  9113. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9114. this._selectors.splice(selectorNb, 1);
  9115. };
  9116. return SelectorGroup;
  9117. }());
  9118. /** Class used to create a CheckboxGroup
  9119. * which contains groups of checkbox buttons
  9120. */
  9121. var CheckboxGroup = /** @class */ (function (_super) {
  9122. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9123. function CheckboxGroup() {
  9124. return _super !== null && _super.apply(this, arguments) || this;
  9125. }
  9126. /** Adds a checkbox as a control
  9127. * @param text is the label for the selector
  9128. * @param func is the function called when the Selector is checked
  9129. * @param checked is true when Selector is checked
  9130. */
  9131. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9132. if (func === void 0) { func = function (s) { }; }
  9133. if (checked === void 0) { checked = false; }
  9134. var checked = checked || false;
  9135. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9136. button.width = "20px";
  9137. button.height = "20px";
  9138. button.color = "#364249";
  9139. button.background = "#CCCCCC";
  9140. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9141. button.onIsCheckedChangedObservable.add(function (state) {
  9142. func(state);
  9143. });
  9144. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9145. _selector.height = "30px";
  9146. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9147. _selector.left = "4px";
  9148. this.groupPanel.addControl(_selector);
  9149. this.selectors.push(_selector);
  9150. button.isChecked = checked;
  9151. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9152. button.color = this.groupPanel.parent.parent.buttonColor;
  9153. button.background = this.groupPanel.parent.parent.buttonBackground;
  9154. }
  9155. };
  9156. /** @hidden */
  9157. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9158. this.selectors[selectorNb].children[1].text = label;
  9159. };
  9160. /** @hidden */
  9161. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9162. this.selectors[selectorNb].children[1].color = color;
  9163. };
  9164. /** @hidden */
  9165. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9166. this.selectors[selectorNb].children[0].color = color;
  9167. };
  9168. /** @hidden */
  9169. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9170. this.selectors[selectorNb].children[0].background = color;
  9171. };
  9172. return CheckboxGroup;
  9173. }(SelectorGroup));
  9174. /** Class used to create a RadioGroup
  9175. * which contains groups of radio buttons
  9176. */
  9177. var RadioGroup = /** @class */ (function (_super) {
  9178. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9179. function RadioGroup() {
  9180. var _this = _super !== null && _super.apply(this, arguments) || this;
  9181. _this._selectNb = 0;
  9182. return _this;
  9183. }
  9184. /** Adds a radio button as a control
  9185. * @param label is the label for the selector
  9186. * @param func is the function called when the Selector is checked
  9187. * @param checked is true when Selector is checked
  9188. */
  9189. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9190. if (func === void 0) { func = function (n) { }; }
  9191. if (checked === void 0) { checked = false; }
  9192. var nb = this._selectNb++;
  9193. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9194. button.name = label;
  9195. button.width = "20px";
  9196. button.height = "20px";
  9197. button.color = "#364249";
  9198. button.background = "#CCCCCC";
  9199. button.group = this.name;
  9200. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9201. button.onIsCheckedChangedObservable.add(function (state) {
  9202. if (state) {
  9203. func(nb);
  9204. }
  9205. });
  9206. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9207. _selector.height = "30px";
  9208. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9209. _selector.left = "4px";
  9210. this.groupPanel.addControl(_selector);
  9211. this.selectors.push(_selector);
  9212. button.isChecked = checked;
  9213. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9214. button.color = this.groupPanel.parent.parent.buttonColor;
  9215. button.background = this.groupPanel.parent.parent.buttonBackground;
  9216. }
  9217. };
  9218. /** @hidden */
  9219. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9220. this.selectors[selectorNb].children[1].text = label;
  9221. };
  9222. /** @hidden */
  9223. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9224. this.selectors[selectorNb].children[1].color = color;
  9225. };
  9226. /** @hidden */
  9227. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9228. this.selectors[selectorNb].children[0].color = color;
  9229. };
  9230. /** @hidden */
  9231. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9232. this.selectors[selectorNb].children[0].background = color;
  9233. };
  9234. return RadioGroup;
  9235. }(SelectorGroup));
  9236. /** Class used to create a SliderGroup
  9237. * which contains groups of slider buttons
  9238. */
  9239. var SliderGroup = /** @class */ (function (_super) {
  9240. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9241. function SliderGroup() {
  9242. return _super !== null && _super.apply(this, arguments) || this;
  9243. }
  9244. /**
  9245. * Adds a slider to the SelectorGroup
  9246. * @param label is the label for the SliderBar
  9247. * @param func is the function called when the Slider moves
  9248. * @param unit is a string describing the units used, eg degrees or metres
  9249. * @param min is the minimum value for the Slider
  9250. * @param max is the maximum value for the Slider
  9251. * @param value is the start value for the Slider between min and max
  9252. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9253. */
  9254. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9255. if (func === void 0) { func = function (v) { }; }
  9256. if (unit === void 0) { unit = "Units"; }
  9257. if (min === void 0) { min = 0; }
  9258. if (max === void 0) { max = 0; }
  9259. if (value === void 0) { value = 0; }
  9260. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9261. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9262. button.name = unit;
  9263. button.value = value;
  9264. button.minimum = min;
  9265. button.maximum = max;
  9266. button.width = 0.9;
  9267. button.height = "20px";
  9268. button.color = "#364249";
  9269. button.background = "#CCCCCC";
  9270. button.borderColor = "black";
  9271. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9272. button.left = "4px";
  9273. button.paddingBottom = "4px";
  9274. button.onValueChangedObservable.add(function (value) {
  9275. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9276. func(value);
  9277. });
  9278. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9279. _selector.height = "60px";
  9280. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9281. _selector.left = "4px";
  9282. _selector.children[0].name = label;
  9283. this.groupPanel.addControl(_selector);
  9284. this.selectors.push(_selector);
  9285. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9286. button.color = this.groupPanel.parent.parent.buttonColor;
  9287. button.background = this.groupPanel.parent.parent.buttonBackground;
  9288. }
  9289. };
  9290. /** @hidden */
  9291. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9292. this.selectors[selectorNb].children[0].name = label;
  9293. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9294. };
  9295. /** @hidden */
  9296. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9297. this.selectors[selectorNb].children[0].color = color;
  9298. };
  9299. /** @hidden */
  9300. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9301. this.selectors[selectorNb].children[1].color = color;
  9302. };
  9303. /** @hidden */
  9304. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9305. this.selectors[selectorNb].children[1].background = color;
  9306. };
  9307. return SliderGroup;
  9308. }(SelectorGroup));
  9309. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9310. * @see http://doc.babylonjs.com/how_to/selector
  9311. */
  9312. var SelectionPanel = /** @class */ (function (_super) {
  9313. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9314. /**
  9315. * Creates a new SelectionPanel
  9316. * @param name of SelectionPanel
  9317. * @param groups is an array of SelectionGroups
  9318. */
  9319. function SelectionPanel(
  9320. /** name of SelectionPanel */
  9321. name,
  9322. /** an array of SelectionGroups */
  9323. groups) {
  9324. if (groups === void 0) { groups = []; }
  9325. var _this = _super.call(this, name) || this;
  9326. _this.name = name;
  9327. _this.groups = groups;
  9328. _this._buttonColor = "#364249";
  9329. _this._buttonBackground = "#CCCCCC";
  9330. _this._headerColor = "black";
  9331. _this._barColor = "white";
  9332. _this._barHeight = "2px";
  9333. _this._spacerHeight = "20px";
  9334. _this._bars = new Array();
  9335. _this._groups = groups;
  9336. _this.thickness = 2;
  9337. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9338. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9339. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9340. _this._panel.top = 5;
  9341. _this._panel.left = 5;
  9342. _this._panel.width = 0.95;
  9343. if (groups.length > 0) {
  9344. for (var i = 0; i < groups.length - 1; i++) {
  9345. _this._panel.addControl(groups[i].groupPanel);
  9346. _this._addSpacer();
  9347. }
  9348. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9349. }
  9350. _this.addControl(_this._panel);
  9351. return _this;
  9352. }
  9353. SelectionPanel.prototype._getTypeName = function () {
  9354. return "SelectionPanel";
  9355. };
  9356. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9357. /** Gets or sets the headerColor */
  9358. get: function () {
  9359. return this._headerColor;
  9360. },
  9361. set: function (color) {
  9362. if (this._headerColor === color) {
  9363. return;
  9364. }
  9365. this._headerColor = color;
  9366. this._setHeaderColor();
  9367. },
  9368. enumerable: true,
  9369. configurable: true
  9370. });
  9371. SelectionPanel.prototype._setHeaderColor = function () {
  9372. for (var i = 0; i < this._groups.length; i++) {
  9373. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9374. }
  9375. };
  9376. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9377. /** Gets or sets the button color */
  9378. get: function () {
  9379. return this._buttonColor;
  9380. },
  9381. set: function (color) {
  9382. if (this._buttonColor === color) {
  9383. return;
  9384. }
  9385. this._buttonColor = color;
  9386. this._setbuttonColor();
  9387. },
  9388. enumerable: true,
  9389. configurable: true
  9390. });
  9391. SelectionPanel.prototype._setbuttonColor = function () {
  9392. for (var i = 0; i < this._groups.length; i++) {
  9393. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9394. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9395. }
  9396. }
  9397. };
  9398. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9399. /** Gets or sets the label color */
  9400. get: function () {
  9401. return this._labelColor;
  9402. },
  9403. set: function (color) {
  9404. if (this._labelColor === color) {
  9405. return;
  9406. }
  9407. this._labelColor = color;
  9408. this._setLabelColor();
  9409. },
  9410. enumerable: true,
  9411. configurable: true
  9412. });
  9413. SelectionPanel.prototype._setLabelColor = function () {
  9414. for (var i = 0; i < this._groups.length; i++) {
  9415. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9416. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9417. }
  9418. }
  9419. };
  9420. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9421. /** Gets or sets the button background */
  9422. get: function () {
  9423. return this._buttonBackground;
  9424. },
  9425. set: function (color) {
  9426. if (this._buttonBackground === color) {
  9427. return;
  9428. }
  9429. this._buttonBackground = color;
  9430. this._setButtonBackground();
  9431. },
  9432. enumerable: true,
  9433. configurable: true
  9434. });
  9435. SelectionPanel.prototype._setButtonBackground = function () {
  9436. for (var i = 0; i < this._groups.length; i++) {
  9437. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9438. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9439. }
  9440. }
  9441. };
  9442. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9443. /** Gets or sets the color of separator bar */
  9444. get: function () {
  9445. return this._barColor;
  9446. },
  9447. set: function (color) {
  9448. if (this._barColor === color) {
  9449. return;
  9450. }
  9451. this._barColor = color;
  9452. this._setBarColor();
  9453. },
  9454. enumerable: true,
  9455. configurable: true
  9456. });
  9457. SelectionPanel.prototype._setBarColor = function () {
  9458. for (var i = 0; i < this._bars.length; i++) {
  9459. this._bars[i].children[0].background = this._barColor;
  9460. }
  9461. };
  9462. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9463. /** Gets or sets the height of separator bar */
  9464. get: function () {
  9465. return this._barHeight;
  9466. },
  9467. set: function (value) {
  9468. if (this._barHeight === value) {
  9469. return;
  9470. }
  9471. this._barHeight = value;
  9472. this._setBarHeight();
  9473. },
  9474. enumerable: true,
  9475. configurable: true
  9476. });
  9477. SelectionPanel.prototype._setBarHeight = function () {
  9478. for (var i = 0; i < this._bars.length; i++) {
  9479. this._bars[i].children[0].height = this._barHeight;
  9480. }
  9481. };
  9482. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9483. /** Gets or sets the height of spacers*/
  9484. get: function () {
  9485. return this._spacerHeight;
  9486. },
  9487. set: function (value) {
  9488. if (this._spacerHeight === value) {
  9489. return;
  9490. }
  9491. this._spacerHeight = value;
  9492. this._setSpacerHeight();
  9493. },
  9494. enumerable: true,
  9495. configurable: true
  9496. });
  9497. SelectionPanel.prototype._setSpacerHeight = function () {
  9498. for (var i = 0; i < this._bars.length; i++) {
  9499. this._bars[i].height = this._spacerHeight;
  9500. }
  9501. };
  9502. /** Adds a bar between groups */
  9503. SelectionPanel.prototype._addSpacer = function () {
  9504. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9505. separator.width = 1;
  9506. separator.height = this._spacerHeight;
  9507. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9508. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9509. bar.width = 1;
  9510. bar.height = this._barHeight;
  9511. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9512. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9513. bar.background = this._barColor;
  9514. bar.color = "transparent";
  9515. separator.addControl(bar);
  9516. this._panel.addControl(separator);
  9517. this._bars.push(separator);
  9518. };
  9519. /** Add a group to the selection panel
  9520. * @param group is the selector group to add
  9521. */
  9522. SelectionPanel.prototype.addGroup = function (group) {
  9523. if (this._groups.length > 0) {
  9524. this._addSpacer();
  9525. }
  9526. this._panel.addControl(group.groupPanel);
  9527. this._groups.push(group);
  9528. group.groupPanel.children[0].color = this._headerColor;
  9529. for (var j = 0; j < group.selectors.length; j++) {
  9530. group._setSelectorButtonColor(j, this._buttonColor);
  9531. group._setSelectorButtonBackground(j, this._buttonBackground);
  9532. }
  9533. };
  9534. /** Remove the group from the given position
  9535. * @param groupNb is the position of the group in the list
  9536. */
  9537. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9538. if (groupNb < 0 || groupNb >= this._groups.length) {
  9539. return;
  9540. }
  9541. var group = this._groups[groupNb];
  9542. this._panel.removeControl(group.groupPanel);
  9543. this._groups.splice(groupNb, 1);
  9544. if (groupNb < this._bars.length) {
  9545. this._panel.removeControl(this._bars[groupNb]);
  9546. this._bars.splice(groupNb, 1);
  9547. }
  9548. };
  9549. /** Change a group header label
  9550. * @param label is the new group header label
  9551. * @param groupNb is the number of the group to relabel
  9552. * */
  9553. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9554. if (groupNb < 0 || groupNb >= this._groups.length) {
  9555. return;
  9556. }
  9557. var group = this._groups[groupNb];
  9558. group.groupPanel.children[0].text = label;
  9559. };
  9560. /** Change selector label to the one given
  9561. * @param label is the new selector label
  9562. * @param groupNb is the number of the groupcontaining the selector
  9563. * @param selectorNb is the number of the selector within a group to relabel
  9564. * */
  9565. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9566. if (groupNb < 0 || groupNb >= this._groups.length) {
  9567. return;
  9568. }
  9569. var group = this._groups[groupNb];
  9570. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9571. return;
  9572. }
  9573. group._setSelectorLabel(selectorNb, label);
  9574. };
  9575. /** For a given group position remove the selector at the given position
  9576. * @param groupNb is the number of the group to remove the selector from
  9577. * @param selectorNb is the number of the selector within the group
  9578. */
  9579. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9580. if (groupNb < 0 || groupNb >= this._groups.length) {
  9581. return;
  9582. }
  9583. var group = this._groups[groupNb];
  9584. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9585. return;
  9586. }
  9587. group.removeSelector(selectorNb);
  9588. };
  9589. /** For a given group position of correct type add a checkbox button
  9590. * @param groupNb is the number of the group to remove the selector from
  9591. * @param label is the label for the selector
  9592. * @param func is the function called when the Selector is checked
  9593. * @param checked is true when Selector is checked
  9594. */
  9595. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9596. if (func === void 0) { func = function () { }; }
  9597. if (checked === void 0) { checked = false; }
  9598. if (groupNb < 0 || groupNb >= this._groups.length) {
  9599. return;
  9600. }
  9601. var group = this._groups[groupNb];
  9602. group.addCheckbox(label, func, checked);
  9603. };
  9604. /** For a given group position of correct type add a radio button
  9605. * @param groupNb is the number of the group to remove the selector from
  9606. * @param label is the label for the selector
  9607. * @param func is the function called when the Selector is checked
  9608. * @param checked is true when Selector is checked
  9609. */
  9610. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9611. if (func === void 0) { func = function () { }; }
  9612. if (checked === void 0) { checked = false; }
  9613. if (groupNb < 0 || groupNb >= this._groups.length) {
  9614. return;
  9615. }
  9616. var group = this._groups[groupNb];
  9617. group.addRadio(label, func, checked);
  9618. };
  9619. /**
  9620. * For a given slider group add a slider
  9621. * @param groupNb is the number of the group to add the slider to
  9622. * @param label is the label for the Slider
  9623. * @param func is the function called when the Slider moves
  9624. * @param unit is a string describing the units used, eg degrees or metres
  9625. * @param min is the minimum value for the Slider
  9626. * @param max is the maximum value for the Slider
  9627. * @param value is the start value for the Slider between min and max
  9628. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9629. */
  9630. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9631. if (func === void 0) { func = function () { }; }
  9632. if (unit === void 0) { unit = "Units"; }
  9633. if (min === void 0) { min = 0; }
  9634. if (max === void 0) { max = 0; }
  9635. if (value === void 0) { value = 0; }
  9636. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9637. if (groupNb < 0 || groupNb >= this._groups.length) {
  9638. return;
  9639. }
  9640. var group = this._groups[groupNb];
  9641. group.addSlider(label, func, unit, min, max, value, onVal);
  9642. };
  9643. return SelectionPanel;
  9644. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9645. /***/ }),
  9646. /***/ "./2D/controls/sliders/baseSlider.ts":
  9647. /*!*******************************************!*\
  9648. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9649. \*******************************************/
  9650. /*! exports provided: BaseSlider */
  9651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9652. "use strict";
  9653. __webpack_require__.r(__webpack_exports__);
  9654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9655. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9656. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  9657. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9658. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9659. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9660. /**
  9661. * Class used to create slider controls
  9662. */
  9663. var BaseSlider = /** @class */ (function (_super) {
  9664. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9665. /**
  9666. * Creates a new BaseSlider
  9667. * @param name defines the control name
  9668. */
  9669. function BaseSlider(name) {
  9670. var _this = _super.call(this, name) || this;
  9671. _this.name = name;
  9672. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9673. _this._minimum = 0;
  9674. _this._maximum = 100;
  9675. _this._value = 50;
  9676. _this._isVertical = false;
  9677. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9678. _this._isThumbClamped = false;
  9679. _this._displayThumb = true;
  9680. // Shared rendering info
  9681. _this._effectiveBarOffset = 0;
  9682. /** Observable raised when the sldier value changes */
  9683. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9684. // Events
  9685. _this._pointerIsDown = false;
  9686. _this.isPointerBlocker = true;
  9687. return _this;
  9688. }
  9689. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9690. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9691. get: function () {
  9692. return this._displayThumb;
  9693. },
  9694. set: function (value) {
  9695. if (this._displayThumb === value) {
  9696. return;
  9697. }
  9698. this._displayThumb = value;
  9699. this._markAsDirty();
  9700. },
  9701. enumerable: true,
  9702. configurable: true
  9703. });
  9704. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9705. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9706. get: function () {
  9707. return this._barOffset.toString(this._host);
  9708. },
  9709. set: function (value) {
  9710. if (this._barOffset.toString(this._host) === value) {
  9711. return;
  9712. }
  9713. if (this._barOffset.fromString(value)) {
  9714. this._markAsDirty();
  9715. }
  9716. },
  9717. enumerable: true,
  9718. configurable: true
  9719. });
  9720. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9721. /** Gets main bar offset in pixels*/
  9722. get: function () {
  9723. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9724. },
  9725. enumerable: true,
  9726. configurable: true
  9727. });
  9728. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9729. /** Gets or sets thumb width */
  9730. get: function () {
  9731. return this._thumbWidth.toString(this._host);
  9732. },
  9733. set: function (value) {
  9734. if (this._thumbWidth.toString(this._host) === value) {
  9735. return;
  9736. }
  9737. if (this._thumbWidth.fromString(value)) {
  9738. this._markAsDirty();
  9739. }
  9740. },
  9741. enumerable: true,
  9742. configurable: true
  9743. });
  9744. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9745. /** Gets thumb width in pixels */
  9746. get: function () {
  9747. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9748. },
  9749. enumerable: true,
  9750. configurable: true
  9751. });
  9752. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9753. /** Gets or sets minimum value */
  9754. get: function () {
  9755. return this._minimum;
  9756. },
  9757. set: function (value) {
  9758. if (this._minimum === value) {
  9759. return;
  9760. }
  9761. this._minimum = value;
  9762. this._markAsDirty();
  9763. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9764. },
  9765. enumerable: true,
  9766. configurable: true
  9767. });
  9768. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9769. /** Gets or sets maximum value */
  9770. get: function () {
  9771. return this._maximum;
  9772. },
  9773. set: function (value) {
  9774. if (this._maximum === value) {
  9775. return;
  9776. }
  9777. this._maximum = value;
  9778. this._markAsDirty();
  9779. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9780. },
  9781. enumerable: true,
  9782. configurable: true
  9783. });
  9784. Object.defineProperty(BaseSlider.prototype, "value", {
  9785. /** Gets or sets current value */
  9786. get: function () {
  9787. return this._value;
  9788. },
  9789. set: function (value) {
  9790. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9791. if (this._value === value) {
  9792. return;
  9793. }
  9794. this._value = value;
  9795. this._markAsDirty();
  9796. this.onValueChangedObservable.notifyObservers(this._value);
  9797. },
  9798. enumerable: true,
  9799. configurable: true
  9800. });
  9801. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9802. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9803. get: function () {
  9804. return this._isVertical;
  9805. },
  9806. set: function (value) {
  9807. if (this._isVertical === value) {
  9808. return;
  9809. }
  9810. this._isVertical = value;
  9811. this._markAsDirty();
  9812. },
  9813. enumerable: true,
  9814. configurable: true
  9815. });
  9816. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9817. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9818. get: function () {
  9819. return this._isThumbClamped;
  9820. },
  9821. set: function (value) {
  9822. if (this._isThumbClamped === value) {
  9823. return;
  9824. }
  9825. this._isThumbClamped = value;
  9826. this._markAsDirty();
  9827. },
  9828. enumerable: true,
  9829. configurable: true
  9830. });
  9831. BaseSlider.prototype._getTypeName = function () {
  9832. return "BaseSlider";
  9833. };
  9834. BaseSlider.prototype._getThumbPosition = function () {
  9835. if (this.isVertical) {
  9836. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9837. }
  9838. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9839. };
  9840. BaseSlider.prototype._getThumbThickness = function (type) {
  9841. var thumbThickness = 0;
  9842. switch (type) {
  9843. case "circle":
  9844. if (this._thumbWidth.isPixel) {
  9845. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9846. }
  9847. else {
  9848. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9849. }
  9850. break;
  9851. case "rectangle":
  9852. if (this._thumbWidth.isPixel) {
  9853. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9854. }
  9855. else {
  9856. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9857. }
  9858. }
  9859. return thumbThickness;
  9860. };
  9861. BaseSlider.prototype._prepareRenderingData = function (type) {
  9862. // Main bar
  9863. this._effectiveBarOffset = 0;
  9864. this._renderLeft = this._currentMeasure.left;
  9865. this._renderTop = this._currentMeasure.top;
  9866. this._renderWidth = this._currentMeasure.width;
  9867. this._renderHeight = this._currentMeasure.height;
  9868. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9869. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9870. this._effectiveThumbThickness = this._getThumbThickness(type);
  9871. if (this.displayThumb) {
  9872. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9873. }
  9874. //throw error when height is less than width for vertical slider
  9875. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9876. console.error("Height should be greater than width");
  9877. return;
  9878. }
  9879. if (this._barOffset.isPixel) {
  9880. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9881. }
  9882. else {
  9883. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9884. }
  9885. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9886. if (this.isVertical) {
  9887. this._renderLeft += this._effectiveBarOffset;
  9888. if (!this.isThumbClamped && this.displayThumb) {
  9889. this._renderTop += (this._effectiveThumbThickness / 2);
  9890. }
  9891. this._renderHeight = this._backgroundBoxLength;
  9892. this._renderWidth = this._backgroundBoxThickness;
  9893. }
  9894. else {
  9895. this._renderTop += this._effectiveBarOffset;
  9896. if (!this.isThumbClamped && this.displayThumb) {
  9897. this._renderLeft += (this._effectiveThumbThickness / 2);
  9898. }
  9899. this._renderHeight = this._backgroundBoxThickness;
  9900. this._renderWidth = this._backgroundBoxLength;
  9901. }
  9902. };
  9903. /** @hidden */
  9904. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9905. if (this.rotation != 0) {
  9906. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9907. x = this._transformedPosition.x;
  9908. y = this._transformedPosition.y;
  9909. }
  9910. if (this._isVertical) {
  9911. this.value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9912. }
  9913. else {
  9914. this.value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9915. }
  9916. };
  9917. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9918. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9919. return false;
  9920. }
  9921. this._pointerIsDown = true;
  9922. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9923. this._host._capturingControl[pointerId] = this;
  9924. return true;
  9925. };
  9926. BaseSlider.prototype._onPointerMove = function (target, coordinates) {
  9927. if (this._pointerIsDown) {
  9928. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9929. }
  9930. _super.prototype._onPointerMove.call(this, target, coordinates);
  9931. };
  9932. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9933. this._pointerIsDown = false;
  9934. delete this._host._capturingControl[pointerId];
  9935. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9936. };
  9937. return BaseSlider;
  9938. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9939. /***/ }),
  9940. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  9941. /*!*************************************************!*\
  9942. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  9943. \*************************************************/
  9944. /*! exports provided: ImageBasedSlider */
  9945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9946. "use strict";
  9947. __webpack_require__.r(__webpack_exports__);
  9948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  9949. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9950. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  9951. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9952. /**
  9953. * Class used to create slider controls based on images
  9954. */
  9955. var ImageBasedSlider = /** @class */ (function (_super) {
  9956. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  9957. /**
  9958. * Creates a new ImageBasedSlider
  9959. * @param name defines the control name
  9960. */
  9961. function ImageBasedSlider(name) {
  9962. var _this = _super.call(this, name) || this;
  9963. _this.name = name;
  9964. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  9965. return _this;
  9966. }
  9967. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  9968. get: function () {
  9969. return this._displayThumb && this.thumbImage != null;
  9970. },
  9971. set: function (value) {
  9972. if (this._displayThumb === value) {
  9973. return;
  9974. }
  9975. this._displayThumb = value;
  9976. this._markAsDirty();
  9977. },
  9978. enumerable: true,
  9979. configurable: true
  9980. });
  9981. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  9982. /**
  9983. * Gets or sets the image used to render the background
  9984. */
  9985. get: function () {
  9986. return this._backgroundImage;
  9987. },
  9988. set: function (value) {
  9989. var _this = this;
  9990. if (this._backgroundImage === value) {
  9991. return;
  9992. }
  9993. this._backgroundImage = value;
  9994. if (value && !value.isLoaded) {
  9995. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  9996. }
  9997. this._markAsDirty();
  9998. },
  9999. enumerable: true,
  10000. configurable: true
  10001. });
  10002. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10003. /**
  10004. * Gets or sets the image used to render the value bar
  10005. */
  10006. get: function () {
  10007. return this._valueBarImage;
  10008. },
  10009. set: function (value) {
  10010. var _this = this;
  10011. if (this._valueBarImage === value) {
  10012. return;
  10013. }
  10014. this._valueBarImage = value;
  10015. if (value && !value.isLoaded) {
  10016. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10017. }
  10018. this._markAsDirty();
  10019. },
  10020. enumerable: true,
  10021. configurable: true
  10022. });
  10023. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10024. /**
  10025. * Gets or sets the image used to render the thumb
  10026. */
  10027. get: function () {
  10028. return this._thumbImage;
  10029. },
  10030. set: function (value) {
  10031. var _this = this;
  10032. if (this._thumbImage === value) {
  10033. return;
  10034. }
  10035. this._thumbImage = value;
  10036. if (value && !value.isLoaded) {
  10037. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10038. }
  10039. this._markAsDirty();
  10040. },
  10041. enumerable: true,
  10042. configurable: true
  10043. });
  10044. ImageBasedSlider.prototype._getTypeName = function () {
  10045. return "ImageBasedSlider";
  10046. };
  10047. ImageBasedSlider.prototype._draw = function (context) {
  10048. context.save();
  10049. this._applyStates(context);
  10050. this._prepareRenderingData("rectangle");
  10051. var thumbPosition = this._getThumbPosition();
  10052. var left = this._renderLeft;
  10053. var top = this._renderTop;
  10054. var width = this._renderWidth;
  10055. var height = this._renderHeight;
  10056. // Background
  10057. if (this._backgroundImage) {
  10058. this._tempMeasure.copyFromFloats(left, top, width, height);
  10059. if (this.isThumbClamped && this.displayThumb) {
  10060. if (this.isVertical) {
  10061. this._tempMeasure.height += this._effectiveThumbThickness;
  10062. }
  10063. else {
  10064. this._tempMeasure.width += this._effectiveThumbThickness;
  10065. }
  10066. }
  10067. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10068. this._backgroundImage._draw(context);
  10069. }
  10070. // Bar
  10071. if (this._valueBarImage) {
  10072. if (this.isVertical) {
  10073. if (this.isThumbClamped && this.displayThumb) {
  10074. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10075. }
  10076. else {
  10077. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10078. }
  10079. }
  10080. else {
  10081. if (this.isThumbClamped && this.displayThumb) {
  10082. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10083. }
  10084. else {
  10085. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10086. }
  10087. }
  10088. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10089. this._valueBarImage._draw(context);
  10090. }
  10091. // Thumb
  10092. if (this.displayThumb) {
  10093. if (this.isVertical) {
  10094. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10095. }
  10096. else {
  10097. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10098. }
  10099. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10100. this._thumbImage._draw(context);
  10101. }
  10102. context.restore();
  10103. };
  10104. return ImageBasedSlider;
  10105. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10106. /***/ }),
  10107. /***/ "./2D/controls/sliders/scrollBar.ts":
  10108. /*!******************************************!*\
  10109. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10110. \******************************************/
  10111. /*! exports provided: ScrollBar */
  10112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10113. "use strict";
  10114. __webpack_require__.r(__webpack_exports__);
  10115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10116. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10117. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10118. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10119. /**
  10120. * Class used to create slider controls
  10121. */
  10122. var ScrollBar = /** @class */ (function (_super) {
  10123. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10124. /**
  10125. * Creates a new Slider
  10126. * @param name defines the control name
  10127. */
  10128. function ScrollBar(name) {
  10129. var _this = _super.call(this, name) || this;
  10130. _this.name = name;
  10131. _this._background = "black";
  10132. _this._borderColor = "white";
  10133. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10134. return _this;
  10135. }
  10136. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10137. /** Gets or sets border color */
  10138. get: function () {
  10139. return this._borderColor;
  10140. },
  10141. set: function (value) {
  10142. if (this._borderColor === value) {
  10143. return;
  10144. }
  10145. this._borderColor = value;
  10146. this._markAsDirty();
  10147. },
  10148. enumerable: true,
  10149. configurable: true
  10150. });
  10151. Object.defineProperty(ScrollBar.prototype, "background", {
  10152. /** Gets or sets background color */
  10153. get: function () {
  10154. return this._background;
  10155. },
  10156. set: function (value) {
  10157. if (this._background === value) {
  10158. return;
  10159. }
  10160. this._background = value;
  10161. this._markAsDirty();
  10162. },
  10163. enumerable: true,
  10164. configurable: true
  10165. });
  10166. ScrollBar.prototype._getTypeName = function () {
  10167. return "Scrollbar";
  10168. };
  10169. ScrollBar.prototype._getThumbThickness = function () {
  10170. var thumbThickness = 0;
  10171. if (this._thumbWidth.isPixel) {
  10172. thumbThickness = this._thumbWidth.getValue(this._host);
  10173. }
  10174. else {
  10175. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10176. }
  10177. return thumbThickness;
  10178. };
  10179. ScrollBar.prototype._draw = function (context) {
  10180. context.save();
  10181. this._applyStates(context);
  10182. this._prepareRenderingData("rectangle");
  10183. var left = this._renderLeft;
  10184. var thumbPosition = this._getThumbPosition();
  10185. context.fillStyle = this._background;
  10186. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10187. // Value bar
  10188. context.fillStyle = this.color;
  10189. // Thumb
  10190. if (this.isVertical) {
  10191. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10192. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10193. this._thumbMeasure.width = this._currentMeasure.width;
  10194. this._thumbMeasure.height = this._effectiveThumbThickness;
  10195. }
  10196. else {
  10197. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10198. this._thumbMeasure.top = this._currentMeasure.top;
  10199. this._thumbMeasure.width = this._effectiveThumbThickness;
  10200. this._thumbMeasure.height = this._currentMeasure.height;
  10201. }
  10202. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10203. context.restore();
  10204. };
  10205. /** @hidden */
  10206. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10207. if (this.rotation != 0) {
  10208. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10209. x = this._transformedPosition.x;
  10210. y = this._transformedPosition.y;
  10211. }
  10212. if (this._first) {
  10213. this._first = false;
  10214. this._originX = x;
  10215. this._originY = y;
  10216. // Check if move is required
  10217. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10218. if (this.isVertical) {
  10219. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10220. }
  10221. else {
  10222. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10223. }
  10224. }
  10225. }
  10226. // Delta mode
  10227. var delta = 0;
  10228. if (this.isVertical) {
  10229. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10230. }
  10231. else {
  10232. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10233. }
  10234. this.value += delta * (this.maximum - this.minimum);
  10235. this._originX = x;
  10236. this._originY = y;
  10237. };
  10238. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10239. this._first = true;
  10240. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10241. };
  10242. return ScrollBar;
  10243. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10244. /***/ }),
  10245. /***/ "./2D/controls/sliders/slider.ts":
  10246. /*!***************************************!*\
  10247. !*** ./2D/controls/sliders/slider.ts ***!
  10248. \***************************************/
  10249. /*! exports provided: Slider */
  10250. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10251. "use strict";
  10252. __webpack_require__.r(__webpack_exports__);
  10253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10254. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10255. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10256. /**
  10257. * Class used to create slider controls
  10258. */
  10259. var Slider = /** @class */ (function (_super) {
  10260. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10261. /**
  10262. * Creates a new Slider
  10263. * @param name defines the control name
  10264. */
  10265. function Slider(name) {
  10266. var _this = _super.call(this, name) || this;
  10267. _this.name = name;
  10268. _this._background = "black";
  10269. _this._borderColor = "white";
  10270. _this._isThumbCircle = false;
  10271. _this._displayValueBar = true;
  10272. return _this;
  10273. }
  10274. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10275. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10276. get: function () {
  10277. return this._displayValueBar;
  10278. },
  10279. set: function (value) {
  10280. if (this._displayValueBar === value) {
  10281. return;
  10282. }
  10283. this._displayValueBar = value;
  10284. this._markAsDirty();
  10285. },
  10286. enumerable: true,
  10287. configurable: true
  10288. });
  10289. Object.defineProperty(Slider.prototype, "borderColor", {
  10290. /** Gets or sets border color */
  10291. get: function () {
  10292. return this._borderColor;
  10293. },
  10294. set: function (value) {
  10295. if (this._borderColor === value) {
  10296. return;
  10297. }
  10298. this._borderColor = value;
  10299. this._markAsDirty();
  10300. },
  10301. enumerable: true,
  10302. configurable: true
  10303. });
  10304. Object.defineProperty(Slider.prototype, "background", {
  10305. /** Gets or sets background color */
  10306. get: function () {
  10307. return this._background;
  10308. },
  10309. set: function (value) {
  10310. if (this._background === value) {
  10311. return;
  10312. }
  10313. this._background = value;
  10314. this._markAsDirty();
  10315. },
  10316. enumerable: true,
  10317. configurable: true
  10318. });
  10319. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10320. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10321. get: function () {
  10322. return this._isThumbCircle;
  10323. },
  10324. set: function (value) {
  10325. if (this._isThumbCircle === value) {
  10326. return;
  10327. }
  10328. this._isThumbCircle = value;
  10329. this._markAsDirty();
  10330. },
  10331. enumerable: true,
  10332. configurable: true
  10333. });
  10334. Slider.prototype._getTypeName = function () {
  10335. return "Slider";
  10336. };
  10337. Slider.prototype._draw = function (context) {
  10338. context.save();
  10339. this._applyStates(context);
  10340. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10341. var left = this._renderLeft;
  10342. var top = this._renderTop;
  10343. var width = this._renderWidth;
  10344. var height = this._renderHeight;
  10345. var radius = 0;
  10346. if (this.isThumbClamped && this.isThumbCircle) {
  10347. if (this.isVertical) {
  10348. top += (this._effectiveThumbThickness / 2);
  10349. }
  10350. else {
  10351. left += (this._effectiveThumbThickness / 2);
  10352. }
  10353. radius = this._backgroundBoxThickness / 2;
  10354. }
  10355. else {
  10356. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10357. }
  10358. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10359. context.shadowColor = this.shadowColor;
  10360. context.shadowBlur = this.shadowBlur;
  10361. context.shadowOffsetX = this.shadowOffsetX;
  10362. context.shadowOffsetY = this.shadowOffsetY;
  10363. }
  10364. var thumbPosition = this._getThumbPosition();
  10365. context.fillStyle = this._background;
  10366. if (this.isVertical) {
  10367. if (this.isThumbClamped) {
  10368. if (this.isThumbCircle) {
  10369. context.beginPath();
  10370. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10371. context.fill();
  10372. context.fillRect(left, top, width, height);
  10373. }
  10374. else {
  10375. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10376. }
  10377. }
  10378. else {
  10379. context.fillRect(left, top, width, height);
  10380. }
  10381. }
  10382. else {
  10383. if (this.isThumbClamped) {
  10384. if (this.isThumbCircle) {
  10385. context.beginPath();
  10386. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10387. context.fill();
  10388. context.fillRect(left, top, width, height);
  10389. }
  10390. else {
  10391. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10392. }
  10393. }
  10394. else {
  10395. context.fillRect(left, top, width, height);
  10396. }
  10397. }
  10398. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10399. context.shadowBlur = 0;
  10400. context.shadowOffsetX = 0;
  10401. context.shadowOffsetY = 0;
  10402. }
  10403. // Value bar
  10404. context.fillStyle = this.color;
  10405. if (this._displayValueBar) {
  10406. if (this.isVertical) {
  10407. if (this.isThumbClamped) {
  10408. if (this.isThumbCircle) {
  10409. context.beginPath();
  10410. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10411. context.fill();
  10412. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10413. }
  10414. else {
  10415. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10416. }
  10417. }
  10418. else {
  10419. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10420. }
  10421. }
  10422. else {
  10423. if (this.isThumbClamped) {
  10424. if (this.isThumbCircle) {
  10425. context.beginPath();
  10426. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10427. context.fill();
  10428. context.fillRect(left, top, thumbPosition, height);
  10429. }
  10430. else {
  10431. context.fillRect(left, top, thumbPosition, height);
  10432. }
  10433. }
  10434. else {
  10435. context.fillRect(left, top, thumbPosition, height);
  10436. }
  10437. }
  10438. }
  10439. // Thumb
  10440. if (this.displayThumb) {
  10441. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10442. context.shadowColor = this.shadowColor;
  10443. context.shadowBlur = this.shadowBlur;
  10444. context.shadowOffsetX = this.shadowOffsetX;
  10445. context.shadowOffsetY = this.shadowOffsetY;
  10446. }
  10447. if (this._isThumbCircle) {
  10448. context.beginPath();
  10449. if (this.isVertical) {
  10450. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10451. }
  10452. else {
  10453. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10454. }
  10455. context.fill();
  10456. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10457. context.shadowBlur = 0;
  10458. context.shadowOffsetX = 0;
  10459. context.shadowOffsetY = 0;
  10460. }
  10461. context.strokeStyle = this._borderColor;
  10462. context.stroke();
  10463. }
  10464. else {
  10465. if (this.isVertical) {
  10466. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10467. }
  10468. else {
  10469. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10470. }
  10471. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10472. context.shadowBlur = 0;
  10473. context.shadowOffsetX = 0;
  10474. context.shadowOffsetY = 0;
  10475. }
  10476. context.strokeStyle = this._borderColor;
  10477. if (this.isVertical) {
  10478. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10479. }
  10480. else {
  10481. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10482. }
  10483. }
  10484. }
  10485. context.restore();
  10486. };
  10487. return Slider;
  10488. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10489. /***/ }),
  10490. /***/ "./2D/controls/stackPanel.ts":
  10491. /*!***********************************!*\
  10492. !*** ./2D/controls/stackPanel.ts ***!
  10493. \***********************************/
  10494. /*! exports provided: StackPanel */
  10495. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10496. "use strict";
  10497. __webpack_require__.r(__webpack_exports__);
  10498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10499. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10500. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  10501. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10502. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10503. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10504. /**
  10505. * Class used to create a 2D stack panel container
  10506. */
  10507. var StackPanel = /** @class */ (function (_super) {
  10508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10509. /**
  10510. * Creates a new StackPanel
  10511. * @param name defines control name
  10512. */
  10513. function StackPanel(name) {
  10514. var _this = _super.call(this, name) || this;
  10515. _this.name = name;
  10516. _this._isVertical = true;
  10517. _this._manualWidth = false;
  10518. _this._manualHeight = false;
  10519. _this._doNotTrackManualChanges = false;
  10520. return _this;
  10521. }
  10522. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10523. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10524. get: function () {
  10525. return this._isVertical;
  10526. },
  10527. set: function (value) {
  10528. if (this._isVertical === value) {
  10529. return;
  10530. }
  10531. this._isVertical = value;
  10532. this._markAsDirty();
  10533. },
  10534. enumerable: true,
  10535. configurable: true
  10536. });
  10537. Object.defineProperty(StackPanel.prototype, "width", {
  10538. get: function () {
  10539. return this._width.toString(this._host);
  10540. },
  10541. /**
  10542. * Gets or sets panel width.
  10543. * This value should not be set when in horizontal mode as it will be computed automatically
  10544. */
  10545. set: function (value) {
  10546. if (!this._doNotTrackManualChanges) {
  10547. this._manualWidth = true;
  10548. }
  10549. if (this._width.toString(this._host) === value) {
  10550. return;
  10551. }
  10552. if (this._width.fromString(value)) {
  10553. this._markAsDirty();
  10554. }
  10555. },
  10556. enumerable: true,
  10557. configurable: true
  10558. });
  10559. Object.defineProperty(StackPanel.prototype, "height", {
  10560. get: function () {
  10561. return this._height.toString(this._host);
  10562. },
  10563. /**
  10564. * Gets or sets panel height.
  10565. * This value should not be set when in vertical mode as it will be computed automatically
  10566. */
  10567. set: function (value) {
  10568. if (!this._doNotTrackManualChanges) {
  10569. this._manualHeight = true;
  10570. }
  10571. if (this._height.toString(this._host) === value) {
  10572. return;
  10573. }
  10574. if (this._height.fromString(value)) {
  10575. this._markAsDirty();
  10576. }
  10577. },
  10578. enumerable: true,
  10579. configurable: true
  10580. });
  10581. StackPanel.prototype._getTypeName = function () {
  10582. return "StackPanel";
  10583. };
  10584. /** @hidden */
  10585. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10586. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10587. var child = _a[_i];
  10588. if (this._isVertical) {
  10589. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10590. }
  10591. else {
  10592. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10593. }
  10594. }
  10595. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10596. };
  10597. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10598. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10599. this._measureForChildren.copyFrom(parentMeasure);
  10600. this._measureForChildren.left = this._currentMeasure.left;
  10601. this._measureForChildren.top = this._currentMeasure.top;
  10602. if (!this.isVertical || this._manualWidth) {
  10603. this._measureForChildren.width = this._currentMeasure.width;
  10604. }
  10605. if (this.isVertical || this._manualHeight) {
  10606. this._measureForChildren.height = this._currentMeasure.height;
  10607. }
  10608. };
  10609. StackPanel.prototype._postMeasure = function () {
  10610. var stackWidth = 0;
  10611. var stackHeight = 0;
  10612. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10613. var child = _a[_i];
  10614. if (!child.isVisible || child.notRenderable) {
  10615. continue;
  10616. }
  10617. if (this._isVertical) {
  10618. if (child.top !== stackHeight + "px") {
  10619. child.top = stackHeight + "px";
  10620. this._rebuildLayout = true;
  10621. child._top.ignoreAdaptiveScaling = true;
  10622. }
  10623. if (child._height.isPercentage) {
  10624. 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");
  10625. }
  10626. else {
  10627. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10628. }
  10629. }
  10630. else {
  10631. if (child.left !== stackWidth + "px") {
  10632. child.left = stackWidth + "px";
  10633. this._rebuildLayout = true;
  10634. child._left.ignoreAdaptiveScaling = true;
  10635. }
  10636. if (child._width.isPercentage) {
  10637. 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");
  10638. }
  10639. else {
  10640. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10641. }
  10642. }
  10643. }
  10644. this._doNotTrackManualChanges = true;
  10645. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10646. // User can now define their own height and width for stack panel.
  10647. var panelWidthChanged = false;
  10648. var panelHeightChanged = false;
  10649. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10650. var previousHeight = this.height;
  10651. this.height = stackHeight + "px";
  10652. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10653. }
  10654. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10655. var previousWidth = this.width;
  10656. this.width = stackWidth + "px";
  10657. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10658. }
  10659. if (panelHeightChanged) {
  10660. this._height.ignoreAdaptiveScaling = true;
  10661. }
  10662. if (panelWidthChanged) {
  10663. this._width.ignoreAdaptiveScaling = true;
  10664. }
  10665. this._doNotTrackManualChanges = false;
  10666. if (panelWidthChanged || panelHeightChanged) {
  10667. this._rebuildLayout = true;
  10668. }
  10669. _super.prototype._postMeasure.call(this);
  10670. };
  10671. return StackPanel;
  10672. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10673. /***/ }),
  10674. /***/ "./2D/controls/statics.ts":
  10675. /*!********************************!*\
  10676. !*** ./2D/controls/statics.ts ***!
  10677. \********************************/
  10678. /*! exports provided: name */
  10679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10680. "use strict";
  10681. __webpack_require__.r(__webpack_exports__);
  10682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10683. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10684. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10685. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10686. /**
  10687. * Forcing an export so that this code will execute
  10688. * @hidden
  10689. */
  10690. var name = "Statics";
  10691. /**
  10692. * Creates a stack panel that can be used to render headers
  10693. * @param control defines the control to associate with the header
  10694. * @param text defines the text of the header
  10695. * @param size defines the size of the header
  10696. * @param options defines options used to configure the header
  10697. * @returns a new StackPanel
  10698. */
  10699. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10700. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10701. var isHorizontal = options ? options.isHorizontal : true;
  10702. var controlFirst = options ? options.controlFirst : true;
  10703. panel.isVertical = !isHorizontal;
  10704. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10705. header.text = text;
  10706. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10707. if (isHorizontal) {
  10708. header.width = size;
  10709. }
  10710. else {
  10711. header.height = size;
  10712. }
  10713. if (controlFirst) {
  10714. panel.addControl(control);
  10715. panel.addControl(header);
  10716. header.paddingLeft = "5px";
  10717. }
  10718. else {
  10719. panel.addControl(header);
  10720. panel.addControl(control);
  10721. header.paddingRight = "5px";
  10722. }
  10723. header.shadowBlur = control.shadowBlur;
  10724. header.shadowColor = control.shadowColor;
  10725. header.shadowOffsetX = control.shadowOffsetX;
  10726. header.shadowOffsetY = control.shadowOffsetY;
  10727. return panel;
  10728. };
  10729. /***/ }),
  10730. /***/ "./2D/controls/textBlock.ts":
  10731. /*!**********************************!*\
  10732. !*** ./2D/controls/textBlock.ts ***!
  10733. \**********************************/
  10734. /*! exports provided: TextWrapping, TextBlock */
  10735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10736. "use strict";
  10737. __webpack_require__.r(__webpack_exports__);
  10738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10740. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10741. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  10742. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10743. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10744. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10745. /**
  10746. * Enum that determines the text-wrapping mode to use.
  10747. */
  10748. var TextWrapping;
  10749. (function (TextWrapping) {
  10750. /**
  10751. * Clip the text when it's larger than Control.width; this is the default mode.
  10752. */
  10753. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10754. /**
  10755. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10756. */
  10757. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10758. /**
  10759. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10760. */
  10761. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10762. })(TextWrapping || (TextWrapping = {}));
  10763. /**
  10764. * Class used to create text block control
  10765. */
  10766. var TextBlock = /** @class */ (function (_super) {
  10767. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10768. /**
  10769. * Creates a new TextBlock object
  10770. * @param name defines the name of the control
  10771. * @param text defines the text to display (emptry string by default)
  10772. */
  10773. function TextBlock(
  10774. /**
  10775. * Defines the name of the control
  10776. */
  10777. name, text) {
  10778. if (text === void 0) { text = ""; }
  10779. var _this = _super.call(this, name) || this;
  10780. _this.name = name;
  10781. _this._text = "";
  10782. _this._textWrapping = TextWrapping.Clip;
  10783. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10784. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10785. _this._resizeToFit = false;
  10786. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10787. _this._outlineWidth = 0;
  10788. _this._outlineColor = "white";
  10789. /**
  10790. * An event triggered after the text is changed
  10791. */
  10792. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10793. /**
  10794. * An event triggered after the text was broken up into lines
  10795. */
  10796. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10797. _this.text = text;
  10798. return _this;
  10799. }
  10800. Object.defineProperty(TextBlock.prototype, "lines", {
  10801. /**
  10802. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10803. */
  10804. get: function () {
  10805. return this._lines;
  10806. },
  10807. enumerable: true,
  10808. configurable: true
  10809. });
  10810. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10811. /**
  10812. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10813. */
  10814. get: function () {
  10815. return this._resizeToFit;
  10816. },
  10817. /**
  10818. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10819. */
  10820. set: function (value) {
  10821. if (this._resizeToFit === value) {
  10822. return;
  10823. }
  10824. this._resizeToFit = value;
  10825. if (this._resizeToFit) {
  10826. this._width.ignoreAdaptiveScaling = true;
  10827. this._height.ignoreAdaptiveScaling = true;
  10828. }
  10829. this._markAsDirty();
  10830. },
  10831. enumerable: true,
  10832. configurable: true
  10833. });
  10834. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10835. /**
  10836. * Gets or sets a boolean indicating if text must be wrapped
  10837. */
  10838. get: function () {
  10839. return this._textWrapping;
  10840. },
  10841. /**
  10842. * Gets or sets a boolean indicating if text must be wrapped
  10843. */
  10844. set: function (value) {
  10845. if (this._textWrapping === value) {
  10846. return;
  10847. }
  10848. this._textWrapping = +value;
  10849. this._markAsDirty();
  10850. },
  10851. enumerable: true,
  10852. configurable: true
  10853. });
  10854. Object.defineProperty(TextBlock.prototype, "text", {
  10855. /**
  10856. * Gets or sets text to display
  10857. */
  10858. get: function () {
  10859. return this._text;
  10860. },
  10861. /**
  10862. * Gets or sets text to display
  10863. */
  10864. set: function (value) {
  10865. if (this._text === value) {
  10866. return;
  10867. }
  10868. this._text = value;
  10869. this._markAsDirty();
  10870. this.onTextChangedObservable.notifyObservers(this);
  10871. },
  10872. enumerable: true,
  10873. configurable: true
  10874. });
  10875. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10876. /**
  10877. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10878. */
  10879. get: function () {
  10880. return this._textHorizontalAlignment;
  10881. },
  10882. /**
  10883. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10884. */
  10885. set: function (value) {
  10886. if (this._textHorizontalAlignment === value) {
  10887. return;
  10888. }
  10889. this._textHorizontalAlignment = value;
  10890. this._markAsDirty();
  10891. },
  10892. enumerable: true,
  10893. configurable: true
  10894. });
  10895. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10896. /**
  10897. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10898. */
  10899. get: function () {
  10900. return this._textVerticalAlignment;
  10901. },
  10902. /**
  10903. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10904. */
  10905. set: function (value) {
  10906. if (this._textVerticalAlignment === value) {
  10907. return;
  10908. }
  10909. this._textVerticalAlignment = value;
  10910. this._markAsDirty();
  10911. },
  10912. enumerable: true,
  10913. configurable: true
  10914. });
  10915. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10916. /**
  10917. * Gets or sets line spacing value
  10918. */
  10919. get: function () {
  10920. return this._lineSpacing.toString(this._host);
  10921. },
  10922. /**
  10923. * Gets or sets line spacing value
  10924. */
  10925. set: function (value) {
  10926. if (this._lineSpacing.fromString(value)) {
  10927. this._markAsDirty();
  10928. }
  10929. },
  10930. enumerable: true,
  10931. configurable: true
  10932. });
  10933. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10934. /**
  10935. * Gets or sets outlineWidth of the text to display
  10936. */
  10937. get: function () {
  10938. return this._outlineWidth;
  10939. },
  10940. /**
  10941. * Gets or sets outlineWidth of the text to display
  10942. */
  10943. set: function (value) {
  10944. if (this._outlineWidth === value) {
  10945. return;
  10946. }
  10947. this._outlineWidth = value;
  10948. this._markAsDirty();
  10949. },
  10950. enumerable: true,
  10951. configurable: true
  10952. });
  10953. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  10954. /**
  10955. * Gets or sets outlineColor of the text to display
  10956. */
  10957. get: function () {
  10958. return this._outlineColor;
  10959. },
  10960. /**
  10961. * Gets or sets outlineColor of the text to display
  10962. */
  10963. set: function (value) {
  10964. if (this._outlineColor === value) {
  10965. return;
  10966. }
  10967. this._outlineColor = value;
  10968. this._markAsDirty();
  10969. },
  10970. enumerable: true,
  10971. configurable: true
  10972. });
  10973. TextBlock.prototype._getTypeName = function () {
  10974. return "TextBlock";
  10975. };
  10976. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  10977. if (!this._fontOffset) {
  10978. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  10979. }
  10980. _super.prototype._processMeasures.call(this, parentMeasure, context);
  10981. // Prepare lines
  10982. this._lines = this._breakLines(this._currentMeasure.width, context);
  10983. this.onLinesReadyObservable.notifyObservers(this);
  10984. var maxLineWidth = 0;
  10985. for (var i = 0; i < this._lines.length; i++) {
  10986. var line = this._lines[i];
  10987. if (line.width > maxLineWidth) {
  10988. maxLineWidth = line.width;
  10989. }
  10990. }
  10991. if (this._resizeToFit) {
  10992. if (this._textWrapping === TextWrapping.Clip) {
  10993. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  10994. if (newWidth !== this._width.internalValue) {
  10995. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10996. this._rebuildLayout = true;
  10997. }
  10998. }
  10999. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11000. if (newHeight !== this._height.internalValue) {
  11001. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11002. this._rebuildLayout = true;
  11003. }
  11004. }
  11005. };
  11006. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11007. var width = this._currentMeasure.width;
  11008. var x = 0;
  11009. switch (this._textHorizontalAlignment) {
  11010. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11011. x = 0;
  11012. break;
  11013. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11014. x = width - textWidth;
  11015. break;
  11016. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11017. x = (width - textWidth) / 2;
  11018. break;
  11019. }
  11020. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11021. context.shadowColor = this.shadowColor;
  11022. context.shadowBlur = this.shadowBlur;
  11023. context.shadowOffsetX = this.shadowOffsetX;
  11024. context.shadowOffsetY = this.shadowOffsetY;
  11025. }
  11026. if (this.outlineWidth) {
  11027. context.strokeText(text, this._currentMeasure.left + x, y);
  11028. }
  11029. context.fillText(text, this._currentMeasure.left + x, y);
  11030. };
  11031. /** @hidden */
  11032. TextBlock.prototype._draw = function (context) {
  11033. context.save();
  11034. this._applyStates(context);
  11035. // Render lines
  11036. this._renderLines(context);
  11037. context.restore();
  11038. };
  11039. TextBlock.prototype._applyStates = function (context) {
  11040. _super.prototype._applyStates.call(this, context);
  11041. if (this.outlineWidth) {
  11042. context.lineWidth = this.outlineWidth;
  11043. context.strokeStyle = this.outlineColor;
  11044. }
  11045. };
  11046. TextBlock.prototype._breakLines = function (refWidth, context) {
  11047. var lines = [];
  11048. var _lines = this.text.split("\n");
  11049. if (this._textWrapping === TextWrapping.Ellipsis) {
  11050. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11051. var _line = _lines_1[_i];
  11052. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11053. }
  11054. }
  11055. else if (this._textWrapping === TextWrapping.WordWrap) {
  11056. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11057. var _line = _lines_2[_a];
  11058. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11059. }
  11060. }
  11061. else {
  11062. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11063. var _line = _lines_3[_b];
  11064. lines.push(this._parseLine(_line, context));
  11065. }
  11066. }
  11067. return lines;
  11068. };
  11069. TextBlock.prototype._parseLine = function (line, context) {
  11070. if (line === void 0) { line = ''; }
  11071. return { text: line, width: context.measureText(line).width };
  11072. };
  11073. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11074. if (line === void 0) { line = ''; }
  11075. var lineWidth = context.measureText(line).width;
  11076. if (lineWidth > width) {
  11077. line += '…';
  11078. }
  11079. while (line.length > 2 && lineWidth > width) {
  11080. line = line.slice(0, -2) + '…';
  11081. lineWidth = context.measureText(line).width;
  11082. }
  11083. return { text: line, width: lineWidth };
  11084. };
  11085. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11086. if (line === void 0) { line = ''; }
  11087. var lines = [];
  11088. var words = line.split(' ');
  11089. var lineWidth = 0;
  11090. for (var n = 0; n < words.length; n++) {
  11091. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11092. var metrics = context.measureText(testLine);
  11093. var testWidth = metrics.width;
  11094. if (testWidth > width && n > 0) {
  11095. lines.push({ text: line, width: lineWidth });
  11096. line = words[n];
  11097. lineWidth = context.measureText(line).width;
  11098. }
  11099. else {
  11100. lineWidth = testWidth;
  11101. line = testLine;
  11102. }
  11103. }
  11104. lines.push({ text: line, width: lineWidth });
  11105. return lines;
  11106. };
  11107. TextBlock.prototype._renderLines = function (context) {
  11108. var height = this._currentMeasure.height;
  11109. var rootY = 0;
  11110. switch (this._textVerticalAlignment) {
  11111. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11112. rootY = this._fontOffset.ascent;
  11113. break;
  11114. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11115. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11116. break;
  11117. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11118. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11119. break;
  11120. }
  11121. rootY += this._currentMeasure.top;
  11122. for (var i = 0; i < this._lines.length; i++) {
  11123. var line = this._lines[i];
  11124. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11125. if (this._lineSpacing.isPixel) {
  11126. rootY += this._lineSpacing.getValue(this._host);
  11127. }
  11128. else {
  11129. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11130. }
  11131. }
  11132. this._drawText(line.text, line.width, rootY, context);
  11133. rootY += this._fontOffset.height;
  11134. }
  11135. };
  11136. /**
  11137. * Given a width constraint applied on the text block, find the expected height
  11138. * @returns expected height
  11139. */
  11140. TextBlock.prototype.computeExpectedHeight = function () {
  11141. if (this.text && this.widthInPixels) {
  11142. var context_1 = document.createElement('canvas').getContext('2d');
  11143. if (context_1) {
  11144. this._applyStates(context_1);
  11145. if (!this._fontOffset) {
  11146. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11147. }
  11148. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11149. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11150. }
  11151. }
  11152. return 0;
  11153. };
  11154. TextBlock.prototype.dispose = function () {
  11155. _super.prototype.dispose.call(this);
  11156. this.onTextChangedObservable.clear();
  11157. };
  11158. return TextBlock;
  11159. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11160. /***/ }),
  11161. /***/ "./2D/controls/virtualKeyboard.ts":
  11162. /*!****************************************!*\
  11163. !*** ./2D/controls/virtualKeyboard.ts ***!
  11164. \****************************************/
  11165. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11167. "use strict";
  11168. __webpack_require__.r(__webpack_exports__);
  11169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11170. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11171. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11172. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  11173. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11174. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11175. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11176. /**
  11177. * Class used to store key control properties
  11178. */
  11179. var KeyPropertySet = /** @class */ (function () {
  11180. function KeyPropertySet() {
  11181. }
  11182. return KeyPropertySet;
  11183. }());
  11184. /**
  11185. * Class used to create virtual keyboard
  11186. */
  11187. var VirtualKeyboard = /** @class */ (function (_super) {
  11188. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11189. function VirtualKeyboard() {
  11190. var _this = _super !== null && _super.apply(this, arguments) || this;
  11191. /** Observable raised when a key is pressed */
  11192. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11193. /** Gets or sets default key button width */
  11194. _this.defaultButtonWidth = "40px";
  11195. /** Gets or sets default key button height */
  11196. _this.defaultButtonHeight = "40px";
  11197. /** Gets or sets default key button left padding */
  11198. _this.defaultButtonPaddingLeft = "2px";
  11199. /** Gets or sets default key button right padding */
  11200. _this.defaultButtonPaddingRight = "2px";
  11201. /** Gets or sets default key button top padding */
  11202. _this.defaultButtonPaddingTop = "2px";
  11203. /** Gets or sets default key button bottom padding */
  11204. _this.defaultButtonPaddingBottom = "2px";
  11205. /** Gets or sets default key button foreground color */
  11206. _this.defaultButtonColor = "#DDD";
  11207. /** Gets or sets default key button background color */
  11208. _this.defaultButtonBackground = "#070707";
  11209. /** Gets or sets shift button foreground color */
  11210. _this.shiftButtonColor = "#7799FF";
  11211. /** Gets or sets shift button thickness*/
  11212. _this.selectedShiftThickness = 1;
  11213. /** Gets shift key state */
  11214. _this.shiftState = 0;
  11215. _this._currentlyConnectedInputText = null;
  11216. _this._connectedInputTexts = [];
  11217. _this._onKeyPressObserver = null;
  11218. return _this;
  11219. }
  11220. VirtualKeyboard.prototype._getTypeName = function () {
  11221. return "VirtualKeyboard";
  11222. };
  11223. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11224. var _this = this;
  11225. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11226. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11227. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11228. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11229. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11230. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11231. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11232. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11233. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11234. button.thickness = 0;
  11235. button.isFocusInvisible = true;
  11236. button.shadowColor = this.shadowColor;
  11237. button.shadowBlur = this.shadowBlur;
  11238. button.shadowOffsetX = this.shadowOffsetX;
  11239. button.shadowOffsetY = this.shadowOffsetY;
  11240. button.onPointerUpObservable.add(function () {
  11241. _this.onKeyPressObservable.notifyObservers(key);
  11242. });
  11243. return button;
  11244. };
  11245. /**
  11246. * Adds a new row of keys
  11247. * @param keys defines the list of keys to add
  11248. * @param propertySets defines the associated property sets
  11249. */
  11250. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11251. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11252. panel.isVertical = false;
  11253. panel.isFocusInvisible = true;
  11254. for (var i = 0; i < keys.length; i++) {
  11255. var properties = null;
  11256. if (propertySets && propertySets.length === keys.length) {
  11257. properties = propertySets[i];
  11258. }
  11259. panel.addControl(this._createKey(keys[i], properties));
  11260. }
  11261. this.addControl(panel);
  11262. };
  11263. /**
  11264. * Set the shift key to a specific state
  11265. * @param shiftState defines the new shift state
  11266. */
  11267. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11268. if (!this.children) {
  11269. return;
  11270. }
  11271. for (var i = 0; i < this.children.length; i++) {
  11272. var row = this.children[i];
  11273. if (!row || !row.children) {
  11274. continue;
  11275. }
  11276. var rowContainer = row;
  11277. for (var j = 0; j < rowContainer.children.length; j++) {
  11278. var button = rowContainer.children[j];
  11279. if (!button || !button.children[0]) {
  11280. continue;
  11281. }
  11282. var button_tblock = button.children[0];
  11283. if (button_tblock.text === "\u21E7") {
  11284. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11285. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11286. }
  11287. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11288. }
  11289. }
  11290. };
  11291. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11292. /** Gets the input text control currently attached to the keyboard */
  11293. get: function () {
  11294. return this._currentlyConnectedInputText;
  11295. },
  11296. enumerable: true,
  11297. configurable: true
  11298. });
  11299. /**
  11300. * Connects the keyboard with an input text control
  11301. *
  11302. * @param input defines the target control
  11303. */
  11304. VirtualKeyboard.prototype.connect = function (input) {
  11305. var _this = this;
  11306. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11307. if (inputTextAlreadyConnected) {
  11308. return;
  11309. }
  11310. if (this._onKeyPressObserver === null) {
  11311. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11312. if (!_this._currentlyConnectedInputText) {
  11313. return;
  11314. }
  11315. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11316. switch (key) {
  11317. case "\u21E7":
  11318. _this.shiftState++;
  11319. if (_this.shiftState > 2) {
  11320. _this.shiftState = 0;
  11321. }
  11322. _this.applyShiftState(_this.shiftState);
  11323. return;
  11324. case "\u2190":
  11325. _this._currentlyConnectedInputText.processKey(8);
  11326. return;
  11327. case "\u21B5":
  11328. _this._currentlyConnectedInputText.processKey(13);
  11329. return;
  11330. }
  11331. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11332. if (_this.shiftState === 1) {
  11333. _this.shiftState = 0;
  11334. _this.applyShiftState(_this.shiftState);
  11335. }
  11336. });
  11337. }
  11338. this.isVisible = false;
  11339. this._currentlyConnectedInputText = input;
  11340. input._connectedVirtualKeyboard = this;
  11341. // Events hooking
  11342. var onFocusObserver = input.onFocusObservable.add(function () {
  11343. _this._currentlyConnectedInputText = input;
  11344. input._connectedVirtualKeyboard = _this;
  11345. _this.isVisible = true;
  11346. });
  11347. var onBlurObserver = input.onBlurObservable.add(function () {
  11348. input._connectedVirtualKeyboard = null;
  11349. _this._currentlyConnectedInputText = null;
  11350. _this.isVisible = false;
  11351. });
  11352. this._connectedInputTexts.push({
  11353. input: input,
  11354. onBlurObserver: onBlurObserver,
  11355. onFocusObserver: onFocusObserver
  11356. });
  11357. };
  11358. /**
  11359. * Disconnects the keyboard from connected InputText controls
  11360. *
  11361. * @param input optionally defines a target control, otherwise all are disconnected
  11362. */
  11363. VirtualKeyboard.prototype.disconnect = function (input) {
  11364. var _this = this;
  11365. if (input) {
  11366. // .find not available on IE
  11367. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11368. if (filtered.length === 1) {
  11369. this._removeConnectedInputObservables(filtered[0]);
  11370. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11371. if (this._currentlyConnectedInputText === input) {
  11372. this._currentlyConnectedInputText = null;
  11373. }
  11374. }
  11375. }
  11376. else {
  11377. this._connectedInputTexts.forEach(function (connectedInputText) {
  11378. _this._removeConnectedInputObservables(connectedInputText);
  11379. });
  11380. this._connectedInputTexts = [];
  11381. }
  11382. if (this._connectedInputTexts.length === 0) {
  11383. this._currentlyConnectedInputText = null;
  11384. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11385. this._onKeyPressObserver = null;
  11386. }
  11387. };
  11388. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11389. connectedInputText.input._connectedVirtualKeyboard = null;
  11390. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11391. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11392. };
  11393. /**
  11394. * Release all resources
  11395. */
  11396. VirtualKeyboard.prototype.dispose = function () {
  11397. _super.prototype.dispose.call(this);
  11398. this.disconnect();
  11399. };
  11400. // Statics
  11401. /**
  11402. * Creates a new keyboard using a default layout
  11403. *
  11404. * @param name defines control name
  11405. * @returns a new VirtualKeyboard
  11406. */
  11407. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11408. var returnValue = new VirtualKeyboard(name);
  11409. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11410. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11411. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11412. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11413. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11414. return returnValue;
  11415. };
  11416. return VirtualKeyboard;
  11417. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11418. /***/ }),
  11419. /***/ "./2D/index.ts":
  11420. /*!*********************!*\
  11421. !*** ./2D/index.ts ***!
  11422. \*********************/
  11423. /*! 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 */
  11424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11425. "use strict";
  11426. __webpack_require__.r(__webpack_exports__);
  11427. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11459. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11461. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11463. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11466. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11468. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11470. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11472. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11474. /***/ }),
  11475. /***/ "./2D/math2D.ts":
  11476. /*!**********************!*\
  11477. !*** ./2D/math2D.ts ***!
  11478. \**********************/
  11479. /*! exports provided: Vector2WithInfo, Matrix2D */
  11480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11481. "use strict";
  11482. __webpack_require__.r(__webpack_exports__);
  11483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11485. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11486. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11487. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11488. /**
  11489. * Class used to transport Vector2 information for pointer events
  11490. */
  11491. var Vector2WithInfo = /** @class */ (function (_super) {
  11492. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11493. /**
  11494. * Creates a new Vector2WithInfo
  11495. * @param source defines the vector2 data to transport
  11496. * @param buttonIndex defines the current mouse button index
  11497. */
  11498. function Vector2WithInfo(source,
  11499. /** defines the current mouse button index */
  11500. buttonIndex) {
  11501. if (buttonIndex === void 0) { buttonIndex = 0; }
  11502. var _this = _super.call(this, source.x, source.y) || this;
  11503. _this.buttonIndex = buttonIndex;
  11504. return _this;
  11505. }
  11506. return Vector2WithInfo;
  11507. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11508. /** Class used to provide 2D matrix features */
  11509. var Matrix2D = /** @class */ (function () {
  11510. /**
  11511. * Creates a new matrix
  11512. * @param m00 defines value for (0, 0)
  11513. * @param m01 defines value for (0, 1)
  11514. * @param m10 defines value for (1, 0)
  11515. * @param m11 defines value for (1, 1)
  11516. * @param m20 defines value for (2, 0)
  11517. * @param m21 defines value for (2, 1)
  11518. */
  11519. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11520. /** Gets the internal array of 6 floats used to store matrix data */
  11521. this.m = new Float32Array(6);
  11522. this.fromValues(m00, m01, m10, m11, m20, m21);
  11523. }
  11524. /**
  11525. * Fills the matrix from direct values
  11526. * @param m00 defines value for (0, 0)
  11527. * @param m01 defines value for (0, 1)
  11528. * @param m10 defines value for (1, 0)
  11529. * @param m11 defines value for (1, 1)
  11530. * @param m20 defines value for (2, 0)
  11531. * @param m21 defines value for (2, 1)
  11532. * @returns the current modified matrix
  11533. */
  11534. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11535. this.m[0] = m00;
  11536. this.m[1] = m01;
  11537. this.m[2] = m10;
  11538. this.m[3] = m11;
  11539. this.m[4] = m20;
  11540. this.m[5] = m21;
  11541. return this;
  11542. };
  11543. /**
  11544. * Gets matrix determinant
  11545. * @returns the determinant
  11546. */
  11547. Matrix2D.prototype.determinant = function () {
  11548. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11549. };
  11550. /**
  11551. * Inverses the matrix and stores it in a target matrix
  11552. * @param result defines the target matrix
  11553. * @returns the current matrix
  11554. */
  11555. Matrix2D.prototype.invertToRef = function (result) {
  11556. var l0 = this.m[0];
  11557. var l1 = this.m[1];
  11558. var l2 = this.m[2];
  11559. var l3 = this.m[3];
  11560. var l4 = this.m[4];
  11561. var l5 = this.m[5];
  11562. var det = this.determinant();
  11563. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11564. result.m[0] = 0;
  11565. result.m[1] = 0;
  11566. result.m[2] = 0;
  11567. result.m[3] = 0;
  11568. result.m[4] = 0;
  11569. result.m[5] = 0;
  11570. return this;
  11571. }
  11572. var detDiv = 1 / det;
  11573. var det4 = l2 * l5 - l3 * l4;
  11574. var det5 = l1 * l4 - l0 * l5;
  11575. result.m[0] = l3 * detDiv;
  11576. result.m[1] = -l1 * detDiv;
  11577. result.m[2] = -l2 * detDiv;
  11578. result.m[3] = l0 * detDiv;
  11579. result.m[4] = det4 * detDiv;
  11580. result.m[5] = det5 * detDiv;
  11581. return this;
  11582. };
  11583. /**
  11584. * Multiplies the current matrix with another one
  11585. * @param other defines the second operand
  11586. * @param result defines the target matrix
  11587. * @returns the current matrix
  11588. */
  11589. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11590. var l0 = this.m[0];
  11591. var l1 = this.m[1];
  11592. var l2 = this.m[2];
  11593. var l3 = this.m[3];
  11594. var l4 = this.m[4];
  11595. var l5 = this.m[5];
  11596. var r0 = other.m[0];
  11597. var r1 = other.m[1];
  11598. var r2 = other.m[2];
  11599. var r3 = other.m[3];
  11600. var r4 = other.m[4];
  11601. var r5 = other.m[5];
  11602. result.m[0] = l0 * r0 + l1 * r2;
  11603. result.m[1] = l0 * r1 + l1 * r3;
  11604. result.m[2] = l2 * r0 + l3 * r2;
  11605. result.m[3] = l2 * r1 + l3 * r3;
  11606. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11607. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11608. return this;
  11609. };
  11610. /**
  11611. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11612. * @param x defines the x coordinate to transform
  11613. * @param y defines the x coordinate to transform
  11614. * @param result defines the target vector2
  11615. * @returns the current matrix
  11616. */
  11617. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11618. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11619. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11620. return this;
  11621. };
  11622. // Statics
  11623. /**
  11624. * Creates an identity matrix
  11625. * @returns a new matrix
  11626. */
  11627. Matrix2D.Identity = function () {
  11628. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11629. };
  11630. /**
  11631. * Creates a translation matrix and stores it in a target matrix
  11632. * @param x defines the x coordinate of the translation
  11633. * @param y defines the y coordinate of the translation
  11634. * @param result defines the target matrix
  11635. */
  11636. Matrix2D.TranslationToRef = function (x, y, result) {
  11637. result.fromValues(1, 0, 0, 1, x, y);
  11638. };
  11639. /**
  11640. * Creates a scaling matrix and stores it in a target matrix
  11641. * @param x defines the x coordinate of the scaling
  11642. * @param y defines the y coordinate of the scaling
  11643. * @param result defines the target matrix
  11644. */
  11645. Matrix2D.ScalingToRef = function (x, y, result) {
  11646. result.fromValues(x, 0, 0, y, 0, 0);
  11647. };
  11648. /**
  11649. * Creates a rotation matrix and stores it in a target matrix
  11650. * @param angle defines the rotation angle
  11651. * @param result defines the target matrix
  11652. */
  11653. Matrix2D.RotationToRef = function (angle, result) {
  11654. var s = Math.sin(angle);
  11655. var c = Math.cos(angle);
  11656. result.fromValues(c, s, -s, c, 0, 0);
  11657. };
  11658. /**
  11659. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11660. * @param tx defines the x coordinate of the translation
  11661. * @param ty defines the y coordinate of the translation
  11662. * @param angle defines the rotation angle
  11663. * @param scaleX defines the x coordinate of the scaling
  11664. * @param scaleY defines the y coordinate of the scaling
  11665. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11666. * @param result defines the target matrix
  11667. */
  11668. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11669. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11670. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11671. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11672. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11673. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11674. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11675. if (parentMatrix) {
  11676. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11677. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11678. }
  11679. else {
  11680. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11681. }
  11682. };
  11683. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11684. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11685. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11686. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11687. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11688. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11689. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11690. return Matrix2D;
  11691. }());
  11692. /***/ }),
  11693. /***/ "./2D/measure.ts":
  11694. /*!***********************!*\
  11695. !*** ./2D/measure.ts ***!
  11696. \***********************/
  11697. /*! exports provided: Measure */
  11698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11699. "use strict";
  11700. __webpack_require__.r(__webpack_exports__);
  11701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11702. /* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs */ "babylonjs/Misc/tools");
  11703. /* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs__WEBPACK_IMPORTED_MODULE_0__);
  11704. /**
  11705. * Class used to store 2D control sizes
  11706. */
  11707. var Measure = /** @class */ (function () {
  11708. /**
  11709. * Creates a new measure
  11710. * @param left defines left coordinate
  11711. * @param top defines top coordinate
  11712. * @param width defines width dimension
  11713. * @param height defines height dimension
  11714. */
  11715. function Measure(
  11716. /** defines left coordinate */
  11717. left,
  11718. /** defines top coordinate */
  11719. top,
  11720. /** defines width dimension */
  11721. width,
  11722. /** defines height dimension */
  11723. height) {
  11724. this.left = left;
  11725. this.top = top;
  11726. this.width = width;
  11727. this.height = height;
  11728. }
  11729. /**
  11730. * Copy from another measure
  11731. * @param other defines the other measure to copy from
  11732. */
  11733. Measure.prototype.copyFrom = function (other) {
  11734. this.left = other.left;
  11735. this.top = other.top;
  11736. this.width = other.width;
  11737. this.height = other.height;
  11738. };
  11739. /**
  11740. * Copy from a group of 4 floats
  11741. * @param left defines left coordinate
  11742. * @param top defines top coordinate
  11743. * @param width defines width dimension
  11744. * @param height defines height dimension
  11745. */
  11746. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11747. this.left = left;
  11748. this.top = top;
  11749. this.width = width;
  11750. this.height = height;
  11751. };
  11752. /**
  11753. * Computes the axis aligned bounding box measure for two given measures
  11754. * @param a Input measure
  11755. * @param b Input measure
  11756. * @param result the resulting bounding measure
  11757. */
  11758. Measure.CombineToRef = function (a, b, result) {
  11759. var left = Math.min(a.left, b.left);
  11760. var top = Math.min(a.top, b.top);
  11761. var right = Math.max(a.left + a.width, b.left + b.width);
  11762. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11763. result.left = left;
  11764. result.top = top;
  11765. result.width = right - left;
  11766. result.height = bottom - top;
  11767. };
  11768. /**
  11769. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11770. * @param transform the matrix to transform the measure before computing the AABB
  11771. * @param result the resulting AABB
  11772. */
  11773. Measure.prototype.transformToRef = function (transform, result) {
  11774. var rectanglePoints = babylonjs__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11775. var min = new babylonjs__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11776. var max = new babylonjs__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11777. for (var i = 0; i < 4; i++) {
  11778. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11779. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11780. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11781. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11782. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11783. }
  11784. result.left = min.x;
  11785. result.top = min.y;
  11786. result.width = max.x - min.x;
  11787. result.height = max.y - min.y;
  11788. };
  11789. /**
  11790. * Check equality between this measure and another one
  11791. * @param other defines the other measures
  11792. * @returns true if both measures are equals
  11793. */
  11794. Measure.prototype.isEqualsTo = function (other) {
  11795. if (this.left !== other.left) {
  11796. return false;
  11797. }
  11798. if (this.top !== other.top) {
  11799. return false;
  11800. }
  11801. if (this.width !== other.width) {
  11802. return false;
  11803. }
  11804. if (this.height !== other.height) {
  11805. return false;
  11806. }
  11807. return true;
  11808. };
  11809. /**
  11810. * Creates an empty measure
  11811. * @returns a new measure
  11812. */
  11813. Measure.Empty = function () {
  11814. return new Measure(0, 0, 0, 0);
  11815. };
  11816. return Measure;
  11817. }());
  11818. /***/ }),
  11819. /***/ "./2D/multiLinePoint.ts":
  11820. /*!******************************!*\
  11821. !*** ./2D/multiLinePoint.ts ***!
  11822. \******************************/
  11823. /*! exports provided: MultiLinePoint */
  11824. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11825. "use strict";
  11826. __webpack_require__.r(__webpack_exports__);
  11827. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11828. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11829. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11830. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11831. /**
  11832. * Class used to store a point for a MultiLine object.
  11833. * The point can be pure 2D coordinates, a mesh or a control
  11834. */
  11835. var MultiLinePoint = /** @class */ (function () {
  11836. /**
  11837. * Creates a new MultiLinePoint
  11838. * @param multiLine defines the source MultiLine object
  11839. */
  11840. function MultiLinePoint(multiLine) {
  11841. this._multiLine = multiLine;
  11842. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11843. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11844. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11845. }
  11846. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11847. /** Gets or sets x coordinate */
  11848. get: function () {
  11849. return this._x.toString(this._multiLine._host);
  11850. },
  11851. set: function (value) {
  11852. if (this._x.toString(this._multiLine._host) === value) {
  11853. return;
  11854. }
  11855. if (this._x.fromString(value)) {
  11856. this._multiLine._markAsDirty();
  11857. }
  11858. },
  11859. enumerable: true,
  11860. configurable: true
  11861. });
  11862. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11863. /** Gets or sets y coordinate */
  11864. get: function () {
  11865. return this._y.toString(this._multiLine._host);
  11866. },
  11867. set: function (value) {
  11868. if (this._y.toString(this._multiLine._host) === value) {
  11869. return;
  11870. }
  11871. if (this._y.fromString(value)) {
  11872. this._multiLine._markAsDirty();
  11873. }
  11874. },
  11875. enumerable: true,
  11876. configurable: true
  11877. });
  11878. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11879. /** Gets or sets the control associated with this point */
  11880. get: function () {
  11881. return this._control;
  11882. },
  11883. set: function (value) {
  11884. if (this._control === value) {
  11885. return;
  11886. }
  11887. if (this._control && this._controlObserver) {
  11888. this._control.onDirtyObservable.remove(this._controlObserver);
  11889. this._controlObserver = null;
  11890. }
  11891. this._control = value;
  11892. if (this._control) {
  11893. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11894. }
  11895. this._multiLine._markAsDirty();
  11896. },
  11897. enumerable: true,
  11898. configurable: true
  11899. });
  11900. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11901. /** Gets or sets the mesh associated with this point */
  11902. get: function () {
  11903. return this._mesh;
  11904. },
  11905. set: function (value) {
  11906. if (this._mesh === value) {
  11907. return;
  11908. }
  11909. if (this._mesh && this._meshObserver) {
  11910. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11911. }
  11912. this._mesh = value;
  11913. if (this._mesh) {
  11914. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11915. }
  11916. this._multiLine._markAsDirty();
  11917. },
  11918. enumerable: true,
  11919. configurable: true
  11920. });
  11921. /** Resets links */
  11922. MultiLinePoint.prototype.resetLinks = function () {
  11923. this.control = null;
  11924. this.mesh = null;
  11925. };
  11926. /**
  11927. * Gets a translation vector
  11928. * @returns the translation vector
  11929. */
  11930. MultiLinePoint.prototype.translate = function () {
  11931. this._point = this._translatePoint();
  11932. return this._point;
  11933. };
  11934. MultiLinePoint.prototype._translatePoint = function () {
  11935. if (this._mesh != null) {
  11936. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  11937. }
  11938. else if (this._control != null) {
  11939. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  11940. }
  11941. else {
  11942. var host = this._multiLine._host;
  11943. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  11944. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  11945. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  11946. }
  11947. };
  11948. /** Release associated resources */
  11949. MultiLinePoint.prototype.dispose = function () {
  11950. this.resetLinks();
  11951. };
  11952. return MultiLinePoint;
  11953. }());
  11954. /***/ }),
  11955. /***/ "./2D/style.ts":
  11956. /*!*********************!*\
  11957. !*** ./2D/style.ts ***!
  11958. \*********************/
  11959. /*! exports provided: Style */
  11960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11961. "use strict";
  11962. __webpack_require__.r(__webpack_exports__);
  11963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  11964. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  11965. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  11966. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11967. /**
  11968. * Define a style used by control to automatically setup properties based on a template.
  11969. * Only support font related properties so far
  11970. */
  11971. var Style = /** @class */ (function () {
  11972. /**
  11973. * Creates a new style object
  11974. * @param host defines the AdvancedDynamicTexture which hosts this style
  11975. */
  11976. function Style(host) {
  11977. this._fontFamily = "Arial";
  11978. this._fontStyle = "";
  11979. this._fontWeight = "";
  11980. /** @hidden */
  11981. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11982. /**
  11983. * Observable raised when the style values are changed
  11984. */
  11985. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  11986. this._host = host;
  11987. }
  11988. Object.defineProperty(Style.prototype, "fontSize", {
  11989. /**
  11990. * Gets or sets the font size
  11991. */
  11992. get: function () {
  11993. return this._fontSize.toString(this._host);
  11994. },
  11995. set: function (value) {
  11996. if (this._fontSize.toString(this._host) === value) {
  11997. return;
  11998. }
  11999. if (this._fontSize.fromString(value)) {
  12000. this.onChangedObservable.notifyObservers(this);
  12001. }
  12002. },
  12003. enumerable: true,
  12004. configurable: true
  12005. });
  12006. Object.defineProperty(Style.prototype, "fontFamily", {
  12007. /**
  12008. * Gets or sets the font family
  12009. */
  12010. get: function () {
  12011. return this._fontFamily;
  12012. },
  12013. set: function (value) {
  12014. if (this._fontFamily === value) {
  12015. return;
  12016. }
  12017. this._fontFamily = value;
  12018. this.onChangedObservable.notifyObservers(this);
  12019. },
  12020. enumerable: true,
  12021. configurable: true
  12022. });
  12023. Object.defineProperty(Style.prototype, "fontStyle", {
  12024. /**
  12025. * Gets or sets the font style
  12026. */
  12027. get: function () {
  12028. return this._fontStyle;
  12029. },
  12030. set: function (value) {
  12031. if (this._fontStyle === value) {
  12032. return;
  12033. }
  12034. this._fontStyle = value;
  12035. this.onChangedObservable.notifyObservers(this);
  12036. },
  12037. enumerable: true,
  12038. configurable: true
  12039. });
  12040. Object.defineProperty(Style.prototype, "fontWeight", {
  12041. /** Gets or sets font weight */
  12042. get: function () {
  12043. return this._fontWeight;
  12044. },
  12045. set: function (value) {
  12046. if (this._fontWeight === value) {
  12047. return;
  12048. }
  12049. this._fontWeight = value;
  12050. this.onChangedObservable.notifyObservers(this);
  12051. },
  12052. enumerable: true,
  12053. configurable: true
  12054. });
  12055. /** Dispose all associated resources */
  12056. Style.prototype.dispose = function () {
  12057. this.onChangedObservable.clear();
  12058. };
  12059. return Style;
  12060. }());
  12061. /***/ }),
  12062. /***/ "./2D/valueAndUnit.ts":
  12063. /*!****************************!*\
  12064. !*** ./2D/valueAndUnit.ts ***!
  12065. \****************************/
  12066. /*! exports provided: ValueAndUnit */
  12067. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12068. "use strict";
  12069. __webpack_require__.r(__webpack_exports__);
  12070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12071. /**
  12072. * Class used to specific a value and its associated unit
  12073. */
  12074. var ValueAndUnit = /** @class */ (function () {
  12075. /**
  12076. * Creates a new ValueAndUnit
  12077. * @param value defines the value to store
  12078. * @param unit defines the unit to store
  12079. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12080. */
  12081. function ValueAndUnit(value,
  12082. /** defines the unit to store */
  12083. unit,
  12084. /** defines a boolean indicating if the value can be negative */
  12085. negativeValueAllowed) {
  12086. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12087. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12088. this.unit = unit;
  12089. this.negativeValueAllowed = negativeValueAllowed;
  12090. this._value = 1;
  12091. /**
  12092. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12093. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12094. */
  12095. this.ignoreAdaptiveScaling = false;
  12096. this._value = value;
  12097. this._originalUnit = unit;
  12098. }
  12099. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12100. /** Gets a boolean indicating if the value is a percentage */
  12101. get: function () {
  12102. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12103. },
  12104. enumerable: true,
  12105. configurable: true
  12106. });
  12107. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12108. /** Gets a boolean indicating if the value is store as pixel */
  12109. get: function () {
  12110. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12111. },
  12112. enumerable: true,
  12113. configurable: true
  12114. });
  12115. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12116. /** Gets direct internal value */
  12117. get: function () {
  12118. return this._value;
  12119. },
  12120. enumerable: true,
  12121. configurable: true
  12122. });
  12123. /**
  12124. * Gets value as pixel
  12125. * @param host defines the root host
  12126. * @param refValue defines the reference value for percentages
  12127. * @returns the value as pixel
  12128. */
  12129. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12130. if (this.isPixel) {
  12131. return this.getValue(host);
  12132. }
  12133. return this.getValue(host) * refValue;
  12134. };
  12135. /**
  12136. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12137. * @param value defines the value to store
  12138. * @param unit defines the unit to store
  12139. * @returns the current ValueAndUnit
  12140. */
  12141. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12142. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12143. this._value = value;
  12144. this.unit = unit;
  12145. return this;
  12146. };
  12147. /**
  12148. * Gets the value accordingly to its unit
  12149. * @param host defines the root host
  12150. * @returns the value
  12151. */
  12152. ValueAndUnit.prototype.getValue = function (host) {
  12153. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12154. var width = 0;
  12155. var height = 0;
  12156. if (host.idealWidth) {
  12157. width = (this._value * host.getSize().width) / host.idealWidth;
  12158. }
  12159. if (host.idealHeight) {
  12160. height = (this._value * host.getSize().height) / host.idealHeight;
  12161. }
  12162. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12163. return window.innerWidth < window.innerHeight ? width : height;
  12164. }
  12165. if (host.idealWidth) { // horizontal
  12166. return width;
  12167. }
  12168. if (host.idealHeight) { // vertical
  12169. return height;
  12170. }
  12171. }
  12172. return this._value;
  12173. };
  12174. /**
  12175. * Gets a string representation of the value
  12176. * @param host defines the root host
  12177. * @returns a string
  12178. */
  12179. ValueAndUnit.prototype.toString = function (host) {
  12180. switch (this.unit) {
  12181. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12182. return (this.getValue(host) * 100) + "%";
  12183. case ValueAndUnit.UNITMODE_PIXEL:
  12184. return this.getValue(host) + "px";
  12185. }
  12186. return this.unit.toString();
  12187. };
  12188. /**
  12189. * Store a value parsed from a string
  12190. * @param source defines the source string
  12191. * @returns true if the value was successfully parsed
  12192. */
  12193. ValueAndUnit.prototype.fromString = function (source) {
  12194. var match = ValueAndUnit._Regex.exec(source.toString());
  12195. if (!match || match.length === 0) {
  12196. return false;
  12197. }
  12198. var sourceValue = parseFloat(match[1]);
  12199. var sourceUnit = this._originalUnit;
  12200. if (!this.negativeValueAllowed) {
  12201. if (sourceValue < 0) {
  12202. sourceValue = 0;
  12203. }
  12204. }
  12205. if (match.length === 4) {
  12206. switch (match[3]) {
  12207. case "px":
  12208. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12209. break;
  12210. case "%":
  12211. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12212. sourceValue /= 100.0;
  12213. break;
  12214. }
  12215. }
  12216. if (sourceValue === this._value && sourceUnit === this.unit) {
  12217. return false;
  12218. }
  12219. this._value = sourceValue;
  12220. this.unit = sourceUnit;
  12221. return true;
  12222. };
  12223. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12224. /** UNITMODE_PERCENTAGE */
  12225. get: function () {
  12226. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12227. },
  12228. enumerable: true,
  12229. configurable: true
  12230. });
  12231. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12232. /** UNITMODE_PIXEL */
  12233. get: function () {
  12234. return ValueAndUnit._UNITMODE_PIXEL;
  12235. },
  12236. enumerable: true,
  12237. configurable: true
  12238. });
  12239. // Static
  12240. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12241. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12242. ValueAndUnit._UNITMODE_PIXEL = 1;
  12243. return ValueAndUnit;
  12244. }());
  12245. /***/ }),
  12246. /***/ "./3D/controls/abstractButton3D.ts":
  12247. /*!*****************************************!*\
  12248. !*** ./3D/controls/abstractButton3D.ts ***!
  12249. \*****************************************/
  12250. /*! exports provided: AbstractButton3D */
  12251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12252. "use strict";
  12253. __webpack_require__.r(__webpack_exports__);
  12254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12255. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12256. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/tools");
  12257. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12258. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12259. /**
  12260. * Class used as a root to all buttons
  12261. */
  12262. var AbstractButton3D = /** @class */ (function (_super) {
  12263. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12264. /**
  12265. * Creates a new button
  12266. * @param name defines the control name
  12267. */
  12268. function AbstractButton3D(name) {
  12269. return _super.call(this, name) || this;
  12270. }
  12271. AbstractButton3D.prototype._getTypeName = function () {
  12272. return "AbstractButton3D";
  12273. };
  12274. // Mesh association
  12275. AbstractButton3D.prototype._createNode = function (scene) {
  12276. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12277. };
  12278. return AbstractButton3D;
  12279. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12280. /***/ }),
  12281. /***/ "./3D/controls/button3D.ts":
  12282. /*!*********************************!*\
  12283. !*** ./3D/controls/button3D.ts ***!
  12284. \*********************************/
  12285. /*! exports provided: Button3D */
  12286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12287. "use strict";
  12288. __webpack_require__.r(__webpack_exports__);
  12289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12290. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12291. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  12292. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12293. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12294. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12295. /**
  12296. * Class used to create a button in 3D
  12297. */
  12298. var Button3D = /** @class */ (function (_super) {
  12299. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12300. /**
  12301. * Creates a new button
  12302. * @param name defines the control name
  12303. */
  12304. function Button3D(name) {
  12305. var _this = _super.call(this, name) || this;
  12306. _this._contentResolution = 512;
  12307. _this._contentScaleRatio = 2;
  12308. // Default animations
  12309. _this.pointerEnterAnimation = function () {
  12310. if (!_this.mesh) {
  12311. return;
  12312. }
  12313. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12314. };
  12315. _this.pointerOutAnimation = function () {
  12316. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12317. };
  12318. _this.pointerDownAnimation = function () {
  12319. if (!_this.mesh) {
  12320. return;
  12321. }
  12322. _this.mesh.scaling.scaleInPlace(0.95);
  12323. };
  12324. _this.pointerUpAnimation = function () {
  12325. if (!_this.mesh) {
  12326. return;
  12327. }
  12328. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12329. };
  12330. return _this;
  12331. }
  12332. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12333. /**
  12334. * Gets or sets the texture resolution used to render content (512 by default)
  12335. */
  12336. get: function () {
  12337. return this._contentResolution;
  12338. },
  12339. set: function (value) {
  12340. if (this._contentResolution === value) {
  12341. return;
  12342. }
  12343. this._contentResolution = value;
  12344. this._resetContent();
  12345. },
  12346. enumerable: true,
  12347. configurable: true
  12348. });
  12349. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12350. /**
  12351. * Gets or sets the texture scale ratio used to render content (2 by default)
  12352. */
  12353. get: function () {
  12354. return this._contentScaleRatio;
  12355. },
  12356. set: function (value) {
  12357. if (this._contentScaleRatio === value) {
  12358. return;
  12359. }
  12360. this._contentScaleRatio = value;
  12361. this._resetContent();
  12362. },
  12363. enumerable: true,
  12364. configurable: true
  12365. });
  12366. Button3D.prototype._disposeFacadeTexture = function () {
  12367. if (this._facadeTexture) {
  12368. this._facadeTexture.dispose();
  12369. this._facadeTexture = null;
  12370. }
  12371. };
  12372. Button3D.prototype._resetContent = function () {
  12373. this._disposeFacadeTexture();
  12374. this.content = this._content;
  12375. };
  12376. Object.defineProperty(Button3D.prototype, "content", {
  12377. /**
  12378. * Gets or sets the GUI 2D content used to display the button's facade
  12379. */
  12380. get: function () {
  12381. return this._content;
  12382. },
  12383. set: function (value) {
  12384. this._content = value;
  12385. if (!this._host || !this._host.utilityLayer) {
  12386. return;
  12387. }
  12388. if (!this._facadeTexture) {
  12389. 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);
  12390. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12391. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12392. this._facadeTexture.premulAlpha = true;
  12393. }
  12394. this._facadeTexture.addControl(value);
  12395. this._applyFacade(this._facadeTexture);
  12396. },
  12397. enumerable: true,
  12398. configurable: true
  12399. });
  12400. /**
  12401. * Apply the facade texture (created from the content property).
  12402. * This function can be overloaded by child classes
  12403. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12404. */
  12405. Button3D.prototype._applyFacade = function (facadeTexture) {
  12406. this._currentMaterial.emissiveTexture = facadeTexture;
  12407. };
  12408. Button3D.prototype._getTypeName = function () {
  12409. return "Button3D";
  12410. };
  12411. // Mesh association
  12412. Button3D.prototype._createNode = function (scene) {
  12413. var faceUV = new Array(6);
  12414. for (var i = 0; i < 6; i++) {
  12415. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12416. }
  12417. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12418. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12419. width: 1.0,
  12420. height: 1.0,
  12421. depth: 0.08,
  12422. faceUV: faceUV
  12423. }, scene);
  12424. return mesh;
  12425. };
  12426. Button3D.prototype._affectMaterial = function (mesh) {
  12427. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12428. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12429. mesh.material = material;
  12430. this._currentMaterial = material;
  12431. this._resetContent();
  12432. };
  12433. /**
  12434. * Releases all associated resources
  12435. */
  12436. Button3D.prototype.dispose = function () {
  12437. _super.prototype.dispose.call(this);
  12438. this._disposeFacadeTexture();
  12439. if (this._currentMaterial) {
  12440. this._currentMaterial.dispose();
  12441. }
  12442. };
  12443. return Button3D;
  12444. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12445. /***/ }),
  12446. /***/ "./3D/controls/container3D.ts":
  12447. /*!************************************!*\
  12448. !*** ./3D/controls/container3D.ts ***!
  12449. \************************************/
  12450. /*! exports provided: Container3D */
  12451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12452. "use strict";
  12453. __webpack_require__.r(__webpack_exports__);
  12454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12455. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12456. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/tools");
  12457. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12458. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12459. /**
  12460. * Class used to create containers for controls
  12461. */
  12462. var Container3D = /** @class */ (function (_super) {
  12463. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12464. /**
  12465. * Creates a new container
  12466. * @param name defines the container name
  12467. */
  12468. function Container3D(name) {
  12469. var _this = _super.call(this, name) || this;
  12470. _this._blockLayout = false;
  12471. /**
  12472. * Gets the list of child controls
  12473. */
  12474. _this._children = new Array();
  12475. return _this;
  12476. }
  12477. Object.defineProperty(Container3D.prototype, "children", {
  12478. /**
  12479. * Gets the list of child controls
  12480. */
  12481. get: function () {
  12482. return this._children;
  12483. },
  12484. enumerable: true,
  12485. configurable: true
  12486. });
  12487. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12488. /**
  12489. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12490. * This is helpful to optimize layout operation when adding multiple children in a row
  12491. */
  12492. get: function () {
  12493. return this._blockLayout;
  12494. },
  12495. set: function (value) {
  12496. if (this._blockLayout === value) {
  12497. return;
  12498. }
  12499. this._blockLayout = value;
  12500. if (!this._blockLayout) {
  12501. this._arrangeChildren();
  12502. }
  12503. },
  12504. enumerable: true,
  12505. configurable: true
  12506. });
  12507. /**
  12508. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12509. * @returns the current container
  12510. */
  12511. Container3D.prototype.updateLayout = function () {
  12512. this._arrangeChildren();
  12513. return this;
  12514. };
  12515. /**
  12516. * Gets a boolean indicating if the given control is in the children of this control
  12517. * @param control defines the control to check
  12518. * @returns true if the control is in the child list
  12519. */
  12520. Container3D.prototype.containsControl = function (control) {
  12521. return this._children.indexOf(control) !== -1;
  12522. };
  12523. /**
  12524. * Adds a control to the children of this control
  12525. * @param control defines the control to add
  12526. * @returns the current container
  12527. */
  12528. Container3D.prototype.addControl = function (control) {
  12529. var index = this._children.indexOf(control);
  12530. if (index !== -1) {
  12531. return this;
  12532. }
  12533. control.parent = this;
  12534. control._host = this._host;
  12535. this._children.push(control);
  12536. if (this._host.utilityLayer) {
  12537. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12538. if (control.node) {
  12539. control.node.parent = this.node;
  12540. }
  12541. if (!this.blockLayout) {
  12542. this._arrangeChildren();
  12543. }
  12544. }
  12545. return this;
  12546. };
  12547. /**
  12548. * This function will be called everytime a new control is added
  12549. */
  12550. Container3D.prototype._arrangeChildren = function () {
  12551. };
  12552. Container3D.prototype._createNode = function (scene) {
  12553. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12554. };
  12555. /**
  12556. * Removes a control from the children of this control
  12557. * @param control defines the control to remove
  12558. * @returns the current container
  12559. */
  12560. Container3D.prototype.removeControl = function (control) {
  12561. var index = this._children.indexOf(control);
  12562. if (index !== -1) {
  12563. this._children.splice(index, 1);
  12564. control.parent = null;
  12565. control._disposeNode();
  12566. }
  12567. return this;
  12568. };
  12569. Container3D.prototype._getTypeName = function () {
  12570. return "Container3D";
  12571. };
  12572. /**
  12573. * Releases all associated resources
  12574. */
  12575. Container3D.prototype.dispose = function () {
  12576. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12577. var control = _a[_i];
  12578. control.dispose();
  12579. }
  12580. this._children = [];
  12581. _super.prototype.dispose.call(this);
  12582. };
  12583. /** Control rotation will remain unchanged */
  12584. Container3D.UNSET_ORIENTATION = 0;
  12585. /** Control will rotate to make it look at sphere central axis */
  12586. Container3D.FACEORIGIN_ORIENTATION = 1;
  12587. /** Control will rotate to make it look back at sphere central axis */
  12588. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12589. /** Control will rotate to look at z axis (0, 0, 1) */
  12590. Container3D.FACEFORWARD_ORIENTATION = 3;
  12591. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12592. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12593. return Container3D;
  12594. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12595. /***/ }),
  12596. /***/ "./3D/controls/control3D.ts":
  12597. /*!**********************************!*\
  12598. !*** ./3D/controls/control3D.ts ***!
  12599. \**********************************/
  12600. /*! exports provided: Control3D */
  12601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12602. "use strict";
  12603. __webpack_require__.r(__webpack_exports__);
  12604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12605. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  12606. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12607. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12608. /**
  12609. * Class used as base class for controls
  12610. */
  12611. var Control3D = /** @class */ (function () {
  12612. /**
  12613. * Creates a new control
  12614. * @param name defines the control name
  12615. */
  12616. function Control3D(
  12617. /** Defines the control name */
  12618. name) {
  12619. this.name = name;
  12620. this._downCount = 0;
  12621. this._enterCount = -1;
  12622. this._downPointerIds = {};
  12623. this._isVisible = true;
  12624. /**
  12625. * An event triggered when the pointer move over the control
  12626. */
  12627. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12628. /**
  12629. * An event triggered when the pointer move out of the control
  12630. */
  12631. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12632. /**
  12633. * An event triggered when the pointer taps the control
  12634. */
  12635. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12636. /**
  12637. * An event triggered when pointer is up
  12638. */
  12639. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12640. /**
  12641. * An event triggered when a control is clicked on (with a mouse)
  12642. */
  12643. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12644. /**
  12645. * An event triggered when pointer enters the control
  12646. */
  12647. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12648. // Behaviors
  12649. this._behaviors = new Array();
  12650. }
  12651. Object.defineProperty(Control3D.prototype, "position", {
  12652. /** Gets or sets the control position in world space */
  12653. get: function () {
  12654. if (!this._node) {
  12655. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12656. }
  12657. return this._node.position;
  12658. },
  12659. set: function (value) {
  12660. if (!this._node) {
  12661. return;
  12662. }
  12663. this._node.position = value;
  12664. },
  12665. enumerable: true,
  12666. configurable: true
  12667. });
  12668. Object.defineProperty(Control3D.prototype, "scaling", {
  12669. /** Gets or sets the control scaling in world space */
  12670. get: function () {
  12671. if (!this._node) {
  12672. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12673. }
  12674. return this._node.scaling;
  12675. },
  12676. set: function (value) {
  12677. if (!this._node) {
  12678. return;
  12679. }
  12680. this._node.scaling = value;
  12681. },
  12682. enumerable: true,
  12683. configurable: true
  12684. });
  12685. Object.defineProperty(Control3D.prototype, "behaviors", {
  12686. /**
  12687. * Gets the list of attached behaviors
  12688. * @see http://doc.babylonjs.com/features/behaviour
  12689. */
  12690. get: function () {
  12691. return this._behaviors;
  12692. },
  12693. enumerable: true,
  12694. configurable: true
  12695. });
  12696. /**
  12697. * Attach a behavior to the control
  12698. * @see http://doc.babylonjs.com/features/behaviour
  12699. * @param behavior defines the behavior to attach
  12700. * @returns the current control
  12701. */
  12702. Control3D.prototype.addBehavior = function (behavior) {
  12703. var _this = this;
  12704. var index = this._behaviors.indexOf(behavior);
  12705. if (index !== -1) {
  12706. return this;
  12707. }
  12708. behavior.init();
  12709. var scene = this._host.scene;
  12710. if (scene.isLoading) {
  12711. // We defer the attach when the scene will be loaded
  12712. scene.onDataLoadedObservable.addOnce(function () {
  12713. behavior.attach(_this);
  12714. });
  12715. }
  12716. else {
  12717. behavior.attach(this);
  12718. }
  12719. this._behaviors.push(behavior);
  12720. return this;
  12721. };
  12722. /**
  12723. * Remove an attached behavior
  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.removeBehavior = function (behavior) {
  12729. var index = this._behaviors.indexOf(behavior);
  12730. if (index === -1) {
  12731. return this;
  12732. }
  12733. this._behaviors[index].detach();
  12734. this._behaviors.splice(index, 1);
  12735. return this;
  12736. };
  12737. /**
  12738. * Gets an attached behavior by name
  12739. * @param name defines the name of the behavior to look for
  12740. * @see http://doc.babylonjs.com/features/behaviour
  12741. * @returns null if behavior was not found else the requested behavior
  12742. */
  12743. Control3D.prototype.getBehaviorByName = function (name) {
  12744. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12745. var behavior = _a[_i];
  12746. if (behavior.name === name) {
  12747. return behavior;
  12748. }
  12749. }
  12750. return null;
  12751. };
  12752. Object.defineProperty(Control3D.prototype, "isVisible", {
  12753. /** Gets or sets a boolean indicating if the control is visible */
  12754. get: function () {
  12755. return this._isVisible;
  12756. },
  12757. set: function (value) {
  12758. if (this._isVisible === value) {
  12759. return;
  12760. }
  12761. this._isVisible = value;
  12762. var mesh = this.mesh;
  12763. if (mesh) {
  12764. mesh.setEnabled(value);
  12765. }
  12766. },
  12767. enumerable: true,
  12768. configurable: true
  12769. });
  12770. Object.defineProperty(Control3D.prototype, "typeName", {
  12771. /**
  12772. * Gets a string representing the class name
  12773. */
  12774. get: function () {
  12775. return this._getTypeName();
  12776. },
  12777. enumerable: true,
  12778. configurable: true
  12779. });
  12780. /**
  12781. * Get the current class name of the control.
  12782. * @returns current class name
  12783. */
  12784. Control3D.prototype.getClassName = function () {
  12785. return this._getTypeName();
  12786. };
  12787. Control3D.prototype._getTypeName = function () {
  12788. return "Control3D";
  12789. };
  12790. Object.defineProperty(Control3D.prototype, "node", {
  12791. /**
  12792. * Gets the transform node used by this control
  12793. */
  12794. get: function () {
  12795. return this._node;
  12796. },
  12797. enumerable: true,
  12798. configurable: true
  12799. });
  12800. Object.defineProperty(Control3D.prototype, "mesh", {
  12801. /**
  12802. * Gets the mesh used to render this control
  12803. */
  12804. get: function () {
  12805. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12806. return this._node;
  12807. }
  12808. return null;
  12809. },
  12810. enumerable: true,
  12811. configurable: true
  12812. });
  12813. /**
  12814. * Link the control as child of the given node
  12815. * @param node defines the node to link to. Use null to unlink the control
  12816. * @returns the current control
  12817. */
  12818. Control3D.prototype.linkToTransformNode = function (node) {
  12819. if (this._node) {
  12820. this._node.parent = node;
  12821. }
  12822. return this;
  12823. };
  12824. /** @hidden **/
  12825. Control3D.prototype._prepareNode = function (scene) {
  12826. if (!this._node) {
  12827. this._node = this._createNode(scene);
  12828. if (!this.node) {
  12829. return;
  12830. }
  12831. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12832. this._node.position = this.position;
  12833. this._node.scaling = this.scaling;
  12834. var mesh = this.mesh;
  12835. if (mesh) {
  12836. mesh.isPickable = true;
  12837. this._affectMaterial(mesh);
  12838. }
  12839. }
  12840. };
  12841. /**
  12842. * Node creation.
  12843. * Can be overriden by children
  12844. * @param scene defines the scene where the node must be attached
  12845. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12846. */
  12847. Control3D.prototype._createNode = function (scene) {
  12848. // Do nothing by default
  12849. return null;
  12850. };
  12851. /**
  12852. * Affect a material to the given mesh
  12853. * @param mesh defines the mesh which will represent the control
  12854. */
  12855. Control3D.prototype._affectMaterial = function (mesh) {
  12856. mesh.material = null;
  12857. };
  12858. // Pointers
  12859. /** @hidden */
  12860. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12861. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12862. };
  12863. /** @hidden */
  12864. Control3D.prototype._onPointerEnter = function (target) {
  12865. if (this._enterCount > 0) {
  12866. return false;
  12867. }
  12868. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12869. this._enterCount = 0;
  12870. }
  12871. this._enterCount++;
  12872. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12873. if (this.pointerEnterAnimation) {
  12874. this.pointerEnterAnimation();
  12875. }
  12876. return true;
  12877. };
  12878. /** @hidden */
  12879. Control3D.prototype._onPointerOut = function (target) {
  12880. this._enterCount = 0;
  12881. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12882. if (this.pointerOutAnimation) {
  12883. this.pointerOutAnimation();
  12884. }
  12885. };
  12886. /** @hidden */
  12887. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12888. if (this._downCount !== 0) {
  12889. return false;
  12890. }
  12891. this._downCount++;
  12892. this._downPointerIds[pointerId] = true;
  12893. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12894. if (this.pointerDownAnimation) {
  12895. this.pointerDownAnimation();
  12896. }
  12897. return true;
  12898. };
  12899. /** @hidden */
  12900. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12901. this._downCount = 0;
  12902. delete this._downPointerIds[pointerId];
  12903. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12904. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12905. }
  12906. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12907. if (this.pointerUpAnimation) {
  12908. this.pointerUpAnimation();
  12909. }
  12910. };
  12911. /** @hidden */
  12912. Control3D.prototype.forcePointerUp = function (pointerId) {
  12913. if (pointerId === void 0) { pointerId = null; }
  12914. if (pointerId !== null) {
  12915. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12916. }
  12917. else {
  12918. for (var key in this._downPointerIds) {
  12919. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12920. }
  12921. }
  12922. };
  12923. /** @hidden */
  12924. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  12925. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  12926. this._onPointerMove(this, pickedPoint);
  12927. var previousControlOver = this._host._lastControlOver[pointerId];
  12928. if (previousControlOver && previousControlOver !== this) {
  12929. previousControlOver._onPointerOut(this);
  12930. }
  12931. if (previousControlOver !== this) {
  12932. this._onPointerEnter(this);
  12933. }
  12934. this._host._lastControlOver[pointerId] = this;
  12935. return true;
  12936. }
  12937. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  12938. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  12939. this._host._lastControlDown[pointerId] = this;
  12940. this._host._lastPickedControl = this;
  12941. return true;
  12942. }
  12943. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  12944. if (this._host._lastControlDown[pointerId]) {
  12945. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  12946. }
  12947. delete this._host._lastControlDown[pointerId];
  12948. return true;
  12949. }
  12950. return false;
  12951. };
  12952. /** @hidden */
  12953. Control3D.prototype._disposeNode = function () {
  12954. if (this._node) {
  12955. this._node.dispose();
  12956. this._node = null;
  12957. }
  12958. };
  12959. /**
  12960. * Releases all associated resources
  12961. */
  12962. Control3D.prototype.dispose = function () {
  12963. this.onPointerDownObservable.clear();
  12964. this.onPointerEnterObservable.clear();
  12965. this.onPointerMoveObservable.clear();
  12966. this.onPointerOutObservable.clear();
  12967. this.onPointerUpObservable.clear();
  12968. this.onPointerClickObservable.clear();
  12969. this._disposeNode();
  12970. // Behaviors
  12971. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12972. var behavior = _a[_i];
  12973. behavior.detach();
  12974. }
  12975. };
  12976. return Control3D;
  12977. }());
  12978. /***/ }),
  12979. /***/ "./3D/controls/cylinderPanel.ts":
  12980. /*!**************************************!*\
  12981. !*** ./3D/controls/cylinderPanel.ts ***!
  12982. \**************************************/
  12983. /*! exports provided: CylinderPanel */
  12984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12985. "use strict";
  12986. __webpack_require__.r(__webpack_exports__);
  12987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  12988. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12989. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  12990. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12991. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  12992. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  12993. /**
  12994. * Class used to create a container panel deployed on the surface of a cylinder
  12995. */
  12996. var CylinderPanel = /** @class */ (function (_super) {
  12997. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  12998. function CylinderPanel() {
  12999. var _this = _super !== null && _super.apply(this, arguments) || this;
  13000. _this._radius = 5.0;
  13001. return _this;
  13002. }
  13003. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13004. /**
  13005. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13006. */
  13007. get: function () {
  13008. return this._radius;
  13009. },
  13010. set: function (value) {
  13011. var _this = this;
  13012. if (this._radius === value) {
  13013. return;
  13014. }
  13015. this._radius = value;
  13016. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13017. _this._arrangeChildren();
  13018. });
  13019. },
  13020. enumerable: true,
  13021. configurable: true
  13022. });
  13023. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13024. var mesh = control.mesh;
  13025. if (!mesh) {
  13026. return;
  13027. }
  13028. var newPos = this._cylindricalMapping(nodePosition);
  13029. control.position = newPos;
  13030. switch (this.orientation) {
  13031. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13032. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13033. break;
  13034. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13035. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13036. break;
  13037. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13038. break;
  13039. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13040. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13041. break;
  13042. }
  13043. };
  13044. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13045. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13046. var yAngle = (source.x / this._radius);
  13047. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13048. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13049. };
  13050. return CylinderPanel;
  13051. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13052. /***/ }),
  13053. /***/ "./3D/controls/holographicButton.ts":
  13054. /*!******************************************!*\
  13055. !*** ./3D/controls/holographicButton.ts ***!
  13056. \******************************************/
  13057. /*! exports provided: HolographicButton */
  13058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13059. "use strict";
  13060. __webpack_require__.r(__webpack_exports__);
  13061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13062. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13063. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13064. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  13065. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13066. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13067. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13068. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13069. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13070. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13071. /**
  13072. * Class used to create a holographic button in 3D
  13073. */
  13074. var HolographicButton = /** @class */ (function (_super) {
  13075. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13076. /**
  13077. * Creates a new button
  13078. * @param name defines the control name
  13079. */
  13080. function HolographicButton(name, shareMaterials) {
  13081. if (shareMaterials === void 0) { shareMaterials = true; }
  13082. var _this = _super.call(this, name) || this;
  13083. _this._shareMaterials = true;
  13084. _this._shareMaterials = shareMaterials;
  13085. // Default animations
  13086. _this.pointerEnterAnimation = function () {
  13087. if (!_this.mesh) {
  13088. return;
  13089. }
  13090. _this._frontPlate.setEnabled(true);
  13091. };
  13092. _this.pointerOutAnimation = function () {
  13093. if (!_this.mesh) {
  13094. return;
  13095. }
  13096. _this._frontPlate.setEnabled(false);
  13097. };
  13098. return _this;
  13099. }
  13100. HolographicButton.prototype._disposeTooltip = function () {
  13101. this._tooltipFade = null;
  13102. if (this._tooltipTextBlock) {
  13103. this._tooltipTextBlock.dispose();
  13104. }
  13105. if (this._tooltipTexture) {
  13106. this._tooltipTexture.dispose();
  13107. }
  13108. if (this._tooltipMesh) {
  13109. this._tooltipMesh.dispose();
  13110. }
  13111. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13112. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13113. };
  13114. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13115. get: function () {
  13116. if (this._tooltipTextBlock) {
  13117. return this._tooltipTextBlock.text;
  13118. }
  13119. return null;
  13120. },
  13121. /**
  13122. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13123. */
  13124. set: function (text) {
  13125. var _this = this;
  13126. if (!text) {
  13127. this._disposeTooltip();
  13128. return;
  13129. }
  13130. if (!this._tooltipFade) {
  13131. // Create tooltip with mesh and text
  13132. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13133. 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);
  13134. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13135. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13136. tooltipBackground.material = mat;
  13137. tooltipBackground.isPickable = false;
  13138. this._tooltipMesh.addChild(tooltipBackground);
  13139. tooltipBackground.position.z = 0.05;
  13140. this._tooltipMesh.scaling.y = 1 / 3;
  13141. this._tooltipMesh.position.y = 0.7;
  13142. this._tooltipMesh.position.z = -0.15;
  13143. this._tooltipMesh.isPickable = false;
  13144. this._tooltipMesh.parent = this._backPlate;
  13145. // Create text texture for the tooltip
  13146. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13147. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13148. this._tooltipTextBlock.scaleY = 3;
  13149. this._tooltipTextBlock.color = "white";
  13150. this._tooltipTextBlock.fontSize = 130;
  13151. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13152. // Add hover action to tooltip
  13153. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13154. this._tooltipFade.delay = 500;
  13155. this._tooltipMesh.addBehavior(this._tooltipFade);
  13156. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13157. if (_this._tooltipFade) {
  13158. _this._tooltipFade.fadeIn(true);
  13159. }
  13160. });
  13161. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13162. if (_this._tooltipFade) {
  13163. _this._tooltipFade.fadeIn(false);
  13164. }
  13165. });
  13166. }
  13167. if (this._tooltipTextBlock) {
  13168. this._tooltipTextBlock.text = text;
  13169. }
  13170. },
  13171. enumerable: true,
  13172. configurable: true
  13173. });
  13174. Object.defineProperty(HolographicButton.prototype, "text", {
  13175. /**
  13176. * Gets or sets text for the button
  13177. */
  13178. get: function () {
  13179. return this._text;
  13180. },
  13181. set: function (value) {
  13182. if (this._text === value) {
  13183. return;
  13184. }
  13185. this._text = value;
  13186. this._rebuildContent();
  13187. },
  13188. enumerable: true,
  13189. configurable: true
  13190. });
  13191. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13192. /**
  13193. * Gets or sets the image url for the button
  13194. */
  13195. get: function () {
  13196. return this._imageUrl;
  13197. },
  13198. set: function (value) {
  13199. if (this._imageUrl === value) {
  13200. return;
  13201. }
  13202. this._imageUrl = value;
  13203. this._rebuildContent();
  13204. },
  13205. enumerable: true,
  13206. configurable: true
  13207. });
  13208. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13209. /**
  13210. * Gets the back material used by this button
  13211. */
  13212. get: function () {
  13213. return this._backMaterial;
  13214. },
  13215. enumerable: true,
  13216. configurable: true
  13217. });
  13218. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13219. /**
  13220. * Gets the front material used by this button
  13221. */
  13222. get: function () {
  13223. return this._frontMaterial;
  13224. },
  13225. enumerable: true,
  13226. configurable: true
  13227. });
  13228. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13229. /**
  13230. * Gets the plate material used by this button
  13231. */
  13232. get: function () {
  13233. return this._plateMaterial;
  13234. },
  13235. enumerable: true,
  13236. configurable: true
  13237. });
  13238. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13239. /**
  13240. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13241. */
  13242. get: function () {
  13243. return this._shareMaterials;
  13244. },
  13245. enumerable: true,
  13246. configurable: true
  13247. });
  13248. HolographicButton.prototype._getTypeName = function () {
  13249. return "HolographicButton";
  13250. };
  13251. HolographicButton.prototype._rebuildContent = function () {
  13252. this._disposeFacadeTexture();
  13253. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13254. panel.isVertical = true;
  13255. if (this._imageUrl) {
  13256. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13257. image.source = this._imageUrl;
  13258. image.paddingTop = "40px";
  13259. image.height = "180px";
  13260. image.width = "100px";
  13261. image.paddingBottom = "40px";
  13262. panel.addControl(image);
  13263. }
  13264. if (this._text) {
  13265. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13266. text.text = this._text;
  13267. text.color = "white";
  13268. text.height = "30px";
  13269. text.fontSize = 24;
  13270. panel.addControl(text);
  13271. }
  13272. if (this._frontPlate) {
  13273. this.content = panel;
  13274. }
  13275. };
  13276. // Mesh association
  13277. HolographicButton.prototype._createNode = function (scene) {
  13278. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13279. width: 1.0,
  13280. height: 1.0,
  13281. depth: 0.08
  13282. }, scene);
  13283. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13284. width: 1.0,
  13285. height: 1.0,
  13286. depth: 0.08
  13287. }, scene);
  13288. this._frontPlate.parent = this._backPlate;
  13289. this._frontPlate.position.z = -0.08;
  13290. this._frontPlate.isPickable = false;
  13291. this._frontPlate.setEnabled(false);
  13292. this._textPlate = _super.prototype._createNode.call(this, scene);
  13293. this._textPlate.parent = this._backPlate;
  13294. this._textPlate.position.z = -0.08;
  13295. this._textPlate.isPickable = false;
  13296. return this._backPlate;
  13297. };
  13298. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13299. this._plateMaterial.emissiveTexture = facadeTexture;
  13300. this._plateMaterial.opacityTexture = facadeTexture;
  13301. };
  13302. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13303. var _this = this;
  13304. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13305. this._backMaterial.renderHoverLight = true;
  13306. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13307. if (pickedPoint) {
  13308. _this._backMaterial.hoverPosition = pickedPoint;
  13309. _this._backMaterial.hoverColor.a = 1.0;
  13310. }
  13311. else {
  13312. _this._backMaterial.hoverColor.a = 0;
  13313. }
  13314. });
  13315. };
  13316. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13317. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13318. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13319. this._frontMaterial.alpha = 0.5; // Additive
  13320. this._frontMaterial.renderBorders = true;
  13321. };
  13322. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13323. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13324. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13325. };
  13326. HolographicButton.prototype._affectMaterial = function (mesh) {
  13327. // Back
  13328. if (this._shareMaterials) {
  13329. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13330. this._createBackMaterial(mesh);
  13331. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13332. }
  13333. else {
  13334. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13335. }
  13336. // Front
  13337. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13338. this._createFrontMaterial(mesh);
  13339. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13340. }
  13341. else {
  13342. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13343. }
  13344. }
  13345. else {
  13346. this._createBackMaterial(mesh);
  13347. this._createFrontMaterial(mesh);
  13348. }
  13349. this._createPlateMaterial(mesh);
  13350. this._backPlate.material = this._backMaterial;
  13351. this._frontPlate.material = this._frontMaterial;
  13352. this._textPlate.material = this._plateMaterial;
  13353. this._rebuildContent();
  13354. };
  13355. /**
  13356. * Releases all associated resources
  13357. */
  13358. HolographicButton.prototype.dispose = function () {
  13359. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13360. this._disposeTooltip();
  13361. if (!this.shareMaterials) {
  13362. this._backMaterial.dispose();
  13363. this._frontMaterial.dispose();
  13364. this._plateMaterial.dispose();
  13365. if (this._pickedPointObserver) {
  13366. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13367. this._pickedPointObserver = null;
  13368. }
  13369. }
  13370. };
  13371. return HolographicButton;
  13372. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13373. /***/ }),
  13374. /***/ "./3D/controls/index.ts":
  13375. /*!******************************!*\
  13376. !*** ./3D/controls/index.ts ***!
  13377. \******************************/
  13378. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13380. "use strict";
  13381. __webpack_require__.r(__webpack_exports__);
  13382. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13384. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13386. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13388. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13390. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13392. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13394. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13396. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13398. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13400. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13402. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13404. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13406. /***/ }),
  13407. /***/ "./3D/controls/meshButton3D.ts":
  13408. /*!*************************************!*\
  13409. !*** ./3D/controls/meshButton3D.ts ***!
  13410. \*************************************/
  13411. /*! exports provided: MeshButton3D */
  13412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13413. "use strict";
  13414. __webpack_require__.r(__webpack_exports__);
  13415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13416. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13417. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13418. /**
  13419. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13420. */
  13421. var MeshButton3D = /** @class */ (function (_super) {
  13422. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13423. /**
  13424. * Creates a new 3D button based on a mesh
  13425. * @param mesh mesh to become a 3D button
  13426. * @param name defines the control name
  13427. */
  13428. function MeshButton3D(mesh, name) {
  13429. var _this = _super.call(this, name) || this;
  13430. _this._currentMesh = mesh;
  13431. /**
  13432. * Provides a default behavior on hover/out & up/down
  13433. * Override those function to create your own desired behavior specific to your mesh
  13434. */
  13435. _this.pointerEnterAnimation = function () {
  13436. if (!_this.mesh) {
  13437. return;
  13438. }
  13439. _this.mesh.scaling.scaleInPlace(1.1);
  13440. };
  13441. _this.pointerOutAnimation = function () {
  13442. if (!_this.mesh) {
  13443. return;
  13444. }
  13445. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13446. };
  13447. _this.pointerDownAnimation = function () {
  13448. if (!_this.mesh) {
  13449. return;
  13450. }
  13451. _this.mesh.scaling.scaleInPlace(0.95);
  13452. };
  13453. _this.pointerUpAnimation = function () {
  13454. if (!_this.mesh) {
  13455. return;
  13456. }
  13457. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13458. };
  13459. return _this;
  13460. }
  13461. MeshButton3D.prototype._getTypeName = function () {
  13462. return "MeshButton3D";
  13463. };
  13464. // Mesh association
  13465. MeshButton3D.prototype._createNode = function (scene) {
  13466. var _this = this;
  13467. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13468. mesh.metadata = _this;
  13469. });
  13470. return this._currentMesh;
  13471. };
  13472. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13473. };
  13474. return MeshButton3D;
  13475. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13476. /***/ }),
  13477. /***/ "./3D/controls/planePanel.ts":
  13478. /*!***********************************!*\
  13479. !*** ./3D/controls/planePanel.ts ***!
  13480. \***********************************/
  13481. /*! exports provided: PlanePanel */
  13482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13483. "use strict";
  13484. __webpack_require__.r(__webpack_exports__);
  13485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13486. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13487. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  13488. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13489. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13490. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13491. /**
  13492. * Class used to create a container panel deployed on the surface of a plane
  13493. */
  13494. var PlanePanel = /** @class */ (function (_super) {
  13495. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13496. function PlanePanel() {
  13497. return _super !== null && _super.apply(this, arguments) || this;
  13498. }
  13499. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13500. var mesh = control.mesh;
  13501. if (!mesh) {
  13502. return;
  13503. }
  13504. control.position = nodePosition.clone();
  13505. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13506. target.copyFrom(nodePosition);
  13507. switch (this.orientation) {
  13508. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13509. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13510. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13511. mesh.lookAt(target);
  13512. break;
  13513. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13514. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13515. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13516. mesh.lookAt(target);
  13517. break;
  13518. }
  13519. };
  13520. return PlanePanel;
  13521. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13522. /***/ }),
  13523. /***/ "./3D/controls/scatterPanel.ts":
  13524. /*!*************************************!*\
  13525. !*** ./3D/controls/scatterPanel.ts ***!
  13526. \*************************************/
  13527. /*! exports provided: ScatterPanel */
  13528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13529. "use strict";
  13530. __webpack_require__.r(__webpack_exports__);
  13531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13532. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13533. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13534. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13535. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13536. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13537. /**
  13538. * Class used to create a container panel where items get randomized planar mapping
  13539. */
  13540. var ScatterPanel = /** @class */ (function (_super) {
  13541. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13542. function ScatterPanel() {
  13543. var _this = _super !== null && _super.apply(this, arguments) || this;
  13544. _this._iteration = 100.0;
  13545. return _this;
  13546. }
  13547. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13548. /**
  13549. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13550. */
  13551. get: function () {
  13552. return this._iteration;
  13553. },
  13554. set: function (value) {
  13555. var _this = this;
  13556. if (this._iteration === value) {
  13557. return;
  13558. }
  13559. this._iteration = value;
  13560. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13561. _this._arrangeChildren();
  13562. });
  13563. },
  13564. enumerable: true,
  13565. configurable: true
  13566. });
  13567. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13568. var mesh = control.mesh;
  13569. var newPos = this._scatterMapping(nodePosition);
  13570. if (!mesh) {
  13571. return;
  13572. }
  13573. switch (this.orientation) {
  13574. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13575. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13576. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13577. break;
  13578. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13579. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13580. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13581. break;
  13582. }
  13583. control.position = newPos;
  13584. };
  13585. ScatterPanel.prototype._scatterMapping = function (source) {
  13586. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13587. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13588. return source;
  13589. };
  13590. ScatterPanel.prototype._finalProcessing = function () {
  13591. var meshes = [];
  13592. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13593. var child = _a[_i];
  13594. if (!child.mesh) {
  13595. continue;
  13596. }
  13597. meshes.push(child.mesh);
  13598. }
  13599. for (var count = 0; count < this._iteration; count++) {
  13600. meshes.sort(function (a, b) {
  13601. var distance1 = a.position.lengthSquared();
  13602. var distance2 = b.position.lengthSquared();
  13603. if (distance1 < distance2) {
  13604. return 1;
  13605. }
  13606. else if (distance1 > distance2) {
  13607. return -1;
  13608. }
  13609. return 0;
  13610. });
  13611. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13612. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13613. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13614. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13615. for (var i = 0; i < meshes.length - 1; i++) {
  13616. for (var j = i + 1; j < meshes.length; j++) {
  13617. if (i != j) {
  13618. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13619. // Ignore Z axis
  13620. difference2D.x = difference.x;
  13621. difference2D.y = difference.y;
  13622. var combinedRadius = cellSize;
  13623. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13624. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13625. distance -= minSeparation;
  13626. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13627. difference2D.normalize();
  13628. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13629. meshes[j].position.addInPlace(difference);
  13630. meshes[i].position.subtractInPlace(difference);
  13631. }
  13632. }
  13633. }
  13634. }
  13635. }
  13636. };
  13637. return ScatterPanel;
  13638. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13639. /***/ }),
  13640. /***/ "./3D/controls/spherePanel.ts":
  13641. /*!************************************!*\
  13642. !*** ./3D/controls/spherePanel.ts ***!
  13643. \************************************/
  13644. /*! exports provided: SpherePanel */
  13645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13646. "use strict";
  13647. __webpack_require__.r(__webpack_exports__);
  13648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13649. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13650. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13651. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13652. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13653. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13654. /**
  13655. * Class used to create a container panel deployed on the surface of a sphere
  13656. */
  13657. var SpherePanel = /** @class */ (function (_super) {
  13658. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13659. function SpherePanel() {
  13660. var _this = _super !== null && _super.apply(this, arguments) || this;
  13661. _this._radius = 5.0;
  13662. return _this;
  13663. }
  13664. Object.defineProperty(SpherePanel.prototype, "radius", {
  13665. /**
  13666. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13667. */
  13668. get: function () {
  13669. return this._radius;
  13670. },
  13671. set: function (value) {
  13672. var _this = this;
  13673. if (this._radius === value) {
  13674. return;
  13675. }
  13676. this._radius = value;
  13677. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13678. _this._arrangeChildren();
  13679. });
  13680. },
  13681. enumerable: true,
  13682. configurable: true
  13683. });
  13684. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13685. var mesh = control.mesh;
  13686. if (!mesh) {
  13687. return;
  13688. }
  13689. var newPos = this._sphericalMapping(nodePosition);
  13690. control.position = newPos;
  13691. switch (this.orientation) {
  13692. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13693. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13694. break;
  13695. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13696. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13697. break;
  13698. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13699. break;
  13700. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13701. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13702. break;
  13703. }
  13704. };
  13705. SpherePanel.prototype._sphericalMapping = function (source) {
  13706. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13707. var xAngle = (source.y / this._radius);
  13708. var yAngle = -(source.x / this._radius);
  13709. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13710. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13711. };
  13712. return SpherePanel;
  13713. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13714. /***/ }),
  13715. /***/ "./3D/controls/stackPanel3D.ts":
  13716. /*!*************************************!*\
  13717. !*** ./3D/controls/stackPanel3D.ts ***!
  13718. \*************************************/
  13719. /*! exports provided: StackPanel3D */
  13720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13721. "use strict";
  13722. __webpack_require__.r(__webpack_exports__);
  13723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13724. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13725. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13726. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13727. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13728. /**
  13729. * Class used to create a stack panel in 3D on XY plane
  13730. */
  13731. var StackPanel3D = /** @class */ (function (_super) {
  13732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13733. /**
  13734. * Creates new StackPanel
  13735. * @param isVertical
  13736. */
  13737. function StackPanel3D(isVertical) {
  13738. if (isVertical === void 0) { isVertical = false; }
  13739. var _this = _super.call(this) || this;
  13740. _this._isVertical = false;
  13741. /**
  13742. * Gets or sets the distance between elements
  13743. */
  13744. _this.margin = 0.1;
  13745. _this._isVertical = isVertical;
  13746. return _this;
  13747. }
  13748. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13749. /**
  13750. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13751. */
  13752. get: function () {
  13753. return this._isVertical;
  13754. },
  13755. set: function (value) {
  13756. var _this = this;
  13757. if (this._isVertical === value) {
  13758. return;
  13759. }
  13760. this._isVertical = value;
  13761. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13762. _this._arrangeChildren();
  13763. });
  13764. },
  13765. enumerable: true,
  13766. configurable: true
  13767. });
  13768. StackPanel3D.prototype._arrangeChildren = function () {
  13769. var width = 0;
  13770. var height = 0;
  13771. var controlCount = 0;
  13772. var extendSizes = [];
  13773. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13774. // Measure
  13775. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13776. var child = _a[_i];
  13777. if (!child.mesh) {
  13778. continue;
  13779. }
  13780. controlCount++;
  13781. child.mesh.computeWorldMatrix(true);
  13782. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13783. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13784. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13785. extendSizes.push(extendSize);
  13786. if (this._isVertical) {
  13787. height += extendSize.y;
  13788. }
  13789. else {
  13790. width += extendSize.x;
  13791. }
  13792. }
  13793. if (this._isVertical) {
  13794. height += (controlCount - 1) * this.margin / 2;
  13795. }
  13796. else {
  13797. width += (controlCount - 1) * this.margin / 2;
  13798. }
  13799. // Arrange
  13800. var offset;
  13801. if (this._isVertical) {
  13802. offset = -height;
  13803. }
  13804. else {
  13805. offset = -width;
  13806. }
  13807. var index = 0;
  13808. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13809. var child = _c[_b];
  13810. if (!child.mesh) {
  13811. continue;
  13812. }
  13813. controlCount--;
  13814. var extendSize = extendSizes[index++];
  13815. if (this._isVertical) {
  13816. child.position.y = offset + extendSize.y;
  13817. child.position.x = 0;
  13818. offset += extendSize.y * 2;
  13819. }
  13820. else {
  13821. child.position.x = offset + extendSize.x;
  13822. child.position.y = 0;
  13823. offset += extendSize.x * 2;
  13824. }
  13825. offset += (controlCount > 0 ? this.margin : 0);
  13826. }
  13827. };
  13828. return StackPanel3D;
  13829. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13830. /***/ }),
  13831. /***/ "./3D/controls/volumeBasedPanel.ts":
  13832. /*!*****************************************!*\
  13833. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13834. \*****************************************/
  13835. /*! exports provided: VolumeBasedPanel */
  13836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13837. "use strict";
  13838. __webpack_require__.r(__webpack_exports__);
  13839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13840. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13841. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13842. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13843. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13844. /**
  13845. * Abstract class used to create a container panel deployed on the surface of a volume
  13846. */
  13847. var VolumeBasedPanel = /** @class */ (function (_super) {
  13848. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13849. /**
  13850. * Creates new VolumeBasedPanel
  13851. */
  13852. function VolumeBasedPanel() {
  13853. var _this = _super.call(this) || this;
  13854. _this._columns = 10;
  13855. _this._rows = 0;
  13856. _this._rowThenColum = true;
  13857. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13858. /**
  13859. * Gets or sets the distance between elements
  13860. */
  13861. _this.margin = 0;
  13862. return _this;
  13863. }
  13864. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13865. /**
  13866. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13867. * | Value | Type | Description |
  13868. * | ----- | ----------------------------------- | ----------- |
  13869. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13870. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13871. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13872. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13873. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13874. */
  13875. get: function () {
  13876. return this._orientation;
  13877. },
  13878. set: function (value) {
  13879. var _this = this;
  13880. if (this._orientation === value) {
  13881. return;
  13882. }
  13883. this._orientation = value;
  13884. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13885. _this._arrangeChildren();
  13886. });
  13887. },
  13888. enumerable: true,
  13889. configurable: true
  13890. });
  13891. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13892. /**
  13893. * Gets or sets the number of columns requested (10 by default).
  13894. * The panel will automatically compute the number of rows based on number of child controls.
  13895. */
  13896. get: function () {
  13897. return this._columns;
  13898. },
  13899. set: function (value) {
  13900. var _this = this;
  13901. if (this._columns === value) {
  13902. return;
  13903. }
  13904. this._columns = value;
  13905. this._rowThenColum = true;
  13906. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13907. _this._arrangeChildren();
  13908. });
  13909. },
  13910. enumerable: true,
  13911. configurable: true
  13912. });
  13913. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13914. /**
  13915. * Gets or sets a the number of rows requested.
  13916. * The panel will automatically compute the number of columns based on number of child controls.
  13917. */
  13918. get: function () {
  13919. return this._rows;
  13920. },
  13921. set: function (value) {
  13922. var _this = this;
  13923. if (this._rows === value) {
  13924. return;
  13925. }
  13926. this._rows = value;
  13927. this._rowThenColum = false;
  13928. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13929. _this._arrangeChildren();
  13930. });
  13931. },
  13932. enumerable: true,
  13933. configurable: true
  13934. });
  13935. VolumeBasedPanel.prototype._arrangeChildren = function () {
  13936. this._cellWidth = 0;
  13937. this._cellHeight = 0;
  13938. var rows = 0;
  13939. var columns = 0;
  13940. var controlCount = 0;
  13941. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13942. // Measure
  13943. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13944. var child = _a[_i];
  13945. if (!child.mesh) {
  13946. continue;
  13947. }
  13948. controlCount++;
  13949. child.mesh.computeWorldMatrix(true);
  13950. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  13951. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  13952. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13953. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  13954. boundingBox.max.subtractToRef(boundingBox.min, diff);
  13955. diff.scaleInPlace(0.5);
  13956. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  13957. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  13958. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  13959. }
  13960. this._cellWidth += this.margin * 2;
  13961. this._cellHeight += this.margin * 2;
  13962. // Arrange
  13963. if (this._rowThenColum) {
  13964. columns = this._columns;
  13965. rows = Math.ceil(controlCount / this._columns);
  13966. }
  13967. else {
  13968. rows = this._rows;
  13969. columns = Math.ceil(controlCount / this._rows);
  13970. }
  13971. var startOffsetX = (columns * 0.5) * this._cellWidth;
  13972. var startOffsetY = (rows * 0.5) * this._cellHeight;
  13973. var nodeGrid = [];
  13974. var cellCounter = 0;
  13975. if (this._rowThenColum) {
  13976. for (var r = 0; r < rows; r++) {
  13977. for (var c = 0; c < columns; c++) {
  13978. 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));
  13979. cellCounter++;
  13980. if (cellCounter > controlCount) {
  13981. break;
  13982. }
  13983. }
  13984. }
  13985. }
  13986. else {
  13987. for (var c = 0; c < columns; c++) {
  13988. for (var r = 0; r < rows; r++) {
  13989. 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));
  13990. cellCounter++;
  13991. if (cellCounter > controlCount) {
  13992. break;
  13993. }
  13994. }
  13995. }
  13996. }
  13997. cellCounter = 0;
  13998. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13999. var child = _c[_b];
  14000. if (!child.mesh) {
  14001. continue;
  14002. }
  14003. this._mapGridNode(child, nodeGrid[cellCounter]);
  14004. cellCounter++;
  14005. }
  14006. this._finalProcessing();
  14007. };
  14008. /** Child classes can implement this function to provide additional processing */
  14009. VolumeBasedPanel.prototype._finalProcessing = function () {
  14010. };
  14011. return VolumeBasedPanel;
  14012. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14013. /***/ }),
  14014. /***/ "./3D/gui3DManager.ts":
  14015. /*!****************************!*\
  14016. !*** ./3D/gui3DManager.ts ***!
  14017. \****************************/
  14018. /*! exports provided: GUI3DManager */
  14019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14020. "use strict";
  14021. __webpack_require__.r(__webpack_exports__);
  14022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14023. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  14024. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14025. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14026. /**
  14027. * Class used to manage 3D user interface
  14028. * @see http://doc.babylonjs.com/how_to/gui3d
  14029. */
  14030. var GUI3DManager = /** @class */ (function () {
  14031. /**
  14032. * Creates a new GUI3DManager
  14033. * @param scene
  14034. */
  14035. function GUI3DManager(scene) {
  14036. var _this = this;
  14037. /** @hidden */
  14038. this._lastControlOver = {};
  14039. /** @hidden */
  14040. this._lastControlDown = {};
  14041. /**
  14042. * Observable raised when the point picked by the pointer events changed
  14043. */
  14044. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14045. // Shared resources
  14046. /** @hidden */
  14047. this._sharedMaterials = {};
  14048. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14049. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14050. _this._sceneDisposeObserver = null;
  14051. _this._utilityLayer = null;
  14052. _this.dispose();
  14053. });
  14054. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14055. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14056. this._utilityLayer.pickUtilitySceneFirst = false;
  14057. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14058. return mesh && mesh.metadata && mesh.metadata._node;
  14059. };
  14060. // Root
  14061. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14062. this._rootContainer._host = this;
  14063. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14064. // Events
  14065. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14066. _this._handlePointerOut(pointerId, true);
  14067. });
  14068. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14069. _this._doPicking(pi);
  14070. });
  14071. // Scene
  14072. this._utilityLayer.utilityLayerScene.autoClear = false;
  14073. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14074. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14075. }
  14076. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14077. /** Gets the hosting scene */
  14078. get: function () {
  14079. return this._scene;
  14080. },
  14081. enumerable: true,
  14082. configurable: true
  14083. });
  14084. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14085. /** Gets associated utility layer */
  14086. get: function () {
  14087. return this._utilityLayer;
  14088. },
  14089. enumerable: true,
  14090. configurable: true
  14091. });
  14092. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14093. var previousControlOver = this._lastControlOver[pointerId];
  14094. if (previousControlOver) {
  14095. previousControlOver._onPointerOut(previousControlOver);
  14096. delete this._lastControlOver[pointerId];
  14097. }
  14098. if (isPointerUp) {
  14099. if (this._lastControlDown[pointerId]) {
  14100. this._lastControlDown[pointerId].forcePointerUp();
  14101. delete this._lastControlDown[pointerId];
  14102. }
  14103. }
  14104. this.onPickedPointChangedObservable.notifyObservers(null);
  14105. };
  14106. GUI3DManager.prototype._doPicking = function (pi) {
  14107. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14108. return false;
  14109. }
  14110. var pointerEvent = (pi.event);
  14111. var pointerId = pointerEvent.pointerId || 0;
  14112. var buttonIndex = pointerEvent.button;
  14113. var pickingInfo = pi.pickInfo;
  14114. if (!pickingInfo || !pickingInfo.hit) {
  14115. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14116. return false;
  14117. }
  14118. var control = (pickingInfo.pickedMesh.metadata);
  14119. if (pickingInfo.pickedPoint) {
  14120. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14121. }
  14122. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14123. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14124. if (this._lastControlOver[pointerId]) {
  14125. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14126. }
  14127. delete this._lastControlOver[pointerId];
  14128. }
  14129. }
  14130. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14131. if (this._lastControlDown[pointerEvent.pointerId]) {
  14132. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14133. delete this._lastControlDown[pointerEvent.pointerId];
  14134. }
  14135. if (pointerEvent.pointerType === "touch") {
  14136. this._handlePointerOut(pointerId, false);
  14137. }
  14138. }
  14139. return true;
  14140. };
  14141. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14142. /**
  14143. * Gets the root container
  14144. */
  14145. get: function () {
  14146. return this._rootContainer;
  14147. },
  14148. enumerable: true,
  14149. configurable: true
  14150. });
  14151. /**
  14152. * Gets a boolean indicating if the given control is in the root child list
  14153. * @param control defines the control to check
  14154. * @returns true if the control is in the root child list
  14155. */
  14156. GUI3DManager.prototype.containsControl = function (control) {
  14157. return this._rootContainer.containsControl(control);
  14158. };
  14159. /**
  14160. * Adds a control to the root child list
  14161. * @param control defines the control to add
  14162. * @returns the current manager
  14163. */
  14164. GUI3DManager.prototype.addControl = function (control) {
  14165. this._rootContainer.addControl(control);
  14166. return this;
  14167. };
  14168. /**
  14169. * Removes a control from the root child list
  14170. * @param control defines the control to remove
  14171. * @returns the current container
  14172. */
  14173. GUI3DManager.prototype.removeControl = function (control) {
  14174. this._rootContainer.removeControl(control);
  14175. return this;
  14176. };
  14177. /**
  14178. * Releases all associated resources
  14179. */
  14180. GUI3DManager.prototype.dispose = function () {
  14181. this._rootContainer.dispose();
  14182. for (var materialName in this._sharedMaterials) {
  14183. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14184. continue;
  14185. }
  14186. this._sharedMaterials[materialName].dispose();
  14187. }
  14188. this._sharedMaterials = {};
  14189. if (this._pointerOutObserver && this._utilityLayer) {
  14190. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14191. this._pointerOutObserver = null;
  14192. }
  14193. this.onPickedPointChangedObservable.clear();
  14194. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14195. if (utilityLayerScene) {
  14196. if (this._pointerObserver) {
  14197. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14198. this._pointerObserver = null;
  14199. }
  14200. }
  14201. if (this._scene) {
  14202. if (this._sceneDisposeObserver) {
  14203. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14204. this._sceneDisposeObserver = null;
  14205. }
  14206. }
  14207. if (this._utilityLayer) {
  14208. this._utilityLayer.dispose();
  14209. }
  14210. };
  14211. return GUI3DManager;
  14212. }());
  14213. /***/ }),
  14214. /***/ "./3D/index.ts":
  14215. /*!*********************!*\
  14216. !*** ./3D/index.ts ***!
  14217. \*********************/
  14218. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14220. "use strict";
  14221. __webpack_require__.r(__webpack_exports__);
  14222. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14235. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14238. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14240. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14242. /***/ }),
  14243. /***/ "./3D/materials/fluentMaterial.ts":
  14244. /*!****************************************!*\
  14245. !*** ./3D/materials/fluentMaterial.ts ***!
  14246. \****************************************/
  14247. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14249. "use strict";
  14250. __webpack_require__.r(__webpack_exports__);
  14251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14253. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14254. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/tools");
  14255. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14256. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14257. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14258. /** @hidden */
  14259. var FluentMaterialDefines = /** @class */ (function (_super) {
  14260. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14261. function FluentMaterialDefines() {
  14262. var _this = _super.call(this) || this;
  14263. _this.INNERGLOW = false;
  14264. _this.BORDER = false;
  14265. _this.HOVERLIGHT = false;
  14266. _this.TEXTURE = false;
  14267. _this.rebuild();
  14268. return _this;
  14269. }
  14270. return FluentMaterialDefines;
  14271. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14272. /**
  14273. * Class used to render controls with fluent desgin
  14274. */
  14275. var FluentMaterial = /** @class */ (function (_super) {
  14276. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14277. /**
  14278. * Creates a new Fluent material
  14279. * @param name defines the name of the material
  14280. * @param scene defines the hosting scene
  14281. */
  14282. function FluentMaterial(name, scene) {
  14283. var _this = _super.call(this, name, scene) || this;
  14284. /**
  14285. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14286. */
  14287. _this.innerGlowColorIntensity = 0.5;
  14288. /**
  14289. * Gets or sets the inner glow color (white by default)
  14290. */
  14291. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14292. /**
  14293. * Gets or sets alpha value (default is 1.0)
  14294. */
  14295. _this.alpha = 1.0;
  14296. /**
  14297. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14298. */
  14299. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14300. /**
  14301. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14302. */
  14303. _this.renderBorders = false;
  14304. /**
  14305. * Gets or sets border width (default is 0.5)
  14306. */
  14307. _this.borderWidth = 0.5;
  14308. /**
  14309. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14310. */
  14311. _this.edgeSmoothingValue = 0.02;
  14312. /**
  14313. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14314. */
  14315. _this.borderMinValue = 0.1;
  14316. /**
  14317. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14318. */
  14319. _this.renderHoverLight = false;
  14320. /**
  14321. * Gets or sets the radius used to render the hover light (default is 1.0)
  14322. */
  14323. _this.hoverRadius = 1.0;
  14324. /**
  14325. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14326. */
  14327. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14328. /**
  14329. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14330. */
  14331. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14332. return _this;
  14333. }
  14334. FluentMaterial.prototype.needAlphaBlending = function () {
  14335. return this.alpha !== 1.0;
  14336. };
  14337. FluentMaterial.prototype.needAlphaTesting = function () {
  14338. return false;
  14339. };
  14340. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14341. return null;
  14342. };
  14343. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14344. if (this.isFrozen) {
  14345. if (this._wasPreviouslyReady && subMesh.effect) {
  14346. return true;
  14347. }
  14348. }
  14349. if (!subMesh._materialDefines) {
  14350. subMesh._materialDefines = new FluentMaterialDefines();
  14351. }
  14352. var scene = this.getScene();
  14353. var defines = subMesh._materialDefines;
  14354. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14355. if (defines._renderId === scene.getRenderId()) {
  14356. return true;
  14357. }
  14358. }
  14359. if (defines._areTexturesDirty) {
  14360. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14361. defines.BORDER = this.renderBorders;
  14362. defines.HOVERLIGHT = this.renderHoverLight;
  14363. if (this._albedoTexture) {
  14364. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14365. return false;
  14366. }
  14367. else {
  14368. defines.TEXTURE = true;
  14369. }
  14370. }
  14371. else {
  14372. defines.TEXTURE = false;
  14373. }
  14374. }
  14375. var engine = scene.getEngine();
  14376. // Get correct effect
  14377. if (defines.isDirty) {
  14378. defines.markAsProcessed();
  14379. scene.resetCachedMaterial();
  14380. //Attributes
  14381. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14382. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14383. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14384. var shaderName = "fluent";
  14385. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14386. "hoverColor", "hoverPosition", "hoverRadius"
  14387. ];
  14388. var samplers = ["albedoSampler"];
  14389. var uniformBuffers = new Array();
  14390. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14391. uniformsNames: uniforms,
  14392. uniformBuffersNames: uniformBuffers,
  14393. samplers: samplers,
  14394. defines: defines,
  14395. maxSimultaneousLights: 4
  14396. });
  14397. var join = defines.toString();
  14398. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14399. attributes: attribs,
  14400. uniformsNames: uniforms,
  14401. uniformBuffersNames: uniformBuffers,
  14402. samplers: samplers,
  14403. defines: join,
  14404. fallbacks: null,
  14405. onCompiled: this.onCompiled,
  14406. onError: this.onError,
  14407. indexParameters: { maxSimultaneousLights: 4 }
  14408. }, engine));
  14409. }
  14410. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14411. return false;
  14412. }
  14413. defines._renderId = scene.getRenderId();
  14414. this._wasPreviouslyReady = true;
  14415. return true;
  14416. };
  14417. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14418. var scene = this.getScene();
  14419. var defines = subMesh._materialDefines;
  14420. if (!defines) {
  14421. return;
  14422. }
  14423. var effect = subMesh.effect;
  14424. if (!effect) {
  14425. return;
  14426. }
  14427. this._activeEffect = effect;
  14428. // Matrices
  14429. this.bindOnlyWorldMatrix(world);
  14430. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14431. if (this._mustRebind(scene, effect)) {
  14432. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14433. if (defines.INNERGLOW) {
  14434. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14435. }
  14436. if (defines.BORDER) {
  14437. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14438. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14439. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14440. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14441. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14442. }
  14443. if (defines.HOVERLIGHT) {
  14444. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14445. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14446. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14447. }
  14448. if (defines.TEXTURE) {
  14449. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14450. }
  14451. }
  14452. this._afterBind(mesh, this._activeEffect);
  14453. };
  14454. FluentMaterial.prototype.getActiveTextures = function () {
  14455. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14456. return activeTextures;
  14457. };
  14458. FluentMaterial.prototype.hasTexture = function (texture) {
  14459. if (_super.prototype.hasTexture.call(this, texture)) {
  14460. return true;
  14461. }
  14462. return false;
  14463. };
  14464. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14465. _super.prototype.dispose.call(this, forceDisposeEffect);
  14466. };
  14467. FluentMaterial.prototype.clone = function (name) {
  14468. var _this = this;
  14469. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14470. };
  14471. FluentMaterial.prototype.serialize = function () {
  14472. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14473. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14474. return serializationObject;
  14475. };
  14476. FluentMaterial.prototype.getClassName = function () {
  14477. return "FluentMaterial";
  14478. };
  14479. // Statics
  14480. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14481. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14482. };
  14483. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14484. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14485. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14486. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14487. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14488. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14489. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14490. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14491. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14492. ], FluentMaterial.prototype, "alpha", void 0);
  14493. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14494. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14495. ], FluentMaterial.prototype, "albedoColor", void 0);
  14496. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14497. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14498. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14499. ], FluentMaterial.prototype, "renderBorders", void 0);
  14500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14501. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14502. ], FluentMaterial.prototype, "borderWidth", void 0);
  14503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14504. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14505. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14507. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14508. ], FluentMaterial.prototype, "borderMinValue", void 0);
  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, "renderHoverLight", void 0);
  14513. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14514. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14515. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14516. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14517. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14518. ], FluentMaterial.prototype, "hoverColor", void 0);
  14519. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14520. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14521. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14523. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14524. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14526. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14527. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14528. return FluentMaterial;
  14529. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14530. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14531. /***/ }),
  14532. /***/ "./3D/materials/index.ts":
  14533. /*!*******************************!*\
  14534. !*** ./3D/materials/index.ts ***!
  14535. \*******************************/
  14536. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14538. "use strict";
  14539. __webpack_require__.r(__webpack_exports__);
  14540. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14543. /***/ }),
  14544. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14545. /*!*************************************************!*\
  14546. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14547. \*************************************************/
  14548. /*! exports provided: fluentPixelShader */
  14549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14550. "use strict";
  14551. __webpack_require__.r(__webpack_exports__);
  14552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14553. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/tools");
  14554. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14555. var name = 'fluentPixelShader';
  14556. 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}";
  14557. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14558. /** @hidden */
  14559. var fluentPixelShader = { name: name, shader: shader };
  14560. /***/ }),
  14561. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14562. /*!***********************************************!*\
  14563. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14564. \***********************************************/
  14565. /*! exports provided: fluentVertexShader */
  14566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14567. "use strict";
  14568. __webpack_require__.r(__webpack_exports__);
  14569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14570. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/tools");
  14571. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14572. var name = 'fluentVertexShader';
  14573. 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";
  14574. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14575. /** @hidden */
  14576. var fluentVertexShader = { name: name, shader: shader };
  14577. /***/ }),
  14578. /***/ "./3D/vector3WithInfo.ts":
  14579. /*!*******************************!*\
  14580. !*** ./3D/vector3WithInfo.ts ***!
  14581. \*******************************/
  14582. /*! exports provided: Vector3WithInfo */
  14583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14584. "use strict";
  14585. __webpack_require__.r(__webpack_exports__);
  14586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14587. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14588. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  14589. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14590. /**
  14591. * Class used to transport Vector3 information for pointer events
  14592. */
  14593. var Vector3WithInfo = /** @class */ (function (_super) {
  14594. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14595. /**
  14596. * Creates a new Vector3WithInfo
  14597. * @param source defines the vector3 data to transport
  14598. * @param buttonIndex defines the current mouse button index
  14599. */
  14600. function Vector3WithInfo(source,
  14601. /** defines the current mouse button index */
  14602. buttonIndex) {
  14603. if (buttonIndex === void 0) { buttonIndex = 0; }
  14604. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14605. _this.buttonIndex = buttonIndex;
  14606. return _this;
  14607. }
  14608. return Vector3WithInfo;
  14609. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14610. /***/ }),
  14611. /***/ "./index.ts":
  14612. /*!******************!*\
  14613. !*** ./index.ts ***!
  14614. \******************/
  14615. /*! 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 */
  14616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14617. "use strict";
  14618. __webpack_require__.r(__webpack_exports__);
  14619. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14659. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14676. /***/ }),
  14677. /***/ "./legacy/legacy.ts":
  14678. /*!**************************!*\
  14679. !*** ./legacy/legacy.ts ***!
  14680. \**************************/
  14681. /*! 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 */
  14682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14683. "use strict";
  14684. __webpack_require__.r(__webpack_exports__);
  14685. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14741. /**
  14742. * Legacy support, defining window.BABYLON.GUI (global variable).
  14743. *
  14744. * This is the entry point for the UMD module.
  14745. * The entry point for a future ESM package should be index.ts
  14746. */
  14747. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14748. if (typeof globalObject !== "undefined") {
  14749. globalObject.BABYLON = globalObject.BABYLON || {};
  14750. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14751. }
  14752. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14753. /***/ }),
  14754. /***/ "babylonjs/Misc/tools":
  14755. /*!****************************************************************************************************!*\
  14756. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14757. \****************************************************************************************************/
  14758. /*! no static exports found */
  14759. /***/ (function(module, exports) {
  14760. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_tools__;
  14761. /***/ })
  14762. /******/ });
  14763. });
  14764. //# sourceMappingURL=babylon.gui.js.map