babylon.gui.js 682 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/perfCounter");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /**
  516. * Define type to string to ensure compatibility across browsers
  517. * Safari doesn't support DataTransfer constructor
  518. */
  519. _this._clipboardData = "";
  520. /**
  521. * Observable event triggered each time an clipboard event is received from the rendering canvas
  522. */
  523. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  524. /**
  525. * Observable event triggered each time a pointer down is intercepted by a control
  526. */
  527. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered before layout is evaluated
  530. */
  531. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered after the layout was evaluated
  534. */
  535. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered before the texture is rendered
  538. */
  539. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered after the texture was rendered
  542. */
  543. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Gets or sets a boolean defining if alpha is stored as premultiplied
  546. */
  547. _this.premulAlpha = false;
  548. _this._useInvalidateRectOptimization = true;
  549. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  550. _this._invalidatedRectangle = null;
  551. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  552. /** @hidden */
  553. _this.onClipboardCopy = function (rawEvt) {
  554. var evt = rawEvt;
  555. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  556. _this.onClipboardObservable.notifyObservers(ev);
  557. evt.preventDefault();
  558. };
  559. /** @hidden */
  560. _this.onClipboardCut = function (rawEvt) {
  561. var evt = rawEvt;
  562. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  563. _this.onClipboardObservable.notifyObservers(ev);
  564. evt.preventDefault();
  565. };
  566. /** @hidden */
  567. _this.onClipboardPaste = function (rawEvt) {
  568. var evt = rawEvt;
  569. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  570. _this.onClipboardObservable.notifyObservers(ev);
  571. evt.preventDefault();
  572. };
  573. scene = _this.getScene();
  574. if (!scene || !_this._texture) {
  575. return _this;
  576. }
  577. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  578. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  579. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  580. if (!_this._focusedControl) {
  581. return;
  582. }
  583. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  584. _this._focusedControl.processKeyboard(info.event);
  585. }
  586. info.skipOnPointerObservable = true;
  587. });
  588. _this._rootContainer._link(_this);
  589. _this.hasAlpha = true;
  590. if (!width || !height) {
  591. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  592. _this._onResize();
  593. }
  594. _this._texture.isReady = true;
  595. return _this;
  596. }
  597. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  598. /**
  599. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  600. * Useful when you want more antialiasing
  601. */
  602. get: function () {
  603. return this._renderScale;
  604. },
  605. set: function (value) {
  606. if (value === this._renderScale) {
  607. return;
  608. }
  609. this._renderScale = value;
  610. this._onResize();
  611. },
  612. enumerable: true,
  613. configurable: true
  614. });
  615. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  616. /** Gets or sets the background color */
  617. get: function () {
  618. return this._background;
  619. },
  620. set: function (value) {
  621. if (this._background === value) {
  622. return;
  623. }
  624. this._background = value;
  625. this.markAsDirty();
  626. },
  627. enumerable: true,
  628. configurable: true
  629. });
  630. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  631. /**
  632. * Gets or sets the ideal width used to design controls.
  633. * The GUI will then rescale everything accordingly
  634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  635. */
  636. get: function () {
  637. return this._idealWidth;
  638. },
  639. set: function (value) {
  640. if (this._idealWidth === value) {
  641. return;
  642. }
  643. this._idealWidth = value;
  644. this.markAsDirty();
  645. this._rootContainer._markAllAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  651. /**
  652. * Gets or sets the ideal height used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealHeight;
  658. },
  659. set: function (value) {
  660. if (this._idealHeight === value) {
  661. return;
  662. }
  663. this._idealHeight = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  671. /**
  672. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  673. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  674. */
  675. get: function () {
  676. return this._useSmallestIdeal;
  677. },
  678. set: function (value) {
  679. if (this._useSmallestIdeal === value) {
  680. return;
  681. }
  682. this._useSmallestIdeal = value;
  683. this.markAsDirty();
  684. this._rootContainer._markAllAsDirty();
  685. },
  686. enumerable: true,
  687. configurable: true
  688. });
  689. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  690. /**
  691. * Gets or sets a boolean indicating if adaptive scaling must be used
  692. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  693. */
  694. get: function () {
  695. return this._renderAtIdealSize;
  696. },
  697. set: function (value) {
  698. if (this._renderAtIdealSize === value) {
  699. return;
  700. }
  701. this._renderAtIdealSize = value;
  702. this._onResize();
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  708. /**
  709. * Gets the underlying layer used to render the texture when in fullscreen mode
  710. */
  711. get: function () {
  712. return this._layerToDispose;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  718. /**
  719. * Gets the root container control
  720. */
  721. get: function () {
  722. return this._rootContainer;
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. /**
  728. * Returns an array containing the root container.
  729. * This is mostly used to let the Inspector introspects the ADT
  730. * @returns an array containing the rootContainer
  731. */
  732. AdvancedDynamicTexture.prototype.getChildren = function () {
  733. return [this._rootContainer];
  734. };
  735. /**
  736. * Will return all controls that are inside this texture
  737. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  738. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  739. * @return all child controls
  740. */
  741. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  742. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  743. };
  744. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  745. /**
  746. * Gets or sets the current focused control
  747. */
  748. get: function () {
  749. return this._focusedControl;
  750. },
  751. set: function (control) {
  752. if (this._focusedControl == control) {
  753. return;
  754. }
  755. if (this._focusedControl) {
  756. this._focusedControl.onBlur();
  757. }
  758. if (control) {
  759. control.onFocus();
  760. }
  761. this._focusedControl = control;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  767. /**
  768. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  769. */
  770. get: function () {
  771. if (!this.layer) {
  772. return true;
  773. }
  774. return (!this.layer.isBackground);
  775. },
  776. set: function (value) {
  777. if (!this.layer) {
  778. return;
  779. }
  780. if (this.layer.isBackground === !value) {
  781. return;
  782. }
  783. this.layer.isBackground = !value;
  784. },
  785. enumerable: true,
  786. configurable: true
  787. });
  788. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  789. /**
  790. * Gets or set information about clipboardData
  791. */
  792. get: function () {
  793. return this._clipboardData;
  794. },
  795. set: function (value) {
  796. this._clipboardData = value;
  797. },
  798. enumerable: true,
  799. configurable: true
  800. });
  801. /**
  802. * Get the current class name of the texture useful for serialization or dynamic coding.
  803. * @returns "AdvancedDynamicTexture"
  804. */
  805. AdvancedDynamicTexture.prototype.getClassName = function () {
  806. return "AdvancedDynamicTexture";
  807. };
  808. /**
  809. * Function used to execute a function on all controls
  810. * @param func defines the function to execute
  811. * @param container defines the container where controls belong. If null the root container will be used
  812. */
  813. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  814. if (!container) {
  815. container = this._rootContainer;
  816. }
  817. func(container);
  818. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  819. var child = _a[_i];
  820. if (child.children) {
  821. this.executeOnAllControls(func, child);
  822. continue;
  823. }
  824. func(child);
  825. }
  826. };
  827. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  828. /**
  829. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  830. */
  831. get: function () {
  832. return this._useInvalidateRectOptimization;
  833. },
  834. set: function (value) {
  835. this._useInvalidateRectOptimization = value;
  836. },
  837. enumerable: true,
  838. configurable: true
  839. });
  840. /**
  841. * Invalidates a rectangle area on the gui texture
  842. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  843. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  844. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  845. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  846. */
  847. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  848. if (!this._useInvalidateRectOptimization) {
  849. return;
  850. }
  851. if (!this._invalidatedRectangle) {
  852. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  853. }
  854. else {
  855. // Compute intersection
  856. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  857. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  858. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  859. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  860. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  861. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  862. }
  863. };
  864. /**
  865. * Marks the texture as dirty forcing a complete update
  866. */
  867. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  868. this._isDirty = true;
  869. };
  870. /**
  871. * Helper function used to create a new style
  872. * @returns a new style
  873. * @see http://doc.babylonjs.com/how_to/gui#styles
  874. */
  875. AdvancedDynamicTexture.prototype.createStyle = function () {
  876. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  877. };
  878. /**
  879. * Adds a new control to the root container
  880. * @param control defines the control to add
  881. * @returns the current texture
  882. */
  883. AdvancedDynamicTexture.prototype.addControl = function (control) {
  884. this._rootContainer.addControl(control);
  885. return this;
  886. };
  887. /**
  888. * Removes a control from the root container
  889. * @param control defines the control to remove
  890. * @returns the current texture
  891. */
  892. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  893. this._rootContainer.removeControl(control);
  894. return this;
  895. };
  896. /**
  897. * Release all resources
  898. */
  899. AdvancedDynamicTexture.prototype.dispose = function () {
  900. var scene = this.getScene();
  901. if (!scene) {
  902. return;
  903. }
  904. this._rootCanvas = null;
  905. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  906. if (this._resizeObserver) {
  907. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  908. }
  909. if (this._pointerMoveObserver) {
  910. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  911. }
  912. if (this._pointerObserver) {
  913. scene.onPointerObservable.remove(this._pointerObserver);
  914. }
  915. if (this._preKeyboardObserver) {
  916. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  917. }
  918. if (this._canvasPointerOutObserver) {
  919. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  920. }
  921. if (this._layerToDispose) {
  922. this._layerToDispose.texture = null;
  923. this._layerToDispose.dispose();
  924. this._layerToDispose = null;
  925. }
  926. this._rootContainer.dispose();
  927. this.onClipboardObservable.clear();
  928. this.onControlPickedObservable.clear();
  929. this.onBeginRenderObservable.clear();
  930. this.onEndRenderObservable.clear();
  931. this.onBeginLayoutObservable.clear();
  932. this.onEndLayoutObservable.clear();
  933. _super.prototype.dispose.call(this);
  934. };
  935. AdvancedDynamicTexture.prototype._onResize = function () {
  936. var scene = this.getScene();
  937. if (!scene) {
  938. return;
  939. }
  940. // Check size
  941. var engine = scene.getEngine();
  942. var textureSize = this.getSize();
  943. var renderWidth = engine.getRenderWidth() * this._renderScale;
  944. var renderHeight = engine.getRenderHeight() * this._renderScale;
  945. if (this._renderAtIdealSize) {
  946. if (this._idealWidth) {
  947. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  948. renderWidth = this._idealWidth;
  949. }
  950. else if (this._idealHeight) {
  951. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  952. renderHeight = this._idealHeight;
  953. }
  954. }
  955. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  956. this.scaleTo(renderWidth, renderHeight);
  957. this.markAsDirty();
  958. if (this._idealWidth || this._idealHeight) {
  959. this._rootContainer._markAllAsDirty();
  960. }
  961. }
  962. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  963. };
  964. /** @hidden */
  965. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  966. var engine = scene.getEngine();
  967. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  968. };
  969. /**
  970. * Get screen coordinates for a vector3
  971. * @param position defines the position to project
  972. * @param worldMatrix defines the world matrix to use
  973. * @returns the projected position
  974. */
  975. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  976. var scene = this.getScene();
  977. if (!scene) {
  978. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  979. }
  980. var globalViewport = this._getGlobalViewport(scene);
  981. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  982. projectedPosition.scaleInPlace(this.renderScale);
  983. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  984. };
  985. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  986. if (this._layerToDispose) {
  987. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  988. return;
  989. }
  990. }
  991. if (this._isFullscreen && this._linkedControls.length) {
  992. var scene = this.getScene();
  993. if (!scene) {
  994. return;
  995. }
  996. var globalViewport = this._getGlobalViewport(scene);
  997. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  998. var control = _a[_i];
  999. if (!control.isVisible) {
  1000. continue;
  1001. }
  1002. var mesh = control._linkedMesh;
  1003. if (!mesh || mesh.isDisposed()) {
  1004. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1005. control.linkWithMesh(null);
  1006. });
  1007. continue;
  1008. }
  1009. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1010. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1011. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1012. control.notRenderable = true;
  1013. continue;
  1014. }
  1015. control.notRenderable = false;
  1016. // Account for RenderScale.
  1017. projectedPosition.scaleInPlace(this.renderScale);
  1018. control._moveToProjectedPosition(projectedPosition);
  1019. }
  1020. }
  1021. if (!this._isDirty && !this._rootContainer.isDirty) {
  1022. return;
  1023. }
  1024. this._isDirty = false;
  1025. this._render();
  1026. this.update(true, this.premulAlpha);
  1027. };
  1028. AdvancedDynamicTexture.prototype._render = function () {
  1029. var textureSize = this.getSize();
  1030. var renderWidth = textureSize.width;
  1031. var renderHeight = textureSize.height;
  1032. var context = this.getContext();
  1033. context.font = "18px Arial";
  1034. context.strokeStyle = "white";
  1035. // Layout
  1036. this.onBeginLayoutObservable.notifyObservers(this);
  1037. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1038. this._rootContainer._layout(measure, context);
  1039. this.onEndLayoutObservable.notifyObservers(this);
  1040. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1041. // Clear
  1042. if (this._invalidatedRectangle) {
  1043. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1044. }
  1045. else {
  1046. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1047. }
  1048. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1049. if (this._background) {
  1050. context.save();
  1051. context.fillStyle = this._background;
  1052. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1053. context.restore();
  1054. }
  1055. // Render
  1056. this.onBeginRenderObservable.notifyObservers(this);
  1057. this._rootContainer._render(context, this._invalidatedRectangle);
  1058. this.onEndRenderObservable.notifyObservers(this);
  1059. this._invalidatedRectangle = null;
  1060. };
  1061. /** @hidden */
  1062. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1063. if (this._rootCanvas) {
  1064. this._rootCanvas.style.cursor = cursor;
  1065. this._cursorChanged = true;
  1066. }
  1067. };
  1068. /** @hidden */
  1069. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1070. this._lastControlDown[pointerId] = control;
  1071. this.onControlPickedObservable.notifyObservers(control);
  1072. };
  1073. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1074. var scene = this.getScene();
  1075. if (!scene) {
  1076. return;
  1077. }
  1078. var engine = scene.getEngine();
  1079. var textureSize = this.getSize();
  1080. if (this._isFullscreen) {
  1081. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1082. var viewport = camera.viewport;
  1083. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1084. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1085. }
  1086. if (this._capturingControl[pointerId]) {
  1087. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1088. return;
  1089. }
  1090. this._cursorChanged = false;
  1091. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1092. this._changeCursor("");
  1093. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1094. if (this._lastControlOver[pointerId]) {
  1095. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1096. delete this._lastControlOver[pointerId];
  1097. }
  1098. }
  1099. }
  1100. if (!this._cursorChanged) {
  1101. this._changeCursor("");
  1102. }
  1103. this._manageFocus();
  1104. };
  1105. /** @hidden */
  1106. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1107. for (var pointerId in list) {
  1108. if (!list.hasOwnProperty(pointerId)) {
  1109. continue;
  1110. }
  1111. var lastControlOver = list[pointerId];
  1112. if (lastControlOver === control) {
  1113. delete list[pointerId];
  1114. }
  1115. }
  1116. };
  1117. /** @hidden */
  1118. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1119. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1120. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1121. };
  1122. /** Attach to all scene events required to support pointer events */
  1123. AdvancedDynamicTexture.prototype.attach = function () {
  1124. var _this = this;
  1125. var scene = this.getScene();
  1126. if (!scene) {
  1127. return;
  1128. }
  1129. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1130. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1131. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1132. return;
  1133. }
  1134. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1135. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1136. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1137. return;
  1138. }
  1139. if (!scene) {
  1140. return;
  1141. }
  1142. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1143. var engine = scene.getEngine();
  1144. if (!camera) {
  1145. tempViewport.x = 0;
  1146. tempViewport.y = 0;
  1147. tempViewport.width = engine.getRenderWidth();
  1148. tempViewport.height = engine.getRenderHeight();
  1149. }
  1150. else {
  1151. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1152. }
  1153. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1154. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1155. _this._shouldBlockPointer = false;
  1156. // Do picking modifies _shouldBlockPointer
  1157. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1158. // Avoid overwriting a true skipOnPointerObservable to false
  1159. if (_this._shouldBlockPointer) {
  1160. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1161. }
  1162. });
  1163. this._attachToOnPointerOut(scene);
  1164. };
  1165. /**
  1166. * Register the clipboard Events onto the canvas
  1167. */
  1168. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1169. self.addEventListener("copy", this.onClipboardCopy, false);
  1170. self.addEventListener("cut", this.onClipboardCut, false);
  1171. self.addEventListener("paste", this.onClipboardPaste, false);
  1172. };
  1173. /**
  1174. * Unregister the clipboard Events from the canvas
  1175. */
  1176. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1177. self.removeEventListener("copy", this.onClipboardCopy);
  1178. self.removeEventListener("cut", this.onClipboardCut);
  1179. self.removeEventListener("paste", this.onClipboardPaste);
  1180. };
  1181. /**
  1182. * Connect the texture to a hosting mesh to enable interactions
  1183. * @param mesh defines the mesh to attach to
  1184. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1185. */
  1186. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1187. var _this = this;
  1188. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1189. var scene = this.getScene();
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1194. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1195. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1196. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1197. return;
  1198. }
  1199. var pointerId = pi.event.pointerId || 0;
  1200. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1201. var uv = pi.pickInfo.getTextureCoordinates();
  1202. if (uv) {
  1203. var size = _this.getSize();
  1204. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1205. }
  1206. }
  1207. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1208. if (_this._lastControlDown[pointerId]) {
  1209. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1210. }
  1211. delete _this._lastControlDown[pointerId];
  1212. if (_this.focusedControl) {
  1213. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1214. var canMoveFocus = true;
  1215. if (friendlyControls) {
  1216. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1217. var control = friendlyControls_1[_i];
  1218. // Same host, no need to keep the focus
  1219. if (_this === control._host) {
  1220. continue;
  1221. }
  1222. // Different hosts
  1223. var otherHost = control._host;
  1224. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1225. canMoveFocus = false;
  1226. break;
  1227. }
  1228. }
  1229. }
  1230. if (canMoveFocus) {
  1231. _this.focusedControl = null;
  1232. }
  1233. }
  1234. }
  1235. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1236. if (_this._lastControlOver[pointerId]) {
  1237. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1238. }
  1239. delete _this._lastControlOver[pointerId];
  1240. }
  1241. });
  1242. mesh.enablePointerMoveEvents = supportPointerMove;
  1243. this._attachToOnPointerOut(scene);
  1244. };
  1245. /**
  1246. * Move the focus to a specific control
  1247. * @param control defines the control which will receive the focus
  1248. */
  1249. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1250. this.focusedControl = control;
  1251. this._lastPickedControl = control;
  1252. this._blockNextFocusCheck = true;
  1253. };
  1254. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1255. if (this._blockNextFocusCheck) {
  1256. this._blockNextFocusCheck = false;
  1257. this._lastPickedControl = this._focusedControl;
  1258. return;
  1259. }
  1260. // Focus management
  1261. if (this._focusedControl) {
  1262. if (this._focusedControl !== this._lastPickedControl) {
  1263. if (this._lastPickedControl.isFocusInvisible) {
  1264. return;
  1265. }
  1266. this.focusedControl = null;
  1267. }
  1268. }
  1269. };
  1270. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1271. var _this = this;
  1272. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1273. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1274. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1275. }
  1276. delete _this._lastControlOver[pointerEvent.pointerId];
  1277. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1278. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1279. delete _this._lastControlDown[pointerEvent.pointerId];
  1280. }
  1281. });
  1282. };
  1283. // Statics
  1284. /**
  1285. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1286. * @param mesh defines the mesh which will receive the texture
  1287. * @param width defines the texture width (1024 by default)
  1288. * @param height defines the texture height (1024 by default)
  1289. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1290. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1291. * @returns a new AdvancedDynamicTexture
  1292. */
  1293. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1294. if (width === void 0) { width = 1024; }
  1295. if (height === void 0) { height = 1024; }
  1296. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1297. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1298. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1299. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1300. material.backFaceCulling = false;
  1301. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1302. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1303. if (onlyAlphaTesting) {
  1304. material.diffuseTexture = result;
  1305. material.emissiveTexture = result;
  1306. result.hasAlpha = true;
  1307. }
  1308. else {
  1309. material.emissiveTexture = result;
  1310. material.opacityTexture = result;
  1311. }
  1312. mesh.material = material;
  1313. result.attachToMesh(mesh, supportPointerMove);
  1314. return result;
  1315. };
  1316. /**
  1317. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1318. * In this mode the texture will rely on a layer for its rendering.
  1319. * This allows it to be treated like any other layer.
  1320. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1321. * LayerMask is set through advancedTexture.layer.layerMask
  1322. * @param name defines name for the texture
  1323. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1324. * @param scene defines the hsoting scene
  1325. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1326. * @returns a new AdvancedDynamicTexture
  1327. */
  1328. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1329. if (foreground === void 0) { foreground = true; }
  1330. if (scene === void 0) { scene = null; }
  1331. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1332. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1333. // Display
  1334. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1335. layer.texture = result;
  1336. result._layerToDispose = layer;
  1337. result._isFullscreen = true;
  1338. // Attach
  1339. result.attach();
  1340. return result;
  1341. };
  1342. return AdvancedDynamicTexture;
  1343. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1344. /***/ }),
  1345. /***/ "./2D/controls/button.ts":
  1346. /*!*******************************!*\
  1347. !*** ./2D/controls/button.ts ***!
  1348. \*******************************/
  1349. /*! exports provided: Button */
  1350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1351. "use strict";
  1352. __webpack_require__.r(__webpack_exports__);
  1353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1355. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1356. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1357. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1358. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1359. /**
  1360. * Class used to create 2D buttons
  1361. */
  1362. var Button = /** @class */ (function (_super) {
  1363. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1364. /**
  1365. * Creates a new Button
  1366. * @param name defines the name of the button
  1367. */
  1368. function Button(name) {
  1369. var _this = _super.call(this, name) || this;
  1370. _this.name = name;
  1371. /**
  1372. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1373. */
  1374. _this.delegatePickingToChildren = false;
  1375. _this.thickness = 1;
  1376. _this.isPointerBlocker = true;
  1377. var alphaStore = null;
  1378. _this.pointerEnterAnimation = function () {
  1379. alphaStore = _this.alpha;
  1380. _this.alpha -= 0.1;
  1381. };
  1382. _this.pointerOutAnimation = function () {
  1383. if (alphaStore !== null) {
  1384. _this.alpha = alphaStore;
  1385. }
  1386. };
  1387. _this.pointerDownAnimation = function () {
  1388. _this.scaleX -= 0.05;
  1389. _this.scaleY -= 0.05;
  1390. };
  1391. _this.pointerUpAnimation = function () {
  1392. _this.scaleX += 0.05;
  1393. _this.scaleY += 0.05;
  1394. };
  1395. return _this;
  1396. }
  1397. Object.defineProperty(Button.prototype, "image", {
  1398. /**
  1399. * Returns the image part of the button (if any)
  1400. */
  1401. get: function () {
  1402. return this._image;
  1403. },
  1404. enumerable: true,
  1405. configurable: true
  1406. });
  1407. Object.defineProperty(Button.prototype, "textBlock", {
  1408. /**
  1409. * Returns the image part of the button (if any)
  1410. */
  1411. get: function () {
  1412. return this._textBlock;
  1413. },
  1414. enumerable: true,
  1415. configurable: true
  1416. });
  1417. Button.prototype._getTypeName = function () {
  1418. return "Button";
  1419. };
  1420. // While being a container, the button behaves like a control.
  1421. /** @hidden */
  1422. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1423. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1424. return false;
  1425. }
  1426. if (!_super.prototype.contains.call(this, x, y)) {
  1427. return false;
  1428. }
  1429. if (this.delegatePickingToChildren) {
  1430. var contains = false;
  1431. for (var index = this._children.length - 1; index >= 0; index--) {
  1432. var child = this._children[index];
  1433. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1434. contains = true;
  1435. break;
  1436. }
  1437. }
  1438. if (!contains) {
  1439. return false;
  1440. }
  1441. }
  1442. this._processObservables(type, x, y, pointerId, buttonIndex);
  1443. return true;
  1444. };
  1445. /** @hidden */
  1446. Button.prototype._onPointerEnter = function (target) {
  1447. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1448. return false;
  1449. }
  1450. if (this.pointerEnterAnimation) {
  1451. this.pointerEnterAnimation();
  1452. }
  1453. return true;
  1454. };
  1455. /** @hidden */
  1456. Button.prototype._onPointerOut = function (target, force) {
  1457. if (force === void 0) { force = false; }
  1458. if (this.pointerOutAnimation) {
  1459. this.pointerOutAnimation();
  1460. }
  1461. _super.prototype._onPointerOut.call(this, target, force);
  1462. };
  1463. /** @hidden */
  1464. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1465. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1466. return false;
  1467. }
  1468. if (this.pointerDownAnimation) {
  1469. this.pointerDownAnimation();
  1470. }
  1471. return true;
  1472. };
  1473. /** @hidden */
  1474. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1475. if (this.pointerUpAnimation) {
  1476. this.pointerUpAnimation();
  1477. }
  1478. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1479. };
  1480. // Statics
  1481. /**
  1482. * Creates a new button made with an image and a text
  1483. * @param name defines the name of the button
  1484. * @param text defines the text of the button
  1485. * @param imageUrl defines the url of the image
  1486. * @returns a new Button
  1487. */
  1488. Button.CreateImageButton = function (name, text, imageUrl) {
  1489. var result = new Button(name);
  1490. // Adding text
  1491. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1492. textBlock.textWrapping = true;
  1493. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1494. textBlock.paddingLeft = "20%";
  1495. result.addControl(textBlock);
  1496. // Adding image
  1497. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1498. iconImage.width = "20%";
  1499. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1500. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1501. result.addControl(iconImage);
  1502. // Store
  1503. result._image = iconImage;
  1504. result._textBlock = textBlock;
  1505. return result;
  1506. };
  1507. /**
  1508. * Creates a new button made with an image
  1509. * @param name defines the name of the button
  1510. * @param imageUrl defines the url of the image
  1511. * @returns a new Button
  1512. */
  1513. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1514. var result = new Button(name);
  1515. // Adding image
  1516. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1517. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1518. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1519. result.addControl(iconImage);
  1520. // Store
  1521. result._image = iconImage;
  1522. return result;
  1523. };
  1524. /**
  1525. * Creates a new button made with a text
  1526. * @param name defines the name of the button
  1527. * @param text defines the text of the button
  1528. * @returns a new Button
  1529. */
  1530. Button.CreateSimpleButton = function (name, text) {
  1531. var result = new Button(name);
  1532. // Adding text
  1533. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1534. textBlock.textWrapping = true;
  1535. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1536. result.addControl(textBlock);
  1537. // Store
  1538. result._textBlock = textBlock;
  1539. return result;
  1540. };
  1541. /**
  1542. * Creates a new button made with an image and a centered text
  1543. * @param name defines the name of the button
  1544. * @param text defines the text of the button
  1545. * @param imageUrl defines the url of the image
  1546. * @returns a new Button
  1547. */
  1548. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1549. var result = new Button(name);
  1550. // Adding image
  1551. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1552. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1553. result.addControl(iconImage);
  1554. // Adding text
  1555. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1556. textBlock.textWrapping = true;
  1557. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1558. result.addControl(textBlock);
  1559. // Store
  1560. result._image = iconImage;
  1561. result._textBlock = textBlock;
  1562. return result;
  1563. };
  1564. return Button;
  1565. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1566. /***/ }),
  1567. /***/ "./2D/controls/checkbox.ts":
  1568. /*!*********************************!*\
  1569. !*** ./2D/controls/checkbox.ts ***!
  1570. \*********************************/
  1571. /*! exports provided: Checkbox */
  1572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1573. "use strict";
  1574. __webpack_require__.r(__webpack_exports__);
  1575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1576. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1577. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1578. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1579. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1580. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1581. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1582. /**
  1583. * Class used to represent a 2D checkbox
  1584. */
  1585. var Checkbox = /** @class */ (function (_super) {
  1586. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1587. /**
  1588. * Creates a new CheckBox
  1589. * @param name defines the control name
  1590. */
  1591. function Checkbox(name) {
  1592. var _this = _super.call(this, name) || this;
  1593. _this.name = name;
  1594. _this._isChecked = false;
  1595. _this._background = "black";
  1596. _this._checkSizeRatio = 0.8;
  1597. _this._thickness = 1;
  1598. /**
  1599. * Observable raised when isChecked property changes
  1600. */
  1601. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1602. _this.isPointerBlocker = true;
  1603. return _this;
  1604. }
  1605. Object.defineProperty(Checkbox.prototype, "thickness", {
  1606. /** Gets or sets border thickness */
  1607. get: function () {
  1608. return this._thickness;
  1609. },
  1610. set: function (value) {
  1611. if (this._thickness === value) {
  1612. return;
  1613. }
  1614. this._thickness = value;
  1615. this._markAsDirty();
  1616. },
  1617. enumerable: true,
  1618. configurable: true
  1619. });
  1620. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1621. /** Gets or sets a value indicating the ratio between overall size and check size */
  1622. get: function () {
  1623. return this._checkSizeRatio;
  1624. },
  1625. set: function (value) {
  1626. value = Math.max(Math.min(1, value), 0);
  1627. if (this._checkSizeRatio === value) {
  1628. return;
  1629. }
  1630. this._checkSizeRatio = value;
  1631. this._markAsDirty();
  1632. },
  1633. enumerable: true,
  1634. configurable: true
  1635. });
  1636. Object.defineProperty(Checkbox.prototype, "background", {
  1637. /** Gets or sets background color */
  1638. get: function () {
  1639. return this._background;
  1640. },
  1641. set: function (value) {
  1642. if (this._background === value) {
  1643. return;
  1644. }
  1645. this._background = value;
  1646. this._markAsDirty();
  1647. },
  1648. enumerable: true,
  1649. configurable: true
  1650. });
  1651. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1652. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1653. get: function () {
  1654. return this._isChecked;
  1655. },
  1656. set: function (value) {
  1657. if (this._isChecked === value) {
  1658. return;
  1659. }
  1660. this._isChecked = value;
  1661. this._markAsDirty();
  1662. this.onIsCheckedChangedObservable.notifyObservers(value);
  1663. },
  1664. enumerable: true,
  1665. configurable: true
  1666. });
  1667. Checkbox.prototype._getTypeName = function () {
  1668. return "Checkbox";
  1669. };
  1670. /** @hidden */
  1671. Checkbox.prototype._draw = function (context) {
  1672. context.save();
  1673. this._applyStates(context);
  1674. var actualWidth = this._currentMeasure.width - this._thickness;
  1675. var actualHeight = this._currentMeasure.height - this._thickness;
  1676. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1677. context.shadowColor = this.shadowColor;
  1678. context.shadowBlur = this.shadowBlur;
  1679. context.shadowOffsetX = this.shadowOffsetX;
  1680. context.shadowOffsetY = this.shadowOffsetY;
  1681. }
  1682. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1683. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1684. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1685. context.shadowBlur = 0;
  1686. context.shadowOffsetX = 0;
  1687. context.shadowOffsetY = 0;
  1688. }
  1689. if (this._isChecked) {
  1690. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1691. var offsetWidth = actualWidth * this._checkSizeRatio;
  1692. var offseHeight = actualHeight * this._checkSizeRatio;
  1693. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1694. }
  1695. context.strokeStyle = this.color;
  1696. context.lineWidth = this._thickness;
  1697. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1698. context.restore();
  1699. };
  1700. // Events
  1701. /** @hidden */
  1702. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1703. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1704. return false;
  1705. }
  1706. this.isChecked = !this.isChecked;
  1707. return true;
  1708. };
  1709. /**
  1710. * Utility function to easily create a checkbox with a header
  1711. * @param title defines the label to use for the header
  1712. * @param onValueChanged defines the callback to call when value changes
  1713. * @returns a StackPanel containing the checkbox and a textBlock
  1714. */
  1715. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1716. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1717. panel.isVertical = false;
  1718. panel.height = "30px";
  1719. var checkbox = new Checkbox();
  1720. checkbox.width = "20px";
  1721. checkbox.height = "20px";
  1722. checkbox.isChecked = true;
  1723. checkbox.color = "green";
  1724. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1725. panel.addControl(checkbox);
  1726. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1727. header.text = title;
  1728. header.width = "180px";
  1729. header.paddingLeft = "5px";
  1730. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1731. header.color = "white";
  1732. panel.addControl(header);
  1733. return panel;
  1734. };
  1735. return Checkbox;
  1736. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1737. /***/ }),
  1738. /***/ "./2D/controls/colorpicker.ts":
  1739. /*!************************************!*\
  1740. !*** ./2D/controls/colorpicker.ts ***!
  1741. \************************************/
  1742. /*! exports provided: ColorPicker */
  1743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1744. "use strict";
  1745. __webpack_require__.r(__webpack_exports__);
  1746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1747. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1748. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1749. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1750. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1751. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1752. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1753. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1754. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1755. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1756. /** Class used to create color pickers */
  1757. var ColorPicker = /** @class */ (function (_super) {
  1758. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1759. /**
  1760. * Creates a new ColorPicker
  1761. * @param name defines the control name
  1762. */
  1763. function ColorPicker(name) {
  1764. var _this = _super.call(this, name) || this;
  1765. _this.name = name;
  1766. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1767. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1768. _this._pointerStartedOnSquare = false;
  1769. _this._pointerStartedOnWheel = false;
  1770. _this._squareLeft = 0;
  1771. _this._squareTop = 0;
  1772. _this._squareSize = 0;
  1773. _this._h = 360;
  1774. _this._s = 1;
  1775. _this._v = 1;
  1776. _this._lastPointerDownID = -1;
  1777. /**
  1778. * Observable raised when the value changes
  1779. */
  1780. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1781. // Events
  1782. _this._pointerIsDown = false;
  1783. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1784. _this.size = "200px";
  1785. _this.isPointerBlocker = true;
  1786. return _this;
  1787. }
  1788. Object.defineProperty(ColorPicker.prototype, "value", {
  1789. /** Gets or sets the color of the color picker */
  1790. get: function () {
  1791. return this._value;
  1792. },
  1793. set: function (value) {
  1794. if (this._value.equals(value)) {
  1795. return;
  1796. }
  1797. this._value.copyFrom(value);
  1798. this._value.toHSVToRef(this._tmpColor);
  1799. this._h = this._tmpColor.r;
  1800. this._s = Math.max(this._tmpColor.g, 0.00001);
  1801. this._v = Math.max(this._tmpColor.b, 0.00001);
  1802. this._markAsDirty();
  1803. if (this._value.r <= ColorPicker._Epsilon) {
  1804. this._value.r = 0;
  1805. }
  1806. if (this._value.g <= ColorPicker._Epsilon) {
  1807. this._value.g = 0;
  1808. }
  1809. if (this._value.b <= ColorPicker._Epsilon) {
  1810. this._value.b = 0;
  1811. }
  1812. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1813. this._value.r = 1.0;
  1814. }
  1815. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1816. this._value.g = 1.0;
  1817. }
  1818. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1819. this._value.b = 1.0;
  1820. }
  1821. this.onValueChangedObservable.notifyObservers(this._value);
  1822. },
  1823. enumerable: true,
  1824. configurable: true
  1825. });
  1826. Object.defineProperty(ColorPicker.prototype, "width", {
  1827. /**
  1828. * Gets or sets control width
  1829. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1830. */
  1831. get: function () {
  1832. return this._width.toString(this._host);
  1833. },
  1834. set: function (value) {
  1835. if (this._width.toString(this._host) === value) {
  1836. return;
  1837. }
  1838. if (this._width.fromString(value)) {
  1839. this._height.fromString(value);
  1840. this._markAsDirty();
  1841. }
  1842. },
  1843. enumerable: true,
  1844. configurable: true
  1845. });
  1846. Object.defineProperty(ColorPicker.prototype, "height", {
  1847. /**
  1848. * Gets or sets control height
  1849. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1850. */
  1851. get: function () {
  1852. return this._height.toString(this._host);
  1853. },
  1854. /** Gets or sets control height */
  1855. set: function (value) {
  1856. if (this._height.toString(this._host) === value) {
  1857. return;
  1858. }
  1859. if (this._height.fromString(value)) {
  1860. this._width.fromString(value);
  1861. this._markAsDirty();
  1862. }
  1863. },
  1864. enumerable: true,
  1865. configurable: true
  1866. });
  1867. Object.defineProperty(ColorPicker.prototype, "size", {
  1868. /** Gets or sets control size */
  1869. get: function () {
  1870. return this.width;
  1871. },
  1872. set: function (value) {
  1873. this.width = value;
  1874. },
  1875. enumerable: true,
  1876. configurable: true
  1877. });
  1878. ColorPicker.prototype._getTypeName = function () {
  1879. return "ColorPicker";
  1880. };
  1881. /** @hidden */
  1882. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1883. if (parentMeasure.width < parentMeasure.height) {
  1884. this._currentMeasure.height = parentMeasure.width;
  1885. }
  1886. else {
  1887. this._currentMeasure.width = parentMeasure.height;
  1888. }
  1889. };
  1890. ColorPicker.prototype._updateSquareProps = function () {
  1891. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1892. var wheelThickness = radius * .2;
  1893. var innerDiameter = (radius - wheelThickness) * 2;
  1894. var squareSize = innerDiameter / (Math.sqrt(2));
  1895. var offset = radius - squareSize * .5;
  1896. this._squareLeft = this._currentMeasure.left + offset;
  1897. this._squareTop = this._currentMeasure.top + offset;
  1898. this._squareSize = squareSize;
  1899. };
  1900. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1901. var lgh = context.createLinearGradient(left, top, width + left, top);
  1902. lgh.addColorStop(0, '#fff');
  1903. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1904. context.fillStyle = lgh;
  1905. context.fillRect(left, top, width, height);
  1906. var lgv = context.createLinearGradient(left, top, left, height + top);
  1907. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1908. lgv.addColorStop(1, '#000');
  1909. context.fillStyle = lgv;
  1910. context.fillRect(left, top, width, height);
  1911. };
  1912. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1913. context.beginPath();
  1914. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1915. context.lineWidth = 3;
  1916. context.strokeStyle = '#333333';
  1917. context.stroke();
  1918. context.beginPath();
  1919. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1920. context.lineWidth = 3;
  1921. context.strokeStyle = '#ffffff';
  1922. context.stroke();
  1923. };
  1924. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1925. var canvas = document.createElement("canvas");
  1926. canvas.width = radius * 2;
  1927. canvas.height = radius * 2;
  1928. var context = canvas.getContext("2d");
  1929. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1930. var data = image.data;
  1931. var color = this._tmpColor;
  1932. var maxDistSq = radius * radius;
  1933. var innerRadius = radius - thickness;
  1934. var minDistSq = innerRadius * innerRadius;
  1935. for (var x = -radius; x < radius; x++) {
  1936. for (var y = -radius; y < radius; y++) {
  1937. var distSq = x * x + y * y;
  1938. if (distSq > maxDistSq || distSq < minDistSq) {
  1939. continue;
  1940. }
  1941. var dist = Math.sqrt(distSq);
  1942. var ang = Math.atan2(y, x);
  1943. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1944. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1945. data[index] = color.r * 255;
  1946. data[index + 1] = color.g * 255;
  1947. data[index + 2] = color.b * 255;
  1948. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1949. //apply less alpha to bigger color pickers
  1950. var alphaAmount = .2;
  1951. var maxAlpha = .2;
  1952. var minAlpha = .04;
  1953. var lowerRadius = 50;
  1954. var upperRadius = 150;
  1955. if (radius < lowerRadius) {
  1956. alphaAmount = maxAlpha;
  1957. }
  1958. else if (radius > upperRadius) {
  1959. alphaAmount = minAlpha;
  1960. }
  1961. else {
  1962. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1963. }
  1964. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1965. if (alphaRatio < alphaAmount) {
  1966. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1967. }
  1968. else if (alphaRatio > 1 - alphaAmount) {
  1969. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1970. }
  1971. else {
  1972. data[index + 3] = 255;
  1973. }
  1974. }
  1975. }
  1976. context.putImageData(image, 0, 0);
  1977. return canvas;
  1978. };
  1979. /** @hidden */
  1980. ColorPicker.prototype._draw = function (context) {
  1981. context.save();
  1982. this._applyStates(context);
  1983. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1984. var wheelThickness = radius * .2;
  1985. var left = this._currentMeasure.left;
  1986. var top = this._currentMeasure.top;
  1987. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1988. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1989. }
  1990. this._updateSquareProps();
  1991. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1992. context.shadowColor = this.shadowColor;
  1993. context.shadowBlur = this.shadowBlur;
  1994. context.shadowOffsetX = this.shadowOffsetX;
  1995. context.shadowOffsetY = this.shadowOffsetY;
  1996. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  1997. }
  1998. context.drawImage(this._colorWheelCanvas, left, top);
  1999. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2000. context.shadowBlur = 0;
  2001. context.shadowOffsetX = 0;
  2002. context.shadowOffsetY = 0;
  2003. }
  2004. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2005. var cx = this._squareLeft + this._squareSize * this._s;
  2006. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2007. this._drawCircle(cx, cy, radius * .04, context);
  2008. var dist = radius - wheelThickness * .5;
  2009. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2010. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2011. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2012. context.restore();
  2013. };
  2014. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2015. if (this._pointerStartedOnWheel) {
  2016. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2017. var centerX = radius + this._currentMeasure.left;
  2018. var centerY = radius + this._currentMeasure.top;
  2019. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2020. }
  2021. else if (this._pointerStartedOnSquare) {
  2022. this._updateSquareProps();
  2023. this._s = (x - this._squareLeft) / this._squareSize;
  2024. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2025. this._s = Math.min(this._s, 1);
  2026. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2027. this._v = Math.min(this._v, 1);
  2028. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2029. }
  2030. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2031. this.value = this._tmpColor;
  2032. };
  2033. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2034. this._updateSquareProps();
  2035. var left = this._squareLeft;
  2036. var top = this._squareTop;
  2037. var size = this._squareSize;
  2038. if (x >= left && x <= left + size &&
  2039. y >= top && y <= top + size) {
  2040. return true;
  2041. }
  2042. return false;
  2043. };
  2044. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2045. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2046. var centerX = radius + this._currentMeasure.left;
  2047. var centerY = radius + this._currentMeasure.top;
  2048. var wheelThickness = radius * .2;
  2049. var innerRadius = radius - wheelThickness;
  2050. var radiusSq = radius * radius;
  2051. var innerRadiusSq = innerRadius * innerRadius;
  2052. var dx = x - centerX;
  2053. var dy = y - centerY;
  2054. var distSq = dx * dx + dy * dy;
  2055. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2056. return true;
  2057. }
  2058. return false;
  2059. };
  2060. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2061. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2062. return false;
  2063. }
  2064. this._pointerIsDown = true;
  2065. this._pointerStartedOnSquare = false;
  2066. this._pointerStartedOnWheel = false;
  2067. // Invert transform
  2068. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2069. var x = this._transformedPosition.x;
  2070. var y = this._transformedPosition.y;
  2071. if (this._isPointOnSquare(x, y)) {
  2072. this._pointerStartedOnSquare = true;
  2073. }
  2074. else if (this._isPointOnWheel(x, y)) {
  2075. this._pointerStartedOnWheel = true;
  2076. }
  2077. this._updateValueFromPointer(x, y);
  2078. this._host._capturingControl[pointerId] = this;
  2079. this._lastPointerDownID = pointerId;
  2080. return true;
  2081. };
  2082. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2083. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2084. if (pointerId != this._lastPointerDownID) {
  2085. return;
  2086. }
  2087. // Invert transform
  2088. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2089. var x = this._transformedPosition.x;
  2090. var y = this._transformedPosition.y;
  2091. if (this._pointerIsDown) {
  2092. this._updateValueFromPointer(x, y);
  2093. }
  2094. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2095. };
  2096. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2097. this._pointerIsDown = false;
  2098. delete this._host._capturingControl[pointerId];
  2099. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2100. };
  2101. /**
  2102. * This function expands the color picker by creating a color picker dialog with manual
  2103. * color value input and the ability to save colors into an array to be used later in
  2104. * subsequent launches of the dialogue.
  2105. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2106. * @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.
  2107. * @returns picked color as a hex string and the saved colors array as hex strings.
  2108. */
  2109. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2110. return new Promise(function (resolve, reject) {
  2111. // Default options
  2112. options.pickerWidth = options.pickerWidth || "640px";
  2113. options.pickerHeight = options.pickerHeight || "400px";
  2114. options.headerHeight = options.headerHeight || "35px";
  2115. options.lastColor = options.lastColor || "#000000";
  2116. options.swatchLimit = options.swatchLimit || 20;
  2117. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2118. // Window size settings
  2119. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2120. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2121. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2122. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2123. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2124. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2125. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2126. // Button Colors
  2127. var buttonColor = "#c0c0c0";
  2128. var buttonBackgroundColor = "#535353";
  2129. var buttonBackgroundHoverColor = "#414141";
  2130. var buttonBackgroundClickColor = "515151";
  2131. var buttonDisabledColor = "#555555";
  2132. var buttonDisabledBackgroundColor = "#454545";
  2133. var currentSwatchesOutlineColor = "#404040";
  2134. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2135. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2136. var iconColorDark = "#aaaaaa";
  2137. var iconColorLight = "#ffffff";
  2138. var closeIconColor;
  2139. // Button settings
  2140. var buttonFontSize;
  2141. var butEdit;
  2142. var buttonWidth;
  2143. var buttonHeight;
  2144. // Input Text Colors
  2145. var inputFieldLabels = ["R", "G", "B"];
  2146. var inputTextBackgroundColor = "#454545";
  2147. var inputTextColor = "#f0f0f0";
  2148. // This is the current color as set by either the picker or by entering a value
  2149. var currentColor;
  2150. // This int is used for naming swatches and serves as the index for calling them from the list
  2151. var swatchNumber;
  2152. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2153. var swatchDrawer;
  2154. var editSwatchMode = false;
  2155. // Color InputText fields that will be updated upon value change
  2156. var picker;
  2157. var rValInt;
  2158. var gValInt;
  2159. var bValInt;
  2160. var rValDec;
  2161. var gValDec;
  2162. var bValDec;
  2163. var hexVal;
  2164. var newSwatch;
  2165. var lastVal;
  2166. var activeField;
  2167. /**
  2168. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2169. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2170. * are will receive no update. This is to prevent the input from the user being overwritten.
  2171. */
  2172. function updateValues(value, inputField) {
  2173. activeField = inputField;
  2174. var pickedColor = value.toHexString();
  2175. newSwatch.background = pickedColor;
  2176. if (rValInt.name != activeField) {
  2177. rValInt.text = Math.floor(value.r * 255).toString();
  2178. }
  2179. if (gValInt.name != activeField) {
  2180. gValInt.text = Math.floor(value.g * 255).toString();
  2181. }
  2182. if (bValInt.name != activeField) {
  2183. bValInt.text = Math.floor(value.b * 255).toString();
  2184. }
  2185. if (rValDec.name != activeField) {
  2186. rValDec.text = value.r.toString();
  2187. }
  2188. if (gValDec.name != activeField) {
  2189. gValDec.text = value.g.toString();
  2190. }
  2191. if (bValDec.name != activeField) {
  2192. bValDec.text = value.b.toString();
  2193. }
  2194. if (hexVal.name != activeField) {
  2195. var minusPound = pickedColor.split("#");
  2196. hexVal.text = minusPound[1];
  2197. }
  2198. if (picker.name != activeField) {
  2199. picker.value = value;
  2200. }
  2201. }
  2202. // 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.
  2203. function updateInt(field, channel) {
  2204. var newValue = field.text;
  2205. var checkVal = /[^0-9]/g.test(newValue);
  2206. if (checkVal) {
  2207. field.text = lastVal;
  2208. return;
  2209. }
  2210. else {
  2211. if (newValue != "") {
  2212. if (Math.floor(parseInt(newValue)) < 0) {
  2213. newValue = "0";
  2214. }
  2215. else if (Math.floor(parseInt(newValue)) > 255) {
  2216. newValue = "255";
  2217. }
  2218. else if (isNaN(parseInt(newValue))) {
  2219. newValue = "0";
  2220. }
  2221. }
  2222. if (activeField == field.name) {
  2223. lastVal = newValue;
  2224. }
  2225. }
  2226. if (newValue != "") {
  2227. newValue = parseInt(newValue).toString();
  2228. field.text = newValue;
  2229. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2230. if (activeField == field.name) {
  2231. if (channel == "r") {
  2232. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2233. }
  2234. else if (channel == "g") {
  2235. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2236. }
  2237. else {
  2238. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2239. }
  2240. }
  2241. }
  2242. }
  2243. // 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.
  2244. function updateFloat(field, channel) {
  2245. var newValue = field.text;
  2246. var checkVal = /[^0-9\.]/g.test(newValue);
  2247. if (checkVal) {
  2248. field.text = lastVal;
  2249. return;
  2250. }
  2251. else {
  2252. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2253. if (parseFloat(newValue) < 0.0) {
  2254. newValue = "0.0";
  2255. }
  2256. else if (parseFloat(newValue) > 1.0) {
  2257. newValue = "1.0";
  2258. }
  2259. else if (isNaN(parseFloat(newValue))) {
  2260. newValue = "0.0";
  2261. }
  2262. }
  2263. if (activeField == field.name) {
  2264. lastVal = newValue;
  2265. }
  2266. }
  2267. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2268. newValue = parseFloat(newValue).toString();
  2269. field.text = newValue;
  2270. }
  2271. else {
  2272. newValue = "0.0";
  2273. }
  2274. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2275. if (activeField == field.name) {
  2276. if (channel == "r") {
  2277. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2278. }
  2279. else if (channel == "g") {
  2280. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2281. }
  2282. else {
  2283. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2284. }
  2285. }
  2286. }
  2287. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2288. function deleteSwatch(index) {
  2289. if (options.savedColors) {
  2290. options.savedColors.splice(index, 1);
  2291. }
  2292. if (options.savedColors && options.savedColors.length == 0) {
  2293. setEditButtonVisibility(false);
  2294. editSwatchMode = false;
  2295. }
  2296. }
  2297. // Creates and styles an individual swatch when updateSwatches is called.
  2298. function createSwatch() {
  2299. if (options.savedColors && options.savedColors[swatchNumber]) {
  2300. if (editSwatchMode) {
  2301. var icon = "b";
  2302. }
  2303. else {
  2304. var icon = "";
  2305. }
  2306. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2307. swatch.fontFamily = "BabylonJSglyphs";
  2308. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2309. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2310. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2311. if (swatchLuminence > luminanceLimit) {
  2312. swatch.color = iconColorDark;
  2313. }
  2314. else {
  2315. swatch.color = iconColorLight;
  2316. }
  2317. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2318. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2319. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2320. swatch.background = options.savedColors[swatchNumber];
  2321. swatch.thickness = 2;
  2322. var metadata_1 = swatchNumber;
  2323. swatch.pointerDownAnimation = function () {
  2324. swatch.thickness = 4;
  2325. };
  2326. swatch.pointerUpAnimation = function () {
  2327. swatch.thickness = 3;
  2328. };
  2329. swatch.pointerEnterAnimation = function () {
  2330. swatch.thickness = 3;
  2331. };
  2332. swatch.pointerOutAnimation = function () {
  2333. swatch.thickness = 2;
  2334. };
  2335. swatch.onPointerClickObservable.add(function () {
  2336. if (!editSwatchMode) {
  2337. if (options.savedColors) {
  2338. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2339. }
  2340. }
  2341. else {
  2342. deleteSwatch(metadata_1);
  2343. updateSwatches("", butSave);
  2344. }
  2345. });
  2346. return swatch;
  2347. }
  2348. else {
  2349. return null;
  2350. }
  2351. }
  2352. // Mode switch to render button text and close symbols on swatch controls
  2353. function editSwatches(mode) {
  2354. if (mode !== undefined) {
  2355. editSwatchMode = mode;
  2356. }
  2357. if (editSwatchMode) {
  2358. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2359. var thisButton = swatchDrawer.children[i];
  2360. thisButton.textBlock.text = "b";
  2361. }
  2362. if (butEdit !== undefined) {
  2363. butEdit.textBlock.text = "Done";
  2364. }
  2365. }
  2366. else {
  2367. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2368. var thisButton = swatchDrawer.children[i];
  2369. thisButton.textBlock.text = "";
  2370. }
  2371. if (butEdit !== undefined) {
  2372. butEdit.textBlock.text = "Edit";
  2373. }
  2374. }
  2375. }
  2376. /**
  2377. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2378. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2379. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2380. * saved colors there are and how many can be stored per row.
  2381. */
  2382. function updateSwatches(color, button) {
  2383. if (options.savedColors) {
  2384. if (color != "") {
  2385. options.savedColors.push(color);
  2386. }
  2387. swatchNumber = 0;
  2388. swatchDrawer.clearControls();
  2389. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2390. if (rowCount == 0) {
  2391. var gutterCount = 0;
  2392. }
  2393. else {
  2394. var gutterCount = rowCount + 1;
  2395. }
  2396. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2397. var currentRows = swatchDrawer.rowCount;
  2398. for (var i = 0; i < currentRows; i++) {
  2399. swatchDrawer.removeRowDefinition(0);
  2400. }
  2401. for (var i = 0; i < rowCount + gutterCount; i++) {
  2402. if (i % 2) {
  2403. swatchDrawer.addRowDefinition(swatchSize, true);
  2404. }
  2405. else {
  2406. swatchDrawer.addRowDefinition(gutterSize, true);
  2407. }
  2408. }
  2409. }
  2410. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2411. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2412. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2413. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2414. var totalButtonsThisRow = options.numSwatchesPerLine;
  2415. }
  2416. else {
  2417. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2418. }
  2419. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2420. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2421. if (x > options.numSwatchesPerLine) {
  2422. continue;
  2423. }
  2424. var swatch = createSwatch();
  2425. if (swatch != null) {
  2426. swatchDrawer.addControl(swatch, y, w);
  2427. w += 2;
  2428. swatchNumber++;
  2429. }
  2430. else {
  2431. continue;
  2432. }
  2433. }
  2434. }
  2435. if (options.savedColors.length >= options.swatchLimit) {
  2436. disableButton(button, true);
  2437. }
  2438. else {
  2439. disableButton(button, false);
  2440. }
  2441. }
  2442. }
  2443. // Shows or hides edit swatches button depending on if there are saved swatches
  2444. function setEditButtonVisibility(enableButton) {
  2445. if (enableButton) {
  2446. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2447. butEdit.width = buttonWidth;
  2448. butEdit.height = buttonHeight;
  2449. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2450. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2451. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2452. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2453. butEdit.thickness = 2;
  2454. butEdit.color = buttonColor;
  2455. butEdit.fontSize = buttonFontSize;
  2456. butEdit.background = buttonBackgroundColor;
  2457. butEdit.onPointerEnterObservable.add(function () {
  2458. butEdit.background = buttonBackgroundHoverColor;
  2459. });
  2460. butEdit.onPointerOutObservable.add(function () {
  2461. butEdit.background = buttonBackgroundColor;
  2462. });
  2463. butEdit.pointerDownAnimation = function () {
  2464. butEdit.background = buttonBackgroundClickColor;
  2465. };
  2466. butEdit.pointerUpAnimation = function () {
  2467. butEdit.background = buttonBackgroundHoverColor;
  2468. };
  2469. butEdit.onPointerClickObservable.add(function () {
  2470. if (editSwatchMode) {
  2471. editSwatchMode = false;
  2472. }
  2473. else {
  2474. editSwatchMode = true;
  2475. }
  2476. editSwatches();
  2477. });
  2478. pickerGrid.addControl(butEdit, 1, 0);
  2479. }
  2480. else {
  2481. pickerGrid.removeControl(butEdit);
  2482. }
  2483. }
  2484. // Called when the user hits the limit of saved colors in the drawer.
  2485. function disableButton(button, disabled) {
  2486. if (disabled) {
  2487. button.color = buttonDisabledColor;
  2488. button.background = buttonDisabledBackgroundColor;
  2489. }
  2490. else {
  2491. button.color = buttonColor;
  2492. button.background = buttonBackgroundColor;
  2493. }
  2494. }
  2495. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2496. function closePicker(color) {
  2497. if (options.savedColors && options.savedColors.length > 0) {
  2498. resolve({
  2499. savedColors: options.savedColors,
  2500. pickedColor: color
  2501. });
  2502. }
  2503. else {
  2504. resolve({
  2505. pickedColor: color
  2506. });
  2507. }
  2508. advancedTexture.removeControl(dialogContainer);
  2509. }
  2510. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2511. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2512. dialogContainer.name = "Dialog Container";
  2513. dialogContainer.width = options.pickerWidth;
  2514. if (options.savedColors) {
  2515. dialogContainer.height = containerSize;
  2516. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2517. dialogContainer.addRowDefinition(topRow, false);
  2518. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2519. }
  2520. else {
  2521. dialogContainer.height = options.pickerHeight;
  2522. dialogContainer.addRowDefinition(1.0, false);
  2523. }
  2524. advancedTexture.addControl(dialogContainer);
  2525. // Swatch drawer which contains all saved color buttons
  2526. if (options.savedColors) {
  2527. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2528. swatchDrawer.name = "Swatch Drawer";
  2529. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2530. swatchDrawer.background = buttonBackgroundColor;
  2531. swatchDrawer.width = options.pickerWidth;
  2532. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2533. if (initialRows == 0) {
  2534. var gutterCount = 0;
  2535. }
  2536. else {
  2537. var gutterCount = initialRows + 1;
  2538. }
  2539. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2540. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2541. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2542. if (i % 2 != 0) {
  2543. swatchDrawer.addRowDefinition(swatchSize, true);
  2544. }
  2545. else {
  2546. swatchDrawer.addRowDefinition(gutterSize, true);
  2547. }
  2548. }
  2549. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2550. if (i % 2 != 0) {
  2551. swatchDrawer.addColumnDefinition(swatchSize, true);
  2552. }
  2553. else {
  2554. swatchDrawer.addColumnDefinition(gutterSize, true);
  2555. }
  2556. }
  2557. dialogContainer.addControl(swatchDrawer, 1, 0);
  2558. }
  2559. // Picker container
  2560. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2561. pickerPanel.name = "Picker Panel";
  2562. pickerPanel.height = options.pickerHeight;
  2563. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2564. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2565. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2566. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2567. dialogContainer.addControl(pickerPanel, 0, 0);
  2568. // Picker container header
  2569. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2570. header.name = "Dialogue Header Bar";
  2571. header.background = "#cccccc";
  2572. header.thickness = 0;
  2573. pickerPanel.addControl(header, 0, 0);
  2574. // Header close button
  2575. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2576. closeButton.fontFamily = "BabylonJSglyphs";
  2577. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2578. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2579. closeButton.color = closeIconColor.toHexString();
  2580. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2581. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2582. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2583. closeButton.height = closeButton.width = options.headerHeight;
  2584. closeButton.background = header.background;
  2585. closeButton.thickness = 0;
  2586. closeButton.pointerDownAnimation = function () {
  2587. };
  2588. closeButton.pointerUpAnimation = function () {
  2589. closeButton.background = header.background;
  2590. };
  2591. closeButton.pointerEnterAnimation = function () {
  2592. closeButton.color = header.background;
  2593. closeButton.background = "red";
  2594. };
  2595. closeButton.pointerOutAnimation = function () {
  2596. closeButton.color = closeIconColor.toHexString();
  2597. closeButton.background = header.background;
  2598. };
  2599. closeButton.onPointerClickObservable.add(function () {
  2600. closePicker(currentSwatch.background);
  2601. });
  2602. pickerPanel.addControl(closeButton, 0, 0);
  2603. // Dialog container body
  2604. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2605. dialogBody.name = "Dialogue Body";
  2606. dialogBody.background = buttonBackgroundColor;
  2607. var dialogBodyCols = [0.4375, 0.5625];
  2608. dialogBody.addRowDefinition(1.0, false);
  2609. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2610. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2611. pickerPanel.addControl(dialogBody, 1, 0);
  2612. // Picker grid
  2613. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2614. pickerGrid.name = "Picker Grid";
  2615. pickerGrid.addRowDefinition(0.85, false);
  2616. pickerGrid.addRowDefinition(0.15, false);
  2617. dialogBody.addControl(pickerGrid, 0, 0);
  2618. // Picker control
  2619. picker = new ColorPicker();
  2620. picker.name = "GUI Color Picker";
  2621. if (options.pickerHeight < options.pickerWidth) {
  2622. picker.width = 0.89;
  2623. }
  2624. else {
  2625. picker.height = 0.89;
  2626. }
  2627. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2628. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2629. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2630. picker.onPointerDownObservable.add(function () {
  2631. activeField = picker.name;
  2632. lastVal = "";
  2633. editSwatches(false);
  2634. });
  2635. picker.onValueChangedObservable.add(function (value) {
  2636. if (activeField == picker.name) {
  2637. updateValues(value, picker.name);
  2638. }
  2639. });
  2640. pickerGrid.addControl(picker, 0, 0);
  2641. // Picker body right quarant
  2642. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2643. pickerBodyRight.name = "Dialogue Right Half";
  2644. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2645. var pickerBodyRightRows = [0.514, 0.486];
  2646. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2647. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2648. dialogBody.addControl(pickerBodyRight, 1, 1);
  2649. // Picker container swatches and buttons
  2650. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2651. pickerSwatchesButtons.name = "Swatches and Buttons";
  2652. var pickerButtonsCol = [0.417, 0.583];
  2653. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2654. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2655. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2656. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2657. // Picker Swatches quadrant
  2658. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2659. pickerSwatches.name = "New and Current Swatches";
  2660. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2661. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2662. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2663. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2664. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2665. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2666. // Active swatches
  2667. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2668. activeSwatches.name = "Active Swatches";
  2669. activeSwatches.width = 0.67;
  2670. activeSwatches.addRowDefinition(0.5, false);
  2671. activeSwatches.addRowDefinition(0.5, false);
  2672. pickerSwatches.addControl(activeSwatches, 2, 0);
  2673. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2674. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2675. if (options.pickerWidth > options.pickerHeight) {
  2676. var labelTextSize = labelHeight;
  2677. }
  2678. else {
  2679. var labelTextSize = labelWidth;
  2680. }
  2681. // New color swatch and previous color button
  2682. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2683. newText.text = "new";
  2684. newText.name = "New Color Label";
  2685. newText.color = buttonColor;
  2686. newText.fontSize = labelTextSize;
  2687. pickerSwatches.addControl(newText, 1, 0);
  2688. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2689. newSwatch.name = "New Color Swatch";
  2690. newSwatch.background = options.lastColor;
  2691. newSwatch.thickness = 0;
  2692. activeSwatches.addControl(newSwatch, 0, 0);
  2693. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2694. currentSwatch.background = options.lastColor;
  2695. currentSwatch.thickness = 0;
  2696. currentSwatch.onPointerClickObservable.add(function () {
  2697. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2698. updateValues(revertColor, currentSwatch.name);
  2699. editSwatches(false);
  2700. });
  2701. currentSwatch.pointerDownAnimation = function () { };
  2702. currentSwatch.pointerUpAnimation = function () { };
  2703. currentSwatch.pointerEnterAnimation = function () { };
  2704. currentSwatch.pointerOutAnimation = function () { };
  2705. activeSwatches.addControl(currentSwatch, 1, 0);
  2706. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2707. swatchOutline.name = "Swatch Outline";
  2708. swatchOutline.width = 0.67;
  2709. swatchOutline.thickness = 2;
  2710. swatchOutline.color = currentSwatchesOutlineColor;
  2711. swatchOutline.isHitTestVisible = false;
  2712. pickerSwatches.addControl(swatchOutline, 2, 0);
  2713. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2714. currentText.name = "Current Color Label";
  2715. currentText.text = "current";
  2716. currentText.color = buttonColor;
  2717. currentText.fontSize = labelTextSize;
  2718. pickerSwatches.addControl(currentText, 3, 0);
  2719. // Buttons grid
  2720. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2721. buttonGrid.name = "Button Grid";
  2722. buttonGrid.height = 0.8;
  2723. var buttonGridRows = 1 / 3;
  2724. buttonGrid.addRowDefinition(buttonGridRows, false);
  2725. buttonGrid.addRowDefinition(buttonGridRows, false);
  2726. buttonGrid.addRowDefinition(buttonGridRows, false);
  2727. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2728. // Determine pixel width and height for all buttons from overall panel dimensions
  2729. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2730. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2731. // Determine button type size
  2732. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2733. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2734. }
  2735. else {
  2736. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2737. }
  2738. // Panel Buttons
  2739. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2740. butOK.width = buttonWidth;
  2741. butOK.height = buttonHeight;
  2742. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2743. butOK.thickness = 2;
  2744. butOK.color = buttonColor;
  2745. butOK.fontSize = buttonFontSize;
  2746. butOK.background = buttonBackgroundColor;
  2747. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2748. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2749. butOK.pointerDownAnimation = function () {
  2750. butOK.background = buttonBackgroundClickColor;
  2751. };
  2752. butOK.pointerUpAnimation = function () {
  2753. butOK.background = buttonBackgroundHoverColor;
  2754. };
  2755. butOK.onPointerClickObservable.add(function () {
  2756. editSwatches(false);
  2757. closePicker(newSwatch.background);
  2758. });
  2759. buttonGrid.addControl(butOK, 0, 0);
  2760. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2761. butCancel.width = buttonWidth;
  2762. butCancel.height = buttonHeight;
  2763. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2764. butCancel.thickness = 2;
  2765. butCancel.color = buttonColor;
  2766. butCancel.fontSize = buttonFontSize;
  2767. butCancel.background = buttonBackgroundColor;
  2768. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2769. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2770. butCancel.pointerDownAnimation = function () {
  2771. butCancel.background = buttonBackgroundClickColor;
  2772. };
  2773. butCancel.pointerUpAnimation = function () {
  2774. butCancel.background = buttonBackgroundHoverColor;
  2775. };
  2776. butCancel.onPointerClickObservable.add(function () {
  2777. editSwatches(false);
  2778. closePicker(currentSwatch.background);
  2779. });
  2780. buttonGrid.addControl(butCancel, 1, 0);
  2781. if (options.savedColors) {
  2782. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2783. butSave.width = buttonWidth;
  2784. butSave.height = buttonHeight;
  2785. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2786. butSave.thickness = 2;
  2787. butSave.fontSize = buttonFontSize;
  2788. if (options.savedColors.length < options.swatchLimit) {
  2789. butSave.color = buttonColor;
  2790. butSave.background = buttonBackgroundColor;
  2791. }
  2792. else {
  2793. disableButton(butSave, true);
  2794. }
  2795. butSave.onPointerEnterObservable.add(function () {
  2796. if (options.savedColors) {
  2797. if (options.savedColors.length < options.swatchLimit) {
  2798. butSave.background = buttonBackgroundHoverColor;
  2799. }
  2800. }
  2801. });
  2802. butSave.onPointerOutObservable.add(function () {
  2803. if (options.savedColors) {
  2804. if (options.savedColors.length < options.swatchLimit) {
  2805. butSave.background = buttonBackgroundColor;
  2806. }
  2807. }
  2808. });
  2809. butSave.pointerDownAnimation = function () {
  2810. if (options.savedColors) {
  2811. if (options.savedColors.length < options.swatchLimit) {
  2812. butSave.background = buttonBackgroundClickColor;
  2813. }
  2814. }
  2815. };
  2816. butSave.pointerUpAnimation = function () {
  2817. if (options.savedColors) {
  2818. if (options.savedColors.length < options.swatchLimit) {
  2819. butSave.background = buttonBackgroundHoverColor;
  2820. }
  2821. }
  2822. };
  2823. butSave.onPointerClickObservable.add(function () {
  2824. if (options.savedColors) {
  2825. if (options.savedColors.length == 0) {
  2826. setEditButtonVisibility(true);
  2827. }
  2828. if (options.savedColors.length < options.swatchLimit) {
  2829. updateSwatches(newSwatch.background, butSave);
  2830. }
  2831. editSwatches(false);
  2832. }
  2833. });
  2834. if (options.savedColors.length > 0) {
  2835. setEditButtonVisibility(true);
  2836. }
  2837. buttonGrid.addControl(butSave, 2, 0);
  2838. }
  2839. // Picker color values input
  2840. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2841. pickerColorValues.name = "Dialog Lower Right";
  2842. pickerColorValues.addRowDefinition(0.02, false);
  2843. pickerColorValues.addRowDefinition(0.63, false);
  2844. pickerColorValues.addRowDefinition(0.21, false);
  2845. pickerColorValues.addRowDefinition(0.14, false);
  2846. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2847. // RGB values text boxes
  2848. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2849. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2850. rgbValuesQuadrant.name = "RGB Values";
  2851. rgbValuesQuadrant.width = 0.82;
  2852. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2853. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2854. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2855. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2856. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2857. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2858. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2859. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2860. for (var i = 0; i < inputFieldLabels.length; i++) {
  2861. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2862. labelText.text = inputFieldLabels[i];
  2863. labelText.color = buttonColor;
  2864. labelText.fontSize = buttonFontSize;
  2865. rgbValuesQuadrant.addControl(labelText, i, 0);
  2866. }
  2867. // Input fields for RGB values
  2868. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2869. rValInt.width = 0.83;
  2870. rValInt.height = 0.72;
  2871. rValInt.name = "rIntField";
  2872. rValInt.fontSize = buttonFontSize;
  2873. rValInt.text = (currentColor.r * 255).toString();
  2874. rValInt.color = inputTextColor;
  2875. rValInt.background = inputTextBackgroundColor;
  2876. rValInt.onFocusObservable.add(function () {
  2877. activeField = rValInt.name;
  2878. lastVal = rValInt.text;
  2879. editSwatches(false);
  2880. });
  2881. rValInt.onBlurObservable.add(function () {
  2882. if (rValInt.text == "") {
  2883. rValInt.text = "0";
  2884. }
  2885. updateInt(rValInt, "r");
  2886. if (activeField == rValInt.name) {
  2887. activeField = "";
  2888. }
  2889. });
  2890. rValInt.onTextChangedObservable.add(function () {
  2891. if (activeField == rValInt.name) {
  2892. updateInt(rValInt, "r");
  2893. }
  2894. });
  2895. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2896. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2897. gValInt.width = 0.83;
  2898. gValInt.height = 0.72;
  2899. gValInt.name = "gIntField";
  2900. gValInt.fontSize = buttonFontSize;
  2901. gValInt.text = (currentColor.g * 255).toString();
  2902. gValInt.color = inputTextColor;
  2903. gValInt.background = inputTextBackgroundColor;
  2904. gValInt.onFocusObservable.add(function () {
  2905. activeField = gValInt.name;
  2906. lastVal = gValInt.text;
  2907. editSwatches(false);
  2908. });
  2909. gValInt.onBlurObservable.add(function () {
  2910. if (gValInt.text == "") {
  2911. gValInt.text = "0";
  2912. }
  2913. updateInt(gValInt, "g");
  2914. if (activeField == gValInt.name) {
  2915. activeField = "";
  2916. }
  2917. });
  2918. gValInt.onTextChangedObservable.add(function () {
  2919. if (activeField == gValInt.name) {
  2920. updateInt(gValInt, "g");
  2921. }
  2922. });
  2923. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2924. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2925. bValInt.width = 0.83;
  2926. bValInt.height = 0.72;
  2927. bValInt.name = "bIntField";
  2928. bValInt.fontSize = buttonFontSize;
  2929. bValInt.text = (currentColor.b * 255).toString();
  2930. bValInt.color = inputTextColor;
  2931. bValInt.background = inputTextBackgroundColor;
  2932. bValInt.onFocusObservable.add(function () {
  2933. activeField = bValInt.name;
  2934. lastVal = bValInt.text;
  2935. editSwatches(false);
  2936. });
  2937. bValInt.onBlurObservable.add(function () {
  2938. if (bValInt.text == "") {
  2939. bValInt.text = "0";
  2940. }
  2941. updateInt(bValInt, "b");
  2942. if (activeField == bValInt.name) {
  2943. activeField = "";
  2944. }
  2945. });
  2946. bValInt.onTextChangedObservable.add(function () {
  2947. if (activeField == bValInt.name) {
  2948. updateInt(bValInt, "b");
  2949. }
  2950. });
  2951. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2952. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2953. rValDec.width = 0.95;
  2954. rValDec.height = 0.72;
  2955. rValDec.name = "rDecField";
  2956. rValDec.fontSize = buttonFontSize;
  2957. rValDec.text = currentColor.r.toString();
  2958. rValDec.color = inputTextColor;
  2959. rValDec.background = inputTextBackgroundColor;
  2960. rValDec.onFocusObservable.add(function () {
  2961. activeField = rValDec.name;
  2962. lastVal = rValDec.text;
  2963. editSwatches(false);
  2964. });
  2965. rValDec.onBlurObservable.add(function () {
  2966. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2967. rValDec.text = "0";
  2968. updateFloat(rValDec, "r");
  2969. }
  2970. if (activeField == rValDec.name) {
  2971. activeField = "";
  2972. }
  2973. });
  2974. rValDec.onTextChangedObservable.add(function () {
  2975. if (activeField == rValDec.name) {
  2976. updateFloat(rValDec, "r");
  2977. }
  2978. });
  2979. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2980. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2981. gValDec.width = 0.95;
  2982. gValDec.height = 0.72;
  2983. gValDec.name = "gDecField";
  2984. gValDec.fontSize = buttonFontSize;
  2985. gValDec.text = currentColor.g.toString();
  2986. gValDec.color = inputTextColor;
  2987. gValDec.background = inputTextBackgroundColor;
  2988. gValDec.onFocusObservable.add(function () {
  2989. activeField = gValDec.name;
  2990. lastVal = gValDec.text;
  2991. editSwatches(false);
  2992. });
  2993. gValDec.onBlurObservable.add(function () {
  2994. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2995. gValDec.text = "0";
  2996. updateFloat(gValDec, "g");
  2997. }
  2998. if (activeField == gValDec.name) {
  2999. activeField = "";
  3000. }
  3001. });
  3002. gValDec.onTextChangedObservable.add(function () {
  3003. if (activeField == gValDec.name) {
  3004. updateFloat(gValDec, "g");
  3005. }
  3006. });
  3007. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3008. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3009. bValDec.width = 0.95;
  3010. bValDec.height = 0.72;
  3011. bValDec.name = "bDecField";
  3012. bValDec.fontSize = buttonFontSize;
  3013. bValDec.text = currentColor.b.toString();
  3014. bValDec.color = inputTextColor;
  3015. bValDec.background = inputTextBackgroundColor;
  3016. bValDec.onFocusObservable.add(function () {
  3017. activeField = bValDec.name;
  3018. lastVal = bValDec.text;
  3019. editSwatches(false);
  3020. });
  3021. bValDec.onBlurObservable.add(function () {
  3022. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3023. bValDec.text = "0";
  3024. updateFloat(bValDec, "b");
  3025. }
  3026. if (activeField == bValDec.name) {
  3027. activeField = "";
  3028. }
  3029. });
  3030. bValDec.onTextChangedObservable.add(function () {
  3031. if (activeField == bValDec.name) {
  3032. updateFloat(bValDec, "b");
  3033. }
  3034. });
  3035. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3036. // Hex value input
  3037. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3038. hexValueQuadrant.name = "Hex Value";
  3039. hexValueQuadrant.width = 0.82;
  3040. hexValueQuadrant.addRowDefinition(1.0, false);
  3041. hexValueQuadrant.addColumnDefinition(0.1, false);
  3042. hexValueQuadrant.addColumnDefinition(0.9, false);
  3043. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3044. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3045. labelText.text = "#";
  3046. labelText.color = buttonColor;
  3047. labelText.fontSize = buttonFontSize;
  3048. hexValueQuadrant.addControl(labelText, 0, 0);
  3049. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3050. hexVal.width = 0.96;
  3051. hexVal.height = 0.72;
  3052. hexVal.name = "hexField";
  3053. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3054. hexVal.fontSize = buttonFontSize;
  3055. var minusPound = options.lastColor.split("#");
  3056. hexVal.text = minusPound[1];
  3057. hexVal.color = inputTextColor;
  3058. hexVal.background = inputTextBackgroundColor;
  3059. hexVal.onFocusObservable.add(function () {
  3060. activeField = hexVal.name;
  3061. lastVal = hexVal.text;
  3062. editSwatches(false);
  3063. });
  3064. hexVal.onBlurObservable.add(function () {
  3065. if (hexVal.text.length == 3) {
  3066. var val = hexVal.text.split("");
  3067. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3068. }
  3069. if (hexVal.text == "") {
  3070. hexVal.text = "000000";
  3071. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3072. }
  3073. if (activeField == hexVal.name) {
  3074. activeField = "";
  3075. }
  3076. });
  3077. hexVal.onTextChangedObservable.add(function () {
  3078. var newHexValue = hexVal.text;
  3079. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3080. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3081. hexVal.text = lastVal;
  3082. }
  3083. else {
  3084. if (hexVal.text.length < 6) {
  3085. var leadingZero = 6 - hexVal.text.length;
  3086. for (var i = 0; i < leadingZero; i++) {
  3087. newHexValue = "0" + newHexValue;
  3088. }
  3089. }
  3090. if (hexVal.text.length == 3) {
  3091. var val = hexVal.text.split("");
  3092. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3093. }
  3094. newHexValue = "#" + newHexValue;
  3095. if (activeField == hexVal.name) {
  3096. lastVal = hexVal.text;
  3097. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3098. }
  3099. }
  3100. });
  3101. hexValueQuadrant.addControl(hexVal, 0, 1);
  3102. if (options.savedColors && options.savedColors.length > 0) {
  3103. updateSwatches("", butSave);
  3104. }
  3105. });
  3106. };
  3107. ColorPicker._Epsilon = 0.000001;
  3108. return ColorPicker;
  3109. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3110. /***/ }),
  3111. /***/ "./2D/controls/container.ts":
  3112. /*!**********************************!*\
  3113. !*** ./2D/controls/container.ts ***!
  3114. \**********************************/
  3115. /*! exports provided: Container */
  3116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3117. "use strict";
  3118. __webpack_require__.r(__webpack_exports__);
  3119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3120. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3121. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3122. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3123. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3124. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3125. /**
  3126. * Root class for 2D containers
  3127. * @see http://doc.babylonjs.com/how_to/gui#containers
  3128. */
  3129. var Container = /** @class */ (function (_super) {
  3130. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3131. /**
  3132. * Creates a new Container
  3133. * @param name defines the name of the container
  3134. */
  3135. function Container(name) {
  3136. var _this = _super.call(this, name) || this;
  3137. _this.name = name;
  3138. /** @hidden */
  3139. _this._children = new Array();
  3140. /** @hidden */
  3141. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3142. /** @hidden */
  3143. _this._background = "";
  3144. /** @hidden */
  3145. _this._adaptWidthToChildren = false;
  3146. /** @hidden */
  3147. _this._adaptHeightToChildren = false;
  3148. /**
  3149. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3150. */
  3151. _this.logLayoutCycleErrors = false;
  3152. /**
  3153. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3154. */
  3155. _this.maxLayoutCycle = 3;
  3156. return _this;
  3157. }
  3158. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3159. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3160. get: function () {
  3161. return this._adaptHeightToChildren;
  3162. },
  3163. set: function (value) {
  3164. if (this._adaptHeightToChildren === value) {
  3165. return;
  3166. }
  3167. this._adaptHeightToChildren = value;
  3168. if (value) {
  3169. this.height = "100%";
  3170. }
  3171. this._markAsDirty();
  3172. },
  3173. enumerable: true,
  3174. configurable: true
  3175. });
  3176. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3177. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3178. get: function () {
  3179. return this._adaptWidthToChildren;
  3180. },
  3181. set: function (value) {
  3182. if (this._adaptWidthToChildren === value) {
  3183. return;
  3184. }
  3185. this._adaptWidthToChildren = value;
  3186. if (value) {
  3187. this.width = "100%";
  3188. }
  3189. this._markAsDirty();
  3190. },
  3191. enumerable: true,
  3192. configurable: true
  3193. });
  3194. Object.defineProperty(Container.prototype, "background", {
  3195. /** Gets or sets background color */
  3196. get: function () {
  3197. return this._background;
  3198. },
  3199. set: function (value) {
  3200. if (this._background === value) {
  3201. return;
  3202. }
  3203. this._background = value;
  3204. this._markAsDirty();
  3205. },
  3206. enumerable: true,
  3207. configurable: true
  3208. });
  3209. Object.defineProperty(Container.prototype, "children", {
  3210. /** Gets the list of children */
  3211. get: function () {
  3212. return this._children;
  3213. },
  3214. enumerable: true,
  3215. configurable: true
  3216. });
  3217. Container.prototype._getTypeName = function () {
  3218. return "Container";
  3219. };
  3220. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3221. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3222. var child = _a[_i];
  3223. child._markMatrixAsDirty();
  3224. }
  3225. };
  3226. /**
  3227. * Gets a child using its name
  3228. * @param name defines the child name to look for
  3229. * @returns the child control if found
  3230. */
  3231. Container.prototype.getChildByName = function (name) {
  3232. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3233. var child = _a[_i];
  3234. if (child.name === name) {
  3235. return child;
  3236. }
  3237. }
  3238. return null;
  3239. };
  3240. /**
  3241. * Gets a child using its type and its name
  3242. * @param name defines the child name to look for
  3243. * @param type defines the child type to look for
  3244. * @returns the child control if found
  3245. */
  3246. Container.prototype.getChildByType = function (name, type) {
  3247. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3248. var child = _a[_i];
  3249. if (child.typeName === type) {
  3250. return child;
  3251. }
  3252. }
  3253. return null;
  3254. };
  3255. /**
  3256. * Search for a specific control in children
  3257. * @param control defines the control to look for
  3258. * @returns true if the control is in child list
  3259. */
  3260. Container.prototype.containsControl = function (control) {
  3261. return this.children.indexOf(control) !== -1;
  3262. };
  3263. /**
  3264. * Adds a new control to the current container
  3265. * @param control defines the control to add
  3266. * @returns the current container
  3267. */
  3268. Container.prototype.addControl = function (control) {
  3269. if (!control) {
  3270. return this;
  3271. }
  3272. var index = this._children.indexOf(control);
  3273. if (index !== -1) {
  3274. return this;
  3275. }
  3276. control._link(this._host);
  3277. control._markAllAsDirty();
  3278. this._reOrderControl(control);
  3279. this._markAsDirty();
  3280. return this;
  3281. };
  3282. /**
  3283. * Removes all controls from the current container
  3284. * @returns the current container
  3285. */
  3286. Container.prototype.clearControls = function () {
  3287. var children = this.children.slice();
  3288. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3289. var child = children_1[_i];
  3290. this.removeControl(child);
  3291. }
  3292. return this;
  3293. };
  3294. /**
  3295. * Removes a control from the current container
  3296. * @param control defines the control to remove
  3297. * @returns the current container
  3298. */
  3299. Container.prototype.removeControl = function (control) {
  3300. var index = this._children.indexOf(control);
  3301. if (index !== -1) {
  3302. this._children.splice(index, 1);
  3303. control.parent = null;
  3304. }
  3305. control.linkWithMesh(null);
  3306. if (this._host) {
  3307. this._host._cleanControlAfterRemoval(control);
  3308. }
  3309. this._markAsDirty();
  3310. return this;
  3311. };
  3312. /** @hidden */
  3313. Container.prototype._reOrderControl = function (control) {
  3314. this.removeControl(control);
  3315. var wasAdded = false;
  3316. for (var index = 0; index < this._children.length; index++) {
  3317. if (this._children[index].zIndex > control.zIndex) {
  3318. this._children.splice(index, 0, control);
  3319. wasAdded = true;
  3320. break;
  3321. }
  3322. }
  3323. if (!wasAdded) {
  3324. this._children.push(control);
  3325. }
  3326. control.parent = this;
  3327. this._markAsDirty();
  3328. };
  3329. /** @hidden */
  3330. Container.prototype._offsetLeft = function (offset) {
  3331. _super.prototype._offsetLeft.call(this, offset);
  3332. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3333. var child = _a[_i];
  3334. child._offsetLeft(offset);
  3335. }
  3336. };
  3337. /** @hidden */
  3338. Container.prototype._offsetTop = function (offset) {
  3339. _super.prototype._offsetTop.call(this, offset);
  3340. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3341. var child = _a[_i];
  3342. child._offsetTop(offset);
  3343. }
  3344. };
  3345. /** @hidden */
  3346. Container.prototype._markAllAsDirty = function () {
  3347. _super.prototype._markAllAsDirty.call(this);
  3348. for (var index = 0; index < this._children.length; index++) {
  3349. this._children[index]._markAllAsDirty();
  3350. }
  3351. };
  3352. /** @hidden */
  3353. Container.prototype._localDraw = function (context) {
  3354. if (this._background) {
  3355. context.save();
  3356. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3357. context.shadowColor = this.shadowColor;
  3358. context.shadowBlur = this.shadowBlur;
  3359. context.shadowOffsetX = this.shadowOffsetX;
  3360. context.shadowOffsetY = this.shadowOffsetY;
  3361. }
  3362. context.fillStyle = this._background;
  3363. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3364. context.restore();
  3365. }
  3366. };
  3367. /** @hidden */
  3368. Container.prototype._link = function (host) {
  3369. _super.prototype._link.call(this, host);
  3370. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3371. var child = _a[_i];
  3372. child._link(host);
  3373. }
  3374. };
  3375. /** @hidden */
  3376. Container.prototype._beforeLayout = function () {
  3377. // Do nothing
  3378. };
  3379. /** @hidden */
  3380. Container.prototype._processMeasures = function (parentMeasure, context) {
  3381. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3382. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3383. this._evaluateClippingState(parentMeasure);
  3384. }
  3385. };
  3386. /** @hidden */
  3387. Container.prototype._layout = function (parentMeasure, context) {
  3388. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3389. return false;
  3390. }
  3391. if (this._isDirty) {
  3392. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3393. }
  3394. var rebuildCount = 0;
  3395. context.save();
  3396. this._applyStates(context);
  3397. this._beforeLayout();
  3398. do {
  3399. var computedWidth = -1;
  3400. var computedHeight = -1;
  3401. this._rebuildLayout = false;
  3402. this._processMeasures(parentMeasure, context);
  3403. if (!this._isClipped) {
  3404. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3405. var child = _a[_i];
  3406. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3407. if (child._layout(this._measureForChildren, context)) {
  3408. if (this.adaptWidthToChildren && child._width.isPixel) {
  3409. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3410. }
  3411. if (this.adaptHeightToChildren && child._height.isPixel) {
  3412. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3413. }
  3414. }
  3415. }
  3416. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3417. if (this.width !== computedWidth + "px") {
  3418. this.width = computedWidth + "px";
  3419. this._rebuildLayout = true;
  3420. }
  3421. }
  3422. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3423. if (this.height !== computedHeight + "px") {
  3424. this.height = computedHeight + "px";
  3425. this._rebuildLayout = true;
  3426. }
  3427. }
  3428. this._postMeasure();
  3429. }
  3430. rebuildCount++;
  3431. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3432. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3433. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3434. }
  3435. context.restore();
  3436. if (this._isDirty) {
  3437. this.invalidateRect();
  3438. this._isDirty = false;
  3439. }
  3440. return true;
  3441. };
  3442. Container.prototype._postMeasure = function () {
  3443. // Do nothing by default
  3444. };
  3445. /** @hidden */
  3446. Container.prototype._draw = function (context, invalidatedRectangle) {
  3447. this._localDraw(context);
  3448. if (this.clipChildren) {
  3449. this._clipForChildren(context);
  3450. }
  3451. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3452. var child = _a[_i];
  3453. // Only redraw parts of the screen that are invalidated
  3454. if (invalidatedRectangle) {
  3455. if (!child._intersectsRect(invalidatedRectangle)) {
  3456. continue;
  3457. }
  3458. }
  3459. child._render(context, invalidatedRectangle);
  3460. }
  3461. };
  3462. /** @hidden */
  3463. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3464. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3465. if (!this.children) {
  3466. return;
  3467. }
  3468. for (var index = 0; index < this.children.length; index++) {
  3469. var item = this.children[index];
  3470. if (!predicate || predicate(item)) {
  3471. results.push(item);
  3472. }
  3473. if (!directDescendantsOnly) {
  3474. item._getDescendants(results, false, predicate);
  3475. }
  3476. }
  3477. };
  3478. /** @hidden */
  3479. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3480. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3481. return false;
  3482. }
  3483. if (!_super.prototype.contains.call(this, x, y)) {
  3484. return false;
  3485. }
  3486. // Checking backwards to pick closest first
  3487. for (var index = this._children.length - 1; index >= 0; index--) {
  3488. var child = this._children[index];
  3489. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3490. if (child.hoverCursor) {
  3491. this._host._changeCursor(child.hoverCursor);
  3492. }
  3493. return true;
  3494. }
  3495. }
  3496. if (!this.isHitTestVisible) {
  3497. return false;
  3498. }
  3499. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3500. };
  3501. /** @hidden */
  3502. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3503. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3504. this._measureForChildren.copyFrom(this._currentMeasure);
  3505. };
  3506. /** Releases associated resources */
  3507. Container.prototype.dispose = function () {
  3508. _super.prototype.dispose.call(this);
  3509. for (var index = this.children.length - 1; index >= 0; index--) {
  3510. this.children[index].dispose();
  3511. }
  3512. };
  3513. return Container;
  3514. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3515. /***/ }),
  3516. /***/ "./2D/controls/control.ts":
  3517. /*!********************************!*\
  3518. !*** ./2D/controls/control.ts ***!
  3519. \********************************/
  3520. /*! exports provided: Control */
  3521. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3522. "use strict";
  3523. __webpack_require__.r(__webpack_exports__);
  3524. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3525. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3526. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3527. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3528. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3529. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3530. /**
  3531. * Root class used for all 2D controls
  3532. * @see http://doc.babylonjs.com/how_to/gui#controls
  3533. */
  3534. var Control = /** @class */ (function () {
  3535. // Functions
  3536. /**
  3537. * Creates a new control
  3538. * @param name defines the name of the control
  3539. */
  3540. function Control(
  3541. /** defines the name of the control */
  3542. name) {
  3543. this.name = name;
  3544. this._alpha = 1;
  3545. this._alphaSet = false;
  3546. this._zIndex = 0;
  3547. /** @hidden */
  3548. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3549. this._fontFamily = "Arial";
  3550. this._fontStyle = "";
  3551. this._fontWeight = "";
  3552. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3553. /** @hidden */
  3554. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3555. /** @hidden */
  3556. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3557. this._color = "";
  3558. this._style = null;
  3559. /** @hidden */
  3560. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3561. /** @hidden */
  3562. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3563. /** @hidden */
  3564. this._isDirty = true;
  3565. /** @hidden */
  3566. this._wasDirty = false;
  3567. /** @hidden */
  3568. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3569. /** @hidden */
  3570. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3571. /** @hidden */
  3572. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3573. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3574. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3575. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3576. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3577. /** @hidden */
  3578. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3579. /** @hidden */
  3580. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3581. this._scaleX = 1.0;
  3582. this._scaleY = 1.0;
  3583. this._rotation = 0;
  3584. this._transformCenterX = 0.5;
  3585. this._transformCenterY = 0.5;
  3586. /** @hidden */
  3587. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3588. /** @hidden */
  3589. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3590. /** @hidden */
  3591. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3592. this._isMatrixDirty = true;
  3593. this._isVisible = true;
  3594. this._isHighlighted = false;
  3595. this._fontSet = false;
  3596. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3597. this._downCount = 0;
  3598. this._enterCount = -1;
  3599. this._doNotRender = false;
  3600. this._downPointerIds = {};
  3601. this._isEnabled = true;
  3602. this._disabledColor = "#9a9a9a";
  3603. /** @hidden */
  3604. this._rebuildLayout = false;
  3605. /** @hidden */
  3606. this._isClipped = false;
  3607. /**
  3608. * Gets or sets an object used to store user defined information for the node
  3609. */
  3610. this.metadata = null;
  3611. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3612. this.isHitTestVisible = true;
  3613. /** Gets or sets a boolean indicating if the control can block pointer events */
  3614. this.isPointerBlocker = false;
  3615. /** Gets or sets a boolean indicating if the control can be focusable */
  3616. this.isFocusInvisible = false;
  3617. /**
  3618. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3619. * 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
  3620. */
  3621. this.clipChildren = true;
  3622. /**
  3623. * Gets or sets a boolean indicating that control content must be clipped
  3624. * 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
  3625. */
  3626. this.clipContent = true;
  3627. /**
  3628. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3629. */
  3630. this.useBitmapCache = false;
  3631. this._shadowOffsetX = 0;
  3632. this._shadowOffsetY = 0;
  3633. this._shadowBlur = 0;
  3634. this._shadowColor = 'black';
  3635. /** Gets or sets the cursor to use when the control is hovered */
  3636. this.hoverCursor = "";
  3637. /** @hidden */
  3638. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3639. /** @hidden */
  3640. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3641. /**
  3642. * An event triggered when the pointer move over the control.
  3643. */
  3644. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3645. /**
  3646. * An event triggered when the pointer move out of the control.
  3647. */
  3648. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3649. /**
  3650. * An event triggered when the pointer taps the control
  3651. */
  3652. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3653. /**
  3654. * An event triggered when pointer up
  3655. */
  3656. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3657. /**
  3658. * An event triggered when a control is clicked on
  3659. */
  3660. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3661. /**
  3662. * An event triggered when pointer enters the control
  3663. */
  3664. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3665. /**
  3666. * An event triggered when the control is marked as dirty
  3667. */
  3668. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3669. /**
  3670. * An event triggered before drawing the control
  3671. */
  3672. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3673. /**
  3674. * An event triggered after the control was drawn
  3675. */
  3676. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3677. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3678. }
  3679. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3680. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3681. get: function () {
  3682. return this._shadowOffsetX;
  3683. },
  3684. set: function (value) {
  3685. if (this._shadowOffsetX === value) {
  3686. return;
  3687. }
  3688. this._shadowOffsetX = value;
  3689. this._markAsDirty();
  3690. },
  3691. enumerable: true,
  3692. configurable: true
  3693. });
  3694. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3695. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3696. get: function () {
  3697. return this._shadowOffsetY;
  3698. },
  3699. set: function (value) {
  3700. if (this._shadowOffsetY === value) {
  3701. return;
  3702. }
  3703. this._shadowOffsetY = value;
  3704. this._markAsDirty();
  3705. },
  3706. enumerable: true,
  3707. configurable: true
  3708. });
  3709. Object.defineProperty(Control.prototype, "shadowBlur", {
  3710. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3711. get: function () {
  3712. return this._shadowBlur;
  3713. },
  3714. set: function (value) {
  3715. if (this._shadowBlur === value) {
  3716. return;
  3717. }
  3718. this._shadowBlur = value;
  3719. this._markAsDirty();
  3720. },
  3721. enumerable: true,
  3722. configurable: true
  3723. });
  3724. Object.defineProperty(Control.prototype, "shadowColor", {
  3725. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3726. get: function () {
  3727. return this._shadowColor;
  3728. },
  3729. set: function (value) {
  3730. if (this._shadowColor === value) {
  3731. return;
  3732. }
  3733. this._shadowColor = value;
  3734. this._markAsDirty();
  3735. },
  3736. enumerable: true,
  3737. configurable: true
  3738. });
  3739. Object.defineProperty(Control.prototype, "typeName", {
  3740. // Properties
  3741. /** Gets the control type name */
  3742. get: function () {
  3743. return this._getTypeName();
  3744. },
  3745. enumerable: true,
  3746. configurable: true
  3747. });
  3748. /**
  3749. * Get the current class name of the control.
  3750. * @returns current class name
  3751. */
  3752. Control.prototype.getClassName = function () {
  3753. return this._getTypeName();
  3754. };
  3755. Object.defineProperty(Control.prototype, "host", {
  3756. /**
  3757. * Get the hosting AdvancedDynamicTexture
  3758. */
  3759. get: function () {
  3760. return this._host;
  3761. },
  3762. enumerable: true,
  3763. configurable: true
  3764. });
  3765. Object.defineProperty(Control.prototype, "fontOffset", {
  3766. /** Gets or set information about font offsets (used to render and align text) */
  3767. get: function () {
  3768. return this._fontOffset;
  3769. },
  3770. set: function (offset) {
  3771. this._fontOffset = offset;
  3772. },
  3773. enumerable: true,
  3774. configurable: true
  3775. });
  3776. Object.defineProperty(Control.prototype, "alpha", {
  3777. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3778. get: function () {
  3779. return this._alpha;
  3780. },
  3781. set: function (value) {
  3782. if (this._alpha === value) {
  3783. return;
  3784. }
  3785. this._alphaSet = true;
  3786. this._alpha = value;
  3787. this._markAsDirty();
  3788. },
  3789. enumerable: true,
  3790. configurable: true
  3791. });
  3792. Object.defineProperty(Control.prototype, "isHighlighted", {
  3793. /**
  3794. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3795. */
  3796. get: function () {
  3797. return this._isHighlighted;
  3798. },
  3799. set: function (value) {
  3800. if (this._isHighlighted === value) {
  3801. return;
  3802. }
  3803. this._isHighlighted = value;
  3804. this._markAsDirty();
  3805. },
  3806. enumerable: true,
  3807. configurable: true
  3808. });
  3809. Object.defineProperty(Control.prototype, "scaleX", {
  3810. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3811. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3812. */
  3813. get: function () {
  3814. return this._scaleX;
  3815. },
  3816. set: function (value) {
  3817. if (this._scaleX === value) {
  3818. return;
  3819. }
  3820. this._scaleX = value;
  3821. this._markAsDirty();
  3822. this._markMatrixAsDirty();
  3823. },
  3824. enumerable: true,
  3825. configurable: true
  3826. });
  3827. Object.defineProperty(Control.prototype, "scaleY", {
  3828. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3829. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3830. */
  3831. get: function () {
  3832. return this._scaleY;
  3833. },
  3834. set: function (value) {
  3835. if (this._scaleY === value) {
  3836. return;
  3837. }
  3838. this._scaleY = value;
  3839. this._markAsDirty();
  3840. this._markMatrixAsDirty();
  3841. },
  3842. enumerable: true,
  3843. configurable: true
  3844. });
  3845. Object.defineProperty(Control.prototype, "rotation", {
  3846. /** Gets or sets the rotation angle (0 by default)
  3847. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3848. */
  3849. get: function () {
  3850. return this._rotation;
  3851. },
  3852. set: function (value) {
  3853. if (this._rotation === value) {
  3854. return;
  3855. }
  3856. this._rotation = value;
  3857. this._markAsDirty();
  3858. this._markMatrixAsDirty();
  3859. },
  3860. enumerable: true,
  3861. configurable: true
  3862. });
  3863. Object.defineProperty(Control.prototype, "transformCenterY", {
  3864. /** Gets or sets the transformation center on Y axis (0 by default)
  3865. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3866. */
  3867. get: function () {
  3868. return this._transformCenterY;
  3869. },
  3870. set: function (value) {
  3871. if (this._transformCenterY === value) {
  3872. return;
  3873. }
  3874. this._transformCenterY = value;
  3875. this._markAsDirty();
  3876. this._markMatrixAsDirty();
  3877. },
  3878. enumerable: true,
  3879. configurable: true
  3880. });
  3881. Object.defineProperty(Control.prototype, "transformCenterX", {
  3882. /** Gets or sets the transformation center on X axis (0 by default)
  3883. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3884. */
  3885. get: function () {
  3886. return this._transformCenterX;
  3887. },
  3888. set: function (value) {
  3889. if (this._transformCenterX === value) {
  3890. return;
  3891. }
  3892. this._transformCenterX = value;
  3893. this._markAsDirty();
  3894. this._markMatrixAsDirty();
  3895. },
  3896. enumerable: true,
  3897. configurable: true
  3898. });
  3899. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3900. /**
  3901. * Gets or sets the horizontal alignment
  3902. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3903. */
  3904. get: function () {
  3905. return this._horizontalAlignment;
  3906. },
  3907. set: function (value) {
  3908. if (this._horizontalAlignment === value) {
  3909. return;
  3910. }
  3911. this._horizontalAlignment = value;
  3912. this._markAsDirty();
  3913. },
  3914. enumerable: true,
  3915. configurable: true
  3916. });
  3917. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3918. /**
  3919. * Gets or sets the vertical alignment
  3920. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3921. */
  3922. get: function () {
  3923. return this._verticalAlignment;
  3924. },
  3925. set: function (value) {
  3926. if (this._verticalAlignment === value) {
  3927. return;
  3928. }
  3929. this._verticalAlignment = value;
  3930. this._markAsDirty();
  3931. },
  3932. enumerable: true,
  3933. configurable: true
  3934. });
  3935. Object.defineProperty(Control.prototype, "width", {
  3936. /**
  3937. * Gets or sets control width
  3938. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3939. */
  3940. get: function () {
  3941. return this._width.toString(this._host);
  3942. },
  3943. set: function (value) {
  3944. if (this._width.toString(this._host) === value) {
  3945. return;
  3946. }
  3947. if (this._width.fromString(value)) {
  3948. this._markAsDirty();
  3949. }
  3950. },
  3951. enumerable: true,
  3952. configurable: true
  3953. });
  3954. Object.defineProperty(Control.prototype, "widthInPixels", {
  3955. /**
  3956. * Gets or sets the control width in pixel
  3957. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3958. */
  3959. get: function () {
  3960. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3961. },
  3962. set: function (value) {
  3963. if (isNaN(value)) {
  3964. return;
  3965. }
  3966. this.width = value + "px";
  3967. },
  3968. enumerable: true,
  3969. configurable: true
  3970. });
  3971. Object.defineProperty(Control.prototype, "height", {
  3972. /**
  3973. * Gets or sets control height
  3974. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3975. */
  3976. get: function () {
  3977. return this._height.toString(this._host);
  3978. },
  3979. set: function (value) {
  3980. if (this._height.toString(this._host) === value) {
  3981. return;
  3982. }
  3983. if (this._height.fromString(value)) {
  3984. this._markAsDirty();
  3985. }
  3986. },
  3987. enumerable: true,
  3988. configurable: true
  3989. });
  3990. Object.defineProperty(Control.prototype, "heightInPixels", {
  3991. /**
  3992. * Gets or sets control height in pixel
  3993. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3994. */
  3995. get: function () {
  3996. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  3997. },
  3998. set: function (value) {
  3999. if (isNaN(value)) {
  4000. return;
  4001. }
  4002. this.height = value + "px";
  4003. },
  4004. enumerable: true,
  4005. configurable: true
  4006. });
  4007. Object.defineProperty(Control.prototype, "fontFamily", {
  4008. /** Gets or set font family */
  4009. get: function () {
  4010. if (!this._fontSet) {
  4011. return "";
  4012. }
  4013. return this._fontFamily;
  4014. },
  4015. set: function (value) {
  4016. if (this._fontFamily === value) {
  4017. return;
  4018. }
  4019. this._fontFamily = value;
  4020. this._resetFontCache();
  4021. },
  4022. enumerable: true,
  4023. configurable: true
  4024. });
  4025. Object.defineProperty(Control.prototype, "fontStyle", {
  4026. /** Gets or sets font style */
  4027. get: function () {
  4028. return this._fontStyle;
  4029. },
  4030. set: function (value) {
  4031. if (this._fontStyle === value) {
  4032. return;
  4033. }
  4034. this._fontStyle = value;
  4035. this._resetFontCache();
  4036. },
  4037. enumerable: true,
  4038. configurable: true
  4039. });
  4040. Object.defineProperty(Control.prototype, "fontWeight", {
  4041. /** Gets or sets font weight */
  4042. get: function () {
  4043. return this._fontWeight;
  4044. },
  4045. set: function (value) {
  4046. if (this._fontWeight === value) {
  4047. return;
  4048. }
  4049. this._fontWeight = value;
  4050. this._resetFontCache();
  4051. },
  4052. enumerable: true,
  4053. configurable: true
  4054. });
  4055. Object.defineProperty(Control.prototype, "style", {
  4056. /**
  4057. * Gets or sets style
  4058. * @see http://doc.babylonjs.com/how_to/gui#styles
  4059. */
  4060. get: function () {
  4061. return this._style;
  4062. },
  4063. set: function (value) {
  4064. var _this = this;
  4065. if (this._style) {
  4066. this._style.onChangedObservable.remove(this._styleObserver);
  4067. this._styleObserver = null;
  4068. }
  4069. this._style = value;
  4070. if (this._style) {
  4071. this._styleObserver = this._style.onChangedObservable.add(function () {
  4072. _this._markAsDirty();
  4073. _this._resetFontCache();
  4074. });
  4075. }
  4076. this._markAsDirty();
  4077. this._resetFontCache();
  4078. },
  4079. enumerable: true,
  4080. configurable: true
  4081. });
  4082. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4083. /** @hidden */
  4084. get: function () {
  4085. return this._fontSize.isPercentage;
  4086. },
  4087. enumerable: true,
  4088. configurable: true
  4089. });
  4090. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4091. /** Gets or sets font size in pixels */
  4092. get: function () {
  4093. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4094. if (fontSizeToUse.isPixel) {
  4095. return fontSizeToUse.getValue(this._host);
  4096. }
  4097. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4098. },
  4099. set: function (value) {
  4100. if (isNaN(value)) {
  4101. return;
  4102. }
  4103. this.fontSize = value + "px";
  4104. },
  4105. enumerable: true,
  4106. configurable: true
  4107. });
  4108. Object.defineProperty(Control.prototype, "fontSize", {
  4109. /** Gets or sets font size */
  4110. get: function () {
  4111. return this._fontSize.toString(this._host);
  4112. },
  4113. set: function (value) {
  4114. if (this._fontSize.toString(this._host) === value) {
  4115. return;
  4116. }
  4117. if (this._fontSize.fromString(value)) {
  4118. this._markAsDirty();
  4119. this._resetFontCache();
  4120. }
  4121. },
  4122. enumerable: true,
  4123. configurable: true
  4124. });
  4125. Object.defineProperty(Control.prototype, "color", {
  4126. /** Gets or sets foreground color */
  4127. get: function () {
  4128. return this._color;
  4129. },
  4130. set: function (value) {
  4131. if (this._color === value) {
  4132. return;
  4133. }
  4134. this._color = value;
  4135. this._markAsDirty();
  4136. },
  4137. enumerable: true,
  4138. configurable: true
  4139. });
  4140. Object.defineProperty(Control.prototype, "zIndex", {
  4141. /** Gets or sets z index which is used to reorder controls on the z axis */
  4142. get: function () {
  4143. return this._zIndex;
  4144. },
  4145. set: function (value) {
  4146. if (this.zIndex === value) {
  4147. return;
  4148. }
  4149. this._zIndex = value;
  4150. if (this.parent) {
  4151. this.parent._reOrderControl(this);
  4152. }
  4153. },
  4154. enumerable: true,
  4155. configurable: true
  4156. });
  4157. Object.defineProperty(Control.prototype, "notRenderable", {
  4158. /** Gets or sets a boolean indicating if the control can be rendered */
  4159. get: function () {
  4160. return this._doNotRender;
  4161. },
  4162. set: function (value) {
  4163. if (this._doNotRender === value) {
  4164. return;
  4165. }
  4166. this._doNotRender = value;
  4167. this._markAsDirty();
  4168. },
  4169. enumerable: true,
  4170. configurable: true
  4171. });
  4172. Object.defineProperty(Control.prototype, "isVisible", {
  4173. /** Gets or sets a boolean indicating if the control is visible */
  4174. get: function () {
  4175. return this._isVisible;
  4176. },
  4177. set: function (value) {
  4178. if (this._isVisible === value) {
  4179. return;
  4180. }
  4181. this._isVisible = value;
  4182. this._markAsDirty(true);
  4183. },
  4184. enumerable: true,
  4185. configurable: true
  4186. });
  4187. Object.defineProperty(Control.prototype, "isDirty", {
  4188. /** Gets a boolean indicating that the control needs to update its rendering */
  4189. get: function () {
  4190. return this._isDirty;
  4191. },
  4192. enumerable: true,
  4193. configurable: true
  4194. });
  4195. Object.defineProperty(Control.prototype, "linkedMesh", {
  4196. /**
  4197. * Gets the current linked mesh (or null if none)
  4198. */
  4199. get: function () {
  4200. return this._linkedMesh;
  4201. },
  4202. enumerable: true,
  4203. configurable: true
  4204. });
  4205. Object.defineProperty(Control.prototype, "paddingLeft", {
  4206. /**
  4207. * Gets or sets a value indicating the padding to use on the left of the control
  4208. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4209. */
  4210. get: function () {
  4211. return this._paddingLeft.toString(this._host);
  4212. },
  4213. set: function (value) {
  4214. if (this._paddingLeft.fromString(value)) {
  4215. this._markAsDirty();
  4216. }
  4217. },
  4218. enumerable: true,
  4219. configurable: true
  4220. });
  4221. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4222. /**
  4223. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4224. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4225. */
  4226. get: function () {
  4227. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4228. },
  4229. set: function (value) {
  4230. if (isNaN(value)) {
  4231. return;
  4232. }
  4233. this.paddingLeft = value + "px";
  4234. },
  4235. enumerable: true,
  4236. configurable: true
  4237. });
  4238. Object.defineProperty(Control.prototype, "paddingRight", {
  4239. /**
  4240. * Gets or sets a value indicating the padding to use on the right of the control
  4241. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4242. */
  4243. get: function () {
  4244. return this._paddingRight.toString(this._host);
  4245. },
  4246. set: function (value) {
  4247. if (this._paddingRight.fromString(value)) {
  4248. this._markAsDirty();
  4249. }
  4250. },
  4251. enumerable: true,
  4252. configurable: true
  4253. });
  4254. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4255. /**
  4256. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4257. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4258. */
  4259. get: function () {
  4260. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4261. },
  4262. set: function (value) {
  4263. if (isNaN(value)) {
  4264. return;
  4265. }
  4266. this.paddingRight = value + "px";
  4267. },
  4268. enumerable: true,
  4269. configurable: true
  4270. });
  4271. Object.defineProperty(Control.prototype, "paddingTop", {
  4272. /**
  4273. * Gets or sets a value indicating the padding 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.toString(this._host);
  4278. },
  4279. set: function (value) {
  4280. if (this._paddingTop.fromString(value)) {
  4281. this._markAsDirty();
  4282. }
  4283. },
  4284. enumerable: true,
  4285. configurable: true
  4286. });
  4287. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4288. /**
  4289. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4290. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4291. */
  4292. get: function () {
  4293. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4294. },
  4295. set: function (value) {
  4296. if (isNaN(value)) {
  4297. return;
  4298. }
  4299. this.paddingTop = value + "px";
  4300. },
  4301. enumerable: true,
  4302. configurable: true
  4303. });
  4304. Object.defineProperty(Control.prototype, "paddingBottom", {
  4305. /**
  4306. * Gets or sets a value indicating the padding to use on the bottom of the control
  4307. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4308. */
  4309. get: function () {
  4310. return this._paddingBottom.toString(this._host);
  4311. },
  4312. set: function (value) {
  4313. if (this._paddingBottom.fromString(value)) {
  4314. this._markAsDirty();
  4315. }
  4316. },
  4317. enumerable: true,
  4318. configurable: true
  4319. });
  4320. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4321. /**
  4322. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4323. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4324. */
  4325. get: function () {
  4326. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4327. },
  4328. set: function (value) {
  4329. if (isNaN(value)) {
  4330. return;
  4331. }
  4332. this.paddingBottom = value + "px";
  4333. },
  4334. enumerable: true,
  4335. configurable: true
  4336. });
  4337. Object.defineProperty(Control.prototype, "left", {
  4338. /**
  4339. * Gets or sets a value indicating the left coordinate of the control
  4340. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4341. */
  4342. get: function () {
  4343. return this._left.toString(this._host);
  4344. },
  4345. set: function (value) {
  4346. if (this._left.fromString(value)) {
  4347. this._markAsDirty();
  4348. }
  4349. },
  4350. enumerable: true,
  4351. configurable: true
  4352. });
  4353. Object.defineProperty(Control.prototype, "leftInPixels", {
  4354. /**
  4355. * Gets or sets a value indicating the left coordinate in pixels of the control
  4356. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4357. */
  4358. get: function () {
  4359. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4360. },
  4361. set: function (value) {
  4362. if (isNaN(value)) {
  4363. return;
  4364. }
  4365. this.left = value + "px";
  4366. },
  4367. enumerable: true,
  4368. configurable: true
  4369. });
  4370. Object.defineProperty(Control.prototype, "top", {
  4371. /**
  4372. * Gets or sets a value indicating the top coordinate of the control
  4373. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4374. */
  4375. get: function () {
  4376. return this._top.toString(this._host);
  4377. },
  4378. set: function (value) {
  4379. if (this._top.fromString(value)) {
  4380. this._markAsDirty();
  4381. }
  4382. },
  4383. enumerable: true,
  4384. configurable: true
  4385. });
  4386. Object.defineProperty(Control.prototype, "topInPixels", {
  4387. /**
  4388. * Gets or sets a value indicating the top coordinate in pixels of the control
  4389. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4390. */
  4391. get: function () {
  4392. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4393. },
  4394. set: function (value) {
  4395. if (isNaN(value)) {
  4396. return;
  4397. }
  4398. this.top = value + "px";
  4399. },
  4400. enumerable: true,
  4401. configurable: true
  4402. });
  4403. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4404. /**
  4405. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4406. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4407. */
  4408. get: function () {
  4409. return this._linkOffsetX.toString(this._host);
  4410. },
  4411. set: function (value) {
  4412. if (this._linkOffsetX.fromString(value)) {
  4413. this._markAsDirty();
  4414. }
  4415. },
  4416. enumerable: true,
  4417. configurable: true
  4418. });
  4419. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4420. /**
  4421. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4422. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4423. */
  4424. get: function () {
  4425. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4426. },
  4427. set: function (value) {
  4428. if (isNaN(value)) {
  4429. return;
  4430. }
  4431. this.linkOffsetX = value + "px";
  4432. },
  4433. enumerable: true,
  4434. configurable: true
  4435. });
  4436. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4437. /**
  4438. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4439. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4440. */
  4441. get: function () {
  4442. return this._linkOffsetY.toString(this._host);
  4443. },
  4444. set: function (value) {
  4445. if (this._linkOffsetY.fromString(value)) {
  4446. this._markAsDirty();
  4447. }
  4448. },
  4449. enumerable: true,
  4450. configurable: true
  4451. });
  4452. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4453. /**
  4454. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4455. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4456. */
  4457. get: function () {
  4458. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4459. },
  4460. set: function (value) {
  4461. if (isNaN(value)) {
  4462. return;
  4463. }
  4464. this.linkOffsetY = value + "px";
  4465. },
  4466. enumerable: true,
  4467. configurable: true
  4468. });
  4469. Object.defineProperty(Control.prototype, "centerX", {
  4470. /** Gets the center coordinate on X axis */
  4471. get: function () {
  4472. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4473. },
  4474. enumerable: true,
  4475. configurable: true
  4476. });
  4477. Object.defineProperty(Control.prototype, "centerY", {
  4478. /** Gets the center coordinate on Y axis */
  4479. get: function () {
  4480. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4481. },
  4482. enumerable: true,
  4483. configurable: true
  4484. });
  4485. Object.defineProperty(Control.prototype, "isEnabled", {
  4486. /** Gets or sets if control is Enabled*/
  4487. get: function () {
  4488. return this._isEnabled;
  4489. },
  4490. set: function (value) {
  4491. if (this._isEnabled === value) {
  4492. return;
  4493. }
  4494. this._isEnabled = value;
  4495. this._markAsDirty();
  4496. },
  4497. enumerable: true,
  4498. configurable: true
  4499. });
  4500. Object.defineProperty(Control.prototype, "disabledColor", {
  4501. /** Gets or sets background color of control if it's disabled*/
  4502. get: function () {
  4503. return this._disabledColor;
  4504. },
  4505. set: function (value) {
  4506. if (this._disabledColor === value) {
  4507. return;
  4508. }
  4509. this._disabledColor = value;
  4510. this._markAsDirty();
  4511. },
  4512. enumerable: true,
  4513. configurable: true
  4514. });
  4515. /** @hidden */
  4516. Control.prototype._getTypeName = function () {
  4517. return "Control";
  4518. };
  4519. /**
  4520. * Gets the first ascendant in the hierarchy of the given type
  4521. * @param className defines the required type
  4522. * @returns the ascendant or null if not found
  4523. */
  4524. Control.prototype.getAscendantOfClass = function (className) {
  4525. if (!this.parent) {
  4526. return null;
  4527. }
  4528. if (this.parent.getClassName() === className) {
  4529. return this.parent;
  4530. }
  4531. return this.parent.getAscendantOfClass(className);
  4532. };
  4533. /** @hidden */
  4534. Control.prototype._resetFontCache = function () {
  4535. this._fontSet = true;
  4536. this._markAsDirty();
  4537. };
  4538. /**
  4539. * Determines if a container is an ascendant of the current control
  4540. * @param container defines the container to look for
  4541. * @returns true if the container is one of the ascendant of the control
  4542. */
  4543. Control.prototype.isAscendant = function (container) {
  4544. if (!this.parent) {
  4545. return false;
  4546. }
  4547. if (this.parent === container) {
  4548. return true;
  4549. }
  4550. return this.parent.isAscendant(container);
  4551. };
  4552. /**
  4553. * Gets coordinates in local control space
  4554. * @param globalCoordinates defines the coordinates to transform
  4555. * @returns the new coordinates in local space
  4556. */
  4557. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4558. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4559. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4560. return result;
  4561. };
  4562. /**
  4563. * Gets coordinates in local control space
  4564. * @param globalCoordinates defines the coordinates to transform
  4565. * @param result defines the target vector2 where to store the result
  4566. * @returns the current control
  4567. */
  4568. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4569. result.x = globalCoordinates.x - this._currentMeasure.left;
  4570. result.y = globalCoordinates.y - this._currentMeasure.top;
  4571. return this;
  4572. };
  4573. /**
  4574. * Gets coordinates in parent local control space
  4575. * @param globalCoordinates defines the coordinates to transform
  4576. * @returns the new coordinates in parent local space
  4577. */
  4578. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4579. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4580. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4581. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4582. return result;
  4583. };
  4584. /**
  4585. * Move the current control to a vector3 position projected onto the screen.
  4586. * @param position defines the target position
  4587. * @param scene defines the hosting scene
  4588. */
  4589. Control.prototype.moveToVector3 = function (position, scene) {
  4590. if (!this._host || this.parent !== this._host._rootContainer) {
  4591. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4592. return;
  4593. }
  4594. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4595. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4596. var globalViewport = this._host._getGlobalViewport(scene);
  4597. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4598. this._moveToProjectedPosition(projectedPosition);
  4599. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4600. this.notRenderable = true;
  4601. return;
  4602. }
  4603. this.notRenderable = false;
  4604. };
  4605. /** @hidden */
  4606. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4607. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4608. // Do nothing by default
  4609. };
  4610. /**
  4611. * Will return all controls that have this control as ascendant
  4612. * @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
  4613. * @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
  4614. * @return all child controls
  4615. */
  4616. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4617. var results = new Array();
  4618. this._getDescendants(results, directDescendantsOnly, predicate);
  4619. return results;
  4620. };
  4621. /**
  4622. * Link current control with a target mesh
  4623. * @param mesh defines the mesh to link with
  4624. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4625. */
  4626. Control.prototype.linkWithMesh = function (mesh) {
  4627. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4628. if (mesh) {
  4629. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4630. }
  4631. return;
  4632. }
  4633. var index = this._host._linkedControls.indexOf(this);
  4634. if (index !== -1) {
  4635. this._linkedMesh = mesh;
  4636. if (!mesh) {
  4637. this._host._linkedControls.splice(index, 1);
  4638. }
  4639. return;
  4640. }
  4641. else if (!mesh) {
  4642. return;
  4643. }
  4644. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4645. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4646. this._linkedMesh = mesh;
  4647. this._host._linkedControls.push(this);
  4648. };
  4649. /** @hidden */
  4650. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4651. var oldLeft = this._left.getValue(this._host);
  4652. var oldTop = this._top.getValue(this._host);
  4653. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4654. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4655. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4656. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4657. newLeft = oldLeft;
  4658. }
  4659. if (Math.abs(newTop - oldTop) < 0.5) {
  4660. newTop = oldTop;
  4661. }
  4662. }
  4663. this.left = newLeft + "px";
  4664. this.top = newTop + "px";
  4665. this._left.ignoreAdaptiveScaling = true;
  4666. this._top.ignoreAdaptiveScaling = true;
  4667. this._markAsDirty();
  4668. };
  4669. /** @hidden */
  4670. Control.prototype._offsetLeft = function (offset) {
  4671. this._isDirty = true;
  4672. this._currentMeasure.left += offset;
  4673. };
  4674. /** @hidden */
  4675. Control.prototype._offsetTop = function (offset) {
  4676. this._isDirty = true;
  4677. this._currentMeasure.top += offset;
  4678. };
  4679. /** @hidden */
  4680. Control.prototype._markMatrixAsDirty = function () {
  4681. this._isMatrixDirty = true;
  4682. this._flagDescendantsAsMatrixDirty();
  4683. };
  4684. /** @hidden */
  4685. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4686. // No child
  4687. };
  4688. /** @hidden */
  4689. Control.prototype._intersectsRect = function (rect) {
  4690. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4691. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4692. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4693. return false;
  4694. }
  4695. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4696. return false;
  4697. }
  4698. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4699. return false;
  4700. }
  4701. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4702. return false;
  4703. }
  4704. return true;
  4705. };
  4706. /** @hidden */
  4707. Control.prototype.invalidateRect = function () {
  4708. this._transform();
  4709. if (this.host && this.host.useInvalidateRectOptimization) {
  4710. // Rotate by transform to get the measure transformed to global space
  4711. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4712. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4713. // the previous measure is used to properly clear a control that is scaled down
  4714. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4715. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4716. // Expand rect based on shadows
  4717. var shadowOffsetX = this.shadowOffsetX;
  4718. var shadowOffsetY = this.shadowOffsetY;
  4719. var shadowBlur = this.shadowBlur;
  4720. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4721. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4722. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4723. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4724. 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));
  4725. }
  4726. else {
  4727. 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));
  4728. }
  4729. }
  4730. };
  4731. /** @hidden */
  4732. Control.prototype._markAsDirty = function (force) {
  4733. if (force === void 0) { force = false; }
  4734. if (!this._isVisible && !force) {
  4735. return;
  4736. }
  4737. this._isDirty = true;
  4738. // Redraw only this rectangle
  4739. if (this._host) {
  4740. this._host.markAsDirty();
  4741. }
  4742. };
  4743. /** @hidden */
  4744. Control.prototype._markAllAsDirty = function () {
  4745. this._markAsDirty();
  4746. if (this._font) {
  4747. this._prepareFont();
  4748. }
  4749. };
  4750. /** @hidden */
  4751. Control.prototype._link = function (host) {
  4752. this._host = host;
  4753. if (this._host) {
  4754. this.uniqueId = this._host.getScene().getUniqueId();
  4755. }
  4756. };
  4757. /** @hidden */
  4758. Control.prototype._transform = function (context) {
  4759. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4760. return;
  4761. }
  4762. // postTranslate
  4763. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4764. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4765. if (context) {
  4766. context.translate(offsetX, offsetY);
  4767. // rotate
  4768. context.rotate(this._rotation);
  4769. // scale
  4770. context.scale(this._scaleX, this._scaleY);
  4771. // preTranslate
  4772. context.translate(-offsetX, -offsetY);
  4773. }
  4774. // Need to update matrices?
  4775. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4776. this._cachedOffsetX = offsetX;
  4777. this._cachedOffsetY = offsetY;
  4778. this._isMatrixDirty = false;
  4779. this._flagDescendantsAsMatrixDirty();
  4780. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4781. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4782. }
  4783. };
  4784. /** @hidden */
  4785. Control.prototype._renderHighlight = function (context) {
  4786. if (!this.isHighlighted) {
  4787. return;
  4788. }
  4789. context.save();
  4790. context.strokeStyle = "#4affff";
  4791. context.lineWidth = 2;
  4792. this._renderHighlightSpecific(context);
  4793. context.restore();
  4794. };
  4795. /** @hidden */
  4796. Control.prototype._renderHighlightSpecific = function (context) {
  4797. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4798. };
  4799. /** @hidden */
  4800. Control.prototype._applyStates = function (context) {
  4801. if (this._isFontSizeInPercentage) {
  4802. this._fontSet = true;
  4803. }
  4804. if (this._fontSet) {
  4805. this._prepareFont();
  4806. this._fontSet = false;
  4807. }
  4808. if (this._font) {
  4809. context.font = this._font;
  4810. }
  4811. if (this._color) {
  4812. context.fillStyle = this._color;
  4813. }
  4814. if (Control.AllowAlphaInheritance) {
  4815. context.globalAlpha *= this._alpha;
  4816. }
  4817. else if (this._alphaSet) {
  4818. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4819. }
  4820. };
  4821. /** @hidden */
  4822. Control.prototype._layout = function (parentMeasure, context) {
  4823. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4824. return false;
  4825. }
  4826. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4827. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4828. context.save();
  4829. this._applyStates(context);
  4830. var rebuildCount = 0;
  4831. do {
  4832. this._rebuildLayout = false;
  4833. this._processMeasures(parentMeasure, context);
  4834. rebuildCount++;
  4835. } while (this._rebuildLayout && rebuildCount < 3);
  4836. if (rebuildCount >= 3) {
  4837. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4838. }
  4839. context.restore();
  4840. this.invalidateRect();
  4841. this._evaluateClippingState(parentMeasure);
  4842. }
  4843. this._wasDirty = this._isDirty;
  4844. this._isDirty = false;
  4845. return true;
  4846. };
  4847. /** @hidden */
  4848. Control.prototype._processMeasures = function (parentMeasure, context) {
  4849. this._currentMeasure.copyFrom(parentMeasure);
  4850. // Let children take some pre-measurement actions
  4851. this._preMeasure(parentMeasure, context);
  4852. this._measure();
  4853. this._computeAlignment(parentMeasure, context);
  4854. // Convert to int values
  4855. this._currentMeasure.left = this._currentMeasure.left | 0;
  4856. this._currentMeasure.top = this._currentMeasure.top | 0;
  4857. this._currentMeasure.width = this._currentMeasure.width | 0;
  4858. this._currentMeasure.height = this._currentMeasure.height | 0;
  4859. // Let children add more features
  4860. this._additionalProcessing(parentMeasure, context);
  4861. this._cachedParentMeasure.copyFrom(parentMeasure);
  4862. if (this.onDirtyObservable.hasObservers()) {
  4863. this.onDirtyObservable.notifyObservers(this);
  4864. }
  4865. };
  4866. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4867. if (this.parent && this.parent.clipChildren) {
  4868. // Early clip
  4869. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4870. this._isClipped = true;
  4871. return;
  4872. }
  4873. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4874. this._isClipped = true;
  4875. return;
  4876. }
  4877. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4878. this._isClipped = true;
  4879. return;
  4880. }
  4881. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4882. this._isClipped = true;
  4883. return;
  4884. }
  4885. }
  4886. this._isClipped = false;
  4887. };
  4888. /** @hidden */
  4889. Control.prototype._measure = function () {
  4890. // Width / Height
  4891. if (this._width.isPixel) {
  4892. this._currentMeasure.width = this._width.getValue(this._host);
  4893. }
  4894. else {
  4895. this._currentMeasure.width *= this._width.getValue(this._host);
  4896. }
  4897. if (this._height.isPixel) {
  4898. this._currentMeasure.height = this._height.getValue(this._host);
  4899. }
  4900. else {
  4901. this._currentMeasure.height *= this._height.getValue(this._host);
  4902. }
  4903. };
  4904. /** @hidden */
  4905. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4906. var width = this._currentMeasure.width;
  4907. var height = this._currentMeasure.height;
  4908. var parentWidth = parentMeasure.width;
  4909. var parentHeight = parentMeasure.height;
  4910. // Left / top
  4911. var x = 0;
  4912. var y = 0;
  4913. switch (this.horizontalAlignment) {
  4914. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4915. x = 0;
  4916. break;
  4917. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4918. x = parentWidth - width;
  4919. break;
  4920. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4921. x = (parentWidth - width) / 2;
  4922. break;
  4923. }
  4924. switch (this.verticalAlignment) {
  4925. case Control.VERTICAL_ALIGNMENT_TOP:
  4926. y = 0;
  4927. break;
  4928. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4929. y = parentHeight - height;
  4930. break;
  4931. case Control.VERTICAL_ALIGNMENT_CENTER:
  4932. y = (parentHeight - height) / 2;
  4933. break;
  4934. }
  4935. if (this._paddingLeft.isPixel) {
  4936. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4937. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4938. }
  4939. else {
  4940. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4941. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4942. }
  4943. if (this._paddingRight.isPixel) {
  4944. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4945. }
  4946. else {
  4947. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4948. }
  4949. if (this._paddingTop.isPixel) {
  4950. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4951. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4952. }
  4953. else {
  4954. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4955. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4956. }
  4957. if (this._paddingBottom.isPixel) {
  4958. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4959. }
  4960. else {
  4961. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4962. }
  4963. if (this._left.isPixel) {
  4964. this._currentMeasure.left += this._left.getValue(this._host);
  4965. }
  4966. else {
  4967. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4968. }
  4969. if (this._top.isPixel) {
  4970. this._currentMeasure.top += this._top.getValue(this._host);
  4971. }
  4972. else {
  4973. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4974. }
  4975. this._currentMeasure.left += x;
  4976. this._currentMeasure.top += y;
  4977. };
  4978. /** @hidden */
  4979. Control.prototype._preMeasure = function (parentMeasure, context) {
  4980. // Do nothing
  4981. };
  4982. /** @hidden */
  4983. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4984. // Do nothing
  4985. };
  4986. /** @hidden */
  4987. Control.prototype._clipForChildren = function (context) {
  4988. // DO nothing
  4989. };
  4990. Control.prototype._clip = function (context, invalidatedRectangle) {
  4991. context.beginPath();
  4992. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4993. if (invalidatedRectangle) {
  4994. // Rotate the invalidated rect into the control's space
  4995. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4996. // Get the intersection of the rect in context space and the current context
  4997. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4998. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4999. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5000. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5001. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5002. Control._ClipMeasure.copyFrom(intersection);
  5003. }
  5004. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5005. var shadowOffsetX = this.shadowOffsetX;
  5006. var shadowOffsetY = this.shadowOffsetY;
  5007. var shadowBlur = this.shadowBlur;
  5008. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5009. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5010. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5011. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5012. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5013. }
  5014. else {
  5015. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5016. }
  5017. context.clip();
  5018. };
  5019. /** @hidden */
  5020. Control.prototype._render = function (context, invalidatedRectangle) {
  5021. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5022. this._isDirty = false;
  5023. return false;
  5024. }
  5025. context.save();
  5026. this._applyStates(context);
  5027. // Transform
  5028. this._transform(context);
  5029. // Clip
  5030. if (this.clipContent) {
  5031. this._clip(context, invalidatedRectangle);
  5032. }
  5033. if (this.onBeforeDrawObservable.hasObservers()) {
  5034. this.onBeforeDrawObservable.notifyObservers(this);
  5035. }
  5036. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5037. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5038. }
  5039. else {
  5040. this._draw(context, invalidatedRectangle);
  5041. }
  5042. if (this.useBitmapCache && this._wasDirty) {
  5043. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5044. }
  5045. this._renderHighlight(context);
  5046. if (this.onAfterDrawObservable.hasObservers()) {
  5047. this.onAfterDrawObservable.notifyObservers(this);
  5048. }
  5049. context.restore();
  5050. return true;
  5051. };
  5052. /** @hidden */
  5053. Control.prototype._draw = function (context, invalidatedRectangle) {
  5054. // Do nothing
  5055. };
  5056. /**
  5057. * Tests if a given coordinates belong to the current control
  5058. * @param x defines x coordinate to test
  5059. * @param y defines y coordinate to test
  5060. * @returns true if the coordinates are inside the control
  5061. */
  5062. Control.prototype.contains = function (x, y) {
  5063. // Invert transform
  5064. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5065. x = this._transformedPosition.x;
  5066. y = this._transformedPosition.y;
  5067. // Check
  5068. if (x < this._currentMeasure.left) {
  5069. return false;
  5070. }
  5071. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5072. return false;
  5073. }
  5074. if (y < this._currentMeasure.top) {
  5075. return false;
  5076. }
  5077. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5078. return false;
  5079. }
  5080. if (this.isPointerBlocker) {
  5081. this._host._shouldBlockPointer = true;
  5082. }
  5083. return true;
  5084. };
  5085. /** @hidden */
  5086. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5087. if (!this._isEnabled) {
  5088. return false;
  5089. }
  5090. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5091. return false;
  5092. }
  5093. if (!this.contains(x, y)) {
  5094. return false;
  5095. }
  5096. this._processObservables(type, x, y, pointerId, buttonIndex);
  5097. return true;
  5098. };
  5099. /** @hidden */
  5100. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5101. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5102. if (canNotify && this.parent != null) {
  5103. this.parent._onPointerMove(target, coordinates, pointerId);
  5104. }
  5105. };
  5106. /** @hidden */
  5107. Control.prototype._onPointerEnter = function (target) {
  5108. if (!this._isEnabled) {
  5109. return false;
  5110. }
  5111. if (this._enterCount > 0) {
  5112. return false;
  5113. }
  5114. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5115. this._enterCount = 0;
  5116. }
  5117. this._enterCount++;
  5118. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5119. if (canNotify && this.parent != null) {
  5120. this.parent._onPointerEnter(target);
  5121. }
  5122. return true;
  5123. };
  5124. /** @hidden */
  5125. Control.prototype._onPointerOut = function (target, force) {
  5126. if (force === void 0) { force = false; }
  5127. if (!force && (!this._isEnabled || target === this)) {
  5128. return;
  5129. }
  5130. this._enterCount = 0;
  5131. var canNotify = true;
  5132. if (!target.isAscendant(this)) {
  5133. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5134. }
  5135. if (canNotify && this.parent != null) {
  5136. this.parent._onPointerOut(target, force);
  5137. }
  5138. };
  5139. /** @hidden */
  5140. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5141. // Prevent pointerout to lose control context.
  5142. // Event redundancy is checked inside the function.
  5143. this._onPointerEnter(this);
  5144. if (this._downCount !== 0) {
  5145. return false;
  5146. }
  5147. this._downCount++;
  5148. this._downPointerIds[pointerId] = true;
  5149. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5150. if (canNotify && this.parent != null) {
  5151. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5152. }
  5153. return true;
  5154. };
  5155. /** @hidden */
  5156. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5157. if (!this._isEnabled) {
  5158. return;
  5159. }
  5160. this._downCount = 0;
  5161. delete this._downPointerIds[pointerId];
  5162. var canNotifyClick = notifyClick;
  5163. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5164. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5165. }
  5166. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5167. if (canNotify && this.parent != null) {
  5168. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5169. }
  5170. };
  5171. /** @hidden */
  5172. Control.prototype._forcePointerUp = function (pointerId) {
  5173. if (pointerId === void 0) { pointerId = null; }
  5174. if (pointerId !== null) {
  5175. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5176. }
  5177. else {
  5178. for (var key in this._downPointerIds) {
  5179. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5180. }
  5181. }
  5182. };
  5183. /** @hidden */
  5184. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5185. if (!this._isEnabled) {
  5186. return false;
  5187. }
  5188. this._dummyVector2.copyFromFloats(x, y);
  5189. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5190. this._onPointerMove(this, this._dummyVector2, pointerId);
  5191. var previousControlOver = this._host._lastControlOver[pointerId];
  5192. if (previousControlOver && previousControlOver !== this) {
  5193. previousControlOver._onPointerOut(this);
  5194. }
  5195. if (previousControlOver !== this) {
  5196. this._onPointerEnter(this);
  5197. }
  5198. this._host._lastControlOver[pointerId] = this;
  5199. return true;
  5200. }
  5201. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5202. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5203. this._host._registerLastControlDown(this, pointerId);
  5204. this._host._lastPickedControl = this;
  5205. return true;
  5206. }
  5207. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5208. if (this._host._lastControlDown[pointerId]) {
  5209. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5210. }
  5211. delete this._host._lastControlDown[pointerId];
  5212. return true;
  5213. }
  5214. return false;
  5215. };
  5216. Control.prototype._prepareFont = function () {
  5217. if (!this._font && !this._fontSet) {
  5218. return;
  5219. }
  5220. if (this._style) {
  5221. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5222. }
  5223. else {
  5224. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5225. }
  5226. this._fontOffset = Control._GetFontOffset(this._font);
  5227. };
  5228. /** Releases associated resources */
  5229. Control.prototype.dispose = function () {
  5230. this.onDirtyObservable.clear();
  5231. this.onBeforeDrawObservable.clear();
  5232. this.onAfterDrawObservable.clear();
  5233. this.onPointerDownObservable.clear();
  5234. this.onPointerEnterObservable.clear();
  5235. this.onPointerMoveObservable.clear();
  5236. this.onPointerOutObservable.clear();
  5237. this.onPointerUpObservable.clear();
  5238. this.onPointerClickObservable.clear();
  5239. if (this._styleObserver && this._style) {
  5240. this._style.onChangedObservable.remove(this._styleObserver);
  5241. this._styleObserver = null;
  5242. }
  5243. if (this.parent) {
  5244. this.parent.removeControl(this);
  5245. this.parent = null;
  5246. }
  5247. if (this._host) {
  5248. var index = this._host._linkedControls.indexOf(this);
  5249. if (index > -1) {
  5250. this.linkWithMesh(null);
  5251. }
  5252. }
  5253. };
  5254. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5255. /** HORIZONTAL_ALIGNMENT_LEFT */
  5256. get: function () {
  5257. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5258. },
  5259. enumerable: true,
  5260. configurable: true
  5261. });
  5262. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5263. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5264. get: function () {
  5265. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5266. },
  5267. enumerable: true,
  5268. configurable: true
  5269. });
  5270. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5271. /** HORIZONTAL_ALIGNMENT_CENTER */
  5272. get: function () {
  5273. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5274. },
  5275. enumerable: true,
  5276. configurable: true
  5277. });
  5278. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5279. /** VERTICAL_ALIGNMENT_TOP */
  5280. get: function () {
  5281. return Control._VERTICAL_ALIGNMENT_TOP;
  5282. },
  5283. enumerable: true,
  5284. configurable: true
  5285. });
  5286. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5287. /** VERTICAL_ALIGNMENT_BOTTOM */
  5288. get: function () {
  5289. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5290. },
  5291. enumerable: true,
  5292. configurable: true
  5293. });
  5294. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5295. /** VERTICAL_ALIGNMENT_CENTER */
  5296. get: function () {
  5297. return Control._VERTICAL_ALIGNMENT_CENTER;
  5298. },
  5299. enumerable: true,
  5300. configurable: true
  5301. });
  5302. /** @hidden */
  5303. Control._GetFontOffset = function (font) {
  5304. if (Control._FontHeightSizes[font]) {
  5305. return Control._FontHeightSizes[font];
  5306. }
  5307. var text = document.createElement("span");
  5308. text.innerHTML = "Hg";
  5309. text.style.font = font;
  5310. var block = document.createElement("div");
  5311. block.style.display = "inline-block";
  5312. block.style.width = "1px";
  5313. block.style.height = "0px";
  5314. block.style.verticalAlign = "bottom";
  5315. var div = document.createElement("div");
  5316. div.appendChild(text);
  5317. div.appendChild(block);
  5318. document.body.appendChild(div);
  5319. var fontAscent = 0;
  5320. var fontHeight = 0;
  5321. try {
  5322. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5323. block.style.verticalAlign = "baseline";
  5324. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5325. }
  5326. finally {
  5327. document.body.removeChild(div);
  5328. }
  5329. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5330. Control._FontHeightSizes[font] = result;
  5331. return result;
  5332. };
  5333. /** @hidden */
  5334. Control.drawEllipse = function (x, y, width, height, context) {
  5335. context.translate(x, y);
  5336. context.scale(width, height);
  5337. context.beginPath();
  5338. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5339. context.closePath();
  5340. context.scale(1 / width, 1 / height);
  5341. context.translate(-x, -y);
  5342. };
  5343. /**
  5344. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5345. */
  5346. Control.AllowAlphaInheritance = false;
  5347. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5348. // Statics
  5349. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5350. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5351. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5352. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5353. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5354. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5355. Control._FontHeightSizes = {};
  5356. /**
  5357. * Creates a stack panel that can be used to render headers
  5358. * @param control defines the control to associate with the header
  5359. * @param text defines the text of the header
  5360. * @param size defines the size of the header
  5361. * @param options defines options used to configure the header
  5362. * @returns a new StackPanel
  5363. * @ignore
  5364. * @hidden
  5365. */
  5366. Control.AddHeader = function () { };
  5367. return Control;
  5368. }());
  5369. /***/ }),
  5370. /***/ "./2D/controls/displayGrid.ts":
  5371. /*!************************************!*\
  5372. !*** ./2D/controls/displayGrid.ts ***!
  5373. \************************************/
  5374. /*! exports provided: DisplayGrid */
  5375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5376. "use strict";
  5377. __webpack_require__.r(__webpack_exports__);
  5378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5380. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5381. /** Class used to render a grid */
  5382. var DisplayGrid = /** @class */ (function (_super) {
  5383. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5384. /**
  5385. * Creates a new GridDisplayRectangle
  5386. * @param name defines the control name
  5387. */
  5388. function DisplayGrid(name) {
  5389. var _this = _super.call(this, name) || this;
  5390. _this.name = name;
  5391. _this._cellWidth = 20;
  5392. _this._cellHeight = 20;
  5393. _this._minorLineTickness = 1;
  5394. _this._minorLineColor = "DarkGray";
  5395. _this._majorLineTickness = 2;
  5396. _this._majorLineColor = "White";
  5397. _this._majorLineFrequency = 5;
  5398. _this._background = "Black";
  5399. _this._displayMajorLines = true;
  5400. _this._displayMinorLines = true;
  5401. return _this;
  5402. }
  5403. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5404. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5405. get: function () {
  5406. return this._displayMinorLines;
  5407. },
  5408. set: function (value) {
  5409. if (this._displayMinorLines === value) {
  5410. return;
  5411. }
  5412. this._displayMinorLines = value;
  5413. this._markAsDirty();
  5414. },
  5415. enumerable: true,
  5416. configurable: true
  5417. });
  5418. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5419. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5420. get: function () {
  5421. return this._displayMajorLines;
  5422. },
  5423. set: function (value) {
  5424. if (this._displayMajorLines === value) {
  5425. return;
  5426. }
  5427. this._displayMajorLines = value;
  5428. this._markAsDirty();
  5429. },
  5430. enumerable: true,
  5431. configurable: true
  5432. });
  5433. Object.defineProperty(DisplayGrid.prototype, "background", {
  5434. /** Gets or sets background color (Black by default) */
  5435. get: function () {
  5436. return this._background;
  5437. },
  5438. set: function (value) {
  5439. if (this._background === value) {
  5440. return;
  5441. }
  5442. this._background = value;
  5443. this._markAsDirty();
  5444. },
  5445. enumerable: true,
  5446. configurable: true
  5447. });
  5448. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5449. /** Gets or sets the width of each cell (20 by default) */
  5450. get: function () {
  5451. return this._cellWidth;
  5452. },
  5453. set: function (value) {
  5454. this._cellWidth = value;
  5455. this._markAsDirty();
  5456. },
  5457. enumerable: true,
  5458. configurable: true
  5459. });
  5460. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5461. /** Gets or sets the height of each cell (20 by default) */
  5462. get: function () {
  5463. return this._cellHeight;
  5464. },
  5465. set: function (value) {
  5466. this._cellHeight = value;
  5467. this._markAsDirty();
  5468. },
  5469. enumerable: true,
  5470. configurable: true
  5471. });
  5472. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5473. /** Gets or sets the tickness of minor lines (1 by default) */
  5474. get: function () {
  5475. return this._minorLineTickness;
  5476. },
  5477. set: function (value) {
  5478. this._minorLineTickness = value;
  5479. this._markAsDirty();
  5480. },
  5481. enumerable: true,
  5482. configurable: true
  5483. });
  5484. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5485. /** Gets or sets the color of minor lines (DarkGray by default) */
  5486. get: function () {
  5487. return this._minorLineColor;
  5488. },
  5489. set: function (value) {
  5490. this._minorLineColor = value;
  5491. this._markAsDirty();
  5492. },
  5493. enumerable: true,
  5494. configurable: true
  5495. });
  5496. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5497. /** Gets or sets the tickness of major lines (2 by default) */
  5498. get: function () {
  5499. return this._majorLineTickness;
  5500. },
  5501. set: function (value) {
  5502. this._majorLineTickness = value;
  5503. this._markAsDirty();
  5504. },
  5505. enumerable: true,
  5506. configurable: true
  5507. });
  5508. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5509. /** Gets or sets the color of major lines (White by default) */
  5510. get: function () {
  5511. return this._majorLineColor;
  5512. },
  5513. set: function (value) {
  5514. this._majorLineColor = value;
  5515. this._markAsDirty();
  5516. },
  5517. enumerable: true,
  5518. configurable: true
  5519. });
  5520. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5521. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5522. get: function () {
  5523. return this._majorLineFrequency;
  5524. },
  5525. set: function (value) {
  5526. this._majorLineFrequency = value;
  5527. this._markAsDirty();
  5528. },
  5529. enumerable: true,
  5530. configurable: true
  5531. });
  5532. DisplayGrid.prototype._draw = function (context) {
  5533. context.save();
  5534. this._applyStates(context);
  5535. if (this._isEnabled) {
  5536. if (this._background) {
  5537. context.fillStyle = this._background;
  5538. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5539. }
  5540. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5541. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5542. // Minor lines
  5543. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5544. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5545. if (this._displayMinorLines) {
  5546. context.strokeStyle = this._minorLineColor;
  5547. context.lineWidth = this._minorLineTickness;
  5548. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5549. var cellX = left + x * this.cellWidth;
  5550. context.beginPath();
  5551. context.moveTo(cellX, this._currentMeasure.top);
  5552. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5553. context.stroke();
  5554. }
  5555. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5556. var cellY = top_1 + y * this.cellHeight;
  5557. context.beginPath();
  5558. context.moveTo(this._currentMeasure.left, cellY);
  5559. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5560. context.stroke();
  5561. }
  5562. }
  5563. // Major lines
  5564. if (this._displayMajorLines) {
  5565. context.strokeStyle = this._majorLineColor;
  5566. context.lineWidth = this._majorLineTickness;
  5567. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5568. var cellX = left + x * this.cellWidth;
  5569. context.beginPath();
  5570. context.moveTo(cellX, this._currentMeasure.top);
  5571. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5572. context.stroke();
  5573. }
  5574. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5575. var cellY = top_1 + y * this.cellHeight;
  5576. context.moveTo(this._currentMeasure.left, cellY);
  5577. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5578. context.closePath();
  5579. context.stroke();
  5580. }
  5581. }
  5582. }
  5583. context.restore();
  5584. };
  5585. DisplayGrid.prototype._getTypeName = function () {
  5586. return "DisplayGrid";
  5587. };
  5588. return DisplayGrid;
  5589. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5590. /***/ }),
  5591. /***/ "./2D/controls/ellipse.ts":
  5592. /*!********************************!*\
  5593. !*** ./2D/controls/ellipse.ts ***!
  5594. \********************************/
  5595. /*! exports provided: Ellipse */
  5596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5597. "use strict";
  5598. __webpack_require__.r(__webpack_exports__);
  5599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5600. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5601. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5602. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5603. /** Class used to create 2D ellipse containers */
  5604. var Ellipse = /** @class */ (function (_super) {
  5605. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5606. /**
  5607. * Creates a new Ellipse
  5608. * @param name defines the control name
  5609. */
  5610. function Ellipse(name) {
  5611. var _this = _super.call(this, name) || this;
  5612. _this.name = name;
  5613. _this._thickness = 1;
  5614. return _this;
  5615. }
  5616. Object.defineProperty(Ellipse.prototype, "thickness", {
  5617. /** Gets or sets border thickness */
  5618. get: function () {
  5619. return this._thickness;
  5620. },
  5621. set: function (value) {
  5622. if (this._thickness === value) {
  5623. return;
  5624. }
  5625. this._thickness = value;
  5626. this._markAsDirty();
  5627. },
  5628. enumerable: true,
  5629. configurable: true
  5630. });
  5631. Ellipse.prototype._getTypeName = function () {
  5632. return "Ellipse";
  5633. };
  5634. Ellipse.prototype._localDraw = function (context) {
  5635. context.save();
  5636. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5637. context.shadowColor = this.shadowColor;
  5638. context.shadowBlur = this.shadowBlur;
  5639. context.shadowOffsetX = this.shadowOffsetX;
  5640. context.shadowOffsetY = this.shadowOffsetY;
  5641. }
  5642. _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);
  5643. if (this._background) {
  5644. context.fillStyle = this._background;
  5645. context.fill();
  5646. }
  5647. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5648. context.shadowBlur = 0;
  5649. context.shadowOffsetX = 0;
  5650. context.shadowOffsetY = 0;
  5651. }
  5652. if (this._thickness) {
  5653. if (this.color) {
  5654. context.strokeStyle = this.color;
  5655. }
  5656. context.lineWidth = this._thickness;
  5657. context.stroke();
  5658. }
  5659. context.restore();
  5660. };
  5661. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5662. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5663. this._measureForChildren.width -= 2 * this._thickness;
  5664. this._measureForChildren.height -= 2 * this._thickness;
  5665. this._measureForChildren.left += this._thickness;
  5666. this._measureForChildren.top += this._thickness;
  5667. };
  5668. Ellipse.prototype._clipForChildren = function (context) {
  5669. _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);
  5670. context.clip();
  5671. };
  5672. return Ellipse;
  5673. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5674. /***/ }),
  5675. /***/ "./2D/controls/grid.ts":
  5676. /*!*****************************!*\
  5677. !*** ./2D/controls/grid.ts ***!
  5678. \*****************************/
  5679. /*! exports provided: Grid */
  5680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5681. "use strict";
  5682. __webpack_require__.r(__webpack_exports__);
  5683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5684. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5685. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5686. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5687. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5688. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5689. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5690. /**
  5691. * Class used to create a 2D grid container
  5692. */
  5693. var Grid = /** @class */ (function (_super) {
  5694. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5695. /**
  5696. * Creates a new Grid
  5697. * @param name defines control name
  5698. */
  5699. function Grid(name) {
  5700. var _this = _super.call(this, name) || this;
  5701. _this.name = name;
  5702. _this._rowDefinitions = new Array();
  5703. _this._columnDefinitions = new Array();
  5704. _this._cells = {};
  5705. _this._childControls = new Array();
  5706. return _this;
  5707. }
  5708. Object.defineProperty(Grid.prototype, "columnCount", {
  5709. /**
  5710. * Gets the number of columns
  5711. */
  5712. get: function () {
  5713. return this._columnDefinitions.length;
  5714. },
  5715. enumerable: true,
  5716. configurable: true
  5717. });
  5718. Object.defineProperty(Grid.prototype, "rowCount", {
  5719. /**
  5720. * Gets the number of rows
  5721. */
  5722. get: function () {
  5723. return this._rowDefinitions.length;
  5724. },
  5725. enumerable: true,
  5726. configurable: true
  5727. });
  5728. Object.defineProperty(Grid.prototype, "children", {
  5729. /** Gets the list of children */
  5730. get: function () {
  5731. return this._childControls;
  5732. },
  5733. enumerable: true,
  5734. configurable: true
  5735. });
  5736. Object.defineProperty(Grid.prototype, "cells", {
  5737. /** Gets the list of cells (e.g. the containers) */
  5738. get: function () {
  5739. return this._cells;
  5740. },
  5741. enumerable: true,
  5742. configurable: true
  5743. });
  5744. /**
  5745. * Gets the definition of a specific row
  5746. * @param index defines the index of the row
  5747. * @returns the row definition
  5748. */
  5749. Grid.prototype.getRowDefinition = function (index) {
  5750. if (index < 0 || index >= this._rowDefinitions.length) {
  5751. return null;
  5752. }
  5753. return this._rowDefinitions[index];
  5754. };
  5755. /**
  5756. * Gets the definition of a specific column
  5757. * @param index defines the index of the column
  5758. * @returns the column definition
  5759. */
  5760. Grid.prototype.getColumnDefinition = function (index) {
  5761. if (index < 0 || index >= this._columnDefinitions.length) {
  5762. return null;
  5763. }
  5764. return this._columnDefinitions[index];
  5765. };
  5766. /**
  5767. * Adds a new row to the grid
  5768. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5769. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5770. * @returns the current grid
  5771. */
  5772. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5773. if (isPixel === void 0) { isPixel = false; }
  5774. 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));
  5775. this._markAsDirty();
  5776. return this;
  5777. };
  5778. /**
  5779. * Adds a new column to the grid
  5780. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5781. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5782. * @returns the current grid
  5783. */
  5784. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5785. if (isPixel === void 0) { isPixel = false; }
  5786. 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));
  5787. this._markAsDirty();
  5788. return this;
  5789. };
  5790. /**
  5791. * Update a row definition
  5792. * @param index defines the index of the row to update
  5793. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5794. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5795. * @returns the current grid
  5796. */
  5797. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5798. if (isPixel === void 0) { isPixel = false; }
  5799. if (index < 0 || index >= this._rowDefinitions.length) {
  5800. return this;
  5801. }
  5802. var current = this._rowDefinitions[index];
  5803. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5804. return this;
  5805. }
  5806. 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);
  5807. this._markAsDirty();
  5808. return this;
  5809. };
  5810. /**
  5811. * Update a column definition
  5812. * @param index defines the index of the column to update
  5813. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5814. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5815. * @returns the current grid
  5816. */
  5817. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5818. if (isPixel === void 0) { isPixel = false; }
  5819. if (index < 0 || index >= this._columnDefinitions.length) {
  5820. return this;
  5821. }
  5822. var current = this._columnDefinitions[index];
  5823. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5824. return this;
  5825. }
  5826. 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);
  5827. this._markAsDirty();
  5828. return this;
  5829. };
  5830. /**
  5831. * Gets the list of children stored in a specific cell
  5832. * @param row defines the row to check
  5833. * @param column defines the column to check
  5834. * @returns the list of controls
  5835. */
  5836. Grid.prototype.getChildrenAt = function (row, column) {
  5837. var cell = this._cells[row + ":" + column];
  5838. if (!cell) {
  5839. return null;
  5840. }
  5841. return cell.children;
  5842. };
  5843. /**
  5844. * Gets a string representing the child cell info (row x column)
  5845. * @param child defines the control to get info from
  5846. * @returns a string containing the child cell info (row x column)
  5847. */
  5848. Grid.prototype.getChildCellInfo = function (child) {
  5849. return child._tag;
  5850. };
  5851. Grid.prototype._removeCell = function (cell, key) {
  5852. if (!cell) {
  5853. return;
  5854. }
  5855. _super.prototype.removeControl.call(this, cell);
  5856. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5857. var control = _a[_i];
  5858. var childIndex = this._childControls.indexOf(control);
  5859. if (childIndex !== -1) {
  5860. this._childControls.splice(childIndex, 1);
  5861. }
  5862. }
  5863. delete this._cells[key];
  5864. };
  5865. Grid.prototype._offsetCell = function (previousKey, key) {
  5866. if (!this._cells[key]) {
  5867. return;
  5868. }
  5869. this._cells[previousKey] = this._cells[key];
  5870. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5871. var control = _a[_i];
  5872. control._tag = previousKey;
  5873. }
  5874. delete this._cells[key];
  5875. };
  5876. /**
  5877. * Remove a column definition at specified index
  5878. * @param index defines the index of the column to remove
  5879. * @returns the current grid
  5880. */
  5881. Grid.prototype.removeColumnDefinition = function (index) {
  5882. if (index < 0 || index >= this._columnDefinitions.length) {
  5883. return this;
  5884. }
  5885. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5886. var key = x + ":" + index;
  5887. var cell = this._cells[key];
  5888. this._removeCell(cell, key);
  5889. }
  5890. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5891. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5892. var previousKey = x + ":" + (y - 1);
  5893. var key = x + ":" + y;
  5894. this._offsetCell(previousKey, key);
  5895. }
  5896. }
  5897. this._columnDefinitions.splice(index, 1);
  5898. this._markAsDirty();
  5899. return this;
  5900. };
  5901. /**
  5902. * Remove a row definition at specified index
  5903. * @param index defines the index of the row to remove
  5904. * @returns the current grid
  5905. */
  5906. Grid.prototype.removeRowDefinition = function (index) {
  5907. if (index < 0 || index >= this._rowDefinitions.length) {
  5908. return this;
  5909. }
  5910. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5911. var key = index + ":" + y;
  5912. var cell = this._cells[key];
  5913. this._removeCell(cell, key);
  5914. }
  5915. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5916. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5917. var previousKey = x - 1 + ":" + y;
  5918. var key = x + ":" + y;
  5919. this._offsetCell(previousKey, key);
  5920. }
  5921. }
  5922. this._rowDefinitions.splice(index, 1);
  5923. this._markAsDirty();
  5924. return this;
  5925. };
  5926. /**
  5927. * Adds a new control to the current grid
  5928. * @param control defines the control to add
  5929. * @param row defines the row where to add the control (0 by default)
  5930. * @param column defines the column where to add the control (0 by default)
  5931. * @returns the current grid
  5932. */
  5933. Grid.prototype.addControl = function (control, row, column) {
  5934. if (row === void 0) { row = 0; }
  5935. if (column === void 0) { column = 0; }
  5936. if (this._rowDefinitions.length === 0) {
  5937. // Add default row definition
  5938. this.addRowDefinition(1, false);
  5939. }
  5940. if (this._columnDefinitions.length === 0) {
  5941. // Add default column definition
  5942. this.addColumnDefinition(1, false);
  5943. }
  5944. if (this._childControls.indexOf(control) !== -1) {
  5945. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].Warn("Control (Name:" + control.name + ", UniqueId:" + control.uniqueId + ") is already associated with this grid. You must remove it before reattaching it");
  5946. return this;
  5947. }
  5948. var x = Math.min(row, this._rowDefinitions.length - 1);
  5949. var y = Math.min(column, this._columnDefinitions.length - 1);
  5950. var key = x + ":" + y;
  5951. var goodContainer = this._cells[key];
  5952. if (!goodContainer) {
  5953. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5954. this._cells[key] = goodContainer;
  5955. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5956. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5957. _super.prototype.addControl.call(this, goodContainer);
  5958. }
  5959. goodContainer.addControl(control);
  5960. this._childControls.push(control);
  5961. control._tag = key;
  5962. control.parent = this;
  5963. this._markAsDirty();
  5964. return this;
  5965. };
  5966. /**
  5967. * Removes a control from the current container
  5968. * @param control defines the control to remove
  5969. * @returns the current container
  5970. */
  5971. Grid.prototype.removeControl = function (control) {
  5972. var index = this._childControls.indexOf(control);
  5973. if (index !== -1) {
  5974. this._childControls.splice(index, 1);
  5975. }
  5976. var cell = this._cells[control._tag];
  5977. if (cell) {
  5978. cell.removeControl(control);
  5979. control._tag = null;
  5980. }
  5981. this._markAsDirty();
  5982. return this;
  5983. };
  5984. Grid.prototype._getTypeName = function () {
  5985. return "Grid";
  5986. };
  5987. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5988. var widths = [];
  5989. var heights = [];
  5990. var lefts = [];
  5991. var tops = [];
  5992. var availableWidth = this._currentMeasure.width;
  5993. var globalWidthPercentage = 0;
  5994. var availableHeight = this._currentMeasure.height;
  5995. var globalHeightPercentage = 0;
  5996. // Heights
  5997. var index = 0;
  5998. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5999. var value = _a[_i];
  6000. if (value.isPixel) {
  6001. var height = value.getValue(this._host);
  6002. availableHeight -= height;
  6003. heights[index] = height;
  6004. }
  6005. else {
  6006. globalHeightPercentage += value.internalValue;
  6007. }
  6008. index++;
  6009. }
  6010. var top = 0;
  6011. index = 0;
  6012. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6013. var value = _c[_b];
  6014. tops.push(top);
  6015. if (!value.isPixel) {
  6016. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6017. top += height;
  6018. heights[index] = height;
  6019. }
  6020. else {
  6021. top += value.getValue(this._host);
  6022. }
  6023. index++;
  6024. }
  6025. // Widths
  6026. index = 0;
  6027. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6028. var value = _e[_d];
  6029. if (value.isPixel) {
  6030. var width = value.getValue(this._host);
  6031. availableWidth -= width;
  6032. widths[index] = width;
  6033. }
  6034. else {
  6035. globalWidthPercentage += value.internalValue;
  6036. }
  6037. index++;
  6038. }
  6039. var left = 0;
  6040. index = 0;
  6041. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6042. var value = _g[_f];
  6043. lefts.push(left);
  6044. if (!value.isPixel) {
  6045. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6046. left += width;
  6047. widths[index] = width;
  6048. }
  6049. else {
  6050. left += value.getValue(this._host);
  6051. }
  6052. index++;
  6053. }
  6054. definitionCallback(lefts, tops, widths, heights);
  6055. };
  6056. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6057. var _this = this;
  6058. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6059. // Setting child sizes
  6060. for (var key in _this._cells) {
  6061. if (!_this._cells.hasOwnProperty(key)) {
  6062. continue;
  6063. }
  6064. var split = key.split(":");
  6065. var x = parseInt(split[0]);
  6066. var y = parseInt(split[1]);
  6067. var cell = _this._cells[key];
  6068. cell.left = lefts[y] + "px";
  6069. cell.top = tops[x] + "px";
  6070. cell.width = widths[y] + "px";
  6071. cell.height = heights[x] + "px";
  6072. cell._left.ignoreAdaptiveScaling = true;
  6073. cell._top.ignoreAdaptiveScaling = true;
  6074. cell._width.ignoreAdaptiveScaling = true;
  6075. cell._height.ignoreAdaptiveScaling = true;
  6076. }
  6077. });
  6078. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6079. };
  6080. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6081. for (var key in this._cells) {
  6082. if (!this._cells.hasOwnProperty(key)) {
  6083. continue;
  6084. }
  6085. var child = this._cells[key];
  6086. child._markMatrixAsDirty();
  6087. }
  6088. };
  6089. Grid.prototype._renderHighlightSpecific = function (context) {
  6090. var _this = this;
  6091. _super.prototype._renderHighlightSpecific.call(this, context);
  6092. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6093. // Columns
  6094. for (var index = 0; index < lefts.length; index++) {
  6095. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6096. context.beginPath();
  6097. context.moveTo(left, _this._currentMeasure.top);
  6098. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6099. context.stroke();
  6100. }
  6101. // Rows
  6102. for (var index = 0; index < tops.length; index++) {
  6103. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6104. context.beginPath();
  6105. context.moveTo(_this._currentMeasure.left, top_1);
  6106. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6107. context.stroke();
  6108. }
  6109. });
  6110. context.restore();
  6111. };
  6112. /** Releases associated resources */
  6113. Grid.prototype.dispose = function () {
  6114. _super.prototype.dispose.call(this);
  6115. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6116. var control = _a[_i];
  6117. control.dispose();
  6118. }
  6119. this._childControls = [];
  6120. };
  6121. return Grid;
  6122. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6123. /***/ }),
  6124. /***/ "./2D/controls/image.ts":
  6125. /*!******************************!*\
  6126. !*** ./2D/controls/image.ts ***!
  6127. \******************************/
  6128. /*! exports provided: Image */
  6129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6130. "use strict";
  6131. __webpack_require__.r(__webpack_exports__);
  6132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6133. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6134. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6135. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6136. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6137. /**
  6138. * Class used to create 2D images
  6139. */
  6140. var Image = /** @class */ (function (_super) {
  6141. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6142. /**
  6143. * Creates a new Image
  6144. * @param name defines the control name
  6145. * @param url defines the image url
  6146. */
  6147. function Image(name, url) {
  6148. if (url === void 0) { url = null; }
  6149. var _this = _super.call(this, name) || this;
  6150. _this.name = name;
  6151. _this._loaded = false;
  6152. _this._stretch = Image.STRETCH_FILL;
  6153. _this._autoScale = false;
  6154. _this._sourceLeft = 0;
  6155. _this._sourceTop = 0;
  6156. _this._sourceWidth = 0;
  6157. _this._sourceHeight = 0;
  6158. _this._cellWidth = 0;
  6159. _this._cellHeight = 0;
  6160. _this._cellId = -1;
  6161. _this._populateNinePatchSlicesFromImage = false;
  6162. /**
  6163. * Observable notified when the content is loaded
  6164. */
  6165. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6166. _this.source = url;
  6167. return _this;
  6168. }
  6169. Object.defineProperty(Image.prototype, "isLoaded", {
  6170. /**
  6171. * Gets a boolean indicating that the content is loaded
  6172. */
  6173. get: function () {
  6174. return this._loaded;
  6175. },
  6176. enumerable: true,
  6177. configurable: true
  6178. });
  6179. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6180. /**
  6181. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6182. */
  6183. get: function () {
  6184. return this._populateNinePatchSlicesFromImage;
  6185. },
  6186. set: function (value) {
  6187. if (this._populateNinePatchSlicesFromImage === value) {
  6188. return;
  6189. }
  6190. this._populateNinePatchSlicesFromImage = value;
  6191. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6192. this._extractNinePatchSliceDataFromImage();
  6193. }
  6194. },
  6195. enumerable: true,
  6196. configurable: true
  6197. });
  6198. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6199. /**
  6200. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6201. * Beware using this as this will comsume more memory as the image has to be stored twice
  6202. */
  6203. get: function () {
  6204. return this._detectPointerOnOpaqueOnly;
  6205. },
  6206. set: function (value) {
  6207. if (this._detectPointerOnOpaqueOnly === value) {
  6208. return;
  6209. }
  6210. this._detectPointerOnOpaqueOnly = value;
  6211. },
  6212. enumerable: true,
  6213. configurable: true
  6214. });
  6215. Object.defineProperty(Image.prototype, "sliceLeft", {
  6216. /**
  6217. * Gets or sets the left value for slicing (9-patch)
  6218. */
  6219. get: function () {
  6220. return this._sliceLeft;
  6221. },
  6222. set: function (value) {
  6223. if (this._sliceLeft === value) {
  6224. return;
  6225. }
  6226. this._sliceLeft = value;
  6227. this._markAsDirty();
  6228. },
  6229. enumerable: true,
  6230. configurable: true
  6231. });
  6232. Object.defineProperty(Image.prototype, "sliceRight", {
  6233. /**
  6234. * Gets or sets the right value for slicing (9-patch)
  6235. */
  6236. get: function () {
  6237. return this._sliceRight;
  6238. },
  6239. set: function (value) {
  6240. if (this._sliceRight === value) {
  6241. return;
  6242. }
  6243. this._sliceRight = value;
  6244. this._markAsDirty();
  6245. },
  6246. enumerable: true,
  6247. configurable: true
  6248. });
  6249. Object.defineProperty(Image.prototype, "sliceTop", {
  6250. /**
  6251. * Gets or sets the top value for slicing (9-patch)
  6252. */
  6253. get: function () {
  6254. return this._sliceTop;
  6255. },
  6256. set: function (value) {
  6257. if (this._sliceTop === value) {
  6258. return;
  6259. }
  6260. this._sliceTop = value;
  6261. this._markAsDirty();
  6262. },
  6263. enumerable: true,
  6264. configurable: true
  6265. });
  6266. Object.defineProperty(Image.prototype, "sliceBottom", {
  6267. /**
  6268. * Gets or sets the bottom value for slicing (9-patch)
  6269. */
  6270. get: function () {
  6271. return this._sliceBottom;
  6272. },
  6273. set: function (value) {
  6274. if (this._sliceBottom === value) {
  6275. return;
  6276. }
  6277. this._sliceBottom = value;
  6278. this._markAsDirty();
  6279. },
  6280. enumerable: true,
  6281. configurable: true
  6282. });
  6283. Object.defineProperty(Image.prototype, "sourceLeft", {
  6284. /**
  6285. * Gets or sets the left coordinate in the source image
  6286. */
  6287. get: function () {
  6288. return this._sourceLeft;
  6289. },
  6290. set: function (value) {
  6291. if (this._sourceLeft === value) {
  6292. return;
  6293. }
  6294. this._sourceLeft = value;
  6295. this._markAsDirty();
  6296. },
  6297. enumerable: true,
  6298. configurable: true
  6299. });
  6300. Object.defineProperty(Image.prototype, "sourceTop", {
  6301. /**
  6302. * Gets or sets the top coordinate in the source image
  6303. */
  6304. get: function () {
  6305. return this._sourceTop;
  6306. },
  6307. set: function (value) {
  6308. if (this._sourceTop === value) {
  6309. return;
  6310. }
  6311. this._sourceTop = value;
  6312. this._markAsDirty();
  6313. },
  6314. enumerable: true,
  6315. configurable: true
  6316. });
  6317. Object.defineProperty(Image.prototype, "sourceWidth", {
  6318. /**
  6319. * Gets or sets the width to capture in the source image
  6320. */
  6321. get: function () {
  6322. return this._sourceWidth;
  6323. },
  6324. set: function (value) {
  6325. if (this._sourceWidth === value) {
  6326. return;
  6327. }
  6328. this._sourceWidth = value;
  6329. this._markAsDirty();
  6330. },
  6331. enumerable: true,
  6332. configurable: true
  6333. });
  6334. Object.defineProperty(Image.prototype, "sourceHeight", {
  6335. /**
  6336. * Gets or sets the height to capture in the source image
  6337. */
  6338. get: function () {
  6339. return this._sourceHeight;
  6340. },
  6341. set: function (value) {
  6342. if (this._sourceHeight === value) {
  6343. return;
  6344. }
  6345. this._sourceHeight = value;
  6346. this._markAsDirty();
  6347. },
  6348. enumerable: true,
  6349. configurable: true
  6350. });
  6351. Object.defineProperty(Image.prototype, "autoScale", {
  6352. /**
  6353. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6354. * @see http://doc.babylonjs.com/how_to/gui#image
  6355. */
  6356. get: function () {
  6357. return this._autoScale;
  6358. },
  6359. set: function (value) {
  6360. if (this._autoScale === value) {
  6361. return;
  6362. }
  6363. this._autoScale = value;
  6364. if (value && this._loaded) {
  6365. this.synchronizeSizeWithContent();
  6366. }
  6367. },
  6368. enumerable: true,
  6369. configurable: true
  6370. });
  6371. Object.defineProperty(Image.prototype, "stretch", {
  6372. /** Gets or sets the streching mode used by the image */
  6373. get: function () {
  6374. return this._stretch;
  6375. },
  6376. set: function (value) {
  6377. if (this._stretch === value) {
  6378. return;
  6379. }
  6380. this._stretch = value;
  6381. this._markAsDirty();
  6382. },
  6383. enumerable: true,
  6384. configurable: true
  6385. });
  6386. Object.defineProperty(Image.prototype, "domImage", {
  6387. get: function () {
  6388. return this._domImage;
  6389. },
  6390. /**
  6391. * Gets or sets the internal DOM image used to render the control
  6392. */
  6393. set: function (value) {
  6394. var _this = this;
  6395. this._domImage = value;
  6396. this._loaded = false;
  6397. if (this._domImage.width) {
  6398. this._onImageLoaded();
  6399. }
  6400. else {
  6401. this._domImage.onload = function () {
  6402. _this._onImageLoaded();
  6403. };
  6404. }
  6405. },
  6406. enumerable: true,
  6407. configurable: true
  6408. });
  6409. Image.prototype._onImageLoaded = function () {
  6410. this._imageWidth = this._domImage.width;
  6411. this._imageHeight = this._domImage.height;
  6412. this._loaded = true;
  6413. if (this._populateNinePatchSlicesFromImage) {
  6414. this._extractNinePatchSliceDataFromImage();
  6415. }
  6416. if (this._autoScale) {
  6417. this.synchronizeSizeWithContent();
  6418. }
  6419. this.onImageLoadedObservable.notifyObservers(this);
  6420. this._markAsDirty();
  6421. };
  6422. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6423. if (!Image._WorkingCanvas) {
  6424. Image._WorkingCanvas = document.createElement('canvas');
  6425. }
  6426. var canvas = Image._WorkingCanvas;
  6427. var context = canvas.getContext('2d');
  6428. var width = this._domImage.width;
  6429. var height = this._domImage.height;
  6430. canvas.width = width;
  6431. canvas.height = height;
  6432. context.drawImage(this._domImage, 0, 0, width, height);
  6433. var imageData = context.getImageData(0, 0, width, height);
  6434. // Left and right
  6435. this._sliceLeft = -1;
  6436. this._sliceRight = -1;
  6437. for (var x = 0; x < width; x++) {
  6438. var alpha = imageData.data[x * 4 + 3];
  6439. if (alpha > 127 && this._sliceLeft === -1) {
  6440. this._sliceLeft = x;
  6441. continue;
  6442. }
  6443. if (alpha < 127 && this._sliceLeft > -1) {
  6444. this._sliceRight = x;
  6445. break;
  6446. }
  6447. }
  6448. // top and bottom
  6449. this._sliceTop = -1;
  6450. this._sliceBottom = -1;
  6451. for (var y = 0; y < height; y++) {
  6452. var alpha = imageData.data[y * width * 4 + 3];
  6453. if (alpha > 127 && this._sliceTop === -1) {
  6454. this._sliceTop = y;
  6455. continue;
  6456. }
  6457. if (alpha < 127 && this._sliceTop > -1) {
  6458. this._sliceBottom = y;
  6459. break;
  6460. }
  6461. }
  6462. };
  6463. Object.defineProperty(Image.prototype, "source", {
  6464. /**
  6465. * Gets or sets image source url
  6466. */
  6467. set: function (value) {
  6468. var _this = this;
  6469. if (this._source === value) {
  6470. return;
  6471. }
  6472. this._loaded = false;
  6473. this._source = value;
  6474. this._domImage = document.createElement("img");
  6475. this._domImage.onload = function () {
  6476. _this._onImageLoaded();
  6477. };
  6478. if (value) {
  6479. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6480. this._domImage.src = value;
  6481. }
  6482. },
  6483. enumerable: true,
  6484. configurable: true
  6485. });
  6486. Object.defineProperty(Image.prototype, "cellWidth", {
  6487. /**
  6488. * Gets or sets the cell width to use when animation sheet is enabled
  6489. * @see http://doc.babylonjs.com/how_to/gui#image
  6490. */
  6491. get: function () {
  6492. return this._cellWidth;
  6493. },
  6494. set: function (value) {
  6495. if (this._cellWidth === value) {
  6496. return;
  6497. }
  6498. this._cellWidth = value;
  6499. this._markAsDirty();
  6500. },
  6501. enumerable: true,
  6502. configurable: true
  6503. });
  6504. Object.defineProperty(Image.prototype, "cellHeight", {
  6505. /**
  6506. * Gets or sets the cell height to use when animation sheet is enabled
  6507. * @see http://doc.babylonjs.com/how_to/gui#image
  6508. */
  6509. get: function () {
  6510. return this._cellHeight;
  6511. },
  6512. set: function (value) {
  6513. if (this._cellHeight === value) {
  6514. return;
  6515. }
  6516. this._cellHeight = value;
  6517. this._markAsDirty();
  6518. },
  6519. enumerable: true,
  6520. configurable: true
  6521. });
  6522. Object.defineProperty(Image.prototype, "cellId", {
  6523. /**
  6524. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6525. * @see http://doc.babylonjs.com/how_to/gui#image
  6526. */
  6527. get: function () {
  6528. return this._cellId;
  6529. },
  6530. set: function (value) {
  6531. if (this._cellId === value) {
  6532. return;
  6533. }
  6534. this._cellId = value;
  6535. this._markAsDirty();
  6536. },
  6537. enumerable: true,
  6538. configurable: true
  6539. });
  6540. /**
  6541. * Tests if a given coordinates belong to the current control
  6542. * @param x defines x coordinate to test
  6543. * @param y defines y coordinate to test
  6544. * @returns true if the coordinates are inside the control
  6545. */
  6546. Image.prototype.contains = function (x, y) {
  6547. if (!_super.prototype.contains.call(this, x, y)) {
  6548. return false;
  6549. }
  6550. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6551. return true;
  6552. }
  6553. var canvas = Image._WorkingCanvas;
  6554. var context = canvas.getContext("2d");
  6555. var width = this._currentMeasure.width | 0;
  6556. var height = this._currentMeasure.height | 0;
  6557. var imageData = context.getImageData(0, 0, width, height).data;
  6558. x = (x - this._currentMeasure.left) | 0;
  6559. y = (y - this._currentMeasure.top) | 0;
  6560. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6561. return pickedPixel > 0;
  6562. };
  6563. Image.prototype._getTypeName = function () {
  6564. return "Image";
  6565. };
  6566. /** Force the control to synchronize with its content */
  6567. Image.prototype.synchronizeSizeWithContent = function () {
  6568. if (!this._loaded) {
  6569. return;
  6570. }
  6571. this.width = this._domImage.width + "px";
  6572. this.height = this._domImage.height + "px";
  6573. };
  6574. Image.prototype._processMeasures = function (parentMeasure, context) {
  6575. if (this._loaded) {
  6576. switch (this._stretch) {
  6577. case Image.STRETCH_NONE:
  6578. break;
  6579. case Image.STRETCH_FILL:
  6580. break;
  6581. case Image.STRETCH_UNIFORM:
  6582. break;
  6583. case Image.STRETCH_NINE_PATCH:
  6584. break;
  6585. case Image.STRETCH_EXTEND:
  6586. if (this._autoScale) {
  6587. this.synchronizeSizeWithContent();
  6588. }
  6589. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6590. this.parent.adaptWidthToChildren = true;
  6591. this.parent.adaptHeightToChildren = true;
  6592. }
  6593. break;
  6594. }
  6595. }
  6596. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6597. };
  6598. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6599. if (!this._detectPointerOnOpaqueOnly) {
  6600. return;
  6601. }
  6602. if (!Image._WorkingCanvas) {
  6603. Image._WorkingCanvas = document.createElement('canvas');
  6604. }
  6605. var canvas = Image._WorkingCanvas;
  6606. var width = this._currentMeasure.width;
  6607. var height = this._currentMeasure.height;
  6608. var context = canvas.getContext("2d");
  6609. canvas.width = width;
  6610. canvas.height = height;
  6611. context.clearRect(0, 0, width, height);
  6612. };
  6613. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6614. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6615. if (!this._detectPointerOnOpaqueOnly) {
  6616. return;
  6617. }
  6618. var canvas = Image._WorkingCanvas;
  6619. context = canvas.getContext("2d");
  6620. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6621. };
  6622. Image.prototype._draw = function (context) {
  6623. context.save();
  6624. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6625. context.shadowColor = this.shadowColor;
  6626. context.shadowBlur = this.shadowBlur;
  6627. context.shadowOffsetX = this.shadowOffsetX;
  6628. context.shadowOffsetY = this.shadowOffsetY;
  6629. }
  6630. var x, y, width, height;
  6631. if (this.cellId == -1) {
  6632. x = this._sourceLeft;
  6633. y = this._sourceTop;
  6634. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6635. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6636. }
  6637. else {
  6638. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6639. var column = (this.cellId / rowCount) >> 0;
  6640. var row = this.cellId % rowCount;
  6641. x = this.cellWidth * row;
  6642. y = this.cellHeight * column;
  6643. width = this.cellWidth;
  6644. height = this.cellHeight;
  6645. }
  6646. this._prepareWorkingCanvasForOpaqueDetection();
  6647. this._applyStates(context);
  6648. if (this._loaded) {
  6649. switch (this._stretch) {
  6650. case Image.STRETCH_NONE:
  6651. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6652. break;
  6653. case Image.STRETCH_FILL:
  6654. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6655. break;
  6656. case Image.STRETCH_UNIFORM:
  6657. var hRatio = this._currentMeasure.width / width;
  6658. var vRatio = this._currentMeasure.height / height;
  6659. var ratio = Math.min(hRatio, vRatio);
  6660. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6661. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6662. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6663. break;
  6664. case Image.STRETCH_EXTEND:
  6665. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6666. break;
  6667. case Image.STRETCH_NINE_PATCH:
  6668. this._renderNinePatch(context);
  6669. break;
  6670. }
  6671. }
  6672. context.restore();
  6673. };
  6674. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6675. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6676. };
  6677. Image.prototype._renderNinePatch = function (context) {
  6678. var height = this._imageHeight;
  6679. var leftWidth = this._sliceLeft;
  6680. var topHeight = this._sliceTop;
  6681. var bottomHeight = this._imageHeight - this._sliceBottom;
  6682. var rightWidth = this._imageWidth - this._sliceRight;
  6683. var left = 0;
  6684. var top = 0;
  6685. if (this._populateNinePatchSlicesFromImage) {
  6686. left = 1;
  6687. top = 1;
  6688. height -= 2;
  6689. leftWidth -= 1;
  6690. topHeight -= 1;
  6691. bottomHeight -= 1;
  6692. rightWidth -= 1;
  6693. }
  6694. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6695. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6696. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6697. // Corners
  6698. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6699. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6700. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6701. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6702. // Center
  6703. 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);
  6704. // Borders
  6705. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6706. 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);
  6707. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6708. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6709. };
  6710. Image.prototype.dispose = function () {
  6711. _super.prototype.dispose.call(this);
  6712. this.onImageLoadedObservable.clear();
  6713. };
  6714. Image._WorkingCanvas = null;
  6715. // Static
  6716. /** STRETCH_NONE */
  6717. Image.STRETCH_NONE = 0;
  6718. /** STRETCH_FILL */
  6719. Image.STRETCH_FILL = 1;
  6720. /** STRETCH_UNIFORM */
  6721. Image.STRETCH_UNIFORM = 2;
  6722. /** STRETCH_EXTEND */
  6723. Image.STRETCH_EXTEND = 3;
  6724. /** NINE_PATCH */
  6725. Image.STRETCH_NINE_PATCH = 4;
  6726. return Image;
  6727. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6728. /***/ }),
  6729. /***/ "./2D/controls/index.ts":
  6730. /*!******************************!*\
  6731. !*** ./2D/controls/index.ts ***!
  6732. \******************************/
  6733. /*! 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 */
  6734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6735. "use strict";
  6736. __webpack_require__.r(__webpack_exports__);
  6737. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6739. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6741. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6743. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6745. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6747. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6749. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6751. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6753. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6755. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6757. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6759. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6761. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6763. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6765. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6771. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6773. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6776. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6779. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6781. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6783. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6785. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6787. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6789. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6791. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6793. /***/ }),
  6794. /***/ "./2D/controls/inputPassword.ts":
  6795. /*!**************************************!*\
  6796. !*** ./2D/controls/inputPassword.ts ***!
  6797. \**************************************/
  6798. /*! exports provided: InputPassword */
  6799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6800. "use strict";
  6801. __webpack_require__.r(__webpack_exports__);
  6802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6803. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6804. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6805. /**
  6806. * Class used to create a password control
  6807. */
  6808. var InputPassword = /** @class */ (function (_super) {
  6809. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6810. function InputPassword() {
  6811. return _super !== null && _super.apply(this, arguments) || this;
  6812. }
  6813. InputPassword.prototype._beforeRenderText = function (text) {
  6814. var txt = "";
  6815. for (var i = 0; i < text.length; i++) {
  6816. txt += "\u2022";
  6817. }
  6818. return txt;
  6819. };
  6820. return InputPassword;
  6821. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6822. /***/ }),
  6823. /***/ "./2D/controls/inputText.ts":
  6824. /*!**********************************!*\
  6825. !*** ./2D/controls/inputText.ts ***!
  6826. \**********************************/
  6827. /*! exports provided: InputText */
  6828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6829. "use strict";
  6830. __webpack_require__.r(__webpack_exports__);
  6831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6832. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6833. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6834. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6835. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6836. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6837. /**
  6838. * Class used to create input text control
  6839. */
  6840. var InputText = /** @class */ (function (_super) {
  6841. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6842. /**
  6843. * Creates a new InputText
  6844. * @param name defines the control name
  6845. * @param text defines the text of the control
  6846. */
  6847. function InputText(name, text) {
  6848. if (text === void 0) { text = ""; }
  6849. var _this = _super.call(this, name) || this;
  6850. _this.name = name;
  6851. _this._text = "";
  6852. _this._placeholderText = "";
  6853. _this._background = "#222222";
  6854. _this._focusedBackground = "#000000";
  6855. _this._focusedColor = "white";
  6856. _this._placeholderColor = "gray";
  6857. _this._thickness = 1;
  6858. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6859. _this._autoStretchWidth = true;
  6860. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6861. _this._isFocused = false;
  6862. _this._blinkIsEven = false;
  6863. _this._cursorOffset = 0;
  6864. _this._deadKey = false;
  6865. _this._addKey = true;
  6866. _this._currentKey = "";
  6867. _this._isTextHighlightOn = false;
  6868. _this._textHighlightColor = "#d5e0ff";
  6869. _this._highligherOpacity = 0.4;
  6870. _this._highlightedText = "";
  6871. _this._startHighlightIndex = 0;
  6872. _this._endHighlightIndex = 0;
  6873. _this._cursorIndex = -1;
  6874. _this._onFocusSelectAll = false;
  6875. _this._isPointerDown = false;
  6876. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6877. _this.promptMessage = "Please enter text:";
  6878. /** Force disable prompt on mobile device */
  6879. _this.disableMobilePrompt = false;
  6880. /** Observable raised when the text changes */
  6881. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6882. /** Observable raised just before an entered character is to be added */
  6883. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6884. /** Observable raised when the control gets the focus */
  6885. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6886. /** Observable raised when the control loses the focus */
  6887. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6888. /**Observable raised when the text is highlighted */
  6889. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6890. /**Observable raised when copy event is triggered */
  6891. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6892. /** Observable raised when cut event is triggered */
  6893. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6894. /** Observable raised when paste event is triggered */
  6895. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6896. /** Observable raised when a key event was processed */
  6897. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6898. _this.text = text;
  6899. _this.isPointerBlocker = true;
  6900. return _this;
  6901. }
  6902. Object.defineProperty(InputText.prototype, "maxWidth", {
  6903. /** Gets or sets the maximum width allowed by the control */
  6904. get: function () {
  6905. return this._maxWidth.toString(this._host);
  6906. },
  6907. set: function (value) {
  6908. if (this._maxWidth.toString(this._host) === value) {
  6909. return;
  6910. }
  6911. if (this._maxWidth.fromString(value)) {
  6912. this._markAsDirty();
  6913. }
  6914. },
  6915. enumerable: true,
  6916. configurable: true
  6917. });
  6918. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6919. /** Gets the maximum width allowed by the control in pixels */
  6920. get: function () {
  6921. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6922. },
  6923. enumerable: true,
  6924. configurable: true
  6925. });
  6926. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6927. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6928. get: function () {
  6929. return this._highligherOpacity;
  6930. },
  6931. set: function (value) {
  6932. if (this._highligherOpacity === value) {
  6933. return;
  6934. }
  6935. this._highligherOpacity = value;
  6936. this._markAsDirty();
  6937. },
  6938. enumerable: true,
  6939. configurable: true
  6940. });
  6941. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6942. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6943. get: function () {
  6944. return this._onFocusSelectAll;
  6945. },
  6946. set: function (value) {
  6947. if (this._onFocusSelectAll === value) {
  6948. return;
  6949. }
  6950. this._onFocusSelectAll = value;
  6951. this._markAsDirty();
  6952. },
  6953. enumerable: true,
  6954. configurable: true
  6955. });
  6956. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6957. /** Gets or sets the text hightlight color */
  6958. get: function () {
  6959. return this._textHighlightColor;
  6960. },
  6961. set: function (value) {
  6962. if (this._textHighlightColor === value) {
  6963. return;
  6964. }
  6965. this._textHighlightColor = value;
  6966. this._markAsDirty();
  6967. },
  6968. enumerable: true,
  6969. configurable: true
  6970. });
  6971. Object.defineProperty(InputText.prototype, "margin", {
  6972. /** Gets or sets control margin */
  6973. get: function () {
  6974. return this._margin.toString(this._host);
  6975. },
  6976. set: function (value) {
  6977. if (this._margin.toString(this._host) === value) {
  6978. return;
  6979. }
  6980. if (this._margin.fromString(value)) {
  6981. this._markAsDirty();
  6982. }
  6983. },
  6984. enumerable: true,
  6985. configurable: true
  6986. });
  6987. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6988. /** Gets control margin in pixels */
  6989. get: function () {
  6990. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6991. },
  6992. enumerable: true,
  6993. configurable: true
  6994. });
  6995. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6996. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6997. get: function () {
  6998. return this._autoStretchWidth;
  6999. },
  7000. set: function (value) {
  7001. if (this._autoStretchWidth === value) {
  7002. return;
  7003. }
  7004. this._autoStretchWidth = value;
  7005. this._markAsDirty();
  7006. },
  7007. enumerable: true,
  7008. configurable: true
  7009. });
  7010. Object.defineProperty(InputText.prototype, "thickness", {
  7011. /** Gets or sets border thickness */
  7012. get: function () {
  7013. return this._thickness;
  7014. },
  7015. set: function (value) {
  7016. if (this._thickness === value) {
  7017. return;
  7018. }
  7019. this._thickness = value;
  7020. this._markAsDirty();
  7021. },
  7022. enumerable: true,
  7023. configurable: true
  7024. });
  7025. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7026. /** Gets or sets the background color when focused */
  7027. get: function () {
  7028. return this._focusedBackground;
  7029. },
  7030. set: function (value) {
  7031. if (this._focusedBackground === value) {
  7032. return;
  7033. }
  7034. this._focusedBackground = value;
  7035. this._markAsDirty();
  7036. },
  7037. enumerable: true,
  7038. configurable: true
  7039. });
  7040. Object.defineProperty(InputText.prototype, "focusedColor", {
  7041. /** Gets or sets the background color when focused */
  7042. get: function () {
  7043. return this._focusedColor;
  7044. },
  7045. set: function (value) {
  7046. if (this._focusedColor === value) {
  7047. return;
  7048. }
  7049. this._focusedColor = value;
  7050. this._markAsDirty();
  7051. },
  7052. enumerable: true,
  7053. configurable: true
  7054. });
  7055. Object.defineProperty(InputText.prototype, "background", {
  7056. /** Gets or sets the background color */
  7057. get: function () {
  7058. return this._background;
  7059. },
  7060. set: function (value) {
  7061. if (this._background === value) {
  7062. return;
  7063. }
  7064. this._background = value;
  7065. this._markAsDirty();
  7066. },
  7067. enumerable: true,
  7068. configurable: true
  7069. });
  7070. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7071. /** Gets or sets the placeholder color */
  7072. get: function () {
  7073. return this._placeholderColor;
  7074. },
  7075. set: function (value) {
  7076. if (this._placeholderColor === value) {
  7077. return;
  7078. }
  7079. this._placeholderColor = value;
  7080. this._markAsDirty();
  7081. },
  7082. enumerable: true,
  7083. configurable: true
  7084. });
  7085. Object.defineProperty(InputText.prototype, "placeholderText", {
  7086. /** Gets or sets the text displayed when the control is empty */
  7087. get: function () {
  7088. return this._placeholderText;
  7089. },
  7090. set: function (value) {
  7091. if (this._placeholderText === value) {
  7092. return;
  7093. }
  7094. this._placeholderText = value;
  7095. this._markAsDirty();
  7096. },
  7097. enumerable: true,
  7098. configurable: true
  7099. });
  7100. Object.defineProperty(InputText.prototype, "deadKey", {
  7101. /** Gets or sets the dead key flag */
  7102. get: function () {
  7103. return this._deadKey;
  7104. },
  7105. set: function (flag) {
  7106. this._deadKey = flag;
  7107. },
  7108. enumerable: true,
  7109. configurable: true
  7110. });
  7111. Object.defineProperty(InputText.prototype, "highlightedText", {
  7112. /** Gets or sets the highlight text */
  7113. get: function () {
  7114. return this._highlightedText;
  7115. },
  7116. set: function (text) {
  7117. if (this._highlightedText === text) {
  7118. return;
  7119. }
  7120. this._highlightedText = text;
  7121. this._markAsDirty();
  7122. },
  7123. enumerable: true,
  7124. configurable: true
  7125. });
  7126. Object.defineProperty(InputText.prototype, "addKey", {
  7127. /** Gets or sets if the current key should be added */
  7128. get: function () {
  7129. return this._addKey;
  7130. },
  7131. set: function (flag) {
  7132. this._addKey = flag;
  7133. },
  7134. enumerable: true,
  7135. configurable: true
  7136. });
  7137. Object.defineProperty(InputText.prototype, "currentKey", {
  7138. /** Gets or sets the value of the current key being entered */
  7139. get: function () {
  7140. return this._currentKey;
  7141. },
  7142. set: function (key) {
  7143. this._currentKey = key;
  7144. },
  7145. enumerable: true,
  7146. configurable: true
  7147. });
  7148. Object.defineProperty(InputText.prototype, "text", {
  7149. /** Gets or sets the text displayed in the control */
  7150. get: function () {
  7151. return this._text;
  7152. },
  7153. set: function (value) {
  7154. var valueAsString = value.toString(); // Forcing convertion
  7155. if (this._text === valueAsString) {
  7156. return;
  7157. }
  7158. this._text = valueAsString;
  7159. this._markAsDirty();
  7160. this.onTextChangedObservable.notifyObservers(this);
  7161. },
  7162. enumerable: true,
  7163. configurable: true
  7164. });
  7165. Object.defineProperty(InputText.prototype, "width", {
  7166. /** Gets or sets control width */
  7167. get: function () {
  7168. return this._width.toString(this._host);
  7169. },
  7170. set: function (value) {
  7171. if (this._width.toString(this._host) === value) {
  7172. return;
  7173. }
  7174. if (this._width.fromString(value)) {
  7175. this._markAsDirty();
  7176. }
  7177. this.autoStretchWidth = false;
  7178. },
  7179. enumerable: true,
  7180. configurable: true
  7181. });
  7182. /** @hidden */
  7183. InputText.prototype.onBlur = function () {
  7184. this._isFocused = false;
  7185. this._scrollLeft = null;
  7186. this._cursorOffset = 0;
  7187. clearTimeout(this._blinkTimeout);
  7188. this._markAsDirty();
  7189. this.onBlurObservable.notifyObservers(this);
  7190. this._host.unRegisterClipboardEvents();
  7191. if (this._onClipboardObserver) {
  7192. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7193. }
  7194. var scene = this._host.getScene();
  7195. if (this._onPointerDblTapObserver && scene) {
  7196. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7197. }
  7198. };
  7199. /** @hidden */
  7200. InputText.prototype.onFocus = function () {
  7201. var _this = this;
  7202. if (!this._isEnabled) {
  7203. return;
  7204. }
  7205. this._scrollLeft = null;
  7206. this._isFocused = true;
  7207. this._blinkIsEven = false;
  7208. this._cursorOffset = 0;
  7209. this._markAsDirty();
  7210. this.onFocusObservable.notifyObservers(this);
  7211. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7212. var value = prompt(this.promptMessage);
  7213. if (value !== null) {
  7214. this.text = value;
  7215. }
  7216. this._host.focusedControl = null;
  7217. return;
  7218. }
  7219. this._host.registerClipboardEvents();
  7220. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7221. // process clipboard event, can be configured.
  7222. switch (clipboardInfo.type) {
  7223. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7224. _this._onCopyText(clipboardInfo.event);
  7225. _this.onTextCopyObservable.notifyObservers(_this);
  7226. break;
  7227. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7228. _this._onCutText(clipboardInfo.event);
  7229. _this.onTextCutObservable.notifyObservers(_this);
  7230. break;
  7231. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7232. _this._onPasteText(clipboardInfo.event);
  7233. _this.onTextPasteObservable.notifyObservers(_this);
  7234. break;
  7235. default: return;
  7236. }
  7237. });
  7238. var scene = this._host.getScene();
  7239. if (scene) {
  7240. //register the pointer double tap event
  7241. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7242. if (!_this._isFocused) {
  7243. return;
  7244. }
  7245. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7246. _this._processDblClick(pointerInfo);
  7247. }
  7248. });
  7249. }
  7250. if (this._onFocusSelectAll) {
  7251. this._selectAllText();
  7252. }
  7253. };
  7254. InputText.prototype._getTypeName = function () {
  7255. return "InputText";
  7256. };
  7257. /**
  7258. * Function called to get the list of controls that should not steal the focus from this control
  7259. * @returns an array of controls
  7260. */
  7261. InputText.prototype.keepsFocusWith = function () {
  7262. if (!this._connectedVirtualKeyboard) {
  7263. return null;
  7264. }
  7265. return [this._connectedVirtualKeyboard];
  7266. };
  7267. /** @hidden */
  7268. InputText.prototype.processKey = function (keyCode, key, evt) {
  7269. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7270. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7271. return;
  7272. }
  7273. //select all
  7274. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7275. this._selectAllText();
  7276. evt.preventDefault();
  7277. return;
  7278. }
  7279. // Specific cases
  7280. switch (keyCode) {
  7281. case 32: //SPACE
  7282. key = " "; //ie11 key for space is "Spacebar"
  7283. break;
  7284. case 191: //SLASH
  7285. if (evt) {
  7286. evt.preventDefault();
  7287. }
  7288. break;
  7289. case 8: // BACKSPACE
  7290. if (this._text && this._text.length > 0) {
  7291. //delete the highlighted text
  7292. if (this._isTextHighlightOn) {
  7293. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7294. this._isTextHighlightOn = false;
  7295. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7296. this._blinkIsEven = false;
  7297. if (evt) {
  7298. evt.preventDefault();
  7299. }
  7300. return;
  7301. }
  7302. //delete single character
  7303. if (this._cursorOffset === 0) {
  7304. this.text = this._text.substr(0, this._text.length - 1);
  7305. }
  7306. else {
  7307. var deletePosition = this._text.length - this._cursorOffset;
  7308. if (deletePosition > 0) {
  7309. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7310. }
  7311. }
  7312. }
  7313. if (evt) {
  7314. evt.preventDefault();
  7315. }
  7316. return;
  7317. case 46: // DELETE
  7318. if (this._isTextHighlightOn) {
  7319. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7320. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7321. while (decrementor > 0 && this._cursorOffset > 0) {
  7322. this._cursorOffset--;
  7323. }
  7324. this._isTextHighlightOn = false;
  7325. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7326. if (evt) {
  7327. evt.preventDefault();
  7328. }
  7329. return;
  7330. }
  7331. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7332. var deletePosition = this._text.length - this._cursorOffset;
  7333. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7334. this._cursorOffset--;
  7335. }
  7336. if (evt) {
  7337. evt.preventDefault();
  7338. }
  7339. return;
  7340. case 13: // RETURN
  7341. this._host.focusedControl = null;
  7342. this._isTextHighlightOn = false;
  7343. return;
  7344. case 35: // END
  7345. this._cursorOffset = 0;
  7346. this._blinkIsEven = false;
  7347. this._isTextHighlightOn = false;
  7348. this._markAsDirty();
  7349. return;
  7350. case 36: // HOME
  7351. this._cursorOffset = this._text.length;
  7352. this._blinkIsEven = false;
  7353. this._isTextHighlightOn = false;
  7354. this._markAsDirty();
  7355. return;
  7356. case 37: // LEFT
  7357. this._cursorOffset++;
  7358. if (this._cursorOffset > this._text.length) {
  7359. this._cursorOffset = this._text.length;
  7360. }
  7361. if (evt && evt.shiftKey) {
  7362. // update the cursor
  7363. this._blinkIsEven = false;
  7364. // shift + ctrl/cmd + <-
  7365. if (evt.ctrlKey || evt.metaKey) {
  7366. if (!this._isTextHighlightOn) {
  7367. if (this._text.length === this._cursorOffset) {
  7368. return;
  7369. }
  7370. else {
  7371. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7372. }
  7373. }
  7374. this._startHighlightIndex = 0;
  7375. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7376. this._cursorOffset = this._text.length;
  7377. this._isTextHighlightOn = true;
  7378. this._markAsDirty();
  7379. return;
  7380. }
  7381. //store the starting point
  7382. if (!this._isTextHighlightOn) {
  7383. this._isTextHighlightOn = true;
  7384. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7385. }
  7386. //if text is already highlighted
  7387. else if (this._cursorIndex === -1) {
  7388. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7389. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7390. }
  7391. //set the highlight indexes
  7392. if (this._cursorIndex < this._cursorOffset) {
  7393. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7394. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7395. }
  7396. else if (this._cursorIndex > this._cursorOffset) {
  7397. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7398. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7399. }
  7400. else {
  7401. this._isTextHighlightOn = false;
  7402. }
  7403. this._markAsDirty();
  7404. return;
  7405. }
  7406. if (this._isTextHighlightOn) {
  7407. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7408. this._isTextHighlightOn = false;
  7409. }
  7410. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7411. this._cursorOffset = this.text.length;
  7412. evt.preventDefault();
  7413. }
  7414. this._blinkIsEven = false;
  7415. this._isTextHighlightOn = false;
  7416. this._cursorIndex = -1;
  7417. this._markAsDirty();
  7418. return;
  7419. case 39: // RIGHT
  7420. this._cursorOffset--;
  7421. if (this._cursorOffset < 0) {
  7422. this._cursorOffset = 0;
  7423. }
  7424. if (evt && evt.shiftKey) {
  7425. //update the cursor
  7426. this._blinkIsEven = false;
  7427. //shift + ctrl/cmd + ->
  7428. if (evt.ctrlKey || evt.metaKey) {
  7429. if (!this._isTextHighlightOn) {
  7430. if (this._cursorOffset === 0) {
  7431. return;
  7432. }
  7433. else {
  7434. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7435. }
  7436. }
  7437. this._endHighlightIndex = this._text.length;
  7438. this._isTextHighlightOn = true;
  7439. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7440. this._cursorOffset = 0;
  7441. this._markAsDirty();
  7442. return;
  7443. }
  7444. if (!this._isTextHighlightOn) {
  7445. this._isTextHighlightOn = true;
  7446. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7447. }
  7448. //if text is already highlighted
  7449. else if (this._cursorIndex === -1) {
  7450. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7451. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7452. }
  7453. //set the highlight indexes
  7454. if (this._cursorIndex < this._cursorOffset) {
  7455. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7456. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7457. }
  7458. else if (this._cursorIndex > this._cursorOffset) {
  7459. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7460. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7461. }
  7462. else {
  7463. this._isTextHighlightOn = false;
  7464. }
  7465. this._markAsDirty();
  7466. return;
  7467. }
  7468. if (this._isTextHighlightOn) {
  7469. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7470. this._isTextHighlightOn = false;
  7471. }
  7472. //ctr + ->
  7473. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7474. this._cursorOffset = 0;
  7475. evt.preventDefault();
  7476. }
  7477. this._blinkIsEven = false;
  7478. this._isTextHighlightOn = false;
  7479. this._cursorIndex = -1;
  7480. this._markAsDirty();
  7481. return;
  7482. case 222: // Dead
  7483. if (evt) {
  7484. evt.preventDefault();
  7485. }
  7486. this._cursorIndex = -1;
  7487. this.deadKey = true;
  7488. break;
  7489. }
  7490. // Printable characters
  7491. if (key &&
  7492. ((keyCode === -1) || // Direct access
  7493. (keyCode === 32) || // Space
  7494. (keyCode > 47 && keyCode < 64) || // Numbers
  7495. (keyCode > 64 && keyCode < 91) || // Letters
  7496. (keyCode > 159 && keyCode < 193) || // Special characters
  7497. (keyCode > 218 && keyCode < 223) || // Special characters
  7498. (keyCode > 95 && keyCode < 112))) { // Numpad
  7499. this._currentKey = key;
  7500. this.onBeforeKeyAddObservable.notifyObservers(this);
  7501. key = this._currentKey;
  7502. if (this._addKey) {
  7503. if (this._isTextHighlightOn) {
  7504. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7505. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7506. this._isTextHighlightOn = false;
  7507. this._blinkIsEven = false;
  7508. this._markAsDirty();
  7509. }
  7510. else if (this._cursorOffset === 0) {
  7511. this.text += key;
  7512. }
  7513. else {
  7514. var insertPosition = this._text.length - this._cursorOffset;
  7515. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7516. }
  7517. }
  7518. }
  7519. };
  7520. /** @hidden */
  7521. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7522. //update the cursor
  7523. this._blinkIsEven = false;
  7524. if (this._cursorIndex === -1) {
  7525. this._cursorIndex = offset;
  7526. }
  7527. else {
  7528. if (this._cursorIndex < this._cursorOffset) {
  7529. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7530. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7531. }
  7532. else if (this._cursorIndex > this._cursorOffset) {
  7533. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7534. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7535. }
  7536. else {
  7537. this._isTextHighlightOn = false;
  7538. this._markAsDirty();
  7539. return;
  7540. }
  7541. }
  7542. this._isTextHighlightOn = true;
  7543. this._markAsDirty();
  7544. };
  7545. /** @hidden */
  7546. InputText.prototype._processDblClick = function (evt) {
  7547. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7548. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7549. this._endHighlightIndex = this._startHighlightIndex;
  7550. var rWord = /\w+/g, moveLeft, moveRight;
  7551. do {
  7552. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7553. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7554. } while (moveLeft || moveRight);
  7555. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7556. this.onTextHighlightObservable.notifyObservers(this);
  7557. this._isTextHighlightOn = true;
  7558. this._clickedCoordinate = null;
  7559. this._blinkIsEven = true;
  7560. this._cursorIndex = -1;
  7561. this._markAsDirty();
  7562. };
  7563. /** @hidden */
  7564. InputText.prototype._selectAllText = function () {
  7565. this._blinkIsEven = true;
  7566. this._isTextHighlightOn = true;
  7567. this._startHighlightIndex = 0;
  7568. this._endHighlightIndex = this._text.length;
  7569. this._cursorOffset = this._text.length;
  7570. this._cursorIndex = -1;
  7571. this._markAsDirty();
  7572. };
  7573. /**
  7574. * Handles the keyboard event
  7575. * @param evt Defines the KeyboardEvent
  7576. */
  7577. InputText.prototype.processKeyboard = function (evt) {
  7578. // process pressed key
  7579. this.processKey(evt.keyCode, evt.key, evt);
  7580. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7581. };
  7582. /** @hidden */
  7583. InputText.prototype._onCopyText = function (ev) {
  7584. this._isTextHighlightOn = false;
  7585. //when write permission to clipbaord data is denied
  7586. try {
  7587. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7588. }
  7589. catch (_a) { } //pass
  7590. this._host.clipboardData = this._highlightedText;
  7591. };
  7592. /** @hidden */
  7593. InputText.prototype._onCutText = function (ev) {
  7594. if (!this._highlightedText) {
  7595. return;
  7596. }
  7597. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7598. this._isTextHighlightOn = false;
  7599. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7600. //when write permission to clipbaord data is denied
  7601. try {
  7602. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7603. }
  7604. catch (_a) { } //pass
  7605. this._host.clipboardData = this._highlightedText;
  7606. this._highlightedText = "";
  7607. };
  7608. /** @hidden */
  7609. InputText.prototype._onPasteText = function (ev) {
  7610. var data = "";
  7611. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7612. data = ev.clipboardData.getData("text/plain");
  7613. }
  7614. else {
  7615. //get the cached data; returns blank string by default
  7616. data = this._host.clipboardData;
  7617. }
  7618. var insertPosition = this._text.length - this._cursorOffset;
  7619. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7620. };
  7621. InputText.prototype._draw = function (context) {
  7622. var _this = this;
  7623. context.save();
  7624. this._applyStates(context);
  7625. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7626. context.shadowColor = this.shadowColor;
  7627. context.shadowBlur = this.shadowBlur;
  7628. context.shadowOffsetX = this.shadowOffsetX;
  7629. context.shadowOffsetY = this.shadowOffsetY;
  7630. }
  7631. // Background
  7632. if (this._isFocused) {
  7633. if (this._focusedBackground) {
  7634. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7635. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7636. }
  7637. }
  7638. else if (this._background) {
  7639. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7640. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7641. }
  7642. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7643. context.shadowBlur = 0;
  7644. context.shadowOffsetX = 0;
  7645. context.shadowOffsetY = 0;
  7646. }
  7647. if (!this._fontOffset) {
  7648. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7649. }
  7650. // Text
  7651. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7652. if (this.color) {
  7653. context.fillStyle = this.color;
  7654. }
  7655. var text = this._beforeRenderText(this._text);
  7656. if (!this._isFocused && !this._text && this._placeholderText) {
  7657. text = this._placeholderText;
  7658. if (this._placeholderColor) {
  7659. context.fillStyle = this._placeholderColor;
  7660. }
  7661. }
  7662. this._textWidth = context.measureText(text).width;
  7663. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7664. if (this._autoStretchWidth) {
  7665. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7666. }
  7667. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7668. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7669. context.save();
  7670. context.beginPath();
  7671. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7672. context.clip();
  7673. if (this._isFocused && this._textWidth > availableWidth) {
  7674. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7675. if (!this._scrollLeft) {
  7676. this._scrollLeft = textLeft;
  7677. }
  7678. }
  7679. else {
  7680. this._scrollLeft = clipTextLeft;
  7681. }
  7682. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7683. // Cursor
  7684. if (this._isFocused) {
  7685. // Need to move cursor
  7686. if (this._clickedCoordinate) {
  7687. var rightPosition = this._scrollLeft + this._textWidth;
  7688. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7689. var currentSize = 0;
  7690. this._cursorOffset = 0;
  7691. var previousDist = 0;
  7692. do {
  7693. if (this._cursorOffset) {
  7694. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7695. }
  7696. this._cursorOffset++;
  7697. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7698. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7699. // Find closest move
  7700. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7701. this._cursorOffset--;
  7702. }
  7703. this._blinkIsEven = false;
  7704. this._clickedCoordinate = null;
  7705. }
  7706. // Render cursor
  7707. if (!this._blinkIsEven) {
  7708. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7709. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7710. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7711. if (cursorLeft < clipTextLeft) {
  7712. this._scrollLeft += (clipTextLeft - cursorLeft);
  7713. cursorLeft = clipTextLeft;
  7714. this._markAsDirty();
  7715. }
  7716. else if (cursorLeft > clipTextLeft + availableWidth) {
  7717. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7718. cursorLeft = clipTextLeft + availableWidth;
  7719. this._markAsDirty();
  7720. }
  7721. if (!this._isTextHighlightOn) {
  7722. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7723. }
  7724. }
  7725. clearTimeout(this._blinkTimeout);
  7726. this._blinkTimeout = setTimeout(function () {
  7727. _this._blinkIsEven = !_this._blinkIsEven;
  7728. _this._markAsDirty();
  7729. }, 500);
  7730. //show the highlighted text
  7731. if (this._isTextHighlightOn) {
  7732. clearTimeout(this._blinkTimeout);
  7733. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7734. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7735. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7736. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7737. if (highlightCursorLeft < clipTextLeft) {
  7738. width = width - (clipTextLeft - highlightCursorLeft);
  7739. if (!width) {
  7740. // when using left arrow on text.length > availableWidth;
  7741. // assigns the width of the first letter after clipTextLeft
  7742. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7743. }
  7744. highlightCursorLeft = clipTextLeft;
  7745. }
  7746. //for transparancy
  7747. context.globalAlpha = this._highligherOpacity;
  7748. context.fillStyle = this._textHighlightColor;
  7749. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7750. context.globalAlpha = 1.0;
  7751. }
  7752. }
  7753. context.restore();
  7754. // Border
  7755. if (this._thickness) {
  7756. if (this._isFocused) {
  7757. if (this.focusedColor) {
  7758. context.strokeStyle = this.focusedColor;
  7759. }
  7760. }
  7761. else {
  7762. if (this.color) {
  7763. context.strokeStyle = this.color;
  7764. }
  7765. }
  7766. context.lineWidth = this._thickness;
  7767. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7768. }
  7769. context.restore();
  7770. };
  7771. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7772. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7773. return false;
  7774. }
  7775. this._clickedCoordinate = coordinates.x;
  7776. this._isTextHighlightOn = false;
  7777. this._highlightedText = "";
  7778. this._cursorIndex = -1;
  7779. this._isPointerDown = true;
  7780. this._host._capturingControl[pointerId] = this;
  7781. if (this._host.focusedControl === this) {
  7782. // Move cursor
  7783. clearTimeout(this._blinkTimeout);
  7784. this._markAsDirty();
  7785. return true;
  7786. }
  7787. if (!this._isEnabled) {
  7788. return false;
  7789. }
  7790. this._host.focusedControl = this;
  7791. return true;
  7792. };
  7793. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7794. if (this._host.focusedControl === this && this._isPointerDown) {
  7795. this._clickedCoordinate = coordinates.x;
  7796. this._markAsDirty();
  7797. this._updateValueFromCursorIndex(this._cursorOffset);
  7798. }
  7799. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7800. };
  7801. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7802. this._isPointerDown = false;
  7803. delete this._host._capturingControl[pointerId];
  7804. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7805. };
  7806. InputText.prototype._beforeRenderText = function (text) {
  7807. return text;
  7808. };
  7809. InputText.prototype.dispose = function () {
  7810. _super.prototype.dispose.call(this);
  7811. this.onBlurObservable.clear();
  7812. this.onFocusObservable.clear();
  7813. this.onTextChangedObservable.clear();
  7814. this.onTextCopyObservable.clear();
  7815. this.onTextCutObservable.clear();
  7816. this.onTextPasteObservable.clear();
  7817. this.onTextHighlightObservable.clear();
  7818. this.onKeyboardEventProcessedObservable.clear();
  7819. };
  7820. return InputText;
  7821. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7822. /***/ }),
  7823. /***/ "./2D/controls/line.ts":
  7824. /*!*****************************!*\
  7825. !*** ./2D/controls/line.ts ***!
  7826. \*****************************/
  7827. /*! exports provided: Line */
  7828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7829. "use strict";
  7830. __webpack_require__.r(__webpack_exports__);
  7831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7832. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7833. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  7834. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7835. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7836. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7837. /** Class used to render 2D lines */
  7838. var Line = /** @class */ (function (_super) {
  7839. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7840. /**
  7841. * Creates a new Line
  7842. * @param name defines the control name
  7843. */
  7844. function Line(name) {
  7845. var _this = _super.call(this, name) || this;
  7846. _this.name = name;
  7847. _this._lineWidth = 1;
  7848. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7849. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7850. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7851. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7852. _this._dash = new Array();
  7853. _this.isHitTestVisible = false;
  7854. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7855. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7856. return _this;
  7857. }
  7858. Object.defineProperty(Line.prototype, "dash", {
  7859. /** Gets or sets the dash pattern */
  7860. get: function () {
  7861. return this._dash;
  7862. },
  7863. set: function (value) {
  7864. if (this._dash === value) {
  7865. return;
  7866. }
  7867. this._dash = value;
  7868. this._markAsDirty();
  7869. },
  7870. enumerable: true,
  7871. configurable: true
  7872. });
  7873. Object.defineProperty(Line.prototype, "connectedControl", {
  7874. /** Gets or sets the control connected with the line end */
  7875. get: function () {
  7876. return this._connectedControl;
  7877. },
  7878. set: function (value) {
  7879. var _this = this;
  7880. if (this._connectedControl === value) {
  7881. return;
  7882. }
  7883. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7884. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7885. this._connectedControlDirtyObserver = null;
  7886. }
  7887. if (value) {
  7888. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7889. }
  7890. this._connectedControl = value;
  7891. this._markAsDirty();
  7892. },
  7893. enumerable: true,
  7894. configurable: true
  7895. });
  7896. Object.defineProperty(Line.prototype, "x1", {
  7897. /** Gets or sets start coordinates on X axis */
  7898. get: function () {
  7899. return this._x1.toString(this._host);
  7900. },
  7901. set: function (value) {
  7902. if (this._x1.toString(this._host) === value) {
  7903. return;
  7904. }
  7905. if (this._x1.fromString(value)) {
  7906. this._markAsDirty();
  7907. }
  7908. },
  7909. enumerable: true,
  7910. configurable: true
  7911. });
  7912. Object.defineProperty(Line.prototype, "y1", {
  7913. /** Gets or sets start coordinates on Y axis */
  7914. get: function () {
  7915. return this._y1.toString(this._host);
  7916. },
  7917. set: function (value) {
  7918. if (this._y1.toString(this._host) === value) {
  7919. return;
  7920. }
  7921. if (this._y1.fromString(value)) {
  7922. this._markAsDirty();
  7923. }
  7924. },
  7925. enumerable: true,
  7926. configurable: true
  7927. });
  7928. Object.defineProperty(Line.prototype, "x2", {
  7929. /** Gets or sets end coordinates on X axis */
  7930. get: function () {
  7931. return this._x2.toString(this._host);
  7932. },
  7933. set: function (value) {
  7934. if (this._x2.toString(this._host) === value) {
  7935. return;
  7936. }
  7937. if (this._x2.fromString(value)) {
  7938. this._markAsDirty();
  7939. }
  7940. },
  7941. enumerable: true,
  7942. configurable: true
  7943. });
  7944. Object.defineProperty(Line.prototype, "y2", {
  7945. /** Gets or sets end coordinates on Y axis */
  7946. get: function () {
  7947. return this._y2.toString(this._host);
  7948. },
  7949. set: function (value) {
  7950. if (this._y2.toString(this._host) === value) {
  7951. return;
  7952. }
  7953. if (this._y2.fromString(value)) {
  7954. this._markAsDirty();
  7955. }
  7956. },
  7957. enumerable: true,
  7958. configurable: true
  7959. });
  7960. Object.defineProperty(Line.prototype, "lineWidth", {
  7961. /** Gets or sets line width */
  7962. get: function () {
  7963. return this._lineWidth;
  7964. },
  7965. set: function (value) {
  7966. if (this._lineWidth === value) {
  7967. return;
  7968. }
  7969. this._lineWidth = value;
  7970. this._markAsDirty();
  7971. },
  7972. enumerable: true,
  7973. configurable: true
  7974. });
  7975. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7976. /** Gets or sets horizontal alignment */
  7977. set: function (value) {
  7978. return;
  7979. },
  7980. enumerable: true,
  7981. configurable: true
  7982. });
  7983. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7984. /** Gets or sets vertical alignment */
  7985. set: function (value) {
  7986. return;
  7987. },
  7988. enumerable: true,
  7989. configurable: true
  7990. });
  7991. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7992. get: function () {
  7993. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7994. },
  7995. enumerable: true,
  7996. configurable: true
  7997. });
  7998. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7999. get: function () {
  8000. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8001. },
  8002. enumerable: true,
  8003. configurable: true
  8004. });
  8005. Line.prototype._getTypeName = function () {
  8006. return "Line";
  8007. };
  8008. Line.prototype._draw = function (context) {
  8009. context.save();
  8010. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8011. context.shadowColor = this.shadowColor;
  8012. context.shadowBlur = this.shadowBlur;
  8013. context.shadowOffsetX = this.shadowOffsetX;
  8014. context.shadowOffsetY = this.shadowOffsetY;
  8015. }
  8016. this._applyStates(context);
  8017. context.strokeStyle = this.color;
  8018. context.lineWidth = this._lineWidth;
  8019. context.setLineDash(this._dash);
  8020. context.beginPath();
  8021. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8022. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8023. context.stroke();
  8024. context.restore();
  8025. };
  8026. Line.prototype._measure = function () {
  8027. // Width / Height
  8028. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8029. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8030. };
  8031. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8032. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8033. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8034. };
  8035. /**
  8036. * Move one end of the line given 3D cartesian coordinates.
  8037. * @param position Targeted world position
  8038. * @param scene Scene
  8039. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8040. */
  8041. Line.prototype.moveToVector3 = function (position, scene, end) {
  8042. if (end === void 0) { end = false; }
  8043. if (!this._host || this.parent !== this._host._rootContainer) {
  8044. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8045. return;
  8046. }
  8047. var globalViewport = this._host._getGlobalViewport(scene);
  8048. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8049. this._moveToProjectedPosition(projectedPosition, end);
  8050. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8051. this.notRenderable = true;
  8052. return;
  8053. }
  8054. this.notRenderable = false;
  8055. };
  8056. /**
  8057. * Move one end of the line to a position in screen absolute space.
  8058. * @param projectedPosition Position in screen absolute space (X, Y)
  8059. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8060. */
  8061. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8062. if (end === void 0) { end = false; }
  8063. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8064. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8065. if (end) {
  8066. this.x2 = x;
  8067. this.y2 = y;
  8068. this._x2.ignoreAdaptiveScaling = true;
  8069. this._y2.ignoreAdaptiveScaling = true;
  8070. }
  8071. else {
  8072. this.x1 = x;
  8073. this.y1 = y;
  8074. this._x1.ignoreAdaptiveScaling = true;
  8075. this._y1.ignoreAdaptiveScaling = true;
  8076. }
  8077. };
  8078. return Line;
  8079. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8080. /***/ }),
  8081. /***/ "./2D/controls/multiLine.ts":
  8082. /*!**********************************!*\
  8083. !*** ./2D/controls/multiLine.ts ***!
  8084. \**********************************/
  8085. /*! exports provided: MultiLine */
  8086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8087. "use strict";
  8088. __webpack_require__.r(__webpack_exports__);
  8089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8090. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8091. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8092. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8093. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8094. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8095. /**
  8096. * Class used to create multi line control
  8097. */
  8098. var MultiLine = /** @class */ (function (_super) {
  8099. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8100. /**
  8101. * Creates a new MultiLine
  8102. * @param name defines the control name
  8103. */
  8104. function MultiLine(name) {
  8105. var _this = _super.call(this, name) || this;
  8106. _this.name = name;
  8107. _this._lineWidth = 1;
  8108. /** Function called when a point is updated */
  8109. _this.onPointUpdate = function () {
  8110. _this._markAsDirty();
  8111. };
  8112. _this.isHitTestVisible = false;
  8113. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8114. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8115. _this._dash = [];
  8116. _this._points = [];
  8117. return _this;
  8118. }
  8119. Object.defineProperty(MultiLine.prototype, "dash", {
  8120. /** Gets or sets dash pattern */
  8121. get: function () {
  8122. return this._dash;
  8123. },
  8124. set: function (value) {
  8125. if (this._dash === value) {
  8126. return;
  8127. }
  8128. this._dash = value;
  8129. this._markAsDirty();
  8130. },
  8131. enumerable: true,
  8132. configurable: true
  8133. });
  8134. /**
  8135. * Gets point stored at specified index
  8136. * @param index defines the index to look for
  8137. * @returns the requested point if found
  8138. */
  8139. MultiLine.prototype.getAt = function (index) {
  8140. if (!this._points[index]) {
  8141. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8142. }
  8143. return this._points[index];
  8144. };
  8145. /**
  8146. * Adds new points to the point collection
  8147. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8148. * @returns the list of created MultiLinePoint
  8149. */
  8150. MultiLine.prototype.add = function () {
  8151. var _this = this;
  8152. var items = [];
  8153. for (var _i = 0; _i < arguments.length; _i++) {
  8154. items[_i] = arguments[_i];
  8155. }
  8156. return items.map(function (item) { return _this.push(item); });
  8157. };
  8158. /**
  8159. * Adds a new point to the point collection
  8160. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8161. * @returns the created MultiLinePoint
  8162. */
  8163. MultiLine.prototype.push = function (item) {
  8164. var point = this.getAt(this._points.length);
  8165. if (item == null) {
  8166. return point;
  8167. }
  8168. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8169. point.mesh = item;
  8170. }
  8171. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8172. point.control = item;
  8173. }
  8174. else if (item.x != null && item.y != null) {
  8175. point.x = item.x;
  8176. point.y = item.y;
  8177. }
  8178. return point;
  8179. };
  8180. /**
  8181. * Remove a specific value or point from the active point collection
  8182. * @param value defines the value or point to remove
  8183. */
  8184. MultiLine.prototype.remove = function (value) {
  8185. var index;
  8186. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8187. index = this._points.indexOf(value);
  8188. if (index === -1) {
  8189. return;
  8190. }
  8191. }
  8192. else {
  8193. index = value;
  8194. }
  8195. var point = this._points[index];
  8196. if (!point) {
  8197. return;
  8198. }
  8199. point.dispose();
  8200. this._points.splice(index, 1);
  8201. };
  8202. /**
  8203. * Resets this object to initial state (no point)
  8204. */
  8205. MultiLine.prototype.reset = function () {
  8206. while (this._points.length > 0) {
  8207. this.remove(this._points.length - 1);
  8208. }
  8209. };
  8210. /**
  8211. * Resets all links
  8212. */
  8213. MultiLine.prototype.resetLinks = function () {
  8214. this._points.forEach(function (point) {
  8215. if (point != null) {
  8216. point.resetLinks();
  8217. }
  8218. });
  8219. };
  8220. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8221. /** Gets or sets line width */
  8222. get: function () {
  8223. return this._lineWidth;
  8224. },
  8225. set: function (value) {
  8226. if (this._lineWidth === value) {
  8227. return;
  8228. }
  8229. this._lineWidth = value;
  8230. this._markAsDirty();
  8231. },
  8232. enumerable: true,
  8233. configurable: true
  8234. });
  8235. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8236. set: function (value) {
  8237. return;
  8238. },
  8239. enumerable: true,
  8240. configurable: true
  8241. });
  8242. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8243. set: function (value) {
  8244. return;
  8245. },
  8246. enumerable: true,
  8247. configurable: true
  8248. });
  8249. MultiLine.prototype._getTypeName = function () {
  8250. return "MultiLine";
  8251. };
  8252. MultiLine.prototype._draw = function (context) {
  8253. context.save();
  8254. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8255. context.shadowColor = this.shadowColor;
  8256. context.shadowBlur = this.shadowBlur;
  8257. context.shadowOffsetX = this.shadowOffsetX;
  8258. context.shadowOffsetY = this.shadowOffsetY;
  8259. }
  8260. this._applyStates(context);
  8261. context.strokeStyle = this.color;
  8262. context.lineWidth = this._lineWidth;
  8263. context.setLineDash(this._dash);
  8264. context.beginPath();
  8265. var first = true; //first index is not necessarily 0
  8266. this._points.forEach(function (point) {
  8267. if (!point) {
  8268. return;
  8269. }
  8270. if (first) {
  8271. context.moveTo(point._point.x, point._point.y);
  8272. first = false;
  8273. }
  8274. else {
  8275. context.lineTo(point._point.x, point._point.y);
  8276. }
  8277. });
  8278. context.stroke();
  8279. context.restore();
  8280. };
  8281. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8282. var _this = this;
  8283. this._minX = null;
  8284. this._minY = null;
  8285. this._maxX = null;
  8286. this._maxY = null;
  8287. this._points.forEach(function (point, index) {
  8288. if (!point) {
  8289. return;
  8290. }
  8291. point.translate();
  8292. if (_this._minX == null || point._point.x < _this._minX) {
  8293. _this._minX = point._point.x;
  8294. }
  8295. if (_this._minY == null || point._point.y < _this._minY) {
  8296. _this._minY = point._point.y;
  8297. }
  8298. if (_this._maxX == null || point._point.x > _this._maxX) {
  8299. _this._maxX = point._point.x;
  8300. }
  8301. if (_this._maxY == null || point._point.y > _this._maxY) {
  8302. _this._maxY = point._point.y;
  8303. }
  8304. });
  8305. if (this._minX == null) {
  8306. this._minX = 0;
  8307. }
  8308. if (this._minY == null) {
  8309. this._minY = 0;
  8310. }
  8311. if (this._maxX == null) {
  8312. this._maxX = 0;
  8313. }
  8314. if (this._maxY == null) {
  8315. this._maxY = 0;
  8316. }
  8317. };
  8318. MultiLine.prototype._measure = function () {
  8319. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8320. return;
  8321. }
  8322. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8323. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8324. };
  8325. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8326. if (this._minX == null || this._minY == null) {
  8327. return;
  8328. }
  8329. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8330. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8331. };
  8332. MultiLine.prototype.dispose = function () {
  8333. this.reset();
  8334. _super.prototype.dispose.call(this);
  8335. };
  8336. return MultiLine;
  8337. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8338. /***/ }),
  8339. /***/ "./2D/controls/radioButton.ts":
  8340. /*!************************************!*\
  8341. !*** ./2D/controls/radioButton.ts ***!
  8342. \************************************/
  8343. /*! exports provided: RadioButton */
  8344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8345. "use strict";
  8346. __webpack_require__.r(__webpack_exports__);
  8347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8348. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8349. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8350. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8351. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8352. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8353. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8354. /**
  8355. * Class used to create radio button controls
  8356. */
  8357. var RadioButton = /** @class */ (function (_super) {
  8358. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8359. /**
  8360. * Creates a new RadioButton
  8361. * @param name defines the control name
  8362. */
  8363. function RadioButton(name) {
  8364. var _this = _super.call(this, name) || this;
  8365. _this.name = name;
  8366. _this._isChecked = false;
  8367. _this._background = "black";
  8368. _this._checkSizeRatio = 0.8;
  8369. _this._thickness = 1;
  8370. /** Gets or sets group name */
  8371. _this.group = "";
  8372. /** Observable raised when isChecked is changed */
  8373. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8374. _this.isPointerBlocker = true;
  8375. return _this;
  8376. }
  8377. Object.defineProperty(RadioButton.prototype, "thickness", {
  8378. /** Gets or sets border thickness */
  8379. get: function () {
  8380. return this._thickness;
  8381. },
  8382. set: function (value) {
  8383. if (this._thickness === value) {
  8384. return;
  8385. }
  8386. this._thickness = value;
  8387. this._markAsDirty();
  8388. },
  8389. enumerable: true,
  8390. configurable: true
  8391. });
  8392. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8393. /** Gets or sets a value indicating the ratio between overall size and check size */
  8394. get: function () {
  8395. return this._checkSizeRatio;
  8396. },
  8397. set: function (value) {
  8398. value = Math.max(Math.min(1, value), 0);
  8399. if (this._checkSizeRatio === value) {
  8400. return;
  8401. }
  8402. this._checkSizeRatio = value;
  8403. this._markAsDirty();
  8404. },
  8405. enumerable: true,
  8406. configurable: true
  8407. });
  8408. Object.defineProperty(RadioButton.prototype, "background", {
  8409. /** Gets or sets background color */
  8410. get: function () {
  8411. return this._background;
  8412. },
  8413. set: function (value) {
  8414. if (this._background === value) {
  8415. return;
  8416. }
  8417. this._background = value;
  8418. this._markAsDirty();
  8419. },
  8420. enumerable: true,
  8421. configurable: true
  8422. });
  8423. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8424. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8425. get: function () {
  8426. return this._isChecked;
  8427. },
  8428. set: function (value) {
  8429. var _this = this;
  8430. if (this._isChecked === value) {
  8431. return;
  8432. }
  8433. this._isChecked = value;
  8434. this._markAsDirty();
  8435. this.onIsCheckedChangedObservable.notifyObservers(value);
  8436. if (this._isChecked && this._host) {
  8437. // Update all controls from same group
  8438. this._host.executeOnAllControls(function (control) {
  8439. if (control === _this) {
  8440. return;
  8441. }
  8442. if (control.group === undefined) {
  8443. return;
  8444. }
  8445. var childRadio = control;
  8446. if (childRadio.group === _this.group) {
  8447. childRadio.isChecked = false;
  8448. }
  8449. });
  8450. }
  8451. },
  8452. enumerable: true,
  8453. configurable: true
  8454. });
  8455. RadioButton.prototype._getTypeName = function () {
  8456. return "RadioButton";
  8457. };
  8458. RadioButton.prototype._draw = function (context) {
  8459. context.save();
  8460. this._applyStates(context);
  8461. var actualWidth = this._currentMeasure.width - this._thickness;
  8462. var actualHeight = this._currentMeasure.height - this._thickness;
  8463. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8464. context.shadowColor = this.shadowColor;
  8465. context.shadowBlur = this.shadowBlur;
  8466. context.shadowOffsetX = this.shadowOffsetX;
  8467. context.shadowOffsetY = this.shadowOffsetY;
  8468. }
  8469. // Outer
  8470. _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);
  8471. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8472. context.fill();
  8473. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8474. context.shadowBlur = 0;
  8475. context.shadowOffsetX = 0;
  8476. context.shadowOffsetY = 0;
  8477. }
  8478. context.strokeStyle = this.color;
  8479. context.lineWidth = this._thickness;
  8480. context.stroke();
  8481. // Inner
  8482. if (this._isChecked) {
  8483. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8484. var offsetWidth = actualWidth * this._checkSizeRatio;
  8485. var offseHeight = actualHeight * this._checkSizeRatio;
  8486. _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);
  8487. context.fill();
  8488. }
  8489. context.restore();
  8490. };
  8491. // Events
  8492. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8493. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8494. return false;
  8495. }
  8496. if (!this.isChecked) {
  8497. this.isChecked = true;
  8498. }
  8499. return true;
  8500. };
  8501. /**
  8502. * Utility function to easily create a radio button with a header
  8503. * @param title defines the label to use for the header
  8504. * @param group defines the group to use for the radio button
  8505. * @param isChecked defines the initial state of the radio button
  8506. * @param onValueChanged defines the callback to call when value changes
  8507. * @returns a StackPanel containing the radio button and a textBlock
  8508. */
  8509. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8510. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8511. panel.isVertical = false;
  8512. panel.height = "30px";
  8513. var radio = new RadioButton();
  8514. radio.width = "20px";
  8515. radio.height = "20px";
  8516. radio.isChecked = isChecked;
  8517. radio.color = "green";
  8518. radio.group = group;
  8519. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8520. panel.addControl(radio);
  8521. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8522. header.text = title;
  8523. header.width = "180px";
  8524. header.paddingLeft = "5px";
  8525. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8526. header.color = "white";
  8527. panel.addControl(header);
  8528. return panel;
  8529. };
  8530. return RadioButton;
  8531. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8532. /***/ }),
  8533. /***/ "./2D/controls/rectangle.ts":
  8534. /*!**********************************!*\
  8535. !*** ./2D/controls/rectangle.ts ***!
  8536. \**********************************/
  8537. /*! exports provided: Rectangle */
  8538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8539. "use strict";
  8540. __webpack_require__.r(__webpack_exports__);
  8541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8542. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8543. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8544. /** Class used to create rectangle container */
  8545. var Rectangle = /** @class */ (function (_super) {
  8546. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8547. /**
  8548. * Creates a new Rectangle
  8549. * @param name defines the control name
  8550. */
  8551. function Rectangle(name) {
  8552. var _this = _super.call(this, name) || this;
  8553. _this.name = name;
  8554. _this._thickness = 1;
  8555. _this._cornerRadius = 0;
  8556. return _this;
  8557. }
  8558. Object.defineProperty(Rectangle.prototype, "thickness", {
  8559. /** Gets or sets border thickness */
  8560. get: function () {
  8561. return this._thickness;
  8562. },
  8563. set: function (value) {
  8564. if (this._thickness === value) {
  8565. return;
  8566. }
  8567. this._thickness = value;
  8568. this._markAsDirty();
  8569. },
  8570. enumerable: true,
  8571. configurable: true
  8572. });
  8573. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8574. /** Gets or sets the corner radius angle */
  8575. get: function () {
  8576. return this._cornerRadius;
  8577. },
  8578. set: function (value) {
  8579. if (value < 0) {
  8580. value = 0;
  8581. }
  8582. if (this._cornerRadius === value) {
  8583. return;
  8584. }
  8585. this._cornerRadius = value;
  8586. this._markAsDirty();
  8587. },
  8588. enumerable: true,
  8589. configurable: true
  8590. });
  8591. Rectangle.prototype._getTypeName = function () {
  8592. return "Rectangle";
  8593. };
  8594. Rectangle.prototype._localDraw = function (context) {
  8595. context.save();
  8596. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8597. context.shadowColor = this.shadowColor;
  8598. context.shadowBlur = this.shadowBlur;
  8599. context.shadowOffsetX = this.shadowOffsetX;
  8600. context.shadowOffsetY = this.shadowOffsetY;
  8601. }
  8602. if (this._background) {
  8603. context.fillStyle = this._background;
  8604. if (this._cornerRadius) {
  8605. this._drawRoundedRect(context, this._thickness / 2);
  8606. context.fill();
  8607. }
  8608. else {
  8609. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8610. }
  8611. }
  8612. if (this._thickness) {
  8613. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8614. context.shadowBlur = 0;
  8615. context.shadowOffsetX = 0;
  8616. context.shadowOffsetY = 0;
  8617. }
  8618. if (this.color) {
  8619. context.strokeStyle = this.color;
  8620. }
  8621. context.lineWidth = this._thickness;
  8622. if (this._cornerRadius) {
  8623. this._drawRoundedRect(context, this._thickness / 2);
  8624. context.stroke();
  8625. }
  8626. else {
  8627. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8628. }
  8629. }
  8630. context.restore();
  8631. };
  8632. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8633. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8634. this._measureForChildren.width -= 2 * this._thickness;
  8635. this._measureForChildren.height -= 2 * this._thickness;
  8636. this._measureForChildren.left += this._thickness;
  8637. this._measureForChildren.top += this._thickness;
  8638. };
  8639. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8640. if (offset === void 0) { offset = 0; }
  8641. var x = this._currentMeasure.left + offset;
  8642. var y = this._currentMeasure.top + offset;
  8643. var width = this._currentMeasure.width - offset * 2;
  8644. var height = this._currentMeasure.height - offset * 2;
  8645. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8646. context.beginPath();
  8647. context.moveTo(x + radius, y);
  8648. context.lineTo(x + width - radius, y);
  8649. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8650. context.lineTo(x + width, y + height - radius);
  8651. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8652. context.lineTo(x + radius, y + height);
  8653. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8654. context.lineTo(x, y + radius);
  8655. context.quadraticCurveTo(x, y, x + radius, y);
  8656. context.closePath();
  8657. };
  8658. Rectangle.prototype._clipForChildren = function (context) {
  8659. if (this._cornerRadius) {
  8660. this._drawRoundedRect(context, this._thickness);
  8661. context.clip();
  8662. }
  8663. };
  8664. return Rectangle;
  8665. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8666. /***/ }),
  8667. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8668. /*!***************************************************!*\
  8669. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8670. \***************************************************/
  8671. /*! exports provided: ScrollViewer */
  8672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8673. "use strict";
  8674. __webpack_require__.r(__webpack_exports__);
  8675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8676. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8677. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/perfCounter");
  8678. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8679. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8680. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8681. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8682. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8683. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8684. /**
  8685. * Class used to hold a viewer window and sliders in a grid
  8686. */
  8687. var ScrollViewer = /** @class */ (function (_super) {
  8688. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8689. /**
  8690. * Creates a new ScrollViewer
  8691. * @param name of ScrollViewer
  8692. */
  8693. function ScrollViewer(name) {
  8694. var _this = _super.call(this, name) || this;
  8695. _this._barSize = 20;
  8696. _this._pointerIsOver = false;
  8697. _this._wheelPrecision = 0.05;
  8698. _this.onDirtyObservable.add(function () {
  8699. _this._horizontalBarSpace.color = _this.color;
  8700. _this._verticalBarSpace.color = _this.color;
  8701. _this._dragSpace.color = _this.color;
  8702. });
  8703. _this.onPointerEnterObservable.add(function () {
  8704. _this._pointerIsOver = true;
  8705. });
  8706. _this.onPointerOutObservable.add(function () {
  8707. _this._pointerIsOver = false;
  8708. });
  8709. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8710. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8711. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8712. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8713. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8714. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8715. _this._grid.addColumnDefinition(1);
  8716. _this._grid.addColumnDefinition(0, true);
  8717. _this._grid.addRowDefinition(1);
  8718. _this._grid.addRowDefinition(0, true);
  8719. _super.prototype.addControl.call(_this, _this._grid);
  8720. _this._grid.addControl(_this._window, 0, 0);
  8721. _this._verticalBar.paddingLeft = 0;
  8722. _this._verticalBar.width = "100%";
  8723. _this._verticalBar.height = "100%";
  8724. _this._verticalBar.barOffset = 0;
  8725. _this._verticalBar.value = 0;
  8726. _this._verticalBar.maximum = 1;
  8727. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8728. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8729. _this._verticalBar.isVertical = true;
  8730. _this._verticalBar.rotation = Math.PI;
  8731. _this._verticalBar.isVisible = false;
  8732. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8733. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8734. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8735. _this._verticalBarSpace.thickness = 1;
  8736. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8737. _this._verticalBarSpace.addControl(_this._verticalBar);
  8738. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8739. _this._window.top = value * _this._endTop + "px";
  8740. });
  8741. _this._horizontalBar.paddingLeft = 0;
  8742. _this._horizontalBar.width = "100%";
  8743. _this._horizontalBar.height = "100%";
  8744. _this._horizontalBar.barOffset = 0;
  8745. _this._horizontalBar.value = 0;
  8746. _this._horizontalBar.maximum = 1;
  8747. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8748. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8749. _this._horizontalBar.isVisible = false;
  8750. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8751. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8752. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8753. _this._horizontalBarSpace.thickness = 1;
  8754. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8755. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8756. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8757. _this._window.left = value * _this._endLeft + "px";
  8758. });
  8759. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8760. _this._dragSpace.thickness = 1;
  8761. _this._grid.addControl(_this._dragSpace, 1, 1);
  8762. // Colors
  8763. _this.barColor = "grey";
  8764. _this.barBackground = "transparent";
  8765. return _this;
  8766. }
  8767. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8768. /**
  8769. * Gets the horizontal scrollbar
  8770. */
  8771. get: function () {
  8772. return this._horizontalBar;
  8773. },
  8774. enumerable: true,
  8775. configurable: true
  8776. });
  8777. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8778. /**
  8779. * Gets the vertical scrollbar
  8780. */
  8781. get: function () {
  8782. return this._verticalBar;
  8783. },
  8784. enumerable: true,
  8785. configurable: true
  8786. });
  8787. /**
  8788. * Adds a new control to the current container
  8789. * @param control defines the control to add
  8790. * @returns the current container
  8791. */
  8792. ScrollViewer.prototype.addControl = function (control) {
  8793. if (!control) {
  8794. return this;
  8795. }
  8796. this._window.addControl(control);
  8797. return this;
  8798. };
  8799. /**
  8800. * Removes a control from the current container
  8801. * @param control defines the control to remove
  8802. * @returns the current container
  8803. */
  8804. ScrollViewer.prototype.removeControl = function (control) {
  8805. this._window.removeControl(control);
  8806. return this;
  8807. };
  8808. Object.defineProperty(ScrollViewer.prototype, "children", {
  8809. /** Gets the list of children */
  8810. get: function () {
  8811. return this._window.children;
  8812. },
  8813. enumerable: true,
  8814. configurable: true
  8815. });
  8816. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8817. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8818. var child = _a[_i];
  8819. child._markMatrixAsDirty();
  8820. }
  8821. };
  8822. /** Reset the scroll viewer window to initial size */
  8823. ScrollViewer.prototype.resetWindow = function () {
  8824. this._window.width = "100%";
  8825. this._window.height = "100%";
  8826. };
  8827. ScrollViewer.prototype._getTypeName = function () {
  8828. return "ScrollViewer";
  8829. };
  8830. ScrollViewer.prototype._buildClientSizes = function () {
  8831. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8832. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8833. this._clientWidth = this._window.parentClientWidth;
  8834. this._clientHeight = this._window.parentClientHeight;
  8835. };
  8836. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8837. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8838. this._buildClientSizes();
  8839. };
  8840. ScrollViewer.prototype._postMeasure = function () {
  8841. _super.prototype._postMeasure.call(this);
  8842. this._updateScroller();
  8843. };
  8844. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8845. /**
  8846. * Gets or sets the mouse wheel precision
  8847. * from 0 to 1 with a default value of 0.05
  8848. * */
  8849. get: function () {
  8850. return this._wheelPrecision;
  8851. },
  8852. set: function (value) {
  8853. if (this._wheelPrecision === value) {
  8854. return;
  8855. }
  8856. if (value < 0) {
  8857. value = 0;
  8858. }
  8859. if (value > 1) {
  8860. value = 1;
  8861. }
  8862. this._wheelPrecision = value;
  8863. },
  8864. enumerable: true,
  8865. configurable: true
  8866. });
  8867. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8868. /** Gets or sets the bar color */
  8869. get: function () {
  8870. return this._barColor;
  8871. },
  8872. set: function (color) {
  8873. if (this._barColor === color) {
  8874. return;
  8875. }
  8876. this._barColor = color;
  8877. this._horizontalBar.color = color;
  8878. this._verticalBar.color = color;
  8879. },
  8880. enumerable: true,
  8881. configurable: true
  8882. });
  8883. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8884. /** Gets or sets the size of the bar */
  8885. get: function () {
  8886. return this._barSize;
  8887. },
  8888. set: function (value) {
  8889. if (this._barSize === value) {
  8890. return;
  8891. }
  8892. this._barSize = value;
  8893. this._markAsDirty();
  8894. if (this._horizontalBar.isVisible) {
  8895. this._grid.setRowDefinition(1, this._barSize, true);
  8896. }
  8897. if (this._verticalBar.isVisible) {
  8898. this._grid.setColumnDefinition(1, this._barSize, true);
  8899. }
  8900. },
  8901. enumerable: true,
  8902. configurable: true
  8903. });
  8904. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8905. /** Gets or sets the bar background */
  8906. get: function () {
  8907. return this._barBackground;
  8908. },
  8909. set: function (color) {
  8910. if (this._barBackground === color) {
  8911. return;
  8912. }
  8913. this._barBackground = color;
  8914. this._horizontalBar.background = color;
  8915. this._verticalBar.background = color;
  8916. this._dragSpace.background = color;
  8917. },
  8918. enumerable: true,
  8919. configurable: true
  8920. });
  8921. /** @hidden */
  8922. ScrollViewer.prototype._updateScroller = function () {
  8923. var windowContentsWidth = this._window._currentMeasure.width;
  8924. var windowContentsHeight = this._window._currentMeasure.height;
  8925. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8926. this._grid.setRowDefinition(1, 0, true);
  8927. this._horizontalBar.isVisible = false;
  8928. this._horizontalBar.value = 0;
  8929. this._rebuildLayout = true;
  8930. }
  8931. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8932. this._grid.setRowDefinition(1, this._barSize, true);
  8933. this._horizontalBar.isVisible = true;
  8934. this._rebuildLayout = true;
  8935. }
  8936. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8937. this._grid.setColumnDefinition(1, 0, true);
  8938. this._verticalBar.isVisible = false;
  8939. this._verticalBar.value = 0;
  8940. this._rebuildLayout = true;
  8941. }
  8942. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8943. this._grid.setColumnDefinition(1, this._barSize, true);
  8944. this._verticalBar.isVisible = true;
  8945. this._rebuildLayout = true;
  8946. }
  8947. this._buildClientSizes();
  8948. this._endLeft = this._clientWidth - windowContentsWidth;
  8949. this._endTop = this._clientHeight - windowContentsHeight;
  8950. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8951. var newTop = this._verticalBar.value * this._endTop + "px";
  8952. if (newLeft !== this._window.left) {
  8953. this._window.left = newLeft;
  8954. this._rebuildLayout = true;
  8955. }
  8956. if (newTop !== this._window.top) {
  8957. this._window.top = newTop;
  8958. this._rebuildLayout = true;
  8959. }
  8960. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8961. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8962. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8963. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8964. };
  8965. ScrollViewer.prototype._link = function (host) {
  8966. _super.prototype._link.call(this, host);
  8967. this._attachWheel();
  8968. };
  8969. /** @hidden */
  8970. ScrollViewer.prototype._attachWheel = function () {
  8971. var _this = this;
  8972. if (!this._host || this._onPointerObserver) {
  8973. return;
  8974. }
  8975. var scene = this._host.getScene();
  8976. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8977. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8978. return;
  8979. }
  8980. if (_this._verticalBar.isVisible == true) {
  8981. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8982. _this._verticalBar.value -= _this._wheelPrecision;
  8983. }
  8984. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8985. _this._verticalBar.value += _this._wheelPrecision;
  8986. }
  8987. }
  8988. if (_this._horizontalBar.isVisible == true) {
  8989. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8990. _this._horizontalBar.value += _this._wheelPrecision;
  8991. }
  8992. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8993. _this._horizontalBar.value -= _this._wheelPrecision;
  8994. }
  8995. }
  8996. });
  8997. };
  8998. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8999. if (!this.isHighlighted) {
  9000. return;
  9001. }
  9002. _super.prototype._renderHighlightSpecific.call(this, context);
  9003. this._grid._renderHighlightSpecific(context);
  9004. context.restore();
  9005. };
  9006. /** Releases associated resources */
  9007. ScrollViewer.prototype.dispose = function () {
  9008. var scene = this._host.getScene();
  9009. if (scene && this._onPointerObserver) {
  9010. scene.onPointerObservable.remove(this._onPointerObserver);
  9011. this._onPointerObserver = null;
  9012. }
  9013. _super.prototype.dispose.call(this);
  9014. };
  9015. return ScrollViewer;
  9016. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9017. /***/ }),
  9018. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9019. /*!*********************************************************!*\
  9020. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9021. \*********************************************************/
  9022. /*! exports provided: _ScrollViewerWindow */
  9023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9024. "use strict";
  9025. __webpack_require__.r(__webpack_exports__);
  9026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9027. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9028. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9029. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9030. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9031. /**
  9032. * Class used to hold a the container for ScrollViewer
  9033. * @hidden
  9034. */
  9035. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9036. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  9037. /**
  9038. * Creates a new ScrollViewerWindow
  9039. * @param name of ScrollViewerWindow
  9040. */
  9041. function _ScrollViewerWindow(name) {
  9042. return _super.call(this, name) || this;
  9043. }
  9044. _ScrollViewerWindow.prototype._getTypeName = function () {
  9045. return "ScrollViewerWindow";
  9046. };
  9047. /** @hidden */
  9048. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9049. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9050. this._measureForChildren.left = this._currentMeasure.left;
  9051. this._measureForChildren.top = this._currentMeasure.top;
  9052. this._measureForChildren.width = parentMeasure.width;
  9053. this._measureForChildren.height = parentMeasure.height;
  9054. };
  9055. _ScrollViewerWindow.prototype._postMeasure = function () {
  9056. var maxWidth = this.parentClientWidth;
  9057. var maxHeight = this.parentClientHeight;
  9058. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9059. var child = _a[_i];
  9060. if (!child.isVisible || child.notRenderable) {
  9061. continue;
  9062. }
  9063. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9064. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9065. }
  9066. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9067. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9068. }
  9069. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9070. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9071. }
  9072. if (this._currentMeasure.width !== maxWidth) {
  9073. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9074. this._currentMeasure.width = maxWidth;
  9075. this._rebuildLayout = true;
  9076. this._isDirty = true;
  9077. }
  9078. if (this._currentMeasure.height !== maxHeight) {
  9079. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9080. this._currentMeasure.height = maxHeight;
  9081. this._rebuildLayout = true;
  9082. this._isDirty = true;
  9083. }
  9084. _super.prototype._postMeasure.call(this);
  9085. };
  9086. return _ScrollViewerWindow;
  9087. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9088. /***/ }),
  9089. /***/ "./2D/controls/selector.ts":
  9090. /*!*********************************!*\
  9091. !*** ./2D/controls/selector.ts ***!
  9092. \*********************************/
  9093. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9095. "use strict";
  9096. __webpack_require__.r(__webpack_exports__);
  9097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9098. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9102. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9103. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9104. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9105. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9106. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9107. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9108. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9109. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9110. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9111. /** Class used to create a RadioGroup
  9112. * which contains groups of radio buttons
  9113. */
  9114. var SelectorGroup = /** @class */ (function () {
  9115. /**
  9116. * Creates a new SelectorGroup
  9117. * @param name of group, used as a group heading
  9118. */
  9119. function SelectorGroup(
  9120. /** name of SelectorGroup */
  9121. name) {
  9122. this.name = name;
  9123. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9124. this._selectors = new Array();
  9125. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9126. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9127. this._groupHeader = this._addGroupHeader(name);
  9128. }
  9129. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9130. /** Gets the groupPanel of the SelectorGroup */
  9131. get: function () {
  9132. return this._groupPanel;
  9133. },
  9134. enumerable: true,
  9135. configurable: true
  9136. });
  9137. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9138. /** Gets the selectors array */
  9139. get: function () {
  9140. return this._selectors;
  9141. },
  9142. enumerable: true,
  9143. configurable: true
  9144. });
  9145. Object.defineProperty(SelectorGroup.prototype, "header", {
  9146. /** Gets and sets the group header */
  9147. get: function () {
  9148. return this._groupHeader.text;
  9149. },
  9150. set: function (label) {
  9151. if (this._groupHeader.text === "label") {
  9152. return;
  9153. }
  9154. this._groupHeader.text = label;
  9155. },
  9156. enumerable: true,
  9157. configurable: true
  9158. });
  9159. /** @hidden */
  9160. SelectorGroup.prototype._addGroupHeader = function (text) {
  9161. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9162. groupHeading.width = 0.9;
  9163. groupHeading.height = "30px";
  9164. groupHeading.textWrapping = true;
  9165. groupHeading.color = "black";
  9166. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9167. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9168. groupHeading.left = "2px";
  9169. this._groupPanel.addControl(groupHeading);
  9170. return groupHeading;
  9171. };
  9172. /** @hidden*/
  9173. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9174. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9175. return;
  9176. }
  9177. return this._selectors[selectorNb];
  9178. };
  9179. /** Removes the selector at the given position
  9180. * @param selectorNb the position of the selector within the group
  9181. */
  9182. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9183. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9184. return;
  9185. }
  9186. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9187. this._selectors.splice(selectorNb, 1);
  9188. };
  9189. return SelectorGroup;
  9190. }());
  9191. /** Class used to create a CheckboxGroup
  9192. * which contains groups of checkbox buttons
  9193. */
  9194. var CheckboxGroup = /** @class */ (function (_super) {
  9195. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9196. function CheckboxGroup() {
  9197. return _super !== null && _super.apply(this, arguments) || this;
  9198. }
  9199. /** Adds a checkbox as a control
  9200. * @param text is the label for the selector
  9201. * @param func is the function called when the Selector is checked
  9202. * @param checked is true when Selector is checked
  9203. */
  9204. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9205. if (func === void 0) { func = function (s) { }; }
  9206. if (checked === void 0) { checked = false; }
  9207. var checked = checked || false;
  9208. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9209. button.width = "20px";
  9210. button.height = "20px";
  9211. button.color = "#364249";
  9212. button.background = "#CCCCCC";
  9213. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9214. button.onIsCheckedChangedObservable.add(function (state) {
  9215. func(state);
  9216. });
  9217. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9218. _selector.height = "30px";
  9219. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9220. _selector.left = "4px";
  9221. this.groupPanel.addControl(_selector);
  9222. this.selectors.push(_selector);
  9223. button.isChecked = checked;
  9224. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9225. button.color = this.groupPanel.parent.parent.buttonColor;
  9226. button.background = this.groupPanel.parent.parent.buttonBackground;
  9227. }
  9228. };
  9229. /** @hidden */
  9230. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9231. this.selectors[selectorNb].children[1].text = label;
  9232. };
  9233. /** @hidden */
  9234. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9235. this.selectors[selectorNb].children[1].color = color;
  9236. };
  9237. /** @hidden */
  9238. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9239. this.selectors[selectorNb].children[0].color = color;
  9240. };
  9241. /** @hidden */
  9242. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9243. this.selectors[selectorNb].children[0].background = color;
  9244. };
  9245. return CheckboxGroup;
  9246. }(SelectorGroup));
  9247. /** Class used to create a RadioGroup
  9248. * which contains groups of radio buttons
  9249. */
  9250. var RadioGroup = /** @class */ (function (_super) {
  9251. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9252. function RadioGroup() {
  9253. var _this = _super !== null && _super.apply(this, arguments) || this;
  9254. _this._selectNb = 0;
  9255. return _this;
  9256. }
  9257. /** Adds a radio button as a control
  9258. * @param label is the label for the selector
  9259. * @param func is the function called when the Selector is checked
  9260. * @param checked is true when Selector is checked
  9261. */
  9262. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9263. if (func === void 0) { func = function (n) { }; }
  9264. if (checked === void 0) { checked = false; }
  9265. var nb = this._selectNb++;
  9266. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9267. button.name = label;
  9268. button.width = "20px";
  9269. button.height = "20px";
  9270. button.color = "#364249";
  9271. button.background = "#CCCCCC";
  9272. button.group = this.name;
  9273. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9274. button.onIsCheckedChangedObservable.add(function (state) {
  9275. if (state) {
  9276. func(nb);
  9277. }
  9278. });
  9279. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9280. _selector.height = "30px";
  9281. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9282. _selector.left = "4px";
  9283. this.groupPanel.addControl(_selector);
  9284. this.selectors.push(_selector);
  9285. button.isChecked = checked;
  9286. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9287. button.color = this.groupPanel.parent.parent.buttonColor;
  9288. button.background = this.groupPanel.parent.parent.buttonBackground;
  9289. }
  9290. };
  9291. /** @hidden */
  9292. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9293. this.selectors[selectorNb].children[1].text = label;
  9294. };
  9295. /** @hidden */
  9296. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9297. this.selectors[selectorNb].children[1].color = color;
  9298. };
  9299. /** @hidden */
  9300. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9301. this.selectors[selectorNb].children[0].color = color;
  9302. };
  9303. /** @hidden */
  9304. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9305. this.selectors[selectorNb].children[0].background = color;
  9306. };
  9307. return RadioGroup;
  9308. }(SelectorGroup));
  9309. /** Class used to create a SliderGroup
  9310. * which contains groups of slider buttons
  9311. */
  9312. var SliderGroup = /** @class */ (function (_super) {
  9313. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9314. function SliderGroup() {
  9315. return _super !== null && _super.apply(this, arguments) || this;
  9316. }
  9317. /**
  9318. * Adds a slider to the SelectorGroup
  9319. * @param label is the label for the SliderBar
  9320. * @param func is the function called when the Slider moves
  9321. * @param unit is a string describing the units used, eg degrees or metres
  9322. * @param min is the minimum value for the Slider
  9323. * @param max is the maximum value for the Slider
  9324. * @param value is the start value for the Slider between min and max
  9325. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9326. */
  9327. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9328. if (func === void 0) { func = function (v) { }; }
  9329. if (unit === void 0) { unit = "Units"; }
  9330. if (min === void 0) { min = 0; }
  9331. if (max === void 0) { max = 0; }
  9332. if (value === void 0) { value = 0; }
  9333. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9334. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9335. button.name = unit;
  9336. button.value = value;
  9337. button.minimum = min;
  9338. button.maximum = max;
  9339. button.width = 0.9;
  9340. button.height = "20px";
  9341. button.color = "#364249";
  9342. button.background = "#CCCCCC";
  9343. button.borderColor = "black";
  9344. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9345. button.left = "4px";
  9346. button.paddingBottom = "4px";
  9347. button.onValueChangedObservable.add(function (value) {
  9348. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9349. func(value);
  9350. });
  9351. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9352. _selector.height = "60px";
  9353. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9354. _selector.left = "4px";
  9355. _selector.children[0].name = label;
  9356. this.groupPanel.addControl(_selector);
  9357. this.selectors.push(_selector);
  9358. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9359. button.color = this.groupPanel.parent.parent.buttonColor;
  9360. button.background = this.groupPanel.parent.parent.buttonBackground;
  9361. }
  9362. };
  9363. /** @hidden */
  9364. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9365. this.selectors[selectorNb].children[0].name = label;
  9366. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9367. };
  9368. /** @hidden */
  9369. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9370. this.selectors[selectorNb].children[0].color = color;
  9371. };
  9372. /** @hidden */
  9373. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9374. this.selectors[selectorNb].children[1].color = color;
  9375. };
  9376. /** @hidden */
  9377. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9378. this.selectors[selectorNb].children[1].background = color;
  9379. };
  9380. return SliderGroup;
  9381. }(SelectorGroup));
  9382. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9383. * @see http://doc.babylonjs.com/how_to/selector
  9384. */
  9385. var SelectionPanel = /** @class */ (function (_super) {
  9386. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9387. /**
  9388. * Creates a new SelectionPanel
  9389. * @param name of SelectionPanel
  9390. * @param groups is an array of SelectionGroups
  9391. */
  9392. function SelectionPanel(
  9393. /** name of SelectionPanel */
  9394. name,
  9395. /** an array of SelectionGroups */
  9396. groups) {
  9397. if (groups === void 0) { groups = []; }
  9398. var _this = _super.call(this, name) || this;
  9399. _this.name = name;
  9400. _this.groups = groups;
  9401. _this._buttonColor = "#364249";
  9402. _this._buttonBackground = "#CCCCCC";
  9403. _this._headerColor = "black";
  9404. _this._barColor = "white";
  9405. _this._barHeight = "2px";
  9406. _this._spacerHeight = "20px";
  9407. _this._bars = new Array();
  9408. _this._groups = groups;
  9409. _this.thickness = 2;
  9410. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9411. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9412. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9413. _this._panel.top = 5;
  9414. _this._panel.left = 5;
  9415. _this._panel.width = 0.95;
  9416. if (groups.length > 0) {
  9417. for (var i = 0; i < groups.length - 1; i++) {
  9418. _this._panel.addControl(groups[i].groupPanel);
  9419. _this._addSpacer();
  9420. }
  9421. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9422. }
  9423. _this.addControl(_this._panel);
  9424. return _this;
  9425. }
  9426. SelectionPanel.prototype._getTypeName = function () {
  9427. return "SelectionPanel";
  9428. };
  9429. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9430. /** Gets or sets the headerColor */
  9431. get: function () {
  9432. return this._headerColor;
  9433. },
  9434. set: function (color) {
  9435. if (this._headerColor === color) {
  9436. return;
  9437. }
  9438. this._headerColor = color;
  9439. this._setHeaderColor();
  9440. },
  9441. enumerable: true,
  9442. configurable: true
  9443. });
  9444. SelectionPanel.prototype._setHeaderColor = function () {
  9445. for (var i = 0; i < this._groups.length; i++) {
  9446. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9447. }
  9448. };
  9449. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9450. /** Gets or sets the button color */
  9451. get: function () {
  9452. return this._buttonColor;
  9453. },
  9454. set: function (color) {
  9455. if (this._buttonColor === color) {
  9456. return;
  9457. }
  9458. this._buttonColor = color;
  9459. this._setbuttonColor();
  9460. },
  9461. enumerable: true,
  9462. configurable: true
  9463. });
  9464. SelectionPanel.prototype._setbuttonColor = function () {
  9465. for (var i = 0; i < this._groups.length; i++) {
  9466. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9467. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9468. }
  9469. }
  9470. };
  9471. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9472. /** Gets or sets the label color */
  9473. get: function () {
  9474. return this._labelColor;
  9475. },
  9476. set: function (color) {
  9477. if (this._labelColor === color) {
  9478. return;
  9479. }
  9480. this._labelColor = color;
  9481. this._setLabelColor();
  9482. },
  9483. enumerable: true,
  9484. configurable: true
  9485. });
  9486. SelectionPanel.prototype._setLabelColor = function () {
  9487. for (var i = 0; i < this._groups.length; i++) {
  9488. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9489. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9490. }
  9491. }
  9492. };
  9493. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9494. /** Gets or sets the button background */
  9495. get: function () {
  9496. return this._buttonBackground;
  9497. },
  9498. set: function (color) {
  9499. if (this._buttonBackground === color) {
  9500. return;
  9501. }
  9502. this._buttonBackground = color;
  9503. this._setButtonBackground();
  9504. },
  9505. enumerable: true,
  9506. configurable: true
  9507. });
  9508. SelectionPanel.prototype._setButtonBackground = function () {
  9509. for (var i = 0; i < this._groups.length; i++) {
  9510. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9511. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9512. }
  9513. }
  9514. };
  9515. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9516. /** Gets or sets the color of separator bar */
  9517. get: function () {
  9518. return this._barColor;
  9519. },
  9520. set: function (color) {
  9521. if (this._barColor === color) {
  9522. return;
  9523. }
  9524. this._barColor = color;
  9525. this._setBarColor();
  9526. },
  9527. enumerable: true,
  9528. configurable: true
  9529. });
  9530. SelectionPanel.prototype._setBarColor = function () {
  9531. for (var i = 0; i < this._bars.length; i++) {
  9532. this._bars[i].children[0].background = this._barColor;
  9533. }
  9534. };
  9535. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9536. /** Gets or sets the height of separator bar */
  9537. get: function () {
  9538. return this._barHeight;
  9539. },
  9540. set: function (value) {
  9541. if (this._barHeight === value) {
  9542. return;
  9543. }
  9544. this._barHeight = value;
  9545. this._setBarHeight();
  9546. },
  9547. enumerable: true,
  9548. configurable: true
  9549. });
  9550. SelectionPanel.prototype._setBarHeight = function () {
  9551. for (var i = 0; i < this._bars.length; i++) {
  9552. this._bars[i].children[0].height = this._barHeight;
  9553. }
  9554. };
  9555. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9556. /** Gets or sets the height of spacers*/
  9557. get: function () {
  9558. return this._spacerHeight;
  9559. },
  9560. set: function (value) {
  9561. if (this._spacerHeight === value) {
  9562. return;
  9563. }
  9564. this._spacerHeight = value;
  9565. this._setSpacerHeight();
  9566. },
  9567. enumerable: true,
  9568. configurable: true
  9569. });
  9570. SelectionPanel.prototype._setSpacerHeight = function () {
  9571. for (var i = 0; i < this._bars.length; i++) {
  9572. this._bars[i].height = this._spacerHeight;
  9573. }
  9574. };
  9575. /** Adds a bar between groups */
  9576. SelectionPanel.prototype._addSpacer = function () {
  9577. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9578. separator.width = 1;
  9579. separator.height = this._spacerHeight;
  9580. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9581. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9582. bar.width = 1;
  9583. bar.height = this._barHeight;
  9584. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9585. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9586. bar.background = this._barColor;
  9587. bar.color = "transparent";
  9588. separator.addControl(bar);
  9589. this._panel.addControl(separator);
  9590. this._bars.push(separator);
  9591. };
  9592. /** Add a group to the selection panel
  9593. * @param group is the selector group to add
  9594. */
  9595. SelectionPanel.prototype.addGroup = function (group) {
  9596. if (this._groups.length > 0) {
  9597. this._addSpacer();
  9598. }
  9599. this._panel.addControl(group.groupPanel);
  9600. this._groups.push(group);
  9601. group.groupPanel.children[0].color = this._headerColor;
  9602. for (var j = 0; j < group.selectors.length; j++) {
  9603. group._setSelectorButtonColor(j, this._buttonColor);
  9604. group._setSelectorButtonBackground(j, this._buttonBackground);
  9605. }
  9606. };
  9607. /** Remove the group from the given position
  9608. * @param groupNb is the position of the group in the list
  9609. */
  9610. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9611. if (groupNb < 0 || groupNb >= this._groups.length) {
  9612. return;
  9613. }
  9614. var group = this._groups[groupNb];
  9615. this._panel.removeControl(group.groupPanel);
  9616. this._groups.splice(groupNb, 1);
  9617. if (groupNb < this._bars.length) {
  9618. this._panel.removeControl(this._bars[groupNb]);
  9619. this._bars.splice(groupNb, 1);
  9620. }
  9621. };
  9622. /** Change a group header label
  9623. * @param label is the new group header label
  9624. * @param groupNb is the number of the group to relabel
  9625. * */
  9626. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9627. if (groupNb < 0 || groupNb >= this._groups.length) {
  9628. return;
  9629. }
  9630. var group = this._groups[groupNb];
  9631. group.groupPanel.children[0].text = label;
  9632. };
  9633. /** Change selector label to the one given
  9634. * @param label is the new selector label
  9635. * @param groupNb is the number of the groupcontaining the selector
  9636. * @param selectorNb is the number of the selector within a group to relabel
  9637. * */
  9638. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9639. if (groupNb < 0 || groupNb >= this._groups.length) {
  9640. return;
  9641. }
  9642. var group = this._groups[groupNb];
  9643. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9644. return;
  9645. }
  9646. group._setSelectorLabel(selectorNb, label);
  9647. };
  9648. /** For a given group position remove the selector at the given position
  9649. * @param groupNb is the number of the group to remove the selector from
  9650. * @param selectorNb is the number of the selector within the group
  9651. */
  9652. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9653. if (groupNb < 0 || groupNb >= this._groups.length) {
  9654. return;
  9655. }
  9656. var group = this._groups[groupNb];
  9657. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9658. return;
  9659. }
  9660. group.removeSelector(selectorNb);
  9661. };
  9662. /** For a given group position of correct type add a checkbox button
  9663. * @param groupNb is the number of the group to remove the selector from
  9664. * @param label is the label for the selector
  9665. * @param func is the function called when the Selector is checked
  9666. * @param checked is true when Selector is checked
  9667. */
  9668. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9669. if (func === void 0) { func = function () { }; }
  9670. if (checked === void 0) { checked = false; }
  9671. if (groupNb < 0 || groupNb >= this._groups.length) {
  9672. return;
  9673. }
  9674. var group = this._groups[groupNb];
  9675. group.addCheckbox(label, func, checked);
  9676. };
  9677. /** For a given group position of correct type add a radio button
  9678. * @param groupNb is the number of the group to remove the selector from
  9679. * @param label is the label for the selector
  9680. * @param func is the function called when the Selector is checked
  9681. * @param checked is true when Selector is checked
  9682. */
  9683. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9684. if (func === void 0) { func = function () { }; }
  9685. if (checked === void 0) { checked = false; }
  9686. if (groupNb < 0 || groupNb >= this._groups.length) {
  9687. return;
  9688. }
  9689. var group = this._groups[groupNb];
  9690. group.addRadio(label, func, checked);
  9691. };
  9692. /**
  9693. * For a given slider group add a slider
  9694. * @param groupNb is the number of the group to add the slider to
  9695. * @param label is the label for the Slider
  9696. * @param func is the function called when the Slider moves
  9697. * @param unit is a string describing the units used, eg degrees or metres
  9698. * @param min is the minimum value for the Slider
  9699. * @param max is the maximum value for the Slider
  9700. * @param value is the start value for the Slider between min and max
  9701. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9702. */
  9703. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9704. if (func === void 0) { func = function () { }; }
  9705. if (unit === void 0) { unit = "Units"; }
  9706. if (min === void 0) { min = 0; }
  9707. if (max === void 0) { max = 0; }
  9708. if (value === void 0) { value = 0; }
  9709. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9710. if (groupNb < 0 || groupNb >= this._groups.length) {
  9711. return;
  9712. }
  9713. var group = this._groups[groupNb];
  9714. group.addSlider(label, func, unit, min, max, value, onVal);
  9715. };
  9716. return SelectionPanel;
  9717. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9718. /***/ }),
  9719. /***/ "./2D/controls/sliders/baseSlider.ts":
  9720. /*!*******************************************!*\
  9721. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9722. \*******************************************/
  9723. /*! exports provided: BaseSlider */
  9724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9725. "use strict";
  9726. __webpack_require__.r(__webpack_exports__);
  9727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9728. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9729. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  9730. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9731. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9732. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9733. /**
  9734. * Class used to create slider controls
  9735. */
  9736. var BaseSlider = /** @class */ (function (_super) {
  9737. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9738. /**
  9739. * Creates a new BaseSlider
  9740. * @param name defines the control name
  9741. */
  9742. function BaseSlider(name) {
  9743. var _this = _super.call(this, name) || this;
  9744. _this.name = name;
  9745. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9746. _this._minimum = 0;
  9747. _this._maximum = 100;
  9748. _this._value = 50;
  9749. _this._isVertical = false;
  9750. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9751. _this._isThumbClamped = false;
  9752. _this._displayThumb = true;
  9753. _this._step = 0;
  9754. _this._lastPointerDownID = -1;
  9755. // Shared rendering info
  9756. _this._effectiveBarOffset = 0;
  9757. /** Observable raised when the sldier value changes */
  9758. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9759. // Events
  9760. _this._pointerIsDown = false;
  9761. _this.isPointerBlocker = true;
  9762. return _this;
  9763. }
  9764. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9765. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9766. get: function () {
  9767. return this._displayThumb;
  9768. },
  9769. set: function (value) {
  9770. if (this._displayThumb === value) {
  9771. return;
  9772. }
  9773. this._displayThumb = value;
  9774. this._markAsDirty();
  9775. },
  9776. enumerable: true,
  9777. configurable: true
  9778. });
  9779. Object.defineProperty(BaseSlider.prototype, "step", {
  9780. /** Gets or sets a step to apply to values (0 by default) */
  9781. get: function () {
  9782. return this._step;
  9783. },
  9784. set: function (value) {
  9785. if (this._step === value) {
  9786. return;
  9787. }
  9788. this._step = value;
  9789. this._markAsDirty();
  9790. },
  9791. enumerable: true,
  9792. configurable: true
  9793. });
  9794. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9795. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9796. get: function () {
  9797. return this._barOffset.toString(this._host);
  9798. },
  9799. set: function (value) {
  9800. if (this._barOffset.toString(this._host) === value) {
  9801. return;
  9802. }
  9803. if (this._barOffset.fromString(value)) {
  9804. this._markAsDirty();
  9805. }
  9806. },
  9807. enumerable: true,
  9808. configurable: true
  9809. });
  9810. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9811. /** Gets main bar offset in pixels*/
  9812. get: function () {
  9813. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9814. },
  9815. enumerable: true,
  9816. configurable: true
  9817. });
  9818. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9819. /** Gets or sets thumb width */
  9820. get: function () {
  9821. return this._thumbWidth.toString(this._host);
  9822. },
  9823. set: function (value) {
  9824. if (this._thumbWidth.toString(this._host) === value) {
  9825. return;
  9826. }
  9827. if (this._thumbWidth.fromString(value)) {
  9828. this._markAsDirty();
  9829. }
  9830. },
  9831. enumerable: true,
  9832. configurable: true
  9833. });
  9834. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9835. /** Gets thumb width in pixels */
  9836. get: function () {
  9837. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9838. },
  9839. enumerable: true,
  9840. configurable: true
  9841. });
  9842. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9843. /** Gets or sets minimum value */
  9844. get: function () {
  9845. return this._minimum;
  9846. },
  9847. set: function (value) {
  9848. if (this._minimum === value) {
  9849. return;
  9850. }
  9851. this._minimum = value;
  9852. this._markAsDirty();
  9853. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9854. },
  9855. enumerable: true,
  9856. configurable: true
  9857. });
  9858. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9859. /** Gets or sets maximum value */
  9860. get: function () {
  9861. return this._maximum;
  9862. },
  9863. set: function (value) {
  9864. if (this._maximum === value) {
  9865. return;
  9866. }
  9867. this._maximum = value;
  9868. this._markAsDirty();
  9869. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9870. },
  9871. enumerable: true,
  9872. configurable: true
  9873. });
  9874. Object.defineProperty(BaseSlider.prototype, "value", {
  9875. /** Gets or sets current value */
  9876. get: function () {
  9877. return this._value;
  9878. },
  9879. set: function (value) {
  9880. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9881. if (this._value === value) {
  9882. return;
  9883. }
  9884. this._value = value;
  9885. this._markAsDirty();
  9886. this.onValueChangedObservable.notifyObservers(this._value);
  9887. },
  9888. enumerable: true,
  9889. configurable: true
  9890. });
  9891. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9892. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9893. get: function () {
  9894. return this._isVertical;
  9895. },
  9896. set: function (value) {
  9897. if (this._isVertical === value) {
  9898. return;
  9899. }
  9900. this._isVertical = value;
  9901. this._markAsDirty();
  9902. },
  9903. enumerable: true,
  9904. configurable: true
  9905. });
  9906. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9907. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9908. get: function () {
  9909. return this._isThumbClamped;
  9910. },
  9911. set: function (value) {
  9912. if (this._isThumbClamped === value) {
  9913. return;
  9914. }
  9915. this._isThumbClamped = value;
  9916. this._markAsDirty();
  9917. },
  9918. enumerable: true,
  9919. configurable: true
  9920. });
  9921. BaseSlider.prototype._getTypeName = function () {
  9922. return "BaseSlider";
  9923. };
  9924. BaseSlider.prototype._getThumbPosition = function () {
  9925. if (this.isVertical) {
  9926. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9927. }
  9928. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9929. };
  9930. BaseSlider.prototype._getThumbThickness = function (type) {
  9931. var thumbThickness = 0;
  9932. switch (type) {
  9933. case "circle":
  9934. if (this._thumbWidth.isPixel) {
  9935. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9936. }
  9937. else {
  9938. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9939. }
  9940. break;
  9941. case "rectangle":
  9942. if (this._thumbWidth.isPixel) {
  9943. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9944. }
  9945. else {
  9946. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9947. }
  9948. }
  9949. return thumbThickness;
  9950. };
  9951. BaseSlider.prototype._prepareRenderingData = function (type) {
  9952. // Main bar
  9953. this._effectiveBarOffset = 0;
  9954. this._renderLeft = this._currentMeasure.left;
  9955. this._renderTop = this._currentMeasure.top;
  9956. this._renderWidth = this._currentMeasure.width;
  9957. this._renderHeight = this._currentMeasure.height;
  9958. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9959. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9960. this._effectiveThumbThickness = this._getThumbThickness(type);
  9961. if (this.displayThumb) {
  9962. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9963. }
  9964. //throw error when height is less than width for vertical slider
  9965. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9966. console.error("Height should be greater than width");
  9967. return;
  9968. }
  9969. if (this._barOffset.isPixel) {
  9970. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9971. }
  9972. else {
  9973. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9974. }
  9975. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9976. if (this.isVertical) {
  9977. this._renderLeft += this._effectiveBarOffset;
  9978. if (!this.isThumbClamped && this.displayThumb) {
  9979. this._renderTop += (this._effectiveThumbThickness / 2);
  9980. }
  9981. this._renderHeight = this._backgroundBoxLength;
  9982. this._renderWidth = this._backgroundBoxThickness;
  9983. }
  9984. else {
  9985. this._renderTop += this._effectiveBarOffset;
  9986. if (!this.isThumbClamped && this.displayThumb) {
  9987. this._renderLeft += (this._effectiveThumbThickness / 2);
  9988. }
  9989. this._renderHeight = this._backgroundBoxThickness;
  9990. this._renderWidth = this._backgroundBoxLength;
  9991. }
  9992. };
  9993. /** @hidden */
  9994. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9995. if (this.rotation != 0) {
  9996. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9997. x = this._transformedPosition.x;
  9998. y = this._transformedPosition.y;
  9999. }
  10000. var value;
  10001. if (this._isVertical) {
  10002. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10003. }
  10004. else {
  10005. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10006. }
  10007. var mult = (1 / this._step) | 0;
  10008. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10009. };
  10010. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10011. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10012. return false;
  10013. }
  10014. this._pointerIsDown = true;
  10015. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10016. this._host._capturingControl[pointerId] = this;
  10017. this._lastPointerDownID = pointerId;
  10018. return true;
  10019. };
  10020. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10021. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10022. if (pointerId != this._lastPointerDownID) {
  10023. return;
  10024. }
  10025. if (this._pointerIsDown) {
  10026. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10027. }
  10028. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10029. };
  10030. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10031. this._pointerIsDown = false;
  10032. delete this._host._capturingControl[pointerId];
  10033. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10034. };
  10035. return BaseSlider;
  10036. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10037. /***/ }),
  10038. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10039. /*!*************************************************!*\
  10040. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10041. \*************************************************/
  10042. /*! exports provided: ImageBasedSlider */
  10043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10044. "use strict";
  10045. __webpack_require__.r(__webpack_exports__);
  10046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10047. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10048. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10049. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10050. /**
  10051. * Class used to create slider controls based on images
  10052. */
  10053. var ImageBasedSlider = /** @class */ (function (_super) {
  10054. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  10055. /**
  10056. * Creates a new ImageBasedSlider
  10057. * @param name defines the control name
  10058. */
  10059. function ImageBasedSlider(name) {
  10060. var _this = _super.call(this, name) || this;
  10061. _this.name = name;
  10062. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10063. return _this;
  10064. }
  10065. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10066. get: function () {
  10067. return this._displayThumb && this.thumbImage != null;
  10068. },
  10069. set: function (value) {
  10070. if (this._displayThumb === value) {
  10071. return;
  10072. }
  10073. this._displayThumb = value;
  10074. this._markAsDirty();
  10075. },
  10076. enumerable: true,
  10077. configurable: true
  10078. });
  10079. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10080. /**
  10081. * Gets or sets the image used to render the background
  10082. */
  10083. get: function () {
  10084. return this._backgroundImage;
  10085. },
  10086. set: function (value) {
  10087. var _this = this;
  10088. if (this._backgroundImage === value) {
  10089. return;
  10090. }
  10091. this._backgroundImage = value;
  10092. if (value && !value.isLoaded) {
  10093. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10094. }
  10095. this._markAsDirty();
  10096. },
  10097. enumerable: true,
  10098. configurable: true
  10099. });
  10100. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10101. /**
  10102. * Gets or sets the image used to render the value bar
  10103. */
  10104. get: function () {
  10105. return this._valueBarImage;
  10106. },
  10107. set: function (value) {
  10108. var _this = this;
  10109. if (this._valueBarImage === value) {
  10110. return;
  10111. }
  10112. this._valueBarImage = value;
  10113. if (value && !value.isLoaded) {
  10114. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10115. }
  10116. this._markAsDirty();
  10117. },
  10118. enumerable: true,
  10119. configurable: true
  10120. });
  10121. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10122. /**
  10123. * Gets or sets the image used to render the thumb
  10124. */
  10125. get: function () {
  10126. return this._thumbImage;
  10127. },
  10128. set: function (value) {
  10129. var _this = this;
  10130. if (this._thumbImage === value) {
  10131. return;
  10132. }
  10133. this._thumbImage = value;
  10134. if (value && !value.isLoaded) {
  10135. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10136. }
  10137. this._markAsDirty();
  10138. },
  10139. enumerable: true,
  10140. configurable: true
  10141. });
  10142. ImageBasedSlider.prototype._getTypeName = function () {
  10143. return "ImageBasedSlider";
  10144. };
  10145. ImageBasedSlider.prototype._draw = function (context) {
  10146. context.save();
  10147. this._applyStates(context);
  10148. this._prepareRenderingData("rectangle");
  10149. var thumbPosition = this._getThumbPosition();
  10150. var left = this._renderLeft;
  10151. var top = this._renderTop;
  10152. var width = this._renderWidth;
  10153. var height = this._renderHeight;
  10154. // Background
  10155. if (this._backgroundImage) {
  10156. this._tempMeasure.copyFromFloats(left, top, width, height);
  10157. if (this.isThumbClamped && this.displayThumb) {
  10158. if (this.isVertical) {
  10159. this._tempMeasure.height += this._effectiveThumbThickness;
  10160. }
  10161. else {
  10162. this._tempMeasure.width += this._effectiveThumbThickness;
  10163. }
  10164. }
  10165. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10166. this._backgroundImage._draw(context);
  10167. }
  10168. // Bar
  10169. if (this._valueBarImage) {
  10170. if (this.isVertical) {
  10171. if (this.isThumbClamped && this.displayThumb) {
  10172. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10173. }
  10174. else {
  10175. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10176. }
  10177. }
  10178. else {
  10179. if (this.isThumbClamped && this.displayThumb) {
  10180. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10181. }
  10182. else {
  10183. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10184. }
  10185. }
  10186. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10187. this._valueBarImage._draw(context);
  10188. }
  10189. // Thumb
  10190. if (this.displayThumb) {
  10191. if (this.isVertical) {
  10192. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10193. }
  10194. else {
  10195. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10196. }
  10197. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10198. this._thumbImage._draw(context);
  10199. }
  10200. context.restore();
  10201. };
  10202. return ImageBasedSlider;
  10203. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10204. /***/ }),
  10205. /***/ "./2D/controls/sliders/scrollBar.ts":
  10206. /*!******************************************!*\
  10207. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10208. \******************************************/
  10209. /*! exports provided: ScrollBar */
  10210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10211. "use strict";
  10212. __webpack_require__.r(__webpack_exports__);
  10213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10214. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10215. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10216. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10217. /**
  10218. * Class used to create slider controls
  10219. */
  10220. var ScrollBar = /** @class */ (function (_super) {
  10221. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10222. /**
  10223. * Creates a new Slider
  10224. * @param name defines the control name
  10225. */
  10226. function ScrollBar(name) {
  10227. var _this = _super.call(this, name) || this;
  10228. _this.name = name;
  10229. _this._background = "black";
  10230. _this._borderColor = "white";
  10231. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10232. return _this;
  10233. }
  10234. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10235. /** Gets or sets border color */
  10236. get: function () {
  10237. return this._borderColor;
  10238. },
  10239. set: function (value) {
  10240. if (this._borderColor === value) {
  10241. return;
  10242. }
  10243. this._borderColor = value;
  10244. this._markAsDirty();
  10245. },
  10246. enumerable: true,
  10247. configurable: true
  10248. });
  10249. Object.defineProperty(ScrollBar.prototype, "background", {
  10250. /** Gets or sets background color */
  10251. get: function () {
  10252. return this._background;
  10253. },
  10254. set: function (value) {
  10255. if (this._background === value) {
  10256. return;
  10257. }
  10258. this._background = value;
  10259. this._markAsDirty();
  10260. },
  10261. enumerable: true,
  10262. configurable: true
  10263. });
  10264. ScrollBar.prototype._getTypeName = function () {
  10265. return "Scrollbar";
  10266. };
  10267. ScrollBar.prototype._getThumbThickness = function () {
  10268. var thumbThickness = 0;
  10269. if (this._thumbWidth.isPixel) {
  10270. thumbThickness = this._thumbWidth.getValue(this._host);
  10271. }
  10272. else {
  10273. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10274. }
  10275. return thumbThickness;
  10276. };
  10277. ScrollBar.prototype._draw = function (context) {
  10278. context.save();
  10279. this._applyStates(context);
  10280. this._prepareRenderingData("rectangle");
  10281. var left = this._renderLeft;
  10282. var thumbPosition = this._getThumbPosition();
  10283. context.fillStyle = this._background;
  10284. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10285. // Value bar
  10286. context.fillStyle = this.color;
  10287. // Thumb
  10288. if (this.isVertical) {
  10289. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10290. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10291. this._thumbMeasure.width = this._currentMeasure.width;
  10292. this._thumbMeasure.height = this._effectiveThumbThickness;
  10293. }
  10294. else {
  10295. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10296. this._thumbMeasure.top = this._currentMeasure.top;
  10297. this._thumbMeasure.width = this._effectiveThumbThickness;
  10298. this._thumbMeasure.height = this._currentMeasure.height;
  10299. }
  10300. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10301. context.restore();
  10302. };
  10303. /** @hidden */
  10304. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10305. if (this.rotation != 0) {
  10306. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10307. x = this._transformedPosition.x;
  10308. y = this._transformedPosition.y;
  10309. }
  10310. if (this._first) {
  10311. this._first = false;
  10312. this._originX = x;
  10313. this._originY = y;
  10314. // Check if move is required
  10315. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10316. if (this.isVertical) {
  10317. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10318. }
  10319. else {
  10320. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10321. }
  10322. }
  10323. }
  10324. // Delta mode
  10325. var delta = 0;
  10326. if (this.isVertical) {
  10327. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10328. }
  10329. else {
  10330. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10331. }
  10332. this.value += delta * (this.maximum - this.minimum);
  10333. this._originX = x;
  10334. this._originY = y;
  10335. };
  10336. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10337. this._first = true;
  10338. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10339. };
  10340. return ScrollBar;
  10341. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10342. /***/ }),
  10343. /***/ "./2D/controls/sliders/slider.ts":
  10344. /*!***************************************!*\
  10345. !*** ./2D/controls/sliders/slider.ts ***!
  10346. \***************************************/
  10347. /*! exports provided: Slider */
  10348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10349. "use strict";
  10350. __webpack_require__.r(__webpack_exports__);
  10351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10352. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10353. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10354. /**
  10355. * Class used to create slider controls
  10356. */
  10357. var Slider = /** @class */ (function (_super) {
  10358. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10359. /**
  10360. * Creates a new Slider
  10361. * @param name defines the control name
  10362. */
  10363. function Slider(name) {
  10364. var _this = _super.call(this, name) || this;
  10365. _this.name = name;
  10366. _this._background = "black";
  10367. _this._borderColor = "white";
  10368. _this._isThumbCircle = false;
  10369. _this._displayValueBar = true;
  10370. return _this;
  10371. }
  10372. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10373. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10374. get: function () {
  10375. return this._displayValueBar;
  10376. },
  10377. set: function (value) {
  10378. if (this._displayValueBar === value) {
  10379. return;
  10380. }
  10381. this._displayValueBar = value;
  10382. this._markAsDirty();
  10383. },
  10384. enumerable: true,
  10385. configurable: true
  10386. });
  10387. Object.defineProperty(Slider.prototype, "borderColor", {
  10388. /** Gets or sets border color */
  10389. get: function () {
  10390. return this._borderColor;
  10391. },
  10392. set: function (value) {
  10393. if (this._borderColor === value) {
  10394. return;
  10395. }
  10396. this._borderColor = value;
  10397. this._markAsDirty();
  10398. },
  10399. enumerable: true,
  10400. configurable: true
  10401. });
  10402. Object.defineProperty(Slider.prototype, "background", {
  10403. /** Gets or sets background color */
  10404. get: function () {
  10405. return this._background;
  10406. },
  10407. set: function (value) {
  10408. if (this._background === value) {
  10409. return;
  10410. }
  10411. this._background = value;
  10412. this._markAsDirty();
  10413. },
  10414. enumerable: true,
  10415. configurable: true
  10416. });
  10417. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10418. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10419. get: function () {
  10420. return this._isThumbCircle;
  10421. },
  10422. set: function (value) {
  10423. if (this._isThumbCircle === value) {
  10424. return;
  10425. }
  10426. this._isThumbCircle = value;
  10427. this._markAsDirty();
  10428. },
  10429. enumerable: true,
  10430. configurable: true
  10431. });
  10432. Slider.prototype._getTypeName = function () {
  10433. return "Slider";
  10434. };
  10435. Slider.prototype._draw = function (context) {
  10436. context.save();
  10437. this._applyStates(context);
  10438. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10439. var left = this._renderLeft;
  10440. var top = this._renderTop;
  10441. var width = this._renderWidth;
  10442. var height = this._renderHeight;
  10443. var radius = 0;
  10444. if (this.isThumbClamped && this.isThumbCircle) {
  10445. if (this.isVertical) {
  10446. top += (this._effectiveThumbThickness / 2);
  10447. }
  10448. else {
  10449. left += (this._effectiveThumbThickness / 2);
  10450. }
  10451. radius = this._backgroundBoxThickness / 2;
  10452. }
  10453. else {
  10454. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10455. }
  10456. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10457. context.shadowColor = this.shadowColor;
  10458. context.shadowBlur = this.shadowBlur;
  10459. context.shadowOffsetX = this.shadowOffsetX;
  10460. context.shadowOffsetY = this.shadowOffsetY;
  10461. }
  10462. var thumbPosition = this._getThumbPosition();
  10463. context.fillStyle = this._background;
  10464. if (this.isVertical) {
  10465. if (this.isThumbClamped) {
  10466. if (this.isThumbCircle) {
  10467. context.beginPath();
  10468. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10469. context.fill();
  10470. context.fillRect(left, top, width, height);
  10471. }
  10472. else {
  10473. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10474. }
  10475. }
  10476. else {
  10477. context.fillRect(left, top, width, height);
  10478. }
  10479. }
  10480. else {
  10481. if (this.isThumbClamped) {
  10482. if (this.isThumbCircle) {
  10483. context.beginPath();
  10484. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10485. context.fill();
  10486. context.fillRect(left, top, width, height);
  10487. }
  10488. else {
  10489. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10490. }
  10491. }
  10492. else {
  10493. context.fillRect(left, top, width, height);
  10494. }
  10495. }
  10496. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10497. context.shadowBlur = 0;
  10498. context.shadowOffsetX = 0;
  10499. context.shadowOffsetY = 0;
  10500. }
  10501. // Value bar
  10502. context.fillStyle = this.color;
  10503. if (this._displayValueBar) {
  10504. if (this.isVertical) {
  10505. if (this.isThumbClamped) {
  10506. if (this.isThumbCircle) {
  10507. context.beginPath();
  10508. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10509. context.fill();
  10510. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10511. }
  10512. else {
  10513. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10514. }
  10515. }
  10516. else {
  10517. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10518. }
  10519. }
  10520. else {
  10521. if (this.isThumbClamped) {
  10522. if (this.isThumbCircle) {
  10523. context.beginPath();
  10524. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10525. context.fill();
  10526. context.fillRect(left, top, thumbPosition, height);
  10527. }
  10528. else {
  10529. context.fillRect(left, top, thumbPosition, height);
  10530. }
  10531. }
  10532. else {
  10533. context.fillRect(left, top, thumbPosition, height);
  10534. }
  10535. }
  10536. }
  10537. // Thumb
  10538. if (this.displayThumb) {
  10539. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10540. context.shadowColor = this.shadowColor;
  10541. context.shadowBlur = this.shadowBlur;
  10542. context.shadowOffsetX = this.shadowOffsetX;
  10543. context.shadowOffsetY = this.shadowOffsetY;
  10544. }
  10545. if (this._isThumbCircle) {
  10546. context.beginPath();
  10547. if (this.isVertical) {
  10548. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10549. }
  10550. else {
  10551. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10552. }
  10553. context.fill();
  10554. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10555. context.shadowBlur = 0;
  10556. context.shadowOffsetX = 0;
  10557. context.shadowOffsetY = 0;
  10558. }
  10559. context.strokeStyle = this._borderColor;
  10560. context.stroke();
  10561. }
  10562. else {
  10563. if (this.isVertical) {
  10564. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10565. }
  10566. else {
  10567. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10568. }
  10569. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10570. context.shadowBlur = 0;
  10571. context.shadowOffsetX = 0;
  10572. context.shadowOffsetY = 0;
  10573. }
  10574. context.strokeStyle = this._borderColor;
  10575. if (this.isVertical) {
  10576. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10577. }
  10578. else {
  10579. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10580. }
  10581. }
  10582. }
  10583. context.restore();
  10584. };
  10585. return Slider;
  10586. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10587. /***/ }),
  10588. /***/ "./2D/controls/stackPanel.ts":
  10589. /*!***********************************!*\
  10590. !*** ./2D/controls/stackPanel.ts ***!
  10591. \***********************************/
  10592. /*! exports provided: StackPanel */
  10593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10594. "use strict";
  10595. __webpack_require__.r(__webpack_exports__);
  10596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10597. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10598. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  10599. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10600. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10601. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10602. /**
  10603. * Class used to create a 2D stack panel container
  10604. */
  10605. var StackPanel = /** @class */ (function (_super) {
  10606. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10607. /**
  10608. * Creates a new StackPanel
  10609. * @param name defines control name
  10610. */
  10611. function StackPanel(name) {
  10612. var _this = _super.call(this, name) || this;
  10613. _this.name = name;
  10614. _this._isVertical = true;
  10615. _this._manualWidth = false;
  10616. _this._manualHeight = false;
  10617. _this._doNotTrackManualChanges = false;
  10618. /**
  10619. * Gets or sets a boolean indicating that layou warnings should be ignored
  10620. */
  10621. _this.ignoreLayoutWarnings = false;
  10622. return _this;
  10623. }
  10624. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10625. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10626. get: function () {
  10627. return this._isVertical;
  10628. },
  10629. set: function (value) {
  10630. if (this._isVertical === value) {
  10631. return;
  10632. }
  10633. this._isVertical = value;
  10634. this._markAsDirty();
  10635. },
  10636. enumerable: true,
  10637. configurable: true
  10638. });
  10639. Object.defineProperty(StackPanel.prototype, "width", {
  10640. get: function () {
  10641. return this._width.toString(this._host);
  10642. },
  10643. /**
  10644. * Gets or sets panel width.
  10645. * This value should not be set when in horizontal mode as it will be computed automatically
  10646. */
  10647. set: function (value) {
  10648. if (!this._doNotTrackManualChanges) {
  10649. this._manualWidth = true;
  10650. }
  10651. if (this._width.toString(this._host) === value) {
  10652. return;
  10653. }
  10654. if (this._width.fromString(value)) {
  10655. this._markAsDirty();
  10656. }
  10657. },
  10658. enumerable: true,
  10659. configurable: true
  10660. });
  10661. Object.defineProperty(StackPanel.prototype, "height", {
  10662. get: function () {
  10663. return this._height.toString(this._host);
  10664. },
  10665. /**
  10666. * Gets or sets panel height.
  10667. * This value should not be set when in vertical mode as it will be computed automatically
  10668. */
  10669. set: function (value) {
  10670. if (!this._doNotTrackManualChanges) {
  10671. this._manualHeight = true;
  10672. }
  10673. if (this._height.toString(this._host) === value) {
  10674. return;
  10675. }
  10676. if (this._height.fromString(value)) {
  10677. this._markAsDirty();
  10678. }
  10679. },
  10680. enumerable: true,
  10681. configurable: true
  10682. });
  10683. StackPanel.prototype._getTypeName = function () {
  10684. return "StackPanel";
  10685. };
  10686. /** @hidden */
  10687. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10688. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10689. var child = _a[_i];
  10690. if (this._isVertical) {
  10691. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10692. }
  10693. else {
  10694. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10695. }
  10696. }
  10697. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10698. };
  10699. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10700. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10701. this._measureForChildren.copyFrom(parentMeasure);
  10702. this._measureForChildren.left = this._currentMeasure.left;
  10703. this._measureForChildren.top = this._currentMeasure.top;
  10704. if (!this.isVertical || this._manualWidth) {
  10705. this._measureForChildren.width = this._currentMeasure.width;
  10706. }
  10707. if (this.isVertical || this._manualHeight) {
  10708. this._measureForChildren.height = this._currentMeasure.height;
  10709. }
  10710. };
  10711. StackPanel.prototype._postMeasure = function () {
  10712. var stackWidth = 0;
  10713. var stackHeight = 0;
  10714. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10715. var child = _a[_i];
  10716. if (!child.isVisible || child.notRenderable) {
  10717. continue;
  10718. }
  10719. if (this._isVertical) {
  10720. if (child.top !== stackHeight + "px") {
  10721. child.top = stackHeight + "px";
  10722. this._rebuildLayout = true;
  10723. child._top.ignoreAdaptiveScaling = true;
  10724. }
  10725. if (child._height.isPercentage) {
  10726. if (!this.ignoreLayoutWarnings) {
  10727. 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");
  10728. }
  10729. }
  10730. else {
  10731. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10732. }
  10733. }
  10734. else {
  10735. if (child.left !== stackWidth + "px") {
  10736. child.left = stackWidth + "px";
  10737. this._rebuildLayout = true;
  10738. child._left.ignoreAdaptiveScaling = true;
  10739. }
  10740. if (child._width.isPercentage) {
  10741. if (!this.ignoreLayoutWarnings) {
  10742. 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");
  10743. }
  10744. }
  10745. else {
  10746. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10747. }
  10748. }
  10749. }
  10750. this._doNotTrackManualChanges = true;
  10751. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10752. // User can now define their own height and width for stack panel.
  10753. var panelWidthChanged = false;
  10754. var panelHeightChanged = false;
  10755. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10756. var previousHeight = this.height;
  10757. this.height = stackHeight + "px";
  10758. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10759. }
  10760. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10761. var previousWidth = this.width;
  10762. this.width = stackWidth + "px";
  10763. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10764. }
  10765. if (panelHeightChanged) {
  10766. this._height.ignoreAdaptiveScaling = true;
  10767. }
  10768. if (panelWidthChanged) {
  10769. this._width.ignoreAdaptiveScaling = true;
  10770. }
  10771. this._doNotTrackManualChanges = false;
  10772. if (panelWidthChanged || panelHeightChanged) {
  10773. this._rebuildLayout = true;
  10774. }
  10775. _super.prototype._postMeasure.call(this);
  10776. };
  10777. return StackPanel;
  10778. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10779. /***/ }),
  10780. /***/ "./2D/controls/statics.ts":
  10781. /*!********************************!*\
  10782. !*** ./2D/controls/statics.ts ***!
  10783. \********************************/
  10784. /*! exports provided: name */
  10785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10786. "use strict";
  10787. __webpack_require__.r(__webpack_exports__);
  10788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10789. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10790. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10791. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10792. /**
  10793. * Forcing an export so that this code will execute
  10794. * @hidden
  10795. */
  10796. var name = "Statics";
  10797. /**
  10798. * Creates a stack panel that can be used to render headers
  10799. * @param control defines the control to associate with the header
  10800. * @param text defines the text of the header
  10801. * @param size defines the size of the header
  10802. * @param options defines options used to configure the header
  10803. * @returns a new StackPanel
  10804. */
  10805. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10806. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10807. var isHorizontal = options ? options.isHorizontal : true;
  10808. var controlFirst = options ? options.controlFirst : true;
  10809. panel.isVertical = !isHorizontal;
  10810. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10811. header.text = text;
  10812. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10813. if (isHorizontal) {
  10814. header.width = size;
  10815. }
  10816. else {
  10817. header.height = size;
  10818. }
  10819. if (controlFirst) {
  10820. panel.addControl(control);
  10821. panel.addControl(header);
  10822. header.paddingLeft = "5px";
  10823. }
  10824. else {
  10825. panel.addControl(header);
  10826. panel.addControl(control);
  10827. header.paddingRight = "5px";
  10828. }
  10829. header.shadowBlur = control.shadowBlur;
  10830. header.shadowColor = control.shadowColor;
  10831. header.shadowOffsetX = control.shadowOffsetX;
  10832. header.shadowOffsetY = control.shadowOffsetY;
  10833. return panel;
  10834. };
  10835. /***/ }),
  10836. /***/ "./2D/controls/textBlock.ts":
  10837. /*!**********************************!*\
  10838. !*** ./2D/controls/textBlock.ts ***!
  10839. \**********************************/
  10840. /*! exports provided: TextWrapping, TextBlock */
  10841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10842. "use strict";
  10843. __webpack_require__.r(__webpack_exports__);
  10844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10846. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10847. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10848. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10849. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10850. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10851. /**
  10852. * Enum that determines the text-wrapping mode to use.
  10853. */
  10854. var TextWrapping;
  10855. (function (TextWrapping) {
  10856. /**
  10857. * Clip the text when it's larger than Control.width; this is the default mode.
  10858. */
  10859. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10860. /**
  10861. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10862. */
  10863. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10864. /**
  10865. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10866. */
  10867. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10868. })(TextWrapping || (TextWrapping = {}));
  10869. /**
  10870. * Class used to create text block control
  10871. */
  10872. var TextBlock = /** @class */ (function (_super) {
  10873. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10874. /**
  10875. * Creates a new TextBlock object
  10876. * @param name defines the name of the control
  10877. * @param text defines the text to display (emptry string by default)
  10878. */
  10879. function TextBlock(
  10880. /**
  10881. * Defines the name of the control
  10882. */
  10883. name, text) {
  10884. if (text === void 0) { text = ""; }
  10885. var _this = _super.call(this, name) || this;
  10886. _this.name = name;
  10887. _this._text = "";
  10888. _this._textWrapping = TextWrapping.Clip;
  10889. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10890. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10891. _this._resizeToFit = false;
  10892. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10893. _this._outlineWidth = 0;
  10894. _this._outlineColor = "white";
  10895. /**
  10896. * An event triggered after the text is changed
  10897. */
  10898. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10899. /**
  10900. * An event triggered after the text was broken up into lines
  10901. */
  10902. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10903. _this.text = text;
  10904. return _this;
  10905. }
  10906. Object.defineProperty(TextBlock.prototype, "lines", {
  10907. /**
  10908. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10909. */
  10910. get: function () {
  10911. return this._lines;
  10912. },
  10913. enumerable: true,
  10914. configurable: true
  10915. });
  10916. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10917. /**
  10918. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10919. */
  10920. get: function () {
  10921. return this._resizeToFit;
  10922. },
  10923. /**
  10924. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10925. */
  10926. set: function (value) {
  10927. if (this._resizeToFit === value) {
  10928. return;
  10929. }
  10930. this._resizeToFit = value;
  10931. if (this._resizeToFit) {
  10932. this._width.ignoreAdaptiveScaling = true;
  10933. this._height.ignoreAdaptiveScaling = true;
  10934. }
  10935. this._markAsDirty();
  10936. },
  10937. enumerable: true,
  10938. configurable: true
  10939. });
  10940. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10941. /**
  10942. * Gets or sets a boolean indicating if text must be wrapped
  10943. */
  10944. get: function () {
  10945. return this._textWrapping;
  10946. },
  10947. /**
  10948. * Gets or sets a boolean indicating if text must be wrapped
  10949. */
  10950. set: function (value) {
  10951. if (this._textWrapping === value) {
  10952. return;
  10953. }
  10954. this._textWrapping = +value;
  10955. this._markAsDirty();
  10956. },
  10957. enumerable: true,
  10958. configurable: true
  10959. });
  10960. Object.defineProperty(TextBlock.prototype, "text", {
  10961. /**
  10962. * Gets or sets text to display
  10963. */
  10964. get: function () {
  10965. return this._text;
  10966. },
  10967. /**
  10968. * Gets or sets text to display
  10969. */
  10970. set: function (value) {
  10971. if (this._text === value) {
  10972. return;
  10973. }
  10974. this._text = value;
  10975. this._markAsDirty();
  10976. this.onTextChangedObservable.notifyObservers(this);
  10977. },
  10978. enumerable: true,
  10979. configurable: true
  10980. });
  10981. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10982. /**
  10983. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10984. */
  10985. get: function () {
  10986. return this._textHorizontalAlignment;
  10987. },
  10988. /**
  10989. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10990. */
  10991. set: function (value) {
  10992. if (this._textHorizontalAlignment === value) {
  10993. return;
  10994. }
  10995. this._textHorizontalAlignment = value;
  10996. this._markAsDirty();
  10997. },
  10998. enumerable: true,
  10999. configurable: true
  11000. });
  11001. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11002. /**
  11003. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11004. */
  11005. get: function () {
  11006. return this._textVerticalAlignment;
  11007. },
  11008. /**
  11009. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11010. */
  11011. set: function (value) {
  11012. if (this._textVerticalAlignment === value) {
  11013. return;
  11014. }
  11015. this._textVerticalAlignment = value;
  11016. this._markAsDirty();
  11017. },
  11018. enumerable: true,
  11019. configurable: true
  11020. });
  11021. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11022. /**
  11023. * Gets or sets line spacing value
  11024. */
  11025. get: function () {
  11026. return this._lineSpacing.toString(this._host);
  11027. },
  11028. /**
  11029. * Gets or sets line spacing value
  11030. */
  11031. set: function (value) {
  11032. if (this._lineSpacing.fromString(value)) {
  11033. this._markAsDirty();
  11034. }
  11035. },
  11036. enumerable: true,
  11037. configurable: true
  11038. });
  11039. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11040. /**
  11041. * Gets or sets outlineWidth of the text to display
  11042. */
  11043. get: function () {
  11044. return this._outlineWidth;
  11045. },
  11046. /**
  11047. * Gets or sets outlineWidth of the text to display
  11048. */
  11049. set: function (value) {
  11050. if (this._outlineWidth === value) {
  11051. return;
  11052. }
  11053. this._outlineWidth = value;
  11054. this._markAsDirty();
  11055. },
  11056. enumerable: true,
  11057. configurable: true
  11058. });
  11059. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11060. /**
  11061. * Gets or sets outlineColor of the text to display
  11062. */
  11063. get: function () {
  11064. return this._outlineColor;
  11065. },
  11066. /**
  11067. * Gets or sets outlineColor of the text to display
  11068. */
  11069. set: function (value) {
  11070. if (this._outlineColor === value) {
  11071. return;
  11072. }
  11073. this._outlineColor = value;
  11074. this._markAsDirty();
  11075. },
  11076. enumerable: true,
  11077. configurable: true
  11078. });
  11079. TextBlock.prototype._getTypeName = function () {
  11080. return "TextBlock";
  11081. };
  11082. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11083. if (!this._fontOffset) {
  11084. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11085. }
  11086. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11087. // Prepare lines
  11088. this._lines = this._breakLines(this._currentMeasure.width, context);
  11089. this.onLinesReadyObservable.notifyObservers(this);
  11090. var maxLineWidth = 0;
  11091. for (var i = 0; i < this._lines.length; i++) {
  11092. var line = this._lines[i];
  11093. if (line.width > maxLineWidth) {
  11094. maxLineWidth = line.width;
  11095. }
  11096. }
  11097. if (this._resizeToFit) {
  11098. if (this._textWrapping === TextWrapping.Clip) {
  11099. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11100. if (newWidth !== this._width.internalValue) {
  11101. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11102. this._rebuildLayout = true;
  11103. }
  11104. }
  11105. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11106. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11107. var lineSpacing = 0;
  11108. if (this._lineSpacing.isPixel) {
  11109. lineSpacing = this._lineSpacing.getValue(this._host);
  11110. }
  11111. else {
  11112. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11113. }
  11114. newHeight += (this._lines.length - 1) * lineSpacing;
  11115. }
  11116. if (newHeight !== this._height.internalValue) {
  11117. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11118. this._rebuildLayout = true;
  11119. }
  11120. }
  11121. };
  11122. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11123. var width = this._currentMeasure.width;
  11124. var x = 0;
  11125. switch (this._textHorizontalAlignment) {
  11126. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11127. x = 0;
  11128. break;
  11129. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11130. x = width - textWidth;
  11131. break;
  11132. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11133. x = (width - textWidth) / 2;
  11134. break;
  11135. }
  11136. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11137. context.shadowColor = this.shadowColor;
  11138. context.shadowBlur = this.shadowBlur;
  11139. context.shadowOffsetX = this.shadowOffsetX;
  11140. context.shadowOffsetY = this.shadowOffsetY;
  11141. }
  11142. if (this.outlineWidth) {
  11143. context.strokeText(text, this._currentMeasure.left + x, y);
  11144. }
  11145. context.fillText(text, this._currentMeasure.left + x, y);
  11146. };
  11147. /** @hidden */
  11148. TextBlock.prototype._draw = function (context) {
  11149. context.save();
  11150. this._applyStates(context);
  11151. // Render lines
  11152. this._renderLines(context);
  11153. context.restore();
  11154. };
  11155. TextBlock.prototype._applyStates = function (context) {
  11156. _super.prototype._applyStates.call(this, context);
  11157. if (this.outlineWidth) {
  11158. context.lineWidth = this.outlineWidth;
  11159. context.strokeStyle = this.outlineColor;
  11160. }
  11161. };
  11162. TextBlock.prototype._breakLines = function (refWidth, context) {
  11163. var lines = [];
  11164. var _lines = this.text.split("\n");
  11165. if (this._textWrapping === TextWrapping.Ellipsis) {
  11166. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11167. var _line = _lines_1[_i];
  11168. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11169. }
  11170. }
  11171. else if (this._textWrapping === TextWrapping.WordWrap) {
  11172. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11173. var _line = _lines_2[_a];
  11174. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11175. }
  11176. }
  11177. else {
  11178. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11179. var _line = _lines_3[_b];
  11180. lines.push(this._parseLine(_line, context));
  11181. }
  11182. }
  11183. return lines;
  11184. };
  11185. TextBlock.prototype._parseLine = function (line, context) {
  11186. if (line === void 0) { line = ''; }
  11187. return { text: line, width: context.measureText(line).width };
  11188. };
  11189. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11190. if (line === void 0) { line = ''; }
  11191. var lineWidth = context.measureText(line).width;
  11192. if (lineWidth > width) {
  11193. line += '…';
  11194. }
  11195. while (line.length > 2 && lineWidth > width) {
  11196. line = line.slice(0, -2) + '…';
  11197. lineWidth = context.measureText(line).width;
  11198. }
  11199. return { text: line, width: lineWidth };
  11200. };
  11201. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11202. if (line === void 0) { line = ''; }
  11203. var lines = [];
  11204. var words = line.split(' ');
  11205. var lineWidth = 0;
  11206. for (var n = 0; n < words.length; n++) {
  11207. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11208. var metrics = context.measureText(testLine);
  11209. var testWidth = metrics.width;
  11210. if (testWidth > width && n > 0) {
  11211. lines.push({ text: line, width: lineWidth });
  11212. line = words[n];
  11213. lineWidth = context.measureText(line).width;
  11214. }
  11215. else {
  11216. lineWidth = testWidth;
  11217. line = testLine;
  11218. }
  11219. }
  11220. lines.push({ text: line, width: lineWidth });
  11221. return lines;
  11222. };
  11223. TextBlock.prototype._renderLines = function (context) {
  11224. var height = this._currentMeasure.height;
  11225. var rootY = 0;
  11226. switch (this._textVerticalAlignment) {
  11227. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11228. rootY = this._fontOffset.ascent;
  11229. break;
  11230. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11231. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11232. break;
  11233. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11234. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11235. break;
  11236. }
  11237. rootY += this._currentMeasure.top;
  11238. for (var i = 0; i < this._lines.length; i++) {
  11239. var line = this._lines[i];
  11240. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11241. if (this._lineSpacing.isPixel) {
  11242. rootY += this._lineSpacing.getValue(this._host);
  11243. }
  11244. else {
  11245. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11246. }
  11247. }
  11248. this._drawText(line.text, line.width, rootY, context);
  11249. rootY += this._fontOffset.height;
  11250. }
  11251. };
  11252. /**
  11253. * Given a width constraint applied on the text block, find the expected height
  11254. * @returns expected height
  11255. */
  11256. TextBlock.prototype.computeExpectedHeight = function () {
  11257. if (this.text && this.widthInPixels) {
  11258. var context_1 = document.createElement('canvas').getContext('2d');
  11259. if (context_1) {
  11260. this._applyStates(context_1);
  11261. if (!this._fontOffset) {
  11262. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11263. }
  11264. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11265. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11266. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11267. var lineSpacing = 0;
  11268. if (this._lineSpacing.isPixel) {
  11269. lineSpacing = this._lineSpacing.getValue(this._host);
  11270. }
  11271. else {
  11272. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11273. }
  11274. newHeight += (lines.length - 1) * lineSpacing;
  11275. }
  11276. return newHeight;
  11277. }
  11278. }
  11279. return 0;
  11280. };
  11281. TextBlock.prototype.dispose = function () {
  11282. _super.prototype.dispose.call(this);
  11283. this.onTextChangedObservable.clear();
  11284. };
  11285. return TextBlock;
  11286. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11287. /***/ }),
  11288. /***/ "./2D/controls/virtualKeyboard.ts":
  11289. /*!****************************************!*\
  11290. !*** ./2D/controls/virtualKeyboard.ts ***!
  11291. \****************************************/
  11292. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11294. "use strict";
  11295. __webpack_require__.r(__webpack_exports__);
  11296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11298. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11299. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11300. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11301. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11302. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11303. /**
  11304. * Class used to store key control properties
  11305. */
  11306. var KeyPropertySet = /** @class */ (function () {
  11307. function KeyPropertySet() {
  11308. }
  11309. return KeyPropertySet;
  11310. }());
  11311. /**
  11312. * Class used to create virtual keyboard
  11313. */
  11314. var VirtualKeyboard = /** @class */ (function (_super) {
  11315. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11316. function VirtualKeyboard() {
  11317. var _this = _super !== null && _super.apply(this, arguments) || this;
  11318. /** Observable raised when a key is pressed */
  11319. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11320. /** Gets or sets default key button width */
  11321. _this.defaultButtonWidth = "40px";
  11322. /** Gets or sets default key button height */
  11323. _this.defaultButtonHeight = "40px";
  11324. /** Gets or sets default key button left padding */
  11325. _this.defaultButtonPaddingLeft = "2px";
  11326. /** Gets or sets default key button right padding */
  11327. _this.defaultButtonPaddingRight = "2px";
  11328. /** Gets or sets default key button top padding */
  11329. _this.defaultButtonPaddingTop = "2px";
  11330. /** Gets or sets default key button bottom padding */
  11331. _this.defaultButtonPaddingBottom = "2px";
  11332. /** Gets or sets default key button foreground color */
  11333. _this.defaultButtonColor = "#DDD";
  11334. /** Gets or sets default key button background color */
  11335. _this.defaultButtonBackground = "#070707";
  11336. /** Gets or sets shift button foreground color */
  11337. _this.shiftButtonColor = "#7799FF";
  11338. /** Gets or sets shift button thickness*/
  11339. _this.selectedShiftThickness = 1;
  11340. /** Gets shift key state */
  11341. _this.shiftState = 0;
  11342. _this._currentlyConnectedInputText = null;
  11343. _this._connectedInputTexts = [];
  11344. _this._onKeyPressObserver = null;
  11345. return _this;
  11346. }
  11347. VirtualKeyboard.prototype._getTypeName = function () {
  11348. return "VirtualKeyboard";
  11349. };
  11350. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11351. var _this = this;
  11352. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11353. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11354. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11355. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11356. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11357. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11358. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11359. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11360. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11361. button.thickness = 0;
  11362. button.isFocusInvisible = true;
  11363. button.shadowColor = this.shadowColor;
  11364. button.shadowBlur = this.shadowBlur;
  11365. button.shadowOffsetX = this.shadowOffsetX;
  11366. button.shadowOffsetY = this.shadowOffsetY;
  11367. button.onPointerUpObservable.add(function () {
  11368. _this.onKeyPressObservable.notifyObservers(key);
  11369. });
  11370. return button;
  11371. };
  11372. /**
  11373. * Adds a new row of keys
  11374. * @param keys defines the list of keys to add
  11375. * @param propertySets defines the associated property sets
  11376. */
  11377. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11378. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11379. panel.isVertical = false;
  11380. panel.isFocusInvisible = true;
  11381. var maxKey = null;
  11382. for (var i = 0; i < keys.length; i++) {
  11383. var properties = null;
  11384. if (propertySets && propertySets.length === keys.length) {
  11385. properties = propertySets[i];
  11386. }
  11387. var key = this._createKey(keys[i], properties);
  11388. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11389. maxKey = key;
  11390. }
  11391. panel.addControl(key);
  11392. }
  11393. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11394. this.addControl(panel);
  11395. };
  11396. /**
  11397. * Set the shift key to a specific state
  11398. * @param shiftState defines the new shift state
  11399. */
  11400. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11401. if (!this.children) {
  11402. return;
  11403. }
  11404. for (var i = 0; i < this.children.length; i++) {
  11405. var row = this.children[i];
  11406. if (!row || !row.children) {
  11407. continue;
  11408. }
  11409. var rowContainer = row;
  11410. for (var j = 0; j < rowContainer.children.length; j++) {
  11411. var button = rowContainer.children[j];
  11412. if (!button || !button.children[0]) {
  11413. continue;
  11414. }
  11415. var button_tblock = button.children[0];
  11416. if (button_tblock.text === "\u21E7") {
  11417. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11418. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11419. }
  11420. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11421. }
  11422. }
  11423. };
  11424. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11425. /** Gets the input text control currently attached to the keyboard */
  11426. get: function () {
  11427. return this._currentlyConnectedInputText;
  11428. },
  11429. enumerable: true,
  11430. configurable: true
  11431. });
  11432. /**
  11433. * Connects the keyboard with an input text control
  11434. *
  11435. * @param input defines the target control
  11436. */
  11437. VirtualKeyboard.prototype.connect = function (input) {
  11438. var _this = this;
  11439. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11440. if (inputTextAlreadyConnected) {
  11441. return;
  11442. }
  11443. if (this._onKeyPressObserver === null) {
  11444. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11445. if (!_this._currentlyConnectedInputText) {
  11446. return;
  11447. }
  11448. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11449. switch (key) {
  11450. case "\u21E7":
  11451. _this.shiftState++;
  11452. if (_this.shiftState > 2) {
  11453. _this.shiftState = 0;
  11454. }
  11455. _this.applyShiftState(_this.shiftState);
  11456. return;
  11457. case "\u2190":
  11458. _this._currentlyConnectedInputText.processKey(8);
  11459. return;
  11460. case "\u21B5":
  11461. _this._currentlyConnectedInputText.processKey(13);
  11462. return;
  11463. }
  11464. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11465. if (_this.shiftState === 1) {
  11466. _this.shiftState = 0;
  11467. _this.applyShiftState(_this.shiftState);
  11468. }
  11469. });
  11470. }
  11471. this.isVisible = false;
  11472. this._currentlyConnectedInputText = input;
  11473. input._connectedVirtualKeyboard = this;
  11474. // Events hooking
  11475. var onFocusObserver = input.onFocusObservable.add(function () {
  11476. _this._currentlyConnectedInputText = input;
  11477. input._connectedVirtualKeyboard = _this;
  11478. _this.isVisible = true;
  11479. });
  11480. var onBlurObserver = input.onBlurObservable.add(function () {
  11481. input._connectedVirtualKeyboard = null;
  11482. _this._currentlyConnectedInputText = null;
  11483. _this.isVisible = false;
  11484. });
  11485. this._connectedInputTexts.push({
  11486. input: input,
  11487. onBlurObserver: onBlurObserver,
  11488. onFocusObserver: onFocusObserver
  11489. });
  11490. };
  11491. /**
  11492. * Disconnects the keyboard from connected InputText controls
  11493. *
  11494. * @param input optionally defines a target control, otherwise all are disconnected
  11495. */
  11496. VirtualKeyboard.prototype.disconnect = function (input) {
  11497. var _this = this;
  11498. if (input) {
  11499. // .find not available on IE
  11500. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11501. if (filtered.length === 1) {
  11502. this._removeConnectedInputObservables(filtered[0]);
  11503. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11504. if (this._currentlyConnectedInputText === input) {
  11505. this._currentlyConnectedInputText = null;
  11506. }
  11507. }
  11508. }
  11509. else {
  11510. this._connectedInputTexts.forEach(function (connectedInputText) {
  11511. _this._removeConnectedInputObservables(connectedInputText);
  11512. });
  11513. this._connectedInputTexts = [];
  11514. }
  11515. if (this._connectedInputTexts.length === 0) {
  11516. this._currentlyConnectedInputText = null;
  11517. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11518. this._onKeyPressObserver = null;
  11519. }
  11520. };
  11521. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11522. connectedInputText.input._connectedVirtualKeyboard = null;
  11523. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11524. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11525. };
  11526. /**
  11527. * Release all resources
  11528. */
  11529. VirtualKeyboard.prototype.dispose = function () {
  11530. _super.prototype.dispose.call(this);
  11531. this.disconnect();
  11532. };
  11533. // Statics
  11534. /**
  11535. * Creates a new keyboard using a default layout
  11536. *
  11537. * @param name defines control name
  11538. * @returns a new VirtualKeyboard
  11539. */
  11540. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11541. var returnValue = new VirtualKeyboard(name);
  11542. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11543. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11544. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11545. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11546. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11547. return returnValue;
  11548. };
  11549. return VirtualKeyboard;
  11550. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11551. /***/ }),
  11552. /***/ "./2D/index.ts":
  11553. /*!*********************!*\
  11554. !*** ./2D/index.ts ***!
  11555. \*********************/
  11556. /*! 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 */
  11557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11558. "use strict";
  11559. __webpack_require__.r(__webpack_exports__);
  11560. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11592. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11594. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11596. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11599. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11601. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11603. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11605. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11607. /***/ }),
  11608. /***/ "./2D/math2D.ts":
  11609. /*!**********************!*\
  11610. !*** ./2D/math2D.ts ***!
  11611. \**********************/
  11612. /*! exports provided: Vector2WithInfo, Matrix2D */
  11613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11614. "use strict";
  11615. __webpack_require__.r(__webpack_exports__);
  11616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11618. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11619. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11620. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11621. /**
  11622. * Class used to transport Vector2 information for pointer events
  11623. */
  11624. var Vector2WithInfo = /** @class */ (function (_super) {
  11625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11626. /**
  11627. * Creates a new Vector2WithInfo
  11628. * @param source defines the vector2 data to transport
  11629. * @param buttonIndex defines the current mouse button index
  11630. */
  11631. function Vector2WithInfo(source,
  11632. /** defines the current mouse button index */
  11633. buttonIndex) {
  11634. if (buttonIndex === void 0) { buttonIndex = 0; }
  11635. var _this = _super.call(this, source.x, source.y) || this;
  11636. _this.buttonIndex = buttonIndex;
  11637. return _this;
  11638. }
  11639. return Vector2WithInfo;
  11640. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11641. /** Class used to provide 2D matrix features */
  11642. var Matrix2D = /** @class */ (function () {
  11643. /**
  11644. * Creates a new matrix
  11645. * @param m00 defines value for (0, 0)
  11646. * @param m01 defines value for (0, 1)
  11647. * @param m10 defines value for (1, 0)
  11648. * @param m11 defines value for (1, 1)
  11649. * @param m20 defines value for (2, 0)
  11650. * @param m21 defines value for (2, 1)
  11651. */
  11652. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11653. /** Gets the internal array of 6 floats used to store matrix data */
  11654. this.m = new Float32Array(6);
  11655. this.fromValues(m00, m01, m10, m11, m20, m21);
  11656. }
  11657. /**
  11658. * Fills the matrix from direct values
  11659. * @param m00 defines value for (0, 0)
  11660. * @param m01 defines value for (0, 1)
  11661. * @param m10 defines value for (1, 0)
  11662. * @param m11 defines value for (1, 1)
  11663. * @param m20 defines value for (2, 0)
  11664. * @param m21 defines value for (2, 1)
  11665. * @returns the current modified matrix
  11666. */
  11667. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11668. this.m[0] = m00;
  11669. this.m[1] = m01;
  11670. this.m[2] = m10;
  11671. this.m[3] = m11;
  11672. this.m[4] = m20;
  11673. this.m[5] = m21;
  11674. return this;
  11675. };
  11676. /**
  11677. * Gets matrix determinant
  11678. * @returns the determinant
  11679. */
  11680. Matrix2D.prototype.determinant = function () {
  11681. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11682. };
  11683. /**
  11684. * Inverses the matrix and stores it in a target matrix
  11685. * @param result defines the target matrix
  11686. * @returns the current matrix
  11687. */
  11688. Matrix2D.prototype.invertToRef = function (result) {
  11689. var l0 = this.m[0];
  11690. var l1 = this.m[1];
  11691. var l2 = this.m[2];
  11692. var l3 = this.m[3];
  11693. var l4 = this.m[4];
  11694. var l5 = this.m[5];
  11695. var det = this.determinant();
  11696. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11697. result.m[0] = 0;
  11698. result.m[1] = 0;
  11699. result.m[2] = 0;
  11700. result.m[3] = 0;
  11701. result.m[4] = 0;
  11702. result.m[5] = 0;
  11703. return this;
  11704. }
  11705. var detDiv = 1 / det;
  11706. var det4 = l2 * l5 - l3 * l4;
  11707. var det5 = l1 * l4 - l0 * l5;
  11708. result.m[0] = l3 * detDiv;
  11709. result.m[1] = -l1 * detDiv;
  11710. result.m[2] = -l2 * detDiv;
  11711. result.m[3] = l0 * detDiv;
  11712. result.m[4] = det4 * detDiv;
  11713. result.m[5] = det5 * detDiv;
  11714. return this;
  11715. };
  11716. /**
  11717. * Multiplies the current matrix with another one
  11718. * @param other defines the second operand
  11719. * @param result defines the target matrix
  11720. * @returns the current matrix
  11721. */
  11722. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11723. var l0 = this.m[0];
  11724. var l1 = this.m[1];
  11725. var l2 = this.m[2];
  11726. var l3 = this.m[3];
  11727. var l4 = this.m[4];
  11728. var l5 = this.m[5];
  11729. var r0 = other.m[0];
  11730. var r1 = other.m[1];
  11731. var r2 = other.m[2];
  11732. var r3 = other.m[3];
  11733. var r4 = other.m[4];
  11734. var r5 = other.m[5];
  11735. result.m[0] = l0 * r0 + l1 * r2;
  11736. result.m[1] = l0 * r1 + l1 * r3;
  11737. result.m[2] = l2 * r0 + l3 * r2;
  11738. result.m[3] = l2 * r1 + l3 * r3;
  11739. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11740. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11741. return this;
  11742. };
  11743. /**
  11744. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11745. * @param x defines the x coordinate to transform
  11746. * @param y defines the x coordinate to transform
  11747. * @param result defines the target vector2
  11748. * @returns the current matrix
  11749. */
  11750. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11751. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11752. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11753. return this;
  11754. };
  11755. // Statics
  11756. /**
  11757. * Creates an identity matrix
  11758. * @returns a new matrix
  11759. */
  11760. Matrix2D.Identity = function () {
  11761. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11762. };
  11763. /**
  11764. * Creates a translation matrix and stores it in a target matrix
  11765. * @param x defines the x coordinate of the translation
  11766. * @param y defines the y coordinate of the translation
  11767. * @param result defines the target matrix
  11768. */
  11769. Matrix2D.TranslationToRef = function (x, y, result) {
  11770. result.fromValues(1, 0, 0, 1, x, y);
  11771. };
  11772. /**
  11773. * Creates a scaling matrix and stores it in a target matrix
  11774. * @param x defines the x coordinate of the scaling
  11775. * @param y defines the y coordinate of the scaling
  11776. * @param result defines the target matrix
  11777. */
  11778. Matrix2D.ScalingToRef = function (x, y, result) {
  11779. result.fromValues(x, 0, 0, y, 0, 0);
  11780. };
  11781. /**
  11782. * Creates a rotation matrix and stores it in a target matrix
  11783. * @param angle defines the rotation angle
  11784. * @param result defines the target matrix
  11785. */
  11786. Matrix2D.RotationToRef = function (angle, result) {
  11787. var s = Math.sin(angle);
  11788. var c = Math.cos(angle);
  11789. result.fromValues(c, s, -s, c, 0, 0);
  11790. };
  11791. /**
  11792. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11793. * @param tx defines the x coordinate of the translation
  11794. * @param ty defines the y coordinate of the translation
  11795. * @param angle defines the rotation angle
  11796. * @param scaleX defines the x coordinate of the scaling
  11797. * @param scaleY defines the y coordinate of the scaling
  11798. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11799. * @param result defines the target matrix
  11800. */
  11801. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11802. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11803. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11804. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11805. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11806. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11807. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11808. if (parentMatrix) {
  11809. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11810. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11811. }
  11812. else {
  11813. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11814. }
  11815. };
  11816. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11817. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11818. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11819. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11820. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11821. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11822. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11823. return Matrix2D;
  11824. }());
  11825. /***/ }),
  11826. /***/ "./2D/measure.ts":
  11827. /*!***********************!*\
  11828. !*** ./2D/measure.ts ***!
  11829. \***********************/
  11830. /*! exports provided: Measure */
  11831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11832. "use strict";
  11833. __webpack_require__.r(__webpack_exports__);
  11834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11835. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11836. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11837. /**
  11838. * Class used to store 2D control sizes
  11839. */
  11840. var Measure = /** @class */ (function () {
  11841. /**
  11842. * Creates a new measure
  11843. * @param left defines left coordinate
  11844. * @param top defines top coordinate
  11845. * @param width defines width dimension
  11846. * @param height defines height dimension
  11847. */
  11848. function Measure(
  11849. /** defines left coordinate */
  11850. left,
  11851. /** defines top coordinate */
  11852. top,
  11853. /** defines width dimension */
  11854. width,
  11855. /** defines height dimension */
  11856. height) {
  11857. this.left = left;
  11858. this.top = top;
  11859. this.width = width;
  11860. this.height = height;
  11861. }
  11862. /**
  11863. * Copy from another measure
  11864. * @param other defines the other measure to copy from
  11865. */
  11866. Measure.prototype.copyFrom = function (other) {
  11867. this.left = other.left;
  11868. this.top = other.top;
  11869. this.width = other.width;
  11870. this.height = other.height;
  11871. };
  11872. /**
  11873. * Copy from a group of 4 floats
  11874. * @param left defines left coordinate
  11875. * @param top defines top coordinate
  11876. * @param width defines width dimension
  11877. * @param height defines height dimension
  11878. */
  11879. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11880. this.left = left;
  11881. this.top = top;
  11882. this.width = width;
  11883. this.height = height;
  11884. };
  11885. /**
  11886. * Computes the axis aligned bounding box measure for two given measures
  11887. * @param a Input measure
  11888. * @param b Input measure
  11889. * @param result the resulting bounding measure
  11890. */
  11891. Measure.CombineToRef = function (a, b, result) {
  11892. var left = Math.min(a.left, b.left);
  11893. var top = Math.min(a.top, b.top);
  11894. var right = Math.max(a.left + a.width, b.left + b.width);
  11895. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11896. result.left = left;
  11897. result.top = top;
  11898. result.width = right - left;
  11899. result.height = bottom - top;
  11900. };
  11901. /**
  11902. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11903. * @param transform the matrix to transform the measure before computing the AABB
  11904. * @param result the resulting AABB
  11905. */
  11906. Measure.prototype.transformToRef = function (transform, result) {
  11907. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11908. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11909. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11910. for (var i = 0; i < 4; i++) {
  11911. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11912. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11913. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11914. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11915. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11916. }
  11917. result.left = min.x;
  11918. result.top = min.y;
  11919. result.width = max.x - min.x;
  11920. result.height = max.y - min.y;
  11921. };
  11922. /**
  11923. * Check equality between this measure and another one
  11924. * @param other defines the other measures
  11925. * @returns true if both measures are equals
  11926. */
  11927. Measure.prototype.isEqualsTo = function (other) {
  11928. if (this.left !== other.left) {
  11929. return false;
  11930. }
  11931. if (this.top !== other.top) {
  11932. return false;
  11933. }
  11934. if (this.width !== other.width) {
  11935. return false;
  11936. }
  11937. if (this.height !== other.height) {
  11938. return false;
  11939. }
  11940. return true;
  11941. };
  11942. /**
  11943. * Creates an empty measure
  11944. * @returns a new measure
  11945. */
  11946. Measure.Empty = function () {
  11947. return new Measure(0, 0, 0, 0);
  11948. };
  11949. return Measure;
  11950. }());
  11951. /***/ }),
  11952. /***/ "./2D/multiLinePoint.ts":
  11953. /*!******************************!*\
  11954. !*** ./2D/multiLinePoint.ts ***!
  11955. \******************************/
  11956. /*! exports provided: MultiLinePoint */
  11957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11958. "use strict";
  11959. __webpack_require__.r(__webpack_exports__);
  11960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11961. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11962. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11963. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11964. /**
  11965. * Class used to store a point for a MultiLine object.
  11966. * The point can be pure 2D coordinates, a mesh or a control
  11967. */
  11968. var MultiLinePoint = /** @class */ (function () {
  11969. /**
  11970. * Creates a new MultiLinePoint
  11971. * @param multiLine defines the source MultiLine object
  11972. */
  11973. function MultiLinePoint(multiLine) {
  11974. this._multiLine = multiLine;
  11975. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11976. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11977. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11978. }
  11979. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11980. /** Gets or sets x coordinate */
  11981. get: function () {
  11982. return this._x.toString(this._multiLine._host);
  11983. },
  11984. set: function (value) {
  11985. if (this._x.toString(this._multiLine._host) === value) {
  11986. return;
  11987. }
  11988. if (this._x.fromString(value)) {
  11989. this._multiLine._markAsDirty();
  11990. }
  11991. },
  11992. enumerable: true,
  11993. configurable: true
  11994. });
  11995. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11996. /** Gets or sets y coordinate */
  11997. get: function () {
  11998. return this._y.toString(this._multiLine._host);
  11999. },
  12000. set: function (value) {
  12001. if (this._y.toString(this._multiLine._host) === value) {
  12002. return;
  12003. }
  12004. if (this._y.fromString(value)) {
  12005. this._multiLine._markAsDirty();
  12006. }
  12007. },
  12008. enumerable: true,
  12009. configurable: true
  12010. });
  12011. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12012. /** Gets or sets the control associated with this point */
  12013. get: function () {
  12014. return this._control;
  12015. },
  12016. set: function (value) {
  12017. if (this._control === value) {
  12018. return;
  12019. }
  12020. if (this._control && this._controlObserver) {
  12021. this._control.onDirtyObservable.remove(this._controlObserver);
  12022. this._controlObserver = null;
  12023. }
  12024. this._control = value;
  12025. if (this._control) {
  12026. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12027. }
  12028. this._multiLine._markAsDirty();
  12029. },
  12030. enumerable: true,
  12031. configurable: true
  12032. });
  12033. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12034. /** Gets or sets the mesh associated with this point */
  12035. get: function () {
  12036. return this._mesh;
  12037. },
  12038. set: function (value) {
  12039. if (this._mesh === value) {
  12040. return;
  12041. }
  12042. if (this._mesh && this._meshObserver) {
  12043. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12044. }
  12045. this._mesh = value;
  12046. if (this._mesh) {
  12047. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12048. }
  12049. this._multiLine._markAsDirty();
  12050. },
  12051. enumerable: true,
  12052. configurable: true
  12053. });
  12054. /** Resets links */
  12055. MultiLinePoint.prototype.resetLinks = function () {
  12056. this.control = null;
  12057. this.mesh = null;
  12058. };
  12059. /**
  12060. * Gets a translation vector
  12061. * @returns the translation vector
  12062. */
  12063. MultiLinePoint.prototype.translate = function () {
  12064. this._point = this._translatePoint();
  12065. return this._point;
  12066. };
  12067. MultiLinePoint.prototype._translatePoint = function () {
  12068. if (this._mesh != null) {
  12069. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12070. }
  12071. else if (this._control != null) {
  12072. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12073. }
  12074. else {
  12075. var host = this._multiLine._host;
  12076. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12077. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12078. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12079. }
  12080. };
  12081. /** Release associated resources */
  12082. MultiLinePoint.prototype.dispose = function () {
  12083. this.resetLinks();
  12084. };
  12085. return MultiLinePoint;
  12086. }());
  12087. /***/ }),
  12088. /***/ "./2D/style.ts":
  12089. /*!*********************!*\
  12090. !*** ./2D/style.ts ***!
  12091. \*********************/
  12092. /*! exports provided: Style */
  12093. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12094. "use strict";
  12095. __webpack_require__.r(__webpack_exports__);
  12096. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12097. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12098. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12099. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12100. /**
  12101. * Define a style used by control to automatically setup properties based on a template.
  12102. * Only support font related properties so far
  12103. */
  12104. var Style = /** @class */ (function () {
  12105. /**
  12106. * Creates a new style object
  12107. * @param host defines the AdvancedDynamicTexture which hosts this style
  12108. */
  12109. function Style(host) {
  12110. this._fontFamily = "Arial";
  12111. this._fontStyle = "";
  12112. this._fontWeight = "";
  12113. /** @hidden */
  12114. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12115. /**
  12116. * Observable raised when the style values are changed
  12117. */
  12118. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12119. this._host = host;
  12120. }
  12121. Object.defineProperty(Style.prototype, "fontSize", {
  12122. /**
  12123. * Gets or sets the font size
  12124. */
  12125. get: function () {
  12126. return this._fontSize.toString(this._host);
  12127. },
  12128. set: function (value) {
  12129. if (this._fontSize.toString(this._host) === value) {
  12130. return;
  12131. }
  12132. if (this._fontSize.fromString(value)) {
  12133. this.onChangedObservable.notifyObservers(this);
  12134. }
  12135. },
  12136. enumerable: true,
  12137. configurable: true
  12138. });
  12139. Object.defineProperty(Style.prototype, "fontFamily", {
  12140. /**
  12141. * Gets or sets the font family
  12142. */
  12143. get: function () {
  12144. return this._fontFamily;
  12145. },
  12146. set: function (value) {
  12147. if (this._fontFamily === value) {
  12148. return;
  12149. }
  12150. this._fontFamily = value;
  12151. this.onChangedObservable.notifyObservers(this);
  12152. },
  12153. enumerable: true,
  12154. configurable: true
  12155. });
  12156. Object.defineProperty(Style.prototype, "fontStyle", {
  12157. /**
  12158. * Gets or sets the font style
  12159. */
  12160. get: function () {
  12161. return this._fontStyle;
  12162. },
  12163. set: function (value) {
  12164. if (this._fontStyle === value) {
  12165. return;
  12166. }
  12167. this._fontStyle = value;
  12168. this.onChangedObservable.notifyObservers(this);
  12169. },
  12170. enumerable: true,
  12171. configurable: true
  12172. });
  12173. Object.defineProperty(Style.prototype, "fontWeight", {
  12174. /** Gets or sets font weight */
  12175. get: function () {
  12176. return this._fontWeight;
  12177. },
  12178. set: function (value) {
  12179. if (this._fontWeight === value) {
  12180. return;
  12181. }
  12182. this._fontWeight = value;
  12183. this.onChangedObservable.notifyObservers(this);
  12184. },
  12185. enumerable: true,
  12186. configurable: true
  12187. });
  12188. /** Dispose all associated resources */
  12189. Style.prototype.dispose = function () {
  12190. this.onChangedObservable.clear();
  12191. };
  12192. return Style;
  12193. }());
  12194. /***/ }),
  12195. /***/ "./2D/valueAndUnit.ts":
  12196. /*!****************************!*\
  12197. !*** ./2D/valueAndUnit.ts ***!
  12198. \****************************/
  12199. /*! exports provided: ValueAndUnit */
  12200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12201. "use strict";
  12202. __webpack_require__.r(__webpack_exports__);
  12203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12204. /**
  12205. * Class used to specific a value and its associated unit
  12206. */
  12207. var ValueAndUnit = /** @class */ (function () {
  12208. /**
  12209. * Creates a new ValueAndUnit
  12210. * @param value defines the value to store
  12211. * @param unit defines the unit to store
  12212. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12213. */
  12214. function ValueAndUnit(value,
  12215. /** defines the unit to store */
  12216. unit,
  12217. /** defines a boolean indicating if the value can be negative */
  12218. negativeValueAllowed) {
  12219. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12220. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12221. this.unit = unit;
  12222. this.negativeValueAllowed = negativeValueAllowed;
  12223. this._value = 1;
  12224. /**
  12225. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12226. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12227. */
  12228. this.ignoreAdaptiveScaling = false;
  12229. this._value = value;
  12230. this._originalUnit = unit;
  12231. }
  12232. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12233. /** Gets a boolean indicating if the value is a percentage */
  12234. get: function () {
  12235. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12236. },
  12237. enumerable: true,
  12238. configurable: true
  12239. });
  12240. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12241. /** Gets a boolean indicating if the value is store as pixel */
  12242. get: function () {
  12243. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12244. },
  12245. enumerable: true,
  12246. configurable: true
  12247. });
  12248. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12249. /** Gets direct internal value */
  12250. get: function () {
  12251. return this._value;
  12252. },
  12253. enumerable: true,
  12254. configurable: true
  12255. });
  12256. /**
  12257. * Gets value as pixel
  12258. * @param host defines the root host
  12259. * @param refValue defines the reference value for percentages
  12260. * @returns the value as pixel
  12261. */
  12262. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12263. if (this.isPixel) {
  12264. return this.getValue(host);
  12265. }
  12266. return this.getValue(host) * refValue;
  12267. };
  12268. /**
  12269. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12270. * @param value defines the value to store
  12271. * @param unit defines the unit to store
  12272. * @returns the current ValueAndUnit
  12273. */
  12274. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12275. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12276. this._value = value;
  12277. this.unit = unit;
  12278. return this;
  12279. };
  12280. /**
  12281. * Gets the value accordingly to its unit
  12282. * @param host defines the root host
  12283. * @returns the value
  12284. */
  12285. ValueAndUnit.prototype.getValue = function (host) {
  12286. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12287. var width = 0;
  12288. var height = 0;
  12289. if (host.idealWidth) {
  12290. width = (this._value * host.getSize().width) / host.idealWidth;
  12291. }
  12292. if (host.idealHeight) {
  12293. height = (this._value * host.getSize().height) / host.idealHeight;
  12294. }
  12295. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12296. return window.innerWidth < window.innerHeight ? width : height;
  12297. }
  12298. if (host.idealWidth) { // horizontal
  12299. return width;
  12300. }
  12301. if (host.idealHeight) { // vertical
  12302. return height;
  12303. }
  12304. }
  12305. return this._value;
  12306. };
  12307. /**
  12308. * Gets a string representation of the value
  12309. * @param host defines the root host
  12310. * @param decimals defines an optional number of decimals to display
  12311. * @returns a string
  12312. */
  12313. ValueAndUnit.prototype.toString = function (host, decimals) {
  12314. switch (this.unit) {
  12315. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12316. var percentage = this.getValue(host) * 100;
  12317. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12318. case ValueAndUnit.UNITMODE_PIXEL:
  12319. var pixels = this.getValue(host);
  12320. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12321. }
  12322. return this.unit.toString();
  12323. };
  12324. /**
  12325. * Store a value parsed from a string
  12326. * @param source defines the source string
  12327. * @returns true if the value was successfully parsed
  12328. */
  12329. ValueAndUnit.prototype.fromString = function (source) {
  12330. var match = ValueAndUnit._Regex.exec(source.toString());
  12331. if (!match || match.length === 0) {
  12332. return false;
  12333. }
  12334. var sourceValue = parseFloat(match[1]);
  12335. var sourceUnit = this._originalUnit;
  12336. if (!this.negativeValueAllowed) {
  12337. if (sourceValue < 0) {
  12338. sourceValue = 0;
  12339. }
  12340. }
  12341. if (match.length === 4) {
  12342. switch (match[3]) {
  12343. case "px":
  12344. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12345. break;
  12346. case "%":
  12347. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12348. sourceValue /= 100.0;
  12349. break;
  12350. }
  12351. }
  12352. if (sourceValue === this._value && sourceUnit === this.unit) {
  12353. return false;
  12354. }
  12355. this._value = sourceValue;
  12356. this.unit = sourceUnit;
  12357. return true;
  12358. };
  12359. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12360. /** UNITMODE_PERCENTAGE */
  12361. get: function () {
  12362. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12363. },
  12364. enumerable: true,
  12365. configurable: true
  12366. });
  12367. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12368. /** UNITMODE_PIXEL */
  12369. get: function () {
  12370. return ValueAndUnit._UNITMODE_PIXEL;
  12371. },
  12372. enumerable: true,
  12373. configurable: true
  12374. });
  12375. // Static
  12376. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12377. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12378. ValueAndUnit._UNITMODE_PIXEL = 1;
  12379. return ValueAndUnit;
  12380. }());
  12381. /***/ }),
  12382. /***/ "./3D/controls/abstractButton3D.ts":
  12383. /*!*****************************************!*\
  12384. !*** ./3D/controls/abstractButton3D.ts ***!
  12385. \*****************************************/
  12386. /*! exports provided: AbstractButton3D */
  12387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12388. "use strict";
  12389. __webpack_require__.r(__webpack_exports__);
  12390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12391. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12392. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  12393. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12394. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12395. /**
  12396. * Class used as a root to all buttons
  12397. */
  12398. var AbstractButton3D = /** @class */ (function (_super) {
  12399. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12400. /**
  12401. * Creates a new button
  12402. * @param name defines the control name
  12403. */
  12404. function AbstractButton3D(name) {
  12405. return _super.call(this, name) || this;
  12406. }
  12407. AbstractButton3D.prototype._getTypeName = function () {
  12408. return "AbstractButton3D";
  12409. };
  12410. // Mesh association
  12411. AbstractButton3D.prototype._createNode = function (scene) {
  12412. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12413. };
  12414. return AbstractButton3D;
  12415. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12416. /***/ }),
  12417. /***/ "./3D/controls/button3D.ts":
  12418. /*!*********************************!*\
  12419. !*** ./3D/controls/button3D.ts ***!
  12420. \*********************************/
  12421. /*! exports provided: Button3D */
  12422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12423. "use strict";
  12424. __webpack_require__.r(__webpack_exports__);
  12425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12426. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12427. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12428. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12429. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12430. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12431. /**
  12432. * Class used to create a button in 3D
  12433. */
  12434. var Button3D = /** @class */ (function (_super) {
  12435. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12436. /**
  12437. * Creates a new button
  12438. * @param name defines the control name
  12439. */
  12440. function Button3D(name) {
  12441. var _this = _super.call(this, name) || this;
  12442. _this._contentResolution = 512;
  12443. _this._contentScaleRatio = 2;
  12444. // Default animations
  12445. _this.pointerEnterAnimation = function () {
  12446. if (!_this.mesh) {
  12447. return;
  12448. }
  12449. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12450. };
  12451. _this.pointerOutAnimation = function () {
  12452. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12453. };
  12454. _this.pointerDownAnimation = function () {
  12455. if (!_this.mesh) {
  12456. return;
  12457. }
  12458. _this.mesh.scaling.scaleInPlace(0.95);
  12459. };
  12460. _this.pointerUpAnimation = function () {
  12461. if (!_this.mesh) {
  12462. return;
  12463. }
  12464. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12465. };
  12466. return _this;
  12467. }
  12468. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12469. /**
  12470. * Gets or sets the texture resolution used to render content (512 by default)
  12471. */
  12472. get: function () {
  12473. return this._contentResolution;
  12474. },
  12475. set: function (value) {
  12476. if (this._contentResolution === value) {
  12477. return;
  12478. }
  12479. this._contentResolution = value;
  12480. this._resetContent();
  12481. },
  12482. enumerable: true,
  12483. configurable: true
  12484. });
  12485. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12486. /**
  12487. * Gets or sets the texture scale ratio used to render content (2 by default)
  12488. */
  12489. get: function () {
  12490. return this._contentScaleRatio;
  12491. },
  12492. set: function (value) {
  12493. if (this._contentScaleRatio === value) {
  12494. return;
  12495. }
  12496. this._contentScaleRatio = value;
  12497. this._resetContent();
  12498. },
  12499. enumerable: true,
  12500. configurable: true
  12501. });
  12502. Button3D.prototype._disposeFacadeTexture = function () {
  12503. if (this._facadeTexture) {
  12504. this._facadeTexture.dispose();
  12505. this._facadeTexture = null;
  12506. }
  12507. };
  12508. Button3D.prototype._resetContent = function () {
  12509. this._disposeFacadeTexture();
  12510. this.content = this._content;
  12511. };
  12512. Object.defineProperty(Button3D.prototype, "content", {
  12513. /**
  12514. * Gets or sets the GUI 2D content used to display the button's facade
  12515. */
  12516. get: function () {
  12517. return this._content;
  12518. },
  12519. set: function (value) {
  12520. this._content = value;
  12521. if (!this._host || !this._host.utilityLayer) {
  12522. return;
  12523. }
  12524. if (!this._facadeTexture) {
  12525. 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);
  12526. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12527. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12528. this._facadeTexture.premulAlpha = true;
  12529. }
  12530. this._facadeTexture.addControl(value);
  12531. this._applyFacade(this._facadeTexture);
  12532. },
  12533. enumerable: true,
  12534. configurable: true
  12535. });
  12536. /**
  12537. * Apply the facade texture (created from the content property).
  12538. * This function can be overloaded by child classes
  12539. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12540. */
  12541. Button3D.prototype._applyFacade = function (facadeTexture) {
  12542. this._currentMaterial.emissiveTexture = facadeTexture;
  12543. };
  12544. Button3D.prototype._getTypeName = function () {
  12545. return "Button3D";
  12546. };
  12547. // Mesh association
  12548. Button3D.prototype._createNode = function (scene) {
  12549. var faceUV = new Array(6);
  12550. for (var i = 0; i < 6; i++) {
  12551. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12552. }
  12553. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12554. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12555. width: 1.0,
  12556. height: 1.0,
  12557. depth: 0.08,
  12558. faceUV: faceUV
  12559. }, scene);
  12560. return mesh;
  12561. };
  12562. Button3D.prototype._affectMaterial = function (mesh) {
  12563. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12564. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12565. mesh.material = material;
  12566. this._currentMaterial = material;
  12567. this._resetContent();
  12568. };
  12569. /**
  12570. * Releases all associated resources
  12571. */
  12572. Button3D.prototype.dispose = function () {
  12573. _super.prototype.dispose.call(this);
  12574. this._disposeFacadeTexture();
  12575. if (this._currentMaterial) {
  12576. this._currentMaterial.dispose();
  12577. }
  12578. };
  12579. return Button3D;
  12580. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12581. /***/ }),
  12582. /***/ "./3D/controls/container3D.ts":
  12583. /*!************************************!*\
  12584. !*** ./3D/controls/container3D.ts ***!
  12585. \************************************/
  12586. /*! exports provided: Container3D */
  12587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12588. "use strict";
  12589. __webpack_require__.r(__webpack_exports__);
  12590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12591. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12592. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  12593. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12594. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12595. /**
  12596. * Class used to create containers for controls
  12597. */
  12598. var Container3D = /** @class */ (function (_super) {
  12599. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12600. /**
  12601. * Creates a new container
  12602. * @param name defines the container name
  12603. */
  12604. function Container3D(name) {
  12605. var _this = _super.call(this, name) || this;
  12606. _this._blockLayout = false;
  12607. /**
  12608. * Gets the list of child controls
  12609. */
  12610. _this._children = new Array();
  12611. return _this;
  12612. }
  12613. Object.defineProperty(Container3D.prototype, "children", {
  12614. /**
  12615. * Gets the list of child controls
  12616. */
  12617. get: function () {
  12618. return this._children;
  12619. },
  12620. enumerable: true,
  12621. configurable: true
  12622. });
  12623. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12624. /**
  12625. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12626. * This is helpful to optimize layout operation when adding multiple children in a row
  12627. */
  12628. get: function () {
  12629. return this._blockLayout;
  12630. },
  12631. set: function (value) {
  12632. if (this._blockLayout === value) {
  12633. return;
  12634. }
  12635. this._blockLayout = value;
  12636. if (!this._blockLayout) {
  12637. this._arrangeChildren();
  12638. }
  12639. },
  12640. enumerable: true,
  12641. configurable: true
  12642. });
  12643. /**
  12644. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12645. * @returns the current container
  12646. */
  12647. Container3D.prototype.updateLayout = function () {
  12648. this._arrangeChildren();
  12649. return this;
  12650. };
  12651. /**
  12652. * Gets a boolean indicating if the given control is in the children of this control
  12653. * @param control defines the control to check
  12654. * @returns true if the control is in the child list
  12655. */
  12656. Container3D.prototype.containsControl = function (control) {
  12657. return this._children.indexOf(control) !== -1;
  12658. };
  12659. /**
  12660. * Adds a control to the children of this control
  12661. * @param control defines the control to add
  12662. * @returns the current container
  12663. */
  12664. Container3D.prototype.addControl = function (control) {
  12665. var index = this._children.indexOf(control);
  12666. if (index !== -1) {
  12667. return this;
  12668. }
  12669. control.parent = this;
  12670. control._host = this._host;
  12671. this._children.push(control);
  12672. if (this._host.utilityLayer) {
  12673. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12674. if (control.node) {
  12675. control.node.parent = this.node;
  12676. }
  12677. if (!this.blockLayout) {
  12678. this._arrangeChildren();
  12679. }
  12680. }
  12681. return this;
  12682. };
  12683. /**
  12684. * This function will be called everytime a new control is added
  12685. */
  12686. Container3D.prototype._arrangeChildren = function () {
  12687. };
  12688. Container3D.prototype._createNode = function (scene) {
  12689. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12690. };
  12691. /**
  12692. * Removes a control from the children of this control
  12693. * @param control defines the control to remove
  12694. * @returns the current container
  12695. */
  12696. Container3D.prototype.removeControl = function (control) {
  12697. var index = this._children.indexOf(control);
  12698. if (index !== -1) {
  12699. this._children.splice(index, 1);
  12700. control.parent = null;
  12701. control._disposeNode();
  12702. }
  12703. return this;
  12704. };
  12705. Container3D.prototype._getTypeName = function () {
  12706. return "Container3D";
  12707. };
  12708. /**
  12709. * Releases all associated resources
  12710. */
  12711. Container3D.prototype.dispose = function () {
  12712. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12713. var control = _a[_i];
  12714. control.dispose();
  12715. }
  12716. this._children = [];
  12717. _super.prototype.dispose.call(this);
  12718. };
  12719. /** Control rotation will remain unchanged */
  12720. Container3D.UNSET_ORIENTATION = 0;
  12721. /** Control will rotate to make it look at sphere central axis */
  12722. Container3D.FACEORIGIN_ORIENTATION = 1;
  12723. /** Control will rotate to make it look back at sphere central axis */
  12724. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12725. /** Control will rotate to look at z axis (0, 0, 1) */
  12726. Container3D.FACEFORWARD_ORIENTATION = 3;
  12727. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12728. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12729. return Container3D;
  12730. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12731. /***/ }),
  12732. /***/ "./3D/controls/control3D.ts":
  12733. /*!**********************************!*\
  12734. !*** ./3D/controls/control3D.ts ***!
  12735. \**********************************/
  12736. /*! exports provided: Control3D */
  12737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12738. "use strict";
  12739. __webpack_require__.r(__webpack_exports__);
  12740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12741. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12742. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12743. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12744. /**
  12745. * Class used as base class for controls
  12746. */
  12747. var Control3D = /** @class */ (function () {
  12748. /**
  12749. * Creates a new control
  12750. * @param name defines the control name
  12751. */
  12752. function Control3D(
  12753. /** Defines the control name */
  12754. name) {
  12755. this.name = name;
  12756. this._downCount = 0;
  12757. this._enterCount = -1;
  12758. this._downPointerIds = {};
  12759. this._isVisible = true;
  12760. /**
  12761. * An event triggered when the pointer move over the control
  12762. */
  12763. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12764. /**
  12765. * An event triggered when the pointer move out of the control
  12766. */
  12767. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12768. /**
  12769. * An event triggered when the pointer taps the control
  12770. */
  12771. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12772. /**
  12773. * An event triggered when pointer is up
  12774. */
  12775. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12776. /**
  12777. * An event triggered when a control is clicked on (with a mouse)
  12778. */
  12779. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12780. /**
  12781. * An event triggered when pointer enters the control
  12782. */
  12783. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12784. // Behaviors
  12785. this._behaviors = new Array();
  12786. }
  12787. Object.defineProperty(Control3D.prototype, "position", {
  12788. /** Gets or sets the control position in world space */
  12789. get: function () {
  12790. if (!this._node) {
  12791. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12792. }
  12793. return this._node.position;
  12794. },
  12795. set: function (value) {
  12796. if (!this._node) {
  12797. return;
  12798. }
  12799. this._node.position = value;
  12800. },
  12801. enumerable: true,
  12802. configurable: true
  12803. });
  12804. Object.defineProperty(Control3D.prototype, "scaling", {
  12805. /** Gets or sets the control scaling in world space */
  12806. get: function () {
  12807. if (!this._node) {
  12808. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12809. }
  12810. return this._node.scaling;
  12811. },
  12812. set: function (value) {
  12813. if (!this._node) {
  12814. return;
  12815. }
  12816. this._node.scaling = value;
  12817. },
  12818. enumerable: true,
  12819. configurable: true
  12820. });
  12821. Object.defineProperty(Control3D.prototype, "behaviors", {
  12822. /**
  12823. * Gets the list of attached behaviors
  12824. * @see http://doc.babylonjs.com/features/behaviour
  12825. */
  12826. get: function () {
  12827. return this._behaviors;
  12828. },
  12829. enumerable: true,
  12830. configurable: true
  12831. });
  12832. /**
  12833. * Attach a behavior to the control
  12834. * @see http://doc.babylonjs.com/features/behaviour
  12835. * @param behavior defines the behavior to attach
  12836. * @returns the current control
  12837. */
  12838. Control3D.prototype.addBehavior = function (behavior) {
  12839. var _this = this;
  12840. var index = this._behaviors.indexOf(behavior);
  12841. if (index !== -1) {
  12842. return this;
  12843. }
  12844. behavior.init();
  12845. var scene = this._host.scene;
  12846. if (scene.isLoading) {
  12847. // We defer the attach when the scene will be loaded
  12848. scene.onDataLoadedObservable.addOnce(function () {
  12849. behavior.attach(_this);
  12850. });
  12851. }
  12852. else {
  12853. behavior.attach(this);
  12854. }
  12855. this._behaviors.push(behavior);
  12856. return this;
  12857. };
  12858. /**
  12859. * Remove an attached behavior
  12860. * @see http://doc.babylonjs.com/features/behaviour
  12861. * @param behavior defines the behavior to attach
  12862. * @returns the current control
  12863. */
  12864. Control3D.prototype.removeBehavior = function (behavior) {
  12865. var index = this._behaviors.indexOf(behavior);
  12866. if (index === -1) {
  12867. return this;
  12868. }
  12869. this._behaviors[index].detach();
  12870. this._behaviors.splice(index, 1);
  12871. return this;
  12872. };
  12873. /**
  12874. * Gets an attached behavior by name
  12875. * @param name defines the name of the behavior to look for
  12876. * @see http://doc.babylonjs.com/features/behaviour
  12877. * @returns null if behavior was not found else the requested behavior
  12878. */
  12879. Control3D.prototype.getBehaviorByName = function (name) {
  12880. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12881. var behavior = _a[_i];
  12882. if (behavior.name === name) {
  12883. return behavior;
  12884. }
  12885. }
  12886. return null;
  12887. };
  12888. Object.defineProperty(Control3D.prototype, "isVisible", {
  12889. /** Gets or sets a boolean indicating if the control is visible */
  12890. get: function () {
  12891. return this._isVisible;
  12892. },
  12893. set: function (value) {
  12894. if (this._isVisible === value) {
  12895. return;
  12896. }
  12897. this._isVisible = value;
  12898. var mesh = this.mesh;
  12899. if (mesh) {
  12900. mesh.setEnabled(value);
  12901. }
  12902. },
  12903. enumerable: true,
  12904. configurable: true
  12905. });
  12906. Object.defineProperty(Control3D.prototype, "typeName", {
  12907. /**
  12908. * Gets a string representing the class name
  12909. */
  12910. get: function () {
  12911. return this._getTypeName();
  12912. },
  12913. enumerable: true,
  12914. configurable: true
  12915. });
  12916. /**
  12917. * Get the current class name of the control.
  12918. * @returns current class name
  12919. */
  12920. Control3D.prototype.getClassName = function () {
  12921. return this._getTypeName();
  12922. };
  12923. Control3D.prototype._getTypeName = function () {
  12924. return "Control3D";
  12925. };
  12926. Object.defineProperty(Control3D.prototype, "node", {
  12927. /**
  12928. * Gets the transform node used by this control
  12929. */
  12930. get: function () {
  12931. return this._node;
  12932. },
  12933. enumerable: true,
  12934. configurable: true
  12935. });
  12936. Object.defineProperty(Control3D.prototype, "mesh", {
  12937. /**
  12938. * Gets the mesh used to render this control
  12939. */
  12940. get: function () {
  12941. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12942. return this._node;
  12943. }
  12944. return null;
  12945. },
  12946. enumerable: true,
  12947. configurable: true
  12948. });
  12949. /**
  12950. * Link the control as child of the given node
  12951. * @param node defines the node to link to. Use null to unlink the control
  12952. * @returns the current control
  12953. */
  12954. Control3D.prototype.linkToTransformNode = function (node) {
  12955. if (this._node) {
  12956. this._node.parent = node;
  12957. }
  12958. return this;
  12959. };
  12960. /** @hidden **/
  12961. Control3D.prototype._prepareNode = function (scene) {
  12962. if (!this._node) {
  12963. this._node = this._createNode(scene);
  12964. if (!this.node) {
  12965. return;
  12966. }
  12967. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12968. this._node.position = this.position;
  12969. this._node.scaling = this.scaling;
  12970. var mesh = this.mesh;
  12971. if (mesh) {
  12972. mesh.isPickable = true;
  12973. this._affectMaterial(mesh);
  12974. }
  12975. }
  12976. };
  12977. /**
  12978. * Node creation.
  12979. * Can be overriden by children
  12980. * @param scene defines the scene where the node must be attached
  12981. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12982. */
  12983. Control3D.prototype._createNode = function (scene) {
  12984. // Do nothing by default
  12985. return null;
  12986. };
  12987. /**
  12988. * Affect a material to the given mesh
  12989. * @param mesh defines the mesh which will represent the control
  12990. */
  12991. Control3D.prototype._affectMaterial = function (mesh) {
  12992. mesh.material = null;
  12993. };
  12994. // Pointers
  12995. /** @hidden */
  12996. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12997. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12998. };
  12999. /** @hidden */
  13000. Control3D.prototype._onPointerEnter = function (target) {
  13001. if (this._enterCount > 0) {
  13002. return false;
  13003. }
  13004. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  13005. this._enterCount = 0;
  13006. }
  13007. this._enterCount++;
  13008. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  13009. if (this.pointerEnterAnimation) {
  13010. this.pointerEnterAnimation();
  13011. }
  13012. return true;
  13013. };
  13014. /** @hidden */
  13015. Control3D.prototype._onPointerOut = function (target) {
  13016. this._enterCount = 0;
  13017. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13018. if (this.pointerOutAnimation) {
  13019. this.pointerOutAnimation();
  13020. }
  13021. };
  13022. /** @hidden */
  13023. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13024. if (this._downCount !== 0) {
  13025. this._downCount++;
  13026. return false;
  13027. }
  13028. this._downCount++;
  13029. this._downPointerIds[pointerId] = true;
  13030. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13031. if (this.pointerDownAnimation) {
  13032. this.pointerDownAnimation();
  13033. }
  13034. return true;
  13035. };
  13036. /** @hidden */
  13037. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13038. this._downCount--;
  13039. delete this._downPointerIds[pointerId];
  13040. if (this._downCount < 0) {
  13041. // Handle if forcePointerUp was called prior to this
  13042. this._downCount = 0;
  13043. return;
  13044. }
  13045. if (this._downCount == 0) {
  13046. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13047. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13048. }
  13049. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13050. if (this.pointerUpAnimation) {
  13051. this.pointerUpAnimation();
  13052. }
  13053. }
  13054. };
  13055. /** @hidden */
  13056. Control3D.prototype.forcePointerUp = function (pointerId) {
  13057. if (pointerId === void 0) { pointerId = null; }
  13058. if (pointerId !== null) {
  13059. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13060. }
  13061. else {
  13062. for (var key in this._downPointerIds) {
  13063. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13064. }
  13065. if (this._downCount > 0) {
  13066. this._downCount = 1;
  13067. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13068. }
  13069. }
  13070. };
  13071. /** @hidden */
  13072. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13073. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13074. this._onPointerMove(this, pickedPoint);
  13075. var previousControlOver = this._host._lastControlOver[pointerId];
  13076. if (previousControlOver && previousControlOver !== this) {
  13077. previousControlOver._onPointerOut(this);
  13078. }
  13079. if (previousControlOver !== this) {
  13080. this._onPointerEnter(this);
  13081. }
  13082. this._host._lastControlOver[pointerId] = this;
  13083. return true;
  13084. }
  13085. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13086. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13087. this._host._lastControlDown[pointerId] = this;
  13088. this._host._lastPickedControl = this;
  13089. return true;
  13090. }
  13091. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13092. if (this._host._lastControlDown[pointerId]) {
  13093. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13094. }
  13095. delete this._host._lastControlDown[pointerId];
  13096. return true;
  13097. }
  13098. return false;
  13099. };
  13100. /** @hidden */
  13101. Control3D.prototype._disposeNode = function () {
  13102. if (this._node) {
  13103. this._node.dispose();
  13104. this._node = null;
  13105. }
  13106. };
  13107. /**
  13108. * Releases all associated resources
  13109. */
  13110. Control3D.prototype.dispose = function () {
  13111. this.onPointerDownObservable.clear();
  13112. this.onPointerEnterObservable.clear();
  13113. this.onPointerMoveObservable.clear();
  13114. this.onPointerOutObservable.clear();
  13115. this.onPointerUpObservable.clear();
  13116. this.onPointerClickObservable.clear();
  13117. this._disposeNode();
  13118. // Behaviors
  13119. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13120. var behavior = _a[_i];
  13121. behavior.detach();
  13122. }
  13123. };
  13124. return Control3D;
  13125. }());
  13126. /***/ }),
  13127. /***/ "./3D/controls/cylinderPanel.ts":
  13128. /*!**************************************!*\
  13129. !*** ./3D/controls/cylinderPanel.ts ***!
  13130. \**************************************/
  13131. /*! exports provided: CylinderPanel */
  13132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13133. "use strict";
  13134. __webpack_require__.r(__webpack_exports__);
  13135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13136. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13137. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13138. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13139. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13140. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13141. /**
  13142. * Class used to create a container panel deployed on the surface of a cylinder
  13143. */
  13144. var CylinderPanel = /** @class */ (function (_super) {
  13145. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13146. function CylinderPanel() {
  13147. var _this = _super !== null && _super.apply(this, arguments) || this;
  13148. _this._radius = 5.0;
  13149. return _this;
  13150. }
  13151. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13152. /**
  13153. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13154. */
  13155. get: function () {
  13156. return this._radius;
  13157. },
  13158. set: function (value) {
  13159. var _this = this;
  13160. if (this._radius === value) {
  13161. return;
  13162. }
  13163. this._radius = value;
  13164. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13165. _this._arrangeChildren();
  13166. });
  13167. },
  13168. enumerable: true,
  13169. configurable: true
  13170. });
  13171. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13172. var mesh = control.mesh;
  13173. if (!mesh) {
  13174. return;
  13175. }
  13176. var newPos = this._cylindricalMapping(nodePosition);
  13177. control.position = newPos;
  13178. switch (this.orientation) {
  13179. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13180. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13181. break;
  13182. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13183. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13184. break;
  13185. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13186. break;
  13187. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13188. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13189. break;
  13190. }
  13191. };
  13192. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13193. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13194. var yAngle = (source.x / this._radius);
  13195. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13196. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13197. };
  13198. return CylinderPanel;
  13199. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13200. /***/ }),
  13201. /***/ "./3D/controls/holographicButton.ts":
  13202. /*!******************************************!*\
  13203. !*** ./3D/controls/holographicButton.ts ***!
  13204. \******************************************/
  13205. /*! exports provided: HolographicButton */
  13206. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13207. "use strict";
  13208. __webpack_require__.r(__webpack_exports__);
  13209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13210. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13211. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13212. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13213. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13214. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13215. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13216. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13217. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13218. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13219. /**
  13220. * Class used to create a holographic button in 3D
  13221. */
  13222. var HolographicButton = /** @class */ (function (_super) {
  13223. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13224. /**
  13225. * Creates a new button
  13226. * @param name defines the control name
  13227. */
  13228. function HolographicButton(name, shareMaterials) {
  13229. if (shareMaterials === void 0) { shareMaterials = true; }
  13230. var _this = _super.call(this, name) || this;
  13231. _this._shareMaterials = true;
  13232. _this._shareMaterials = shareMaterials;
  13233. // Default animations
  13234. _this.pointerEnterAnimation = function () {
  13235. if (!_this.mesh) {
  13236. return;
  13237. }
  13238. _this._frontPlate.setEnabled(true);
  13239. };
  13240. _this.pointerOutAnimation = function () {
  13241. if (!_this.mesh) {
  13242. return;
  13243. }
  13244. _this._frontPlate.setEnabled(false);
  13245. };
  13246. return _this;
  13247. }
  13248. HolographicButton.prototype._disposeTooltip = function () {
  13249. this._tooltipFade = null;
  13250. if (this._tooltipTextBlock) {
  13251. this._tooltipTextBlock.dispose();
  13252. }
  13253. if (this._tooltipTexture) {
  13254. this._tooltipTexture.dispose();
  13255. }
  13256. if (this._tooltipMesh) {
  13257. this._tooltipMesh.dispose();
  13258. }
  13259. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13260. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13261. };
  13262. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13263. get: function () {
  13264. if (this._tooltipTextBlock) {
  13265. return this._tooltipTextBlock.text;
  13266. }
  13267. return null;
  13268. },
  13269. /**
  13270. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13271. */
  13272. set: function (text) {
  13273. var _this = this;
  13274. if (!text) {
  13275. this._disposeTooltip();
  13276. return;
  13277. }
  13278. if (!this._tooltipFade) {
  13279. // Create tooltip with mesh and text
  13280. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13281. 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);
  13282. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13283. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13284. tooltipBackground.material = mat;
  13285. tooltipBackground.isPickable = false;
  13286. this._tooltipMesh.addChild(tooltipBackground);
  13287. tooltipBackground.position.z = 0.05;
  13288. this._tooltipMesh.scaling.y = 1 / 3;
  13289. this._tooltipMesh.position.y = 0.7;
  13290. this._tooltipMesh.position.z = -0.15;
  13291. this._tooltipMesh.isPickable = false;
  13292. this._tooltipMesh.parent = this._backPlate;
  13293. // Create text texture for the tooltip
  13294. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13295. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13296. this._tooltipTextBlock.scaleY = 3;
  13297. this._tooltipTextBlock.color = "white";
  13298. this._tooltipTextBlock.fontSize = 130;
  13299. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13300. // Add hover action to tooltip
  13301. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13302. this._tooltipFade.delay = 500;
  13303. this._tooltipMesh.addBehavior(this._tooltipFade);
  13304. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13305. if (_this._tooltipFade) {
  13306. _this._tooltipFade.fadeIn(true);
  13307. }
  13308. });
  13309. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13310. if (_this._tooltipFade) {
  13311. _this._tooltipFade.fadeIn(false);
  13312. }
  13313. });
  13314. }
  13315. if (this._tooltipTextBlock) {
  13316. this._tooltipTextBlock.text = text;
  13317. }
  13318. },
  13319. enumerable: true,
  13320. configurable: true
  13321. });
  13322. Object.defineProperty(HolographicButton.prototype, "text", {
  13323. /**
  13324. * Gets or sets text for the button
  13325. */
  13326. get: function () {
  13327. return this._text;
  13328. },
  13329. set: function (value) {
  13330. if (this._text === value) {
  13331. return;
  13332. }
  13333. this._text = value;
  13334. this._rebuildContent();
  13335. },
  13336. enumerable: true,
  13337. configurable: true
  13338. });
  13339. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13340. /**
  13341. * Gets or sets the image url for the button
  13342. */
  13343. get: function () {
  13344. return this._imageUrl;
  13345. },
  13346. set: function (value) {
  13347. if (this._imageUrl === value) {
  13348. return;
  13349. }
  13350. this._imageUrl = value;
  13351. this._rebuildContent();
  13352. },
  13353. enumerable: true,
  13354. configurable: true
  13355. });
  13356. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13357. /**
  13358. * Gets the back material used by this button
  13359. */
  13360. get: function () {
  13361. return this._backMaterial;
  13362. },
  13363. enumerable: true,
  13364. configurable: true
  13365. });
  13366. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13367. /**
  13368. * Gets the front material used by this button
  13369. */
  13370. get: function () {
  13371. return this._frontMaterial;
  13372. },
  13373. enumerable: true,
  13374. configurable: true
  13375. });
  13376. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13377. /**
  13378. * Gets the plate material used by this button
  13379. */
  13380. get: function () {
  13381. return this._plateMaterial;
  13382. },
  13383. enumerable: true,
  13384. configurable: true
  13385. });
  13386. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13387. /**
  13388. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13389. */
  13390. get: function () {
  13391. return this._shareMaterials;
  13392. },
  13393. enumerable: true,
  13394. configurable: true
  13395. });
  13396. HolographicButton.prototype._getTypeName = function () {
  13397. return "HolographicButton";
  13398. };
  13399. HolographicButton.prototype._rebuildContent = function () {
  13400. this._disposeFacadeTexture();
  13401. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13402. panel.isVertical = true;
  13403. if (this._imageUrl) {
  13404. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13405. image.source = this._imageUrl;
  13406. image.paddingTop = "40px";
  13407. image.height = "180px";
  13408. image.width = "100px";
  13409. image.paddingBottom = "40px";
  13410. panel.addControl(image);
  13411. }
  13412. if (this._text) {
  13413. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13414. text.text = this._text;
  13415. text.color = "white";
  13416. text.height = "30px";
  13417. text.fontSize = 24;
  13418. panel.addControl(text);
  13419. }
  13420. if (this._frontPlate) {
  13421. this.content = panel;
  13422. }
  13423. };
  13424. // Mesh association
  13425. HolographicButton.prototype._createNode = function (scene) {
  13426. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13427. width: 1.0,
  13428. height: 1.0,
  13429. depth: 0.08
  13430. }, scene);
  13431. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13432. width: 1.0,
  13433. height: 1.0,
  13434. depth: 0.08
  13435. }, scene);
  13436. this._frontPlate.parent = this._backPlate;
  13437. this._frontPlate.position.z = -0.08;
  13438. this._frontPlate.isPickable = false;
  13439. this._frontPlate.setEnabled(false);
  13440. this._textPlate = _super.prototype._createNode.call(this, scene);
  13441. this._textPlate.parent = this._backPlate;
  13442. this._textPlate.position.z = -0.08;
  13443. this._textPlate.isPickable = false;
  13444. return this._backPlate;
  13445. };
  13446. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13447. this._plateMaterial.emissiveTexture = facadeTexture;
  13448. this._plateMaterial.opacityTexture = facadeTexture;
  13449. };
  13450. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13451. var _this = this;
  13452. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13453. this._backMaterial.renderHoverLight = true;
  13454. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13455. if (pickedPoint) {
  13456. _this._backMaterial.hoverPosition = pickedPoint;
  13457. _this._backMaterial.hoverColor.a = 1.0;
  13458. }
  13459. else {
  13460. _this._backMaterial.hoverColor.a = 0;
  13461. }
  13462. });
  13463. };
  13464. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13465. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13466. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13467. this._frontMaterial.alpha = 0.5; // Additive
  13468. this._frontMaterial.renderBorders = true;
  13469. };
  13470. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13471. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13472. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13473. };
  13474. HolographicButton.prototype._affectMaterial = function (mesh) {
  13475. // Back
  13476. if (this._shareMaterials) {
  13477. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13478. this._createBackMaterial(mesh);
  13479. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13480. }
  13481. else {
  13482. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13483. }
  13484. // Front
  13485. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13486. this._createFrontMaterial(mesh);
  13487. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13488. }
  13489. else {
  13490. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13491. }
  13492. }
  13493. else {
  13494. this._createBackMaterial(mesh);
  13495. this._createFrontMaterial(mesh);
  13496. }
  13497. this._createPlateMaterial(mesh);
  13498. this._backPlate.material = this._backMaterial;
  13499. this._frontPlate.material = this._frontMaterial;
  13500. this._textPlate.material = this._plateMaterial;
  13501. this._rebuildContent();
  13502. };
  13503. /**
  13504. * Releases all associated resources
  13505. */
  13506. HolographicButton.prototype.dispose = function () {
  13507. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13508. this._disposeTooltip();
  13509. if (!this.shareMaterials) {
  13510. this._backMaterial.dispose();
  13511. this._frontMaterial.dispose();
  13512. this._plateMaterial.dispose();
  13513. if (this._pickedPointObserver) {
  13514. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13515. this._pickedPointObserver = null;
  13516. }
  13517. }
  13518. };
  13519. return HolographicButton;
  13520. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13521. /***/ }),
  13522. /***/ "./3D/controls/index.ts":
  13523. /*!******************************!*\
  13524. !*** ./3D/controls/index.ts ***!
  13525. \******************************/
  13526. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13528. "use strict";
  13529. __webpack_require__.r(__webpack_exports__);
  13530. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13532. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13534. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13536. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13538. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13540. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13542. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13544. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13546. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13548. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13550. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13552. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13554. /***/ }),
  13555. /***/ "./3D/controls/meshButton3D.ts":
  13556. /*!*************************************!*\
  13557. !*** ./3D/controls/meshButton3D.ts ***!
  13558. \*************************************/
  13559. /*! exports provided: MeshButton3D */
  13560. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13561. "use strict";
  13562. __webpack_require__.r(__webpack_exports__);
  13563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13564. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13565. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13566. /**
  13567. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13568. */
  13569. var MeshButton3D = /** @class */ (function (_super) {
  13570. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13571. /**
  13572. * Creates a new 3D button based on a mesh
  13573. * @param mesh mesh to become a 3D button
  13574. * @param name defines the control name
  13575. */
  13576. function MeshButton3D(mesh, name) {
  13577. var _this = _super.call(this, name) || this;
  13578. _this._currentMesh = mesh;
  13579. /**
  13580. * Provides a default behavior on hover/out & up/down
  13581. * Override those function to create your own desired behavior specific to your mesh
  13582. */
  13583. _this.pointerEnterAnimation = function () {
  13584. if (!_this.mesh) {
  13585. return;
  13586. }
  13587. _this.mesh.scaling.scaleInPlace(1.1);
  13588. };
  13589. _this.pointerOutAnimation = function () {
  13590. if (!_this.mesh) {
  13591. return;
  13592. }
  13593. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13594. };
  13595. _this.pointerDownAnimation = function () {
  13596. if (!_this.mesh) {
  13597. return;
  13598. }
  13599. _this.mesh.scaling.scaleInPlace(0.95);
  13600. };
  13601. _this.pointerUpAnimation = function () {
  13602. if (!_this.mesh) {
  13603. return;
  13604. }
  13605. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13606. };
  13607. return _this;
  13608. }
  13609. MeshButton3D.prototype._getTypeName = function () {
  13610. return "MeshButton3D";
  13611. };
  13612. // Mesh association
  13613. MeshButton3D.prototype._createNode = function (scene) {
  13614. var _this = this;
  13615. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13616. mesh.metadata = _this;
  13617. });
  13618. return this._currentMesh;
  13619. };
  13620. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13621. };
  13622. return MeshButton3D;
  13623. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13624. /***/ }),
  13625. /***/ "./3D/controls/planePanel.ts":
  13626. /*!***********************************!*\
  13627. !*** ./3D/controls/planePanel.ts ***!
  13628. \***********************************/
  13629. /*! exports provided: PlanePanel */
  13630. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13631. "use strict";
  13632. __webpack_require__.r(__webpack_exports__);
  13633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13634. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13635. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13636. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13637. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13638. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13639. /**
  13640. * Class used to create a container panel deployed on the surface of a plane
  13641. */
  13642. var PlanePanel = /** @class */ (function (_super) {
  13643. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13644. function PlanePanel() {
  13645. return _super !== null && _super.apply(this, arguments) || this;
  13646. }
  13647. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13648. var mesh = control.mesh;
  13649. if (!mesh) {
  13650. return;
  13651. }
  13652. control.position = nodePosition.clone();
  13653. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13654. target.copyFrom(nodePosition);
  13655. switch (this.orientation) {
  13656. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13657. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13658. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13659. mesh.lookAt(target);
  13660. break;
  13661. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13662. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13663. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13664. mesh.lookAt(target);
  13665. break;
  13666. }
  13667. };
  13668. return PlanePanel;
  13669. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13670. /***/ }),
  13671. /***/ "./3D/controls/scatterPanel.ts":
  13672. /*!*************************************!*\
  13673. !*** ./3D/controls/scatterPanel.ts ***!
  13674. \*************************************/
  13675. /*! exports provided: ScatterPanel */
  13676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13677. "use strict";
  13678. __webpack_require__.r(__webpack_exports__);
  13679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13680. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13681. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13682. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13683. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13684. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13685. /**
  13686. * Class used to create a container panel where items get randomized planar mapping
  13687. */
  13688. var ScatterPanel = /** @class */ (function (_super) {
  13689. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13690. function ScatterPanel() {
  13691. var _this = _super !== null && _super.apply(this, arguments) || this;
  13692. _this._iteration = 100.0;
  13693. return _this;
  13694. }
  13695. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13696. /**
  13697. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13698. */
  13699. get: function () {
  13700. return this._iteration;
  13701. },
  13702. set: function (value) {
  13703. var _this = this;
  13704. if (this._iteration === value) {
  13705. return;
  13706. }
  13707. this._iteration = value;
  13708. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13709. _this._arrangeChildren();
  13710. });
  13711. },
  13712. enumerable: true,
  13713. configurable: true
  13714. });
  13715. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13716. var mesh = control.mesh;
  13717. var newPos = this._scatterMapping(nodePosition);
  13718. if (!mesh) {
  13719. return;
  13720. }
  13721. switch (this.orientation) {
  13722. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13723. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13724. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13725. break;
  13726. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13727. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13728. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13729. break;
  13730. }
  13731. control.position = newPos;
  13732. };
  13733. ScatterPanel.prototype._scatterMapping = function (source) {
  13734. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13735. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13736. return source;
  13737. };
  13738. ScatterPanel.prototype._finalProcessing = function () {
  13739. var meshes = [];
  13740. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13741. var child = _a[_i];
  13742. if (!child.mesh) {
  13743. continue;
  13744. }
  13745. meshes.push(child.mesh);
  13746. }
  13747. for (var count = 0; count < this._iteration; count++) {
  13748. meshes.sort(function (a, b) {
  13749. var distance1 = a.position.lengthSquared();
  13750. var distance2 = b.position.lengthSquared();
  13751. if (distance1 < distance2) {
  13752. return 1;
  13753. }
  13754. else if (distance1 > distance2) {
  13755. return -1;
  13756. }
  13757. return 0;
  13758. });
  13759. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13760. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13761. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  13762. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13763. for (var i = 0; i < meshes.length - 1; i++) {
  13764. for (var j = i + 1; j < meshes.length; j++) {
  13765. if (i != j) {
  13766. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13767. // Ignore Z axis
  13768. difference2D.x = difference.x;
  13769. difference2D.y = difference.y;
  13770. var combinedRadius = cellSize;
  13771. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13772. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13773. distance -= minSeparation;
  13774. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13775. difference2D.normalize();
  13776. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13777. meshes[j].position.addInPlace(difference);
  13778. meshes[i].position.subtractInPlace(difference);
  13779. }
  13780. }
  13781. }
  13782. }
  13783. }
  13784. };
  13785. return ScatterPanel;
  13786. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13787. /***/ }),
  13788. /***/ "./3D/controls/spherePanel.ts":
  13789. /*!************************************!*\
  13790. !*** ./3D/controls/spherePanel.ts ***!
  13791. \************************************/
  13792. /*! exports provided: SpherePanel */
  13793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13794. "use strict";
  13795. __webpack_require__.r(__webpack_exports__);
  13796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13797. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13798. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13799. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13800. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13801. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13802. /**
  13803. * Class used to create a container panel deployed on the surface of a sphere
  13804. */
  13805. var SpherePanel = /** @class */ (function (_super) {
  13806. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13807. function SpherePanel() {
  13808. var _this = _super !== null && _super.apply(this, arguments) || this;
  13809. _this._radius = 5.0;
  13810. return _this;
  13811. }
  13812. Object.defineProperty(SpherePanel.prototype, "radius", {
  13813. /**
  13814. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13815. */
  13816. get: function () {
  13817. return this._radius;
  13818. },
  13819. set: function (value) {
  13820. var _this = this;
  13821. if (this._radius === value) {
  13822. return;
  13823. }
  13824. this._radius = value;
  13825. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13826. _this._arrangeChildren();
  13827. });
  13828. },
  13829. enumerable: true,
  13830. configurable: true
  13831. });
  13832. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13833. var mesh = control.mesh;
  13834. if (!mesh) {
  13835. return;
  13836. }
  13837. var newPos = this._sphericalMapping(nodePosition);
  13838. control.position = newPos;
  13839. switch (this.orientation) {
  13840. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13841. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13842. break;
  13843. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13844. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13845. break;
  13846. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13847. break;
  13848. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13849. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13850. break;
  13851. }
  13852. };
  13853. SpherePanel.prototype._sphericalMapping = function (source) {
  13854. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13855. var xAngle = (source.y / this._radius);
  13856. var yAngle = -(source.x / this._radius);
  13857. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13858. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13859. };
  13860. return SpherePanel;
  13861. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13862. /***/ }),
  13863. /***/ "./3D/controls/stackPanel3D.ts":
  13864. /*!*************************************!*\
  13865. !*** ./3D/controls/stackPanel3D.ts ***!
  13866. \*************************************/
  13867. /*! exports provided: StackPanel3D */
  13868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13869. "use strict";
  13870. __webpack_require__.r(__webpack_exports__);
  13871. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13872. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13873. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13874. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13875. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13876. /**
  13877. * Class used to create a stack panel in 3D on XY plane
  13878. */
  13879. var StackPanel3D = /** @class */ (function (_super) {
  13880. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13881. /**
  13882. * Creates new StackPanel
  13883. * @param isVertical
  13884. */
  13885. function StackPanel3D(isVertical) {
  13886. if (isVertical === void 0) { isVertical = false; }
  13887. var _this = _super.call(this) || this;
  13888. _this._isVertical = false;
  13889. /**
  13890. * Gets or sets the distance between elements
  13891. */
  13892. _this.margin = 0.1;
  13893. _this._isVertical = isVertical;
  13894. return _this;
  13895. }
  13896. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13897. /**
  13898. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13899. */
  13900. get: function () {
  13901. return this._isVertical;
  13902. },
  13903. set: function (value) {
  13904. var _this = this;
  13905. if (this._isVertical === value) {
  13906. return;
  13907. }
  13908. this._isVertical = value;
  13909. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13910. _this._arrangeChildren();
  13911. });
  13912. },
  13913. enumerable: true,
  13914. configurable: true
  13915. });
  13916. StackPanel3D.prototype._arrangeChildren = function () {
  13917. var width = 0;
  13918. var height = 0;
  13919. var controlCount = 0;
  13920. var extendSizes = [];
  13921. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13922. // Measure
  13923. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13924. var child = _a[_i];
  13925. if (!child.mesh) {
  13926. continue;
  13927. }
  13928. controlCount++;
  13929. child.mesh.computeWorldMatrix(true);
  13930. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13931. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13932. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13933. extendSizes.push(extendSize);
  13934. if (this._isVertical) {
  13935. height += extendSize.y;
  13936. }
  13937. else {
  13938. width += extendSize.x;
  13939. }
  13940. }
  13941. if (this._isVertical) {
  13942. height += (controlCount - 1) * this.margin / 2;
  13943. }
  13944. else {
  13945. width += (controlCount - 1) * this.margin / 2;
  13946. }
  13947. // Arrange
  13948. var offset;
  13949. if (this._isVertical) {
  13950. offset = -height;
  13951. }
  13952. else {
  13953. offset = -width;
  13954. }
  13955. var index = 0;
  13956. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13957. var child = _c[_b];
  13958. if (!child.mesh) {
  13959. continue;
  13960. }
  13961. controlCount--;
  13962. var extendSize = extendSizes[index++];
  13963. if (this._isVertical) {
  13964. child.position.y = offset + extendSize.y;
  13965. child.position.x = 0;
  13966. offset += extendSize.y * 2;
  13967. }
  13968. else {
  13969. child.position.x = offset + extendSize.x;
  13970. child.position.y = 0;
  13971. offset += extendSize.x * 2;
  13972. }
  13973. offset += (controlCount > 0 ? this.margin : 0);
  13974. }
  13975. };
  13976. return StackPanel3D;
  13977. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13978. /***/ }),
  13979. /***/ "./3D/controls/volumeBasedPanel.ts":
  13980. /*!*****************************************!*\
  13981. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13982. \*****************************************/
  13983. /*! exports provided: VolumeBasedPanel */
  13984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13985. "use strict";
  13986. __webpack_require__.r(__webpack_exports__);
  13987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13988. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13989. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13990. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13991. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13992. /**
  13993. * Abstract class used to create a container panel deployed on the surface of a volume
  13994. */
  13995. var VolumeBasedPanel = /** @class */ (function (_super) {
  13996. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13997. /**
  13998. * Creates new VolumeBasedPanel
  13999. */
  14000. function VolumeBasedPanel() {
  14001. var _this = _super.call(this) || this;
  14002. _this._columns = 10;
  14003. _this._rows = 0;
  14004. _this._rowThenColum = true;
  14005. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  14006. /**
  14007. * Gets or sets the distance between elements
  14008. */
  14009. _this.margin = 0;
  14010. return _this;
  14011. }
  14012. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14013. /**
  14014. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14015. * | Value | Type | Description |
  14016. * | ----- | ----------------------------------- | ----------- |
  14017. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14018. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14019. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14020. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14021. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14022. */
  14023. get: function () {
  14024. return this._orientation;
  14025. },
  14026. set: function (value) {
  14027. var _this = this;
  14028. if (this._orientation === value) {
  14029. return;
  14030. }
  14031. this._orientation = value;
  14032. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14033. _this._arrangeChildren();
  14034. });
  14035. },
  14036. enumerable: true,
  14037. configurable: true
  14038. });
  14039. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14040. /**
  14041. * Gets or sets the number of columns requested (10 by default).
  14042. * The panel will automatically compute the number of rows based on number of child controls.
  14043. */
  14044. get: function () {
  14045. return this._columns;
  14046. },
  14047. set: function (value) {
  14048. var _this = this;
  14049. if (this._columns === value) {
  14050. return;
  14051. }
  14052. this._columns = value;
  14053. this._rowThenColum = true;
  14054. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14055. _this._arrangeChildren();
  14056. });
  14057. },
  14058. enumerable: true,
  14059. configurable: true
  14060. });
  14061. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14062. /**
  14063. * Gets or sets a the number of rows requested.
  14064. * The panel will automatically compute the number of columns based on number of child controls.
  14065. */
  14066. get: function () {
  14067. return this._rows;
  14068. },
  14069. set: function (value) {
  14070. var _this = this;
  14071. if (this._rows === value) {
  14072. return;
  14073. }
  14074. this._rows = value;
  14075. this._rowThenColum = false;
  14076. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14077. _this._arrangeChildren();
  14078. });
  14079. },
  14080. enumerable: true,
  14081. configurable: true
  14082. });
  14083. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14084. this._cellWidth = 0;
  14085. this._cellHeight = 0;
  14086. var rows = 0;
  14087. var columns = 0;
  14088. var controlCount = 0;
  14089. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14090. // Measure
  14091. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14092. var child = _a[_i];
  14093. if (!child.mesh) {
  14094. continue;
  14095. }
  14096. controlCount++;
  14097. child.mesh.computeWorldMatrix(true);
  14098. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14099. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14100. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14101. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14102. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14103. diff.scaleInPlace(0.5);
  14104. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14105. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14106. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14107. }
  14108. this._cellWidth += this.margin * 2;
  14109. this._cellHeight += this.margin * 2;
  14110. // Arrange
  14111. if (this._rowThenColum) {
  14112. columns = this._columns;
  14113. rows = Math.ceil(controlCount / this._columns);
  14114. }
  14115. else {
  14116. rows = this._rows;
  14117. columns = Math.ceil(controlCount / this._rows);
  14118. }
  14119. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14120. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14121. var nodeGrid = [];
  14122. var cellCounter = 0;
  14123. if (this._rowThenColum) {
  14124. for (var r = 0; r < rows; r++) {
  14125. for (var c = 0; c < columns; c++) {
  14126. 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));
  14127. cellCounter++;
  14128. if (cellCounter > controlCount) {
  14129. break;
  14130. }
  14131. }
  14132. }
  14133. }
  14134. else {
  14135. for (var c = 0; c < columns; c++) {
  14136. for (var r = 0; r < rows; r++) {
  14137. 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));
  14138. cellCounter++;
  14139. if (cellCounter > controlCount) {
  14140. break;
  14141. }
  14142. }
  14143. }
  14144. }
  14145. cellCounter = 0;
  14146. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14147. var child = _c[_b];
  14148. if (!child.mesh) {
  14149. continue;
  14150. }
  14151. this._mapGridNode(child, nodeGrid[cellCounter]);
  14152. cellCounter++;
  14153. }
  14154. this._finalProcessing();
  14155. };
  14156. /** Child classes can implement this function to provide additional processing */
  14157. VolumeBasedPanel.prototype._finalProcessing = function () {
  14158. };
  14159. return VolumeBasedPanel;
  14160. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14161. /***/ }),
  14162. /***/ "./3D/gui3DManager.ts":
  14163. /*!****************************!*\
  14164. !*** ./3D/gui3DManager.ts ***!
  14165. \****************************/
  14166. /*! exports provided: GUI3DManager */
  14167. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14168. "use strict";
  14169. __webpack_require__.r(__webpack_exports__);
  14170. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14171. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14172. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14173. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14174. /**
  14175. * Class used to manage 3D user interface
  14176. * @see http://doc.babylonjs.com/how_to/gui3d
  14177. */
  14178. var GUI3DManager = /** @class */ (function () {
  14179. /**
  14180. * Creates a new GUI3DManager
  14181. * @param scene
  14182. */
  14183. function GUI3DManager(scene) {
  14184. var _this = this;
  14185. /** @hidden */
  14186. this._lastControlOver = {};
  14187. /** @hidden */
  14188. this._lastControlDown = {};
  14189. /**
  14190. * Observable raised when the point picked by the pointer events changed
  14191. */
  14192. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14193. // Shared resources
  14194. /** @hidden */
  14195. this._sharedMaterials = {};
  14196. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14197. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14198. _this._sceneDisposeObserver = null;
  14199. _this._utilityLayer = null;
  14200. _this.dispose();
  14201. });
  14202. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14203. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14204. this._utilityLayer.pickUtilitySceneFirst = false;
  14205. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14206. return mesh && mesh.metadata && mesh.metadata._node;
  14207. };
  14208. // Root
  14209. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14210. this._rootContainer._host = this;
  14211. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14212. // Events
  14213. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14214. _this._handlePointerOut(pointerId, true);
  14215. });
  14216. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14217. _this._doPicking(pi);
  14218. });
  14219. // Scene
  14220. this._utilityLayer.utilityLayerScene.autoClear = false;
  14221. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14222. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14223. }
  14224. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14225. /** Gets the hosting scene */
  14226. get: function () {
  14227. return this._scene;
  14228. },
  14229. enumerable: true,
  14230. configurable: true
  14231. });
  14232. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14233. /** Gets associated utility layer */
  14234. get: function () {
  14235. return this._utilityLayer;
  14236. },
  14237. enumerable: true,
  14238. configurable: true
  14239. });
  14240. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14241. var previousControlOver = this._lastControlOver[pointerId];
  14242. if (previousControlOver) {
  14243. previousControlOver._onPointerOut(previousControlOver);
  14244. delete this._lastControlOver[pointerId];
  14245. }
  14246. if (isPointerUp) {
  14247. if (this._lastControlDown[pointerId]) {
  14248. this._lastControlDown[pointerId].forcePointerUp();
  14249. delete this._lastControlDown[pointerId];
  14250. }
  14251. }
  14252. this.onPickedPointChangedObservable.notifyObservers(null);
  14253. };
  14254. GUI3DManager.prototype._doPicking = function (pi) {
  14255. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14256. return false;
  14257. }
  14258. var pointerEvent = (pi.event);
  14259. var pointerId = pointerEvent.pointerId || 0;
  14260. var buttonIndex = pointerEvent.button;
  14261. var pickingInfo = pi.pickInfo;
  14262. if (!pickingInfo || !pickingInfo.hit) {
  14263. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14264. return false;
  14265. }
  14266. var control = (pickingInfo.pickedMesh.metadata);
  14267. if (pickingInfo.pickedPoint) {
  14268. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14269. }
  14270. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14271. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14272. if (this._lastControlOver[pointerId]) {
  14273. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14274. }
  14275. delete this._lastControlOver[pointerId];
  14276. }
  14277. }
  14278. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14279. if (this._lastControlDown[pointerEvent.pointerId]) {
  14280. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14281. delete this._lastControlDown[pointerEvent.pointerId];
  14282. }
  14283. if (pointerEvent.pointerType === "touch") {
  14284. this._handlePointerOut(pointerId, false);
  14285. }
  14286. }
  14287. return true;
  14288. };
  14289. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14290. /**
  14291. * Gets the root container
  14292. */
  14293. get: function () {
  14294. return this._rootContainer;
  14295. },
  14296. enumerable: true,
  14297. configurable: true
  14298. });
  14299. /**
  14300. * Gets a boolean indicating if the given control is in the root child list
  14301. * @param control defines the control to check
  14302. * @returns true if the control is in the root child list
  14303. */
  14304. GUI3DManager.prototype.containsControl = function (control) {
  14305. return this._rootContainer.containsControl(control);
  14306. };
  14307. /**
  14308. * Adds a control to the root child list
  14309. * @param control defines the control to add
  14310. * @returns the current manager
  14311. */
  14312. GUI3DManager.prototype.addControl = function (control) {
  14313. this._rootContainer.addControl(control);
  14314. return this;
  14315. };
  14316. /**
  14317. * Removes a control from the root child list
  14318. * @param control defines the control to remove
  14319. * @returns the current container
  14320. */
  14321. GUI3DManager.prototype.removeControl = function (control) {
  14322. this._rootContainer.removeControl(control);
  14323. return this;
  14324. };
  14325. /**
  14326. * Releases all associated resources
  14327. */
  14328. GUI3DManager.prototype.dispose = function () {
  14329. this._rootContainer.dispose();
  14330. for (var materialName in this._sharedMaterials) {
  14331. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14332. continue;
  14333. }
  14334. this._sharedMaterials[materialName].dispose();
  14335. }
  14336. this._sharedMaterials = {};
  14337. if (this._pointerOutObserver && this._utilityLayer) {
  14338. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14339. this._pointerOutObserver = null;
  14340. }
  14341. this.onPickedPointChangedObservable.clear();
  14342. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14343. if (utilityLayerScene) {
  14344. if (this._pointerObserver) {
  14345. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14346. this._pointerObserver = null;
  14347. }
  14348. }
  14349. if (this._scene) {
  14350. if (this._sceneDisposeObserver) {
  14351. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14352. this._sceneDisposeObserver = null;
  14353. }
  14354. }
  14355. if (this._utilityLayer) {
  14356. this._utilityLayer.dispose();
  14357. }
  14358. };
  14359. return GUI3DManager;
  14360. }());
  14361. /***/ }),
  14362. /***/ "./3D/index.ts":
  14363. /*!*********************!*\
  14364. !*** ./3D/index.ts ***!
  14365. \*********************/
  14366. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14368. "use strict";
  14369. __webpack_require__.r(__webpack_exports__);
  14370. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14383. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14386. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14388. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14390. /***/ }),
  14391. /***/ "./3D/materials/fluentMaterial.ts":
  14392. /*!****************************************!*\
  14393. !*** ./3D/materials/fluentMaterial.ts ***!
  14394. \****************************************/
  14395. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14397. "use strict";
  14398. __webpack_require__.r(__webpack_exports__);
  14399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14401. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14402. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  14403. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14404. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14405. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14406. /** @hidden */
  14407. var FluentMaterialDefines = /** @class */ (function (_super) {
  14408. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14409. function FluentMaterialDefines() {
  14410. var _this = _super.call(this) || this;
  14411. _this.INNERGLOW = false;
  14412. _this.BORDER = false;
  14413. _this.HOVERLIGHT = false;
  14414. _this.TEXTURE = false;
  14415. _this.rebuild();
  14416. return _this;
  14417. }
  14418. return FluentMaterialDefines;
  14419. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14420. /**
  14421. * Class used to render controls with fluent desgin
  14422. */
  14423. var FluentMaterial = /** @class */ (function (_super) {
  14424. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14425. /**
  14426. * Creates a new Fluent material
  14427. * @param name defines the name of the material
  14428. * @param scene defines the hosting scene
  14429. */
  14430. function FluentMaterial(name, scene) {
  14431. var _this = _super.call(this, name, scene) || this;
  14432. /**
  14433. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14434. */
  14435. _this.innerGlowColorIntensity = 0.5;
  14436. /**
  14437. * Gets or sets the inner glow color (white by default)
  14438. */
  14439. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14440. /**
  14441. * Gets or sets alpha value (default is 1.0)
  14442. */
  14443. _this.alpha = 1.0;
  14444. /**
  14445. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14446. */
  14447. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14448. /**
  14449. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14450. */
  14451. _this.renderBorders = false;
  14452. /**
  14453. * Gets or sets border width (default is 0.5)
  14454. */
  14455. _this.borderWidth = 0.5;
  14456. /**
  14457. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14458. */
  14459. _this.edgeSmoothingValue = 0.02;
  14460. /**
  14461. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14462. */
  14463. _this.borderMinValue = 0.1;
  14464. /**
  14465. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14466. */
  14467. _this.renderHoverLight = false;
  14468. /**
  14469. * Gets or sets the radius used to render the hover light (default is 1.0)
  14470. */
  14471. _this.hoverRadius = 1.0;
  14472. /**
  14473. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14474. */
  14475. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14476. /**
  14477. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14478. */
  14479. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14480. return _this;
  14481. }
  14482. FluentMaterial.prototype.needAlphaBlending = function () {
  14483. return this.alpha !== 1.0;
  14484. };
  14485. FluentMaterial.prototype.needAlphaTesting = function () {
  14486. return false;
  14487. };
  14488. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14489. return null;
  14490. };
  14491. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14492. if (this.isFrozen) {
  14493. if (this._wasPreviouslyReady && subMesh.effect) {
  14494. return true;
  14495. }
  14496. }
  14497. if (!subMesh._materialDefines) {
  14498. subMesh._materialDefines = new FluentMaterialDefines();
  14499. }
  14500. var scene = this.getScene();
  14501. var defines = subMesh._materialDefines;
  14502. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14503. if (defines._renderId === scene.getRenderId()) {
  14504. return true;
  14505. }
  14506. }
  14507. if (defines._areTexturesDirty) {
  14508. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14509. defines.BORDER = this.renderBorders;
  14510. defines.HOVERLIGHT = this.renderHoverLight;
  14511. if (this._albedoTexture) {
  14512. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14513. return false;
  14514. }
  14515. else {
  14516. defines.TEXTURE = true;
  14517. }
  14518. }
  14519. else {
  14520. defines.TEXTURE = false;
  14521. }
  14522. }
  14523. var engine = scene.getEngine();
  14524. // Get correct effect
  14525. if (defines.isDirty) {
  14526. defines.markAsProcessed();
  14527. scene.resetCachedMaterial();
  14528. //Attributes
  14529. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14530. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14531. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14532. var shaderName = "fluent";
  14533. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14534. "hoverColor", "hoverPosition", "hoverRadius"
  14535. ];
  14536. var samplers = ["albedoSampler"];
  14537. var uniformBuffers = new Array();
  14538. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14539. uniformsNames: uniforms,
  14540. uniformBuffersNames: uniformBuffers,
  14541. samplers: samplers,
  14542. defines: defines,
  14543. maxSimultaneousLights: 4
  14544. });
  14545. var join = defines.toString();
  14546. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14547. attributes: attribs,
  14548. uniformsNames: uniforms,
  14549. uniformBuffersNames: uniformBuffers,
  14550. samplers: samplers,
  14551. defines: join,
  14552. fallbacks: null,
  14553. onCompiled: this.onCompiled,
  14554. onError: this.onError,
  14555. indexParameters: { maxSimultaneousLights: 4 }
  14556. }, engine));
  14557. }
  14558. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14559. return false;
  14560. }
  14561. defines._renderId = scene.getRenderId();
  14562. this._wasPreviouslyReady = true;
  14563. return true;
  14564. };
  14565. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14566. var scene = this.getScene();
  14567. var defines = subMesh._materialDefines;
  14568. if (!defines) {
  14569. return;
  14570. }
  14571. var effect = subMesh.effect;
  14572. if (!effect) {
  14573. return;
  14574. }
  14575. this._activeEffect = effect;
  14576. // Matrices
  14577. this.bindOnlyWorldMatrix(world);
  14578. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14579. if (this._mustRebind(scene, effect)) {
  14580. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14581. if (defines.INNERGLOW) {
  14582. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14583. }
  14584. if (defines.BORDER) {
  14585. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14586. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14587. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14588. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14589. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14590. }
  14591. if (defines.HOVERLIGHT) {
  14592. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14593. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14594. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14595. }
  14596. if (defines.TEXTURE) {
  14597. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14598. }
  14599. }
  14600. this._afterBind(mesh, this._activeEffect);
  14601. };
  14602. FluentMaterial.prototype.getActiveTextures = function () {
  14603. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14604. return activeTextures;
  14605. };
  14606. FluentMaterial.prototype.hasTexture = function (texture) {
  14607. if (_super.prototype.hasTexture.call(this, texture)) {
  14608. return true;
  14609. }
  14610. return false;
  14611. };
  14612. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14613. _super.prototype.dispose.call(this, forceDisposeEffect);
  14614. };
  14615. FluentMaterial.prototype.clone = function (name) {
  14616. var _this = this;
  14617. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14618. };
  14619. FluentMaterial.prototype.serialize = function () {
  14620. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14621. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14622. return serializationObject;
  14623. };
  14624. FluentMaterial.prototype.getClassName = function () {
  14625. return "FluentMaterial";
  14626. };
  14627. // Statics
  14628. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14629. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14630. };
  14631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14632. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14633. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14634. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14636. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14637. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14639. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14640. ], FluentMaterial.prototype, "alpha", void 0);
  14641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14642. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14643. ], FluentMaterial.prototype, "albedoColor", void 0);
  14644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14645. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14646. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14647. ], FluentMaterial.prototype, "renderBorders", void 0);
  14648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14649. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14650. ], FluentMaterial.prototype, "borderWidth", void 0);
  14651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14652. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14653. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14655. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14656. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14658. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14659. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14660. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14662. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14663. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14665. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14666. ], FluentMaterial.prototype, "hoverColor", void 0);
  14667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14668. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14669. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14671. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14672. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14674. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14675. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14676. return FluentMaterial;
  14677. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14678. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14679. /***/ }),
  14680. /***/ "./3D/materials/index.ts":
  14681. /*!*******************************!*\
  14682. !*** ./3D/materials/index.ts ***!
  14683. \*******************************/
  14684. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14686. "use strict";
  14687. __webpack_require__.r(__webpack_exports__);
  14688. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14691. /***/ }),
  14692. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14693. /*!*************************************************!*\
  14694. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14695. \*************************************************/
  14696. /*! exports provided: fluentPixelShader */
  14697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14698. "use strict";
  14699. __webpack_require__.r(__webpack_exports__);
  14700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14701. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  14702. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14703. var name = 'fluentPixelShader';
  14704. 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}";
  14705. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14706. /** @hidden */
  14707. var fluentPixelShader = { name: name, shader: shader };
  14708. /***/ }),
  14709. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14710. /*!***********************************************!*\
  14711. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14712. \***********************************************/
  14713. /*! exports provided: fluentVertexShader */
  14714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14715. "use strict";
  14716. __webpack_require__.r(__webpack_exports__);
  14717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14718. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  14719. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14720. var name = 'fluentVertexShader';
  14721. 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";
  14722. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14723. /** @hidden */
  14724. var fluentVertexShader = { name: name, shader: shader };
  14725. /***/ }),
  14726. /***/ "./3D/vector3WithInfo.ts":
  14727. /*!*******************************!*\
  14728. !*** ./3D/vector3WithInfo.ts ***!
  14729. \*******************************/
  14730. /*! exports provided: Vector3WithInfo */
  14731. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14732. "use strict";
  14733. __webpack_require__.r(__webpack_exports__);
  14734. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14735. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14736. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14737. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14738. /**
  14739. * Class used to transport Vector3 information for pointer events
  14740. */
  14741. var Vector3WithInfo = /** @class */ (function (_super) {
  14742. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14743. /**
  14744. * Creates a new Vector3WithInfo
  14745. * @param source defines the vector3 data to transport
  14746. * @param buttonIndex defines the current mouse button index
  14747. */
  14748. function Vector3WithInfo(source,
  14749. /** defines the current mouse button index */
  14750. buttonIndex) {
  14751. if (buttonIndex === void 0) { buttonIndex = 0; }
  14752. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14753. _this.buttonIndex = buttonIndex;
  14754. return _this;
  14755. }
  14756. return Vector3WithInfo;
  14757. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14758. /***/ }),
  14759. /***/ "./index.ts":
  14760. /*!******************!*\
  14761. !*** ./index.ts ***!
  14762. \******************/
  14763. /*! 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 */
  14764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14765. "use strict";
  14766. __webpack_require__.r(__webpack_exports__);
  14767. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14807. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14824. /***/ }),
  14825. /***/ "./legacy/legacy.ts":
  14826. /*!**************************!*\
  14827. !*** ./legacy/legacy.ts ***!
  14828. \**************************/
  14829. /*! 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 */
  14830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14831. "use strict";
  14832. __webpack_require__.r(__webpack_exports__);
  14833. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14889. /**
  14890. * Legacy support, defining window.BABYLON.GUI (global variable).
  14891. *
  14892. * This is the entry point for the UMD module.
  14893. * The entry point for a future ESM package should be index.ts
  14894. */
  14895. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14896. if (typeof globalObject !== "undefined") {
  14897. globalObject.BABYLON = globalObject.BABYLON || {};
  14898. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14899. }
  14900. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14901. /***/ }),
  14902. /***/ "babylonjs/Misc/perfCounter":
  14903. /*!****************************************************************************************************!*\
  14904. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14905. \****************************************************************************************************/
  14906. /*! no static exports found */
  14907. /***/ (function(module, exports) {
  14908. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  14909. /***/ })
  14910. /******/ });
  14911. });
  14912. //# sourceMappingURL=babylon.gui.js.map