babylon.gui.js 680 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_tools__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!*****************************************************************************!*\
  100. !*** C:/Users/trbaron/workspace/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \*****************************************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../../node_modules/webpack/buildin/global.js":
  291. /*!***********************************!*\
  292. !*** (webpack)/buildin/global.js ***!
  293. \***********************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./2D/adtInstrumentation.ts":
  314. /*!**********************************!*\
  315. !*** ./2D/adtInstrumentation.ts ***!
  316. \**********************************/
  317. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  322. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  323. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  324. /**
  325. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  326. */
  327. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  328. /**
  329. * Instantiates a new advanced dynamic texture instrumentation.
  330. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  331. * @param texture Defines the AdvancedDynamicTexture to instrument
  332. */
  333. function AdvancedDynamicTextureInstrumentation(
  334. /**
  335. * Define the instrumented AdvancedDynamicTexture.
  336. */
  337. texture) {
  338. this.texture = texture;
  339. this._captureRenderTime = false;
  340. this._renderTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  341. this._captureLayoutTime = false;
  342. this._layoutTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  343. // Observers
  344. this._onBeginRenderObserver = null;
  345. this._onEndRenderObserver = null;
  346. this._onBeginLayoutObserver = null;
  347. this._onEndLayoutObserver = null;
  348. }
  349. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  350. // Properties
  351. /**
  352. * Gets the perf counter used to capture render time
  353. */
  354. get: function () {
  355. return this._renderTime;
  356. },
  357. enumerable: true,
  358. configurable: true
  359. });
  360. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  361. /**
  362. * Gets the perf counter used to capture layout time
  363. */
  364. get: function () {
  365. return this._layoutTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  371. /**
  372. * Enable or disable the render time capture
  373. */
  374. get: function () {
  375. return this._captureRenderTime;
  376. },
  377. set: function (value) {
  378. var _this = this;
  379. if (value === this._captureRenderTime) {
  380. return;
  381. }
  382. this._captureRenderTime = value;
  383. if (value) {
  384. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  385. _this._renderTime.beginMonitoring();
  386. });
  387. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  388. _this._renderTime.endMonitoring(true);
  389. });
  390. }
  391. else {
  392. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  393. this._onBeginRenderObserver = null;
  394. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  395. this._onEndRenderObserver = null;
  396. }
  397. },
  398. enumerable: true,
  399. configurable: true
  400. });
  401. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  402. /**
  403. * Enable or disable the layout time capture
  404. */
  405. get: function () {
  406. return this._captureLayoutTime;
  407. },
  408. set: function (value) {
  409. var _this = this;
  410. if (value === this._captureLayoutTime) {
  411. return;
  412. }
  413. this._captureLayoutTime = value;
  414. if (value) {
  415. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  416. _this._layoutTime.beginMonitoring();
  417. });
  418. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  419. _this._layoutTime.endMonitoring(true);
  420. });
  421. }
  422. else {
  423. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  424. this._onBeginLayoutObserver = null;
  425. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  426. this._onEndLayoutObserver = null;
  427. }
  428. },
  429. enumerable: true,
  430. configurable: true
  431. });
  432. /**
  433. * Dispose and release associated resources.
  434. */
  435. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  436. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  437. this._onBeginRenderObserver = null;
  438. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  439. this._onEndRenderObserver = null;
  440. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  441. this._onBeginLayoutObserver = null;
  442. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  443. this._onEndLayoutObserver = null;
  444. this.texture = null;
  445. };
  446. return AdvancedDynamicTextureInstrumentation;
  447. }());
  448. /***/ }),
  449. /***/ "./2D/advancedDynamicTexture.ts":
  450. /*!**************************************!*\
  451. !*** ./2D/advancedDynamicTexture.ts ***!
  452. \**************************************/
  453. /*! exports provided: AdvancedDynamicTexture */
  454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  455. "use strict";
  456. __webpack_require__.r(__webpack_exports__);
  457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  459. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  460. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  461. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  462. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  463. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  464. /**
  465. * Class used to create texture to support 2D GUI elements
  466. * @see http://doc.babylonjs.com/how_to/gui
  467. */
  468. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  470. /**
  471. * Creates a new AdvancedDynamicTexture
  472. * @param name defines the name of the texture
  473. * @param width defines the width of the texture
  474. * @param height defines the height of the texture
  475. * @param scene defines the hosting scene
  476. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  477. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  478. */
  479. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  480. if (width === void 0) { width = 0; }
  481. if (height === void 0) { height = 0; }
  482. if (generateMipMaps === void 0) { generateMipMaps = false; }
  483. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  484. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  485. _this._isDirty = false;
  486. /** @hidden */
  487. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  488. /** @hidden */
  489. _this._lastControlOver = {};
  490. /** @hidden */
  491. _this._lastControlDown = {};
  492. /** @hidden */
  493. _this._capturingControl = {};
  494. /** @hidden */
  495. _this._linkedControls = new Array();
  496. _this._isFullscreen = false;
  497. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  498. _this._idealWidth = 0;
  499. _this._idealHeight = 0;
  500. _this._useSmallestIdeal = false;
  501. _this._renderAtIdealSize = false;
  502. _this._blockNextFocusCheck = false;
  503. _this._renderScale = 1;
  504. _this._cursorChanged = false;
  505. /**
  506. * Define type to string to ensure compatibility across browsers
  507. * Safari doesn't support DataTransfer constructor
  508. */
  509. _this._clipboardData = "";
  510. /**
  511. * Observable event triggered each time an clipboard event is received from the rendering canvas
  512. */
  513. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  514. /**
  515. * Observable event triggered each time a pointer down is intercepted by a control
  516. */
  517. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  518. /**
  519. * Observable event triggered before layout is evaluated
  520. */
  521. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  522. /**
  523. * Observable event triggered after the layout was evaluated
  524. */
  525. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  526. /**
  527. * Observable event triggered before the texture is rendered
  528. */
  529. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  530. /**
  531. * Observable event triggered after the texture was rendered
  532. */
  533. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  534. /**
  535. * Gets or sets a boolean defining if alpha is stored as premultiplied
  536. */
  537. _this.premulAlpha = false;
  538. _this._useInvalidateRectOptimization = true;
  539. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  540. _this._invalidatedRectangle = null;
  541. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  542. /** @hidden */
  543. _this.onClipboardCopy = function (rawEvt) {
  544. var evt = rawEvt;
  545. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  546. _this.onClipboardObservable.notifyObservers(ev);
  547. evt.preventDefault();
  548. };
  549. /** @hidden */
  550. _this.onClipboardCut = function (rawEvt) {
  551. var evt = rawEvt;
  552. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  553. _this.onClipboardObservable.notifyObservers(ev);
  554. evt.preventDefault();
  555. };
  556. /** @hidden */
  557. _this.onClipboardPaste = function (rawEvt) {
  558. var evt = rawEvt;
  559. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  560. _this.onClipboardObservable.notifyObservers(ev);
  561. evt.preventDefault();
  562. };
  563. scene = _this.getScene();
  564. if (!scene || !_this._texture) {
  565. return _this;
  566. }
  567. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  568. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  569. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  570. if (!_this._focusedControl) {
  571. return;
  572. }
  573. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  574. _this._focusedControl.processKeyboard(info.event);
  575. }
  576. info.skipOnPointerObservable = true;
  577. });
  578. _this._rootContainer._link(_this);
  579. _this.hasAlpha = true;
  580. if (!width || !height) {
  581. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  582. _this._onResize();
  583. }
  584. _this._texture.isReady = true;
  585. return _this;
  586. }
  587. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  588. /**
  589. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  590. * Useful when you want more antialiasing
  591. */
  592. get: function () {
  593. return this._renderScale;
  594. },
  595. set: function (value) {
  596. if (value === this._renderScale) {
  597. return;
  598. }
  599. this._renderScale = value;
  600. this._onResize();
  601. },
  602. enumerable: true,
  603. configurable: true
  604. });
  605. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  606. /** Gets or sets the background color */
  607. get: function () {
  608. return this._background;
  609. },
  610. set: function (value) {
  611. if (this._background === value) {
  612. return;
  613. }
  614. this._background = value;
  615. this.markAsDirty();
  616. },
  617. enumerable: true,
  618. configurable: true
  619. });
  620. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  621. /**
  622. * Gets or sets the ideal width used to design controls.
  623. * The GUI will then rescale everything accordingly
  624. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  625. */
  626. get: function () {
  627. return this._idealWidth;
  628. },
  629. set: function (value) {
  630. if (this._idealWidth === value) {
  631. return;
  632. }
  633. this._idealWidth = value;
  634. this.markAsDirty();
  635. this._rootContainer._markAllAsDirty();
  636. },
  637. enumerable: true,
  638. configurable: true
  639. });
  640. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  641. /**
  642. * Gets or sets the ideal height used to design controls.
  643. * The GUI will then rescale everything accordingly
  644. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  645. */
  646. get: function () {
  647. return this._idealHeight;
  648. },
  649. set: function (value) {
  650. if (this._idealHeight === value) {
  651. return;
  652. }
  653. this._idealHeight = value;
  654. this.markAsDirty();
  655. this._rootContainer._markAllAsDirty();
  656. },
  657. enumerable: true,
  658. configurable: true
  659. });
  660. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  661. /**
  662. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  663. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  664. */
  665. get: function () {
  666. return this._useSmallestIdeal;
  667. },
  668. set: function (value) {
  669. if (this._useSmallestIdeal === value) {
  670. return;
  671. }
  672. this._useSmallestIdeal = value;
  673. this.markAsDirty();
  674. this._rootContainer._markAllAsDirty();
  675. },
  676. enumerable: true,
  677. configurable: true
  678. });
  679. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  680. /**
  681. * Gets or sets a boolean indicating if adaptive scaling must be used
  682. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  683. */
  684. get: function () {
  685. return this._renderAtIdealSize;
  686. },
  687. set: function (value) {
  688. if (this._renderAtIdealSize === value) {
  689. return;
  690. }
  691. this._renderAtIdealSize = value;
  692. this._onResize();
  693. },
  694. enumerable: true,
  695. configurable: true
  696. });
  697. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  698. /**
  699. * Gets the underlying layer used to render the texture when in fullscreen mode
  700. */
  701. get: function () {
  702. return this._layerToDispose;
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  708. /**
  709. * Gets the root container control
  710. */
  711. get: function () {
  712. return this._rootContainer;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. /**
  718. * Returns an array containing the root container.
  719. * This is mostly used to let the Inspector introspects the ADT
  720. * @returns an array containing the rootContainer
  721. */
  722. AdvancedDynamicTexture.prototype.getChildren = function () {
  723. return [this._rootContainer];
  724. };
  725. /**
  726. * Will return all controls that are inside this texture
  727. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  728. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  729. * @return all child controls
  730. */
  731. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  732. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  733. };
  734. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  735. /**
  736. * Gets or sets the current focused control
  737. */
  738. get: function () {
  739. return this._focusedControl;
  740. },
  741. set: function (control) {
  742. if (this._focusedControl == control) {
  743. return;
  744. }
  745. if (this._focusedControl) {
  746. this._focusedControl.onBlur();
  747. }
  748. if (control) {
  749. control.onFocus();
  750. }
  751. this._focusedControl = control;
  752. },
  753. enumerable: true,
  754. configurable: true
  755. });
  756. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  757. /**
  758. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  759. */
  760. get: function () {
  761. if (!this.layer) {
  762. return true;
  763. }
  764. return (!this.layer.isBackground);
  765. },
  766. set: function (value) {
  767. if (!this.layer) {
  768. return;
  769. }
  770. if (this.layer.isBackground === !value) {
  771. return;
  772. }
  773. this.layer.isBackground = !value;
  774. },
  775. enumerable: true,
  776. configurable: true
  777. });
  778. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  779. /**
  780. * Gets or set information about clipboardData
  781. */
  782. get: function () {
  783. return this._clipboardData;
  784. },
  785. set: function (value) {
  786. this._clipboardData = value;
  787. },
  788. enumerable: true,
  789. configurable: true
  790. });
  791. /**
  792. * Get the current class name of the texture useful for serialization or dynamic coding.
  793. * @returns "AdvancedDynamicTexture"
  794. */
  795. AdvancedDynamicTexture.prototype.getClassName = function () {
  796. return "AdvancedDynamicTexture";
  797. };
  798. /**
  799. * Function used to execute a function on all controls
  800. * @param func defines the function to execute
  801. * @param container defines the container where controls belong. If null the root container will be used
  802. */
  803. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  804. if (!container) {
  805. container = this._rootContainer;
  806. }
  807. func(container);
  808. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  809. var child = _a[_i];
  810. if (child.children) {
  811. this.executeOnAllControls(func, child);
  812. continue;
  813. }
  814. func(child);
  815. }
  816. };
  817. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  818. /**
  819. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  820. */
  821. get: function () {
  822. return this._useInvalidateRectOptimization;
  823. },
  824. set: function (value) {
  825. this._useInvalidateRectOptimization = value;
  826. },
  827. enumerable: true,
  828. configurable: true
  829. });
  830. /**
  831. * Invalidates a rectangle area on the gui texture
  832. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  833. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  834. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  835. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  836. */
  837. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  838. if (!this._useInvalidateRectOptimization) {
  839. return;
  840. }
  841. if (!this._invalidatedRectangle) {
  842. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  843. }
  844. else {
  845. // Compute intersection
  846. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  847. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  848. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  849. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  850. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  851. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  852. }
  853. };
  854. /**
  855. * Marks the texture as dirty forcing a complete update
  856. */
  857. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  858. this._isDirty = true;
  859. };
  860. /**
  861. * Helper function used to create a new style
  862. * @returns a new style
  863. * @see http://doc.babylonjs.com/how_to/gui#styles
  864. */
  865. AdvancedDynamicTexture.prototype.createStyle = function () {
  866. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  867. };
  868. /**
  869. * Adds a new control to the root container
  870. * @param control defines the control to add
  871. * @returns the current texture
  872. */
  873. AdvancedDynamicTexture.prototype.addControl = function (control) {
  874. this._rootContainer.addControl(control);
  875. return this;
  876. };
  877. /**
  878. * Removes a control from the root container
  879. * @param control defines the control to remove
  880. * @returns the current texture
  881. */
  882. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  883. this._rootContainer.removeControl(control);
  884. return this;
  885. };
  886. /**
  887. * Release all resources
  888. */
  889. AdvancedDynamicTexture.prototype.dispose = function () {
  890. var scene = this.getScene();
  891. if (!scene) {
  892. return;
  893. }
  894. this._rootCanvas = null;
  895. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  896. if (this._resizeObserver) {
  897. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  898. }
  899. if (this._pointerMoveObserver) {
  900. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  901. }
  902. if (this._pointerObserver) {
  903. scene.onPointerObservable.remove(this._pointerObserver);
  904. }
  905. if (this._preKeyboardObserver) {
  906. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  907. }
  908. if (this._canvasPointerOutObserver) {
  909. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  910. }
  911. if (this._layerToDispose) {
  912. this._layerToDispose.texture = null;
  913. this._layerToDispose.dispose();
  914. this._layerToDispose = null;
  915. }
  916. this._rootContainer.dispose();
  917. this.onClipboardObservable.clear();
  918. this.onControlPickedObservable.clear();
  919. this.onBeginRenderObservable.clear();
  920. this.onEndRenderObservable.clear();
  921. this.onBeginLayoutObservable.clear();
  922. this.onEndLayoutObservable.clear();
  923. _super.prototype.dispose.call(this);
  924. };
  925. AdvancedDynamicTexture.prototype._onResize = function () {
  926. var scene = this.getScene();
  927. if (!scene) {
  928. return;
  929. }
  930. // Check size
  931. var engine = scene.getEngine();
  932. var textureSize = this.getSize();
  933. var renderWidth = engine.getRenderWidth() * this._renderScale;
  934. var renderHeight = engine.getRenderHeight() * this._renderScale;
  935. if (this._renderAtIdealSize) {
  936. if (this._idealWidth) {
  937. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  938. renderWidth = this._idealWidth;
  939. }
  940. else if (this._idealHeight) {
  941. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  942. renderHeight = this._idealHeight;
  943. }
  944. }
  945. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  946. this.scaleTo(renderWidth, renderHeight);
  947. this.markAsDirty();
  948. if (this._idealWidth || this._idealHeight) {
  949. this._rootContainer._markAllAsDirty();
  950. }
  951. }
  952. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  953. };
  954. /** @hidden */
  955. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  956. var engine = scene.getEngine();
  957. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  958. };
  959. /**
  960. * Get screen coordinates for a vector3
  961. * @param position defines the position to project
  962. * @param worldMatrix defines the world matrix to use
  963. * @returns the projected position
  964. */
  965. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  966. var scene = this.getScene();
  967. if (!scene) {
  968. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  969. }
  970. var globalViewport = this._getGlobalViewport(scene);
  971. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  972. projectedPosition.scaleInPlace(this.renderScale);
  973. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  974. };
  975. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  976. if (this._layerToDispose) {
  977. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  978. return;
  979. }
  980. }
  981. if (this._isFullscreen && this._linkedControls.length) {
  982. var scene = this.getScene();
  983. if (!scene) {
  984. return;
  985. }
  986. var globalViewport = this._getGlobalViewport(scene);
  987. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  988. var control = _a[_i];
  989. if (!control.isVisible) {
  990. continue;
  991. }
  992. var mesh = control._linkedMesh;
  993. if (!mesh || mesh.isDisposed()) {
  994. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  995. control.linkWithMesh(null);
  996. });
  997. continue;
  998. }
  999. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : mesh.getAbsolutePosition();
  1000. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1001. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1002. control.notRenderable = true;
  1003. continue;
  1004. }
  1005. control.notRenderable = false;
  1006. // Account for RenderScale.
  1007. projectedPosition.scaleInPlace(this.renderScale);
  1008. control._moveToProjectedPosition(projectedPosition);
  1009. }
  1010. }
  1011. if (!this._isDirty && !this._rootContainer.isDirty) {
  1012. return;
  1013. }
  1014. this._isDirty = false;
  1015. this._render();
  1016. this.update(true, this.premulAlpha);
  1017. };
  1018. AdvancedDynamicTexture.prototype._render = function () {
  1019. var textureSize = this.getSize();
  1020. var renderWidth = textureSize.width;
  1021. var renderHeight = textureSize.height;
  1022. var context = this.getContext();
  1023. context.font = "18px Arial";
  1024. context.strokeStyle = "white";
  1025. // Layout
  1026. this.onBeginLayoutObservable.notifyObservers(this);
  1027. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1028. this._rootContainer._layout(measure, context);
  1029. this.onEndLayoutObservable.notifyObservers(this);
  1030. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1031. // Clear
  1032. if (this._invalidatedRectangle) {
  1033. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1034. }
  1035. else {
  1036. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1037. }
  1038. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1039. if (this._background) {
  1040. context.save();
  1041. context.fillStyle = this._background;
  1042. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1043. context.restore();
  1044. }
  1045. // Render
  1046. this.onBeginRenderObservable.notifyObservers(this);
  1047. this._rootContainer._render(context, this._invalidatedRectangle);
  1048. this.onEndRenderObservable.notifyObservers(this);
  1049. this._invalidatedRectangle = null;
  1050. };
  1051. /** @hidden */
  1052. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1053. if (this._rootCanvas) {
  1054. this._rootCanvas.style.cursor = cursor;
  1055. this._cursorChanged = true;
  1056. }
  1057. };
  1058. /** @hidden */
  1059. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1060. this._lastControlDown[pointerId] = control;
  1061. this.onControlPickedObservable.notifyObservers(control);
  1062. };
  1063. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1064. var scene = this.getScene();
  1065. if (!scene) {
  1066. return;
  1067. }
  1068. var engine = scene.getEngine();
  1069. var textureSize = this.getSize();
  1070. if (this._isFullscreen) {
  1071. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1072. var viewport = camera.viewport;
  1073. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1074. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1075. }
  1076. if (this._capturingControl[pointerId]) {
  1077. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1078. return;
  1079. }
  1080. this._cursorChanged = false;
  1081. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1082. this._changeCursor("");
  1083. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1084. if (this._lastControlOver[pointerId]) {
  1085. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1086. delete this._lastControlOver[pointerId];
  1087. }
  1088. }
  1089. }
  1090. if (!this._cursorChanged) {
  1091. this._changeCursor("");
  1092. }
  1093. this._manageFocus();
  1094. };
  1095. /** @hidden */
  1096. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1097. for (var pointerId in list) {
  1098. if (!list.hasOwnProperty(pointerId)) {
  1099. continue;
  1100. }
  1101. var lastControlOver = list[pointerId];
  1102. if (lastControlOver === control) {
  1103. delete list[pointerId];
  1104. }
  1105. }
  1106. };
  1107. /** @hidden */
  1108. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1109. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1110. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1111. };
  1112. /** Attach to all scene events required to support pointer events */
  1113. AdvancedDynamicTexture.prototype.attach = function () {
  1114. var _this = this;
  1115. var scene = this.getScene();
  1116. if (!scene) {
  1117. return;
  1118. }
  1119. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1120. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1121. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1122. return;
  1123. }
  1124. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1125. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1126. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1127. return;
  1128. }
  1129. if (!scene) {
  1130. return;
  1131. }
  1132. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1133. var engine = scene.getEngine();
  1134. if (!camera) {
  1135. tempViewport.x = 0;
  1136. tempViewport.y = 0;
  1137. tempViewport.width = engine.getRenderWidth();
  1138. tempViewport.height = engine.getRenderHeight();
  1139. }
  1140. else {
  1141. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1142. }
  1143. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1144. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1145. _this._shouldBlockPointer = false;
  1146. // Do picking modifies _shouldBlockPointer
  1147. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1148. // Avoid overwriting a true skipOnPointerObservable to false
  1149. if (_this._shouldBlockPointer) {
  1150. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1151. }
  1152. });
  1153. this._attachToOnPointerOut(scene);
  1154. };
  1155. /**
  1156. * Register the clipboard Events onto the canvas
  1157. */
  1158. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1159. self.addEventListener("copy", this.onClipboardCopy, false);
  1160. self.addEventListener("cut", this.onClipboardCut, false);
  1161. self.addEventListener("paste", this.onClipboardPaste, false);
  1162. };
  1163. /**
  1164. * Unregister the clipboard Events from the canvas
  1165. */
  1166. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1167. self.removeEventListener("copy", this.onClipboardCopy);
  1168. self.removeEventListener("cut", this.onClipboardCut);
  1169. self.removeEventListener("paste", this.onClipboardPaste);
  1170. };
  1171. /**
  1172. * Connect the texture to a hosting mesh to enable interactions
  1173. * @param mesh defines the mesh to attach to
  1174. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1175. */
  1176. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1177. var _this = this;
  1178. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1179. var scene = this.getScene();
  1180. if (!scene) {
  1181. return;
  1182. }
  1183. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1184. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1185. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1186. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1187. return;
  1188. }
  1189. var pointerId = pi.event.pointerId || 0;
  1190. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1191. var uv = pi.pickInfo.getTextureCoordinates();
  1192. if (uv) {
  1193. var size = _this.getSize();
  1194. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1195. }
  1196. }
  1197. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1198. if (_this._lastControlDown[pointerId]) {
  1199. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1200. }
  1201. delete _this._lastControlDown[pointerId];
  1202. if (_this.focusedControl) {
  1203. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1204. var canMoveFocus = true;
  1205. if (friendlyControls) {
  1206. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1207. var control = friendlyControls_1[_i];
  1208. // Same host, no need to keep the focus
  1209. if (_this === control._host) {
  1210. continue;
  1211. }
  1212. // Different hosts
  1213. var otherHost = control._host;
  1214. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1215. canMoveFocus = false;
  1216. break;
  1217. }
  1218. }
  1219. }
  1220. if (canMoveFocus) {
  1221. _this.focusedControl = null;
  1222. }
  1223. }
  1224. }
  1225. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1226. if (_this._lastControlOver[pointerId]) {
  1227. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1228. }
  1229. delete _this._lastControlOver[pointerId];
  1230. }
  1231. });
  1232. mesh.enablePointerMoveEvents = supportPointerMove;
  1233. this._attachToOnPointerOut(scene);
  1234. };
  1235. /**
  1236. * Move the focus to a specific control
  1237. * @param control defines the control which will receive the focus
  1238. */
  1239. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1240. this.focusedControl = control;
  1241. this._lastPickedControl = control;
  1242. this._blockNextFocusCheck = true;
  1243. };
  1244. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1245. if (this._blockNextFocusCheck) {
  1246. this._blockNextFocusCheck = false;
  1247. this._lastPickedControl = this._focusedControl;
  1248. return;
  1249. }
  1250. // Focus management
  1251. if (this._focusedControl) {
  1252. if (this._focusedControl !== this._lastPickedControl) {
  1253. if (this._lastPickedControl.isFocusInvisible) {
  1254. return;
  1255. }
  1256. this.focusedControl = null;
  1257. }
  1258. }
  1259. };
  1260. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1261. var _this = this;
  1262. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1263. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1264. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1265. }
  1266. delete _this._lastControlOver[pointerEvent.pointerId];
  1267. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1268. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1269. delete _this._lastControlDown[pointerEvent.pointerId];
  1270. }
  1271. });
  1272. };
  1273. // Statics
  1274. /**
  1275. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1276. * @param mesh defines the mesh which will receive the texture
  1277. * @param width defines the texture width (1024 by default)
  1278. * @param height defines the texture height (1024 by default)
  1279. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1280. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1281. * @returns a new AdvancedDynamicTexture
  1282. */
  1283. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1284. if (width === void 0) { width = 1024; }
  1285. if (height === void 0) { height = 1024; }
  1286. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1287. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1288. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1289. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1290. material.backFaceCulling = false;
  1291. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1292. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1293. if (onlyAlphaTesting) {
  1294. material.diffuseTexture = result;
  1295. material.emissiveTexture = result;
  1296. result.hasAlpha = true;
  1297. }
  1298. else {
  1299. material.emissiveTexture = result;
  1300. material.opacityTexture = result;
  1301. }
  1302. mesh.material = material;
  1303. result.attachToMesh(mesh, supportPointerMove);
  1304. return result;
  1305. };
  1306. /**
  1307. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1308. * In this mode the texture will rely on a layer for its rendering.
  1309. * This allows it to be treated like any other layer.
  1310. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1311. * LayerMask is set through advancedTexture.layer.layerMask
  1312. * @param name defines name for the texture
  1313. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1314. * @param scene defines the hsoting scene
  1315. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1316. * @returns a new AdvancedDynamicTexture
  1317. */
  1318. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1319. if (foreground === void 0) { foreground = true; }
  1320. if (scene === void 0) { scene = null; }
  1321. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1322. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1323. // Display
  1324. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1325. layer.texture = result;
  1326. result._layerToDispose = layer;
  1327. result._isFullscreen = true;
  1328. // Attach
  1329. result.attach();
  1330. return result;
  1331. };
  1332. return AdvancedDynamicTexture;
  1333. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1334. /***/ }),
  1335. /***/ "./2D/controls/button.ts":
  1336. /*!*******************************!*\
  1337. !*** ./2D/controls/button.ts ***!
  1338. \*******************************/
  1339. /*! exports provided: Button */
  1340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1341. "use strict";
  1342. __webpack_require__.r(__webpack_exports__);
  1343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1344. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1345. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1346. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1347. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1348. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1349. /**
  1350. * Class used to create 2D buttons
  1351. */
  1352. var Button = /** @class */ (function (_super) {
  1353. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1354. /**
  1355. * Creates a new Button
  1356. * @param name defines the name of the button
  1357. */
  1358. function Button(name) {
  1359. var _this = _super.call(this, name) || this;
  1360. _this.name = name;
  1361. _this.thickness = 1;
  1362. _this.isPointerBlocker = true;
  1363. var alphaStore = null;
  1364. _this.pointerEnterAnimation = function () {
  1365. alphaStore = _this.alpha;
  1366. _this.alpha -= 0.1;
  1367. };
  1368. _this.pointerOutAnimation = function () {
  1369. if (alphaStore !== null) {
  1370. _this.alpha = alphaStore;
  1371. }
  1372. };
  1373. _this.pointerDownAnimation = function () {
  1374. _this.scaleX -= 0.05;
  1375. _this.scaleY -= 0.05;
  1376. };
  1377. _this.pointerUpAnimation = function () {
  1378. _this.scaleX += 0.05;
  1379. _this.scaleY += 0.05;
  1380. };
  1381. return _this;
  1382. }
  1383. Object.defineProperty(Button.prototype, "image", {
  1384. /**
  1385. * Returns the image part of the button (if any)
  1386. */
  1387. get: function () {
  1388. return this._image;
  1389. },
  1390. enumerable: true,
  1391. configurable: true
  1392. });
  1393. Object.defineProperty(Button.prototype, "textBlock", {
  1394. /**
  1395. * Returns the image part of the button (if any)
  1396. */
  1397. get: function () {
  1398. return this._textBlock;
  1399. },
  1400. enumerable: true,
  1401. configurable: true
  1402. });
  1403. Button.prototype._getTypeName = function () {
  1404. return "Button";
  1405. };
  1406. // While being a container, the button behaves like a control.
  1407. /** @hidden */
  1408. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1409. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1410. return false;
  1411. }
  1412. if (!_super.prototype.contains.call(this, x, y)) {
  1413. return false;
  1414. }
  1415. this._processObservables(type, x, y, pointerId, buttonIndex);
  1416. return true;
  1417. };
  1418. /** @hidden */
  1419. Button.prototype._onPointerEnter = function (target) {
  1420. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1421. return false;
  1422. }
  1423. if (this.pointerEnterAnimation) {
  1424. this.pointerEnterAnimation();
  1425. }
  1426. return true;
  1427. };
  1428. /** @hidden */
  1429. Button.prototype._onPointerOut = function (target, force) {
  1430. if (force === void 0) { force = false; }
  1431. if (this.pointerOutAnimation) {
  1432. this.pointerOutAnimation();
  1433. }
  1434. _super.prototype._onPointerOut.call(this, target, force);
  1435. };
  1436. /** @hidden */
  1437. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1438. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1439. return false;
  1440. }
  1441. if (this.pointerDownAnimation) {
  1442. this.pointerDownAnimation();
  1443. }
  1444. return true;
  1445. };
  1446. /** @hidden */
  1447. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1448. if (this.pointerUpAnimation) {
  1449. this.pointerUpAnimation();
  1450. }
  1451. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1452. };
  1453. // Statics
  1454. /**
  1455. * Creates a new button made with an image and a text
  1456. * @param name defines the name of the button
  1457. * @param text defines the text of the button
  1458. * @param imageUrl defines the url of the image
  1459. * @returns a new Button
  1460. */
  1461. Button.CreateImageButton = function (name, text, imageUrl) {
  1462. var result = new Button(name);
  1463. // Adding text
  1464. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1465. textBlock.textWrapping = true;
  1466. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1467. textBlock.paddingLeft = "20%";
  1468. result.addControl(textBlock);
  1469. // Adding image
  1470. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1471. iconImage.width = "20%";
  1472. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1473. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1474. result.addControl(iconImage);
  1475. // Store
  1476. result._image = iconImage;
  1477. result._textBlock = textBlock;
  1478. return result;
  1479. };
  1480. /**
  1481. * Creates a new button made with an image
  1482. * @param name defines the name of the button
  1483. * @param imageUrl defines the url of the image
  1484. * @returns a new Button
  1485. */
  1486. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1487. var result = new Button(name);
  1488. // Adding image
  1489. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1490. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1491. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1492. result.addControl(iconImage);
  1493. // Store
  1494. result._image = iconImage;
  1495. return result;
  1496. };
  1497. /**
  1498. * Creates a new button made with a text
  1499. * @param name defines the name of the button
  1500. * @param text defines the text of the button
  1501. * @returns a new Button
  1502. */
  1503. Button.CreateSimpleButton = function (name, text) {
  1504. var result = new Button(name);
  1505. // Adding text
  1506. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1507. textBlock.textWrapping = true;
  1508. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1509. result.addControl(textBlock);
  1510. // Store
  1511. result._textBlock = textBlock;
  1512. return result;
  1513. };
  1514. /**
  1515. * Creates a new button made with an image and a centered text
  1516. * @param name defines the name of the button
  1517. * @param text defines the text of the button
  1518. * @param imageUrl defines the url of the image
  1519. * @returns a new Button
  1520. */
  1521. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1522. var result = new Button(name);
  1523. // Adding image
  1524. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1525. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1526. result.addControl(iconImage);
  1527. // Adding text
  1528. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1529. textBlock.textWrapping = true;
  1530. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1531. result.addControl(textBlock);
  1532. // Store
  1533. result._image = iconImage;
  1534. result._textBlock = textBlock;
  1535. return result;
  1536. };
  1537. return Button;
  1538. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1539. /***/ }),
  1540. /***/ "./2D/controls/checkbox.ts":
  1541. /*!*********************************!*\
  1542. !*** ./2D/controls/checkbox.ts ***!
  1543. \*********************************/
  1544. /*! exports provided: Checkbox */
  1545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1546. "use strict";
  1547. __webpack_require__.r(__webpack_exports__);
  1548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1550. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  1551. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1552. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1553. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1554. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1555. /**
  1556. * Class used to represent a 2D checkbox
  1557. */
  1558. var Checkbox = /** @class */ (function (_super) {
  1559. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1560. /**
  1561. * Creates a new CheckBox
  1562. * @param name defines the control name
  1563. */
  1564. function Checkbox(name) {
  1565. var _this = _super.call(this, name) || this;
  1566. _this.name = name;
  1567. _this._isChecked = false;
  1568. _this._background = "black";
  1569. _this._checkSizeRatio = 0.8;
  1570. _this._thickness = 1;
  1571. /**
  1572. * Observable raised when isChecked property changes
  1573. */
  1574. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1575. _this.isPointerBlocker = true;
  1576. return _this;
  1577. }
  1578. Object.defineProperty(Checkbox.prototype, "thickness", {
  1579. /** Gets or sets border thickness */
  1580. get: function () {
  1581. return this._thickness;
  1582. },
  1583. set: function (value) {
  1584. if (this._thickness === value) {
  1585. return;
  1586. }
  1587. this._thickness = value;
  1588. this._markAsDirty();
  1589. },
  1590. enumerable: true,
  1591. configurable: true
  1592. });
  1593. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1594. /** Gets or sets a value indicating the ratio between overall size and check size */
  1595. get: function () {
  1596. return this._checkSizeRatio;
  1597. },
  1598. set: function (value) {
  1599. value = Math.max(Math.min(1, value), 0);
  1600. if (this._checkSizeRatio === value) {
  1601. return;
  1602. }
  1603. this._checkSizeRatio = value;
  1604. this._markAsDirty();
  1605. },
  1606. enumerable: true,
  1607. configurable: true
  1608. });
  1609. Object.defineProperty(Checkbox.prototype, "background", {
  1610. /** Gets or sets background color */
  1611. get: function () {
  1612. return this._background;
  1613. },
  1614. set: function (value) {
  1615. if (this._background === value) {
  1616. return;
  1617. }
  1618. this._background = value;
  1619. this._markAsDirty();
  1620. },
  1621. enumerable: true,
  1622. configurable: true
  1623. });
  1624. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1625. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1626. get: function () {
  1627. return this._isChecked;
  1628. },
  1629. set: function (value) {
  1630. if (this._isChecked === value) {
  1631. return;
  1632. }
  1633. this._isChecked = value;
  1634. this._markAsDirty();
  1635. this.onIsCheckedChangedObservable.notifyObservers(value);
  1636. },
  1637. enumerable: true,
  1638. configurable: true
  1639. });
  1640. Checkbox.prototype._getTypeName = function () {
  1641. return "Checkbox";
  1642. };
  1643. /** @hidden */
  1644. Checkbox.prototype._draw = function (context) {
  1645. context.save();
  1646. this._applyStates(context);
  1647. var actualWidth = this._currentMeasure.width - this._thickness;
  1648. var actualHeight = this._currentMeasure.height - this._thickness;
  1649. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1650. context.shadowColor = this.shadowColor;
  1651. context.shadowBlur = this.shadowBlur;
  1652. context.shadowOffsetX = this.shadowOffsetX;
  1653. context.shadowOffsetY = this.shadowOffsetY;
  1654. }
  1655. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1656. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1657. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1658. context.shadowBlur = 0;
  1659. context.shadowOffsetX = 0;
  1660. context.shadowOffsetY = 0;
  1661. }
  1662. if (this._isChecked) {
  1663. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1664. var offsetWidth = actualWidth * this._checkSizeRatio;
  1665. var offseHeight = actualHeight * this._checkSizeRatio;
  1666. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1667. }
  1668. context.strokeStyle = this.color;
  1669. context.lineWidth = this._thickness;
  1670. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1671. context.restore();
  1672. };
  1673. // Events
  1674. /** @hidden */
  1675. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1676. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1677. return false;
  1678. }
  1679. this.isChecked = !this.isChecked;
  1680. return true;
  1681. };
  1682. /**
  1683. * Utility function to easily create a checkbox with a header
  1684. * @param title defines the label to use for the header
  1685. * @param onValueChanged defines the callback to call when value changes
  1686. * @returns a StackPanel containing the checkbox and a textBlock
  1687. */
  1688. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1689. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1690. panel.isVertical = false;
  1691. panel.height = "30px";
  1692. var checkbox = new Checkbox();
  1693. checkbox.width = "20px";
  1694. checkbox.height = "20px";
  1695. checkbox.isChecked = true;
  1696. checkbox.color = "green";
  1697. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1698. panel.addControl(checkbox);
  1699. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1700. header.text = title;
  1701. header.width = "180px";
  1702. header.paddingLeft = "5px";
  1703. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1704. header.color = "white";
  1705. panel.addControl(header);
  1706. return panel;
  1707. };
  1708. return Checkbox;
  1709. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1710. /***/ }),
  1711. /***/ "./2D/controls/colorpicker.ts":
  1712. /*!************************************!*\
  1713. !*** ./2D/controls/colorpicker.ts ***!
  1714. \************************************/
  1715. /*! exports provided: ColorPicker */
  1716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1717. "use strict";
  1718. __webpack_require__.r(__webpack_exports__);
  1719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1720. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1721. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  1722. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1723. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1724. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1725. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1726. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1727. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1728. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1729. /** Class used to create color pickers */
  1730. var ColorPicker = /** @class */ (function (_super) {
  1731. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1732. /**
  1733. * Creates a new ColorPicker
  1734. * @param name defines the control name
  1735. */
  1736. function ColorPicker(name) {
  1737. var _this = _super.call(this, name) || this;
  1738. _this.name = name;
  1739. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1740. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1741. _this._pointerStartedOnSquare = false;
  1742. _this._pointerStartedOnWheel = false;
  1743. _this._squareLeft = 0;
  1744. _this._squareTop = 0;
  1745. _this._squareSize = 0;
  1746. _this._h = 360;
  1747. _this._s = 1;
  1748. _this._v = 1;
  1749. _this._lastPointerDownID = -1;
  1750. /**
  1751. * Observable raised when the value changes
  1752. */
  1753. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1754. // Events
  1755. _this._pointerIsDown = false;
  1756. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1757. _this.size = "200px";
  1758. _this.isPointerBlocker = true;
  1759. return _this;
  1760. }
  1761. Object.defineProperty(ColorPicker.prototype, "value", {
  1762. /** Gets or sets the color of the color picker */
  1763. get: function () {
  1764. return this._value;
  1765. },
  1766. set: function (value) {
  1767. if (this._value.equals(value)) {
  1768. return;
  1769. }
  1770. this._value.copyFrom(value);
  1771. this._RGBtoHSV(this._value, this._tmpColor);
  1772. this._h = this._tmpColor.r;
  1773. this._s = Math.max(this._tmpColor.g, 0.00001);
  1774. this._v = Math.max(this._tmpColor.b, 0.00001);
  1775. this._markAsDirty();
  1776. if (this._value.r <= ColorPicker._Epsilon) {
  1777. this._value.r = 0;
  1778. }
  1779. if (this._value.g <= ColorPicker._Epsilon) {
  1780. this._value.g = 0;
  1781. }
  1782. if (this._value.b <= ColorPicker._Epsilon) {
  1783. this._value.b = 0;
  1784. }
  1785. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1786. this._value.r = 1.0;
  1787. }
  1788. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1789. this._value.g = 1.0;
  1790. }
  1791. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1792. this._value.b = 1.0;
  1793. }
  1794. this.onValueChangedObservable.notifyObservers(this._value);
  1795. },
  1796. enumerable: true,
  1797. configurable: true
  1798. });
  1799. Object.defineProperty(ColorPicker.prototype, "width", {
  1800. /**
  1801. * Gets or sets control width
  1802. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1803. */
  1804. get: function () {
  1805. return this._width.toString(this._host);
  1806. },
  1807. set: function (value) {
  1808. if (this._width.toString(this._host) === value) {
  1809. return;
  1810. }
  1811. if (this._width.fromString(value)) {
  1812. this._height.fromString(value);
  1813. this._markAsDirty();
  1814. }
  1815. },
  1816. enumerable: true,
  1817. configurable: true
  1818. });
  1819. Object.defineProperty(ColorPicker.prototype, "height", {
  1820. /**
  1821. * Gets or sets control height
  1822. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1823. */
  1824. get: function () {
  1825. return this._height.toString(this._host);
  1826. },
  1827. /** Gets or sets control height */
  1828. set: function (value) {
  1829. if (this._height.toString(this._host) === value) {
  1830. return;
  1831. }
  1832. if (this._height.fromString(value)) {
  1833. this._width.fromString(value);
  1834. this._markAsDirty();
  1835. }
  1836. },
  1837. enumerable: true,
  1838. configurable: true
  1839. });
  1840. Object.defineProperty(ColorPicker.prototype, "size", {
  1841. /** Gets or sets control size */
  1842. get: function () {
  1843. return this.width;
  1844. },
  1845. set: function (value) {
  1846. this.width = value;
  1847. },
  1848. enumerable: true,
  1849. configurable: true
  1850. });
  1851. ColorPicker.prototype._getTypeName = function () {
  1852. return "ColorPicker";
  1853. };
  1854. /** @hidden */
  1855. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1856. if (parentMeasure.width < parentMeasure.height) {
  1857. this._currentMeasure.height = parentMeasure.width;
  1858. }
  1859. else {
  1860. this._currentMeasure.width = parentMeasure.height;
  1861. }
  1862. };
  1863. ColorPicker.prototype._updateSquareProps = function () {
  1864. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1865. var wheelThickness = radius * .2;
  1866. var innerDiameter = (radius - wheelThickness) * 2;
  1867. var squareSize = innerDiameter / (Math.sqrt(2));
  1868. var offset = radius - squareSize * .5;
  1869. this._squareLeft = this._currentMeasure.left + offset;
  1870. this._squareTop = this._currentMeasure.top + offset;
  1871. this._squareSize = squareSize;
  1872. };
  1873. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1874. var lgh = context.createLinearGradient(left, top, width + left, top);
  1875. lgh.addColorStop(0, '#fff');
  1876. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1877. context.fillStyle = lgh;
  1878. context.fillRect(left, top, width, height);
  1879. var lgv = context.createLinearGradient(left, top, left, height + top);
  1880. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1881. lgv.addColorStop(1, '#000');
  1882. context.fillStyle = lgv;
  1883. context.fillRect(left, top, width, height);
  1884. };
  1885. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1886. context.beginPath();
  1887. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1888. context.lineWidth = 3;
  1889. context.strokeStyle = '#333333';
  1890. context.stroke();
  1891. context.beginPath();
  1892. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1893. context.lineWidth = 3;
  1894. context.strokeStyle = '#ffffff';
  1895. context.stroke();
  1896. };
  1897. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1898. var canvas = document.createElement("canvas");
  1899. canvas.width = radius * 2;
  1900. canvas.height = radius * 2;
  1901. var context = canvas.getContext("2d");
  1902. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1903. var data = image.data;
  1904. var color = this._tmpColor;
  1905. var maxDistSq = radius * radius;
  1906. var innerRadius = radius - thickness;
  1907. var minDistSq = innerRadius * innerRadius;
  1908. for (var x = -radius; x < radius; x++) {
  1909. for (var y = -radius; y < radius; y++) {
  1910. var distSq = x * x + y * y;
  1911. if (distSq > maxDistSq || distSq < minDistSq) {
  1912. continue;
  1913. }
  1914. var dist = Math.sqrt(distSq);
  1915. var ang = Math.atan2(y, x);
  1916. this._HSVtoRGB(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1917. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1918. data[index] = color.r * 255;
  1919. data[index + 1] = color.g * 255;
  1920. data[index + 2] = color.b * 255;
  1921. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1922. //apply less alpha to bigger color pickers
  1923. var alphaAmount = .2;
  1924. var maxAlpha = .2;
  1925. var minAlpha = .04;
  1926. var lowerRadius = 50;
  1927. var upperRadius = 150;
  1928. if (radius < lowerRadius) {
  1929. alphaAmount = maxAlpha;
  1930. }
  1931. else if (radius > upperRadius) {
  1932. alphaAmount = minAlpha;
  1933. }
  1934. else {
  1935. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1936. }
  1937. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1938. if (alphaRatio < alphaAmount) {
  1939. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1940. }
  1941. else if (alphaRatio > 1 - alphaAmount) {
  1942. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1943. }
  1944. else {
  1945. data[index + 3] = 255;
  1946. }
  1947. }
  1948. }
  1949. context.putImageData(image, 0, 0);
  1950. return canvas;
  1951. };
  1952. ColorPicker.prototype._RGBtoHSV = function (color, result) {
  1953. var r = color.r;
  1954. var g = color.g;
  1955. var b = color.b;
  1956. var max = Math.max(r, g, b);
  1957. var min = Math.min(r, g, b);
  1958. var h = 0;
  1959. var s = 0;
  1960. var v = max;
  1961. var dm = max - min;
  1962. if (max !== 0) {
  1963. s = dm / max;
  1964. }
  1965. if (max != min) {
  1966. if (max == r) {
  1967. h = (g - b) / dm;
  1968. if (g < b) {
  1969. h += 6;
  1970. }
  1971. }
  1972. else if (max == g) {
  1973. h = (b - r) / dm + 2;
  1974. }
  1975. else if (max == b) {
  1976. h = (r - g) / dm + 4;
  1977. }
  1978. h *= 60;
  1979. }
  1980. result.r = h;
  1981. result.g = s;
  1982. result.b = v;
  1983. };
  1984. ColorPicker.prototype._HSVtoRGB = function (hue, saturation, value, result) {
  1985. var chroma = value * saturation;
  1986. var h = hue / 60;
  1987. var x = chroma * (1 - Math.abs((h % 2) - 1));
  1988. var r = 0;
  1989. var g = 0;
  1990. var b = 0;
  1991. if (h >= 0 && h <= 1) {
  1992. r = chroma;
  1993. g = x;
  1994. }
  1995. else if (h >= 1 && h <= 2) {
  1996. r = x;
  1997. g = chroma;
  1998. }
  1999. else if (h >= 2 && h <= 3) {
  2000. g = chroma;
  2001. b = x;
  2002. }
  2003. else if (h >= 3 && h <= 4) {
  2004. g = x;
  2005. b = chroma;
  2006. }
  2007. else if (h >= 4 && h <= 5) {
  2008. r = x;
  2009. b = chroma;
  2010. }
  2011. else if (h >= 5 && h <= 6) {
  2012. r = chroma;
  2013. b = x;
  2014. }
  2015. var m = value - chroma;
  2016. result.set((r + m), (g + m), (b + m));
  2017. };
  2018. /** @hidden */
  2019. ColorPicker.prototype._draw = function (context) {
  2020. context.save();
  2021. this._applyStates(context);
  2022. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2023. var wheelThickness = radius * .2;
  2024. var left = this._currentMeasure.left;
  2025. var top = this._currentMeasure.top;
  2026. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2027. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2028. }
  2029. this._updateSquareProps();
  2030. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2031. context.shadowColor = this.shadowColor;
  2032. context.shadowBlur = this.shadowBlur;
  2033. context.shadowOffsetX = this.shadowOffsetX;
  2034. context.shadowOffsetY = this.shadowOffsetY;
  2035. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2036. }
  2037. context.drawImage(this._colorWheelCanvas, left, top);
  2038. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2039. context.shadowBlur = 0;
  2040. context.shadowOffsetX = 0;
  2041. context.shadowOffsetY = 0;
  2042. }
  2043. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2044. var cx = this._squareLeft + this._squareSize * this._s;
  2045. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2046. this._drawCircle(cx, cy, radius * .04, context);
  2047. var dist = radius - wheelThickness * .5;
  2048. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2049. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2050. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2051. context.restore();
  2052. };
  2053. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2054. if (this._pointerStartedOnWheel) {
  2055. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2056. var centerX = radius + this._currentMeasure.left;
  2057. var centerY = radius + this._currentMeasure.top;
  2058. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2059. }
  2060. else if (this._pointerStartedOnSquare) {
  2061. this._updateSquareProps();
  2062. this._s = (x - this._squareLeft) / this._squareSize;
  2063. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2064. this._s = Math.min(this._s, 1);
  2065. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2066. this._v = Math.min(this._v, 1);
  2067. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2068. }
  2069. this._HSVtoRGB(this._h, this._s, this._v, this._tmpColor);
  2070. this.value = this._tmpColor;
  2071. };
  2072. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2073. this._updateSquareProps();
  2074. var left = this._squareLeft;
  2075. var top = this._squareTop;
  2076. var size = this._squareSize;
  2077. if (x >= left && x <= left + size &&
  2078. y >= top && y <= top + size) {
  2079. return true;
  2080. }
  2081. return false;
  2082. };
  2083. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2084. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2085. var centerX = radius + this._currentMeasure.left;
  2086. var centerY = radius + this._currentMeasure.top;
  2087. var wheelThickness = radius * .2;
  2088. var innerRadius = radius - wheelThickness;
  2089. var radiusSq = radius * radius;
  2090. var innerRadiusSq = innerRadius * innerRadius;
  2091. var dx = x - centerX;
  2092. var dy = y - centerY;
  2093. var distSq = dx * dx + dy * dy;
  2094. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2095. return true;
  2096. }
  2097. return false;
  2098. };
  2099. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2100. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2101. return false;
  2102. }
  2103. this._pointerIsDown = true;
  2104. this._pointerStartedOnSquare = false;
  2105. this._pointerStartedOnWheel = false;
  2106. // Invert transform
  2107. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2108. var x = this._transformedPosition.x;
  2109. var y = this._transformedPosition.y;
  2110. if (this._isPointOnSquare(x, y)) {
  2111. this._pointerStartedOnSquare = true;
  2112. }
  2113. else if (this._isPointOnWheel(x, y)) {
  2114. this._pointerStartedOnWheel = true;
  2115. }
  2116. this._updateValueFromPointer(x, y);
  2117. this._host._capturingControl[pointerId] = this;
  2118. this._lastPointerDownID = pointerId;
  2119. return true;
  2120. };
  2121. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2122. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2123. if (pointerId != this._lastPointerDownID) {
  2124. return;
  2125. }
  2126. // Invert transform
  2127. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2128. var x = this._transformedPosition.x;
  2129. var y = this._transformedPosition.y;
  2130. if (this._pointerIsDown) {
  2131. this._updateValueFromPointer(x, y);
  2132. }
  2133. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2134. };
  2135. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2136. this._pointerIsDown = false;
  2137. delete this._host._capturingControl[pointerId];
  2138. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2139. };
  2140. /**
  2141. * This function expands the color picker by creating a color picker dialog with manual
  2142. * color value input and the ability to save colors into an array to be used later in
  2143. * subsequent launches of the dialogue.
  2144. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2145. * @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.
  2146. * @returns picked color as a hex string and the saved colors array as hex strings.
  2147. */
  2148. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2149. return new Promise(function (resolve, reject) {
  2150. // Default options
  2151. options.pickerWidth = options.pickerWidth || "640px";
  2152. options.pickerHeight = options.pickerHeight || "400px";
  2153. options.headerHeight = options.headerHeight || "35px";
  2154. options.lastColor = options.lastColor || "#000000";
  2155. options.swatchLimit = options.swatchLimit || 20;
  2156. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2157. // Window size settings
  2158. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2159. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2160. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2161. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2162. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2163. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2164. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2165. // Button Colors
  2166. var buttonColor = "#c0c0c0";
  2167. var buttonBackgroundColor = "#535353";
  2168. var buttonBackgroundHoverColor = "#414141";
  2169. var buttonBackgroundClickColor = "515151";
  2170. var buttonDisabledColor = "#555555";
  2171. var buttonDisabledBackgroundColor = "#454545";
  2172. var currentSwatchesOutlineColor = "#404040";
  2173. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2174. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2175. var iconColorDark = "#aaaaaa";
  2176. var iconColorLight = "#ffffff";
  2177. var closeIconColor;
  2178. // Button settings
  2179. var buttonFontSize;
  2180. var butEdit;
  2181. var buttonWidth;
  2182. var buttonHeight;
  2183. // Input Text Colors
  2184. var inputFieldLabels = ["R", "G", "B"];
  2185. var inputTextBackgroundColor = "#454545";
  2186. var inputTextColor = "#f0f0f0";
  2187. // This is the current color as set by either the picker or by entering a value
  2188. var currentColor;
  2189. // This int is used for naming swatches and serves as the index for calling them from the list
  2190. var swatchNumber;
  2191. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2192. var swatchDrawer;
  2193. var editSwatchMode = false;
  2194. // Color InputText fields that will be updated upon value change
  2195. var picker;
  2196. var rValInt;
  2197. var gValInt;
  2198. var bValInt;
  2199. var rValDec;
  2200. var gValDec;
  2201. var bValDec;
  2202. var hexVal;
  2203. var newSwatch;
  2204. var lastVal;
  2205. var activeField;
  2206. /**
  2207. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2208. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2209. * are will receive no update. This is to prevent the input from the user being overwritten.
  2210. */
  2211. function updateValues(value, inputField) {
  2212. activeField = inputField;
  2213. var pickedColor = value.toHexString();
  2214. newSwatch.background = pickedColor;
  2215. if (rValInt.name != activeField) {
  2216. rValInt.text = Math.floor(value.r * 255).toString();
  2217. }
  2218. if (gValInt.name != activeField) {
  2219. gValInt.text = Math.floor(value.g * 255).toString();
  2220. }
  2221. if (bValInt.name != activeField) {
  2222. bValInt.text = Math.floor(value.b * 255).toString();
  2223. }
  2224. if (rValDec.name != activeField) {
  2225. rValDec.text = value.r.toString();
  2226. }
  2227. if (gValDec.name != activeField) {
  2228. gValDec.text = value.g.toString();
  2229. }
  2230. if (bValDec.name != activeField) {
  2231. bValDec.text = value.b.toString();
  2232. }
  2233. if (hexVal.name != activeField) {
  2234. var minusPound = pickedColor.split("#");
  2235. hexVal.text = minusPound[1];
  2236. }
  2237. if (picker.name != activeField) {
  2238. picker.value = value;
  2239. }
  2240. }
  2241. // 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.
  2242. function updateInt(field, channel) {
  2243. var newValue = field.text;
  2244. var checkVal = /[^0-9]/g.test(newValue);
  2245. if (checkVal) {
  2246. field.text = lastVal;
  2247. return;
  2248. }
  2249. else {
  2250. if (newValue != "") {
  2251. if (Math.floor(parseInt(newValue)) < 0) {
  2252. newValue = "0";
  2253. }
  2254. else if (Math.floor(parseInt(newValue)) > 255) {
  2255. newValue = "255";
  2256. }
  2257. else if (isNaN(parseInt(newValue))) {
  2258. newValue = "0";
  2259. }
  2260. }
  2261. if (activeField == field.name) {
  2262. lastVal = newValue;
  2263. }
  2264. }
  2265. if (newValue != "") {
  2266. newValue = parseInt(newValue).toString();
  2267. field.text = newValue;
  2268. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2269. if (activeField == field.name) {
  2270. if (channel == "r") {
  2271. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2272. }
  2273. else if (channel == "g") {
  2274. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2275. }
  2276. else {
  2277. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2278. }
  2279. }
  2280. }
  2281. }
  2282. // 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.
  2283. function updateFloat(field, channel) {
  2284. var newValue = field.text;
  2285. var checkVal = /[^0-9\.]/g.test(newValue);
  2286. if (checkVal) {
  2287. field.text = lastVal;
  2288. return;
  2289. }
  2290. else {
  2291. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2292. if (parseFloat(newValue) < 0.0) {
  2293. newValue = "0.0";
  2294. }
  2295. else if (parseFloat(newValue) > 1.0) {
  2296. newValue = "1.0";
  2297. }
  2298. else if (isNaN(parseFloat(newValue))) {
  2299. newValue = "0.0";
  2300. }
  2301. }
  2302. if (activeField == field.name) {
  2303. lastVal = newValue;
  2304. }
  2305. }
  2306. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2307. newValue = parseFloat(newValue).toString();
  2308. field.text = newValue;
  2309. }
  2310. else {
  2311. newValue = "0.0";
  2312. }
  2313. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2314. if (activeField == field.name) {
  2315. if (channel == "r") {
  2316. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2317. }
  2318. else if (channel == "g") {
  2319. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2320. }
  2321. else {
  2322. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2323. }
  2324. }
  2325. }
  2326. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2327. function deleteSwatch(index) {
  2328. if (options.savedColors) {
  2329. options.savedColors.splice(index, 1);
  2330. }
  2331. if (options.savedColors && options.savedColors.length == 0) {
  2332. setEditButtonVisibility(false);
  2333. editSwatchMode = false;
  2334. }
  2335. }
  2336. // Creates and styles an individual swatch when updateSwatches is called.
  2337. function createSwatch() {
  2338. if (options.savedColors && options.savedColors[swatchNumber]) {
  2339. if (editSwatchMode) {
  2340. var icon = "b";
  2341. }
  2342. else {
  2343. var icon = "";
  2344. }
  2345. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2346. swatch.fontFamily = "BabylonJSglyphs";
  2347. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2348. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2349. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2350. if (swatchLuminence > luminanceLimit) {
  2351. swatch.color = iconColorDark;
  2352. }
  2353. else {
  2354. swatch.color = iconColorLight;
  2355. }
  2356. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2357. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2358. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2359. swatch.background = options.savedColors[swatchNumber];
  2360. swatch.thickness = 2;
  2361. var metadata_1 = swatchNumber;
  2362. swatch.pointerDownAnimation = function () {
  2363. swatch.thickness = 4;
  2364. };
  2365. swatch.pointerUpAnimation = function () {
  2366. swatch.thickness = 3;
  2367. };
  2368. swatch.pointerEnterAnimation = function () {
  2369. swatch.thickness = 3;
  2370. };
  2371. swatch.pointerOutAnimation = function () {
  2372. swatch.thickness = 2;
  2373. };
  2374. swatch.onPointerClickObservable.add(function () {
  2375. if (!editSwatchMode) {
  2376. if (options.savedColors) {
  2377. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2378. }
  2379. }
  2380. else {
  2381. deleteSwatch(metadata_1);
  2382. updateSwatches("", butSave);
  2383. }
  2384. });
  2385. return swatch;
  2386. }
  2387. else {
  2388. return null;
  2389. }
  2390. }
  2391. // Mode switch to render button text and close symbols on swatch controls
  2392. function editSwatches(mode) {
  2393. if (mode !== undefined) {
  2394. editSwatchMode = mode;
  2395. }
  2396. if (editSwatchMode) {
  2397. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2398. var thisButton = swatchDrawer.children[i];
  2399. thisButton.textBlock.text = "b";
  2400. }
  2401. if (butEdit !== undefined) {
  2402. butEdit.textBlock.text = "Done";
  2403. }
  2404. }
  2405. else {
  2406. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2407. var thisButton = swatchDrawer.children[i];
  2408. thisButton.textBlock.text = "";
  2409. }
  2410. if (butEdit !== undefined) {
  2411. butEdit.textBlock.text = "Edit";
  2412. }
  2413. }
  2414. }
  2415. /**
  2416. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2417. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2418. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2419. * saved colors there are and how many can be stored per row.
  2420. */
  2421. function updateSwatches(color, button) {
  2422. if (options.savedColors) {
  2423. if (color != "") {
  2424. options.savedColors.push(color);
  2425. }
  2426. swatchNumber = 0;
  2427. swatchDrawer.clearControls();
  2428. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2429. if (rowCount == 0) {
  2430. var gutterCount = 0;
  2431. }
  2432. else {
  2433. var gutterCount = rowCount + 1;
  2434. }
  2435. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2436. var currentRows = swatchDrawer.rowCount;
  2437. for (var i = 0; i < currentRows; i++) {
  2438. swatchDrawer.removeRowDefinition(0);
  2439. }
  2440. for (var i = 0; i < rowCount + gutterCount; i++) {
  2441. if (i % 2) {
  2442. swatchDrawer.addRowDefinition(swatchSize, true);
  2443. }
  2444. else {
  2445. swatchDrawer.addRowDefinition(gutterSize, true);
  2446. }
  2447. }
  2448. }
  2449. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2450. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2451. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2452. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2453. var totalButtonsThisRow = options.numSwatchesPerLine;
  2454. }
  2455. else {
  2456. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2457. }
  2458. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2459. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2460. if (x > options.numSwatchesPerLine) {
  2461. continue;
  2462. }
  2463. var swatch = createSwatch();
  2464. if (swatch != null) {
  2465. swatchDrawer.addControl(swatch, y, w);
  2466. w += 2;
  2467. swatchNumber++;
  2468. }
  2469. else {
  2470. continue;
  2471. }
  2472. }
  2473. }
  2474. if (options.savedColors.length >= options.swatchLimit) {
  2475. disableButton(button, true);
  2476. }
  2477. else {
  2478. disableButton(button, false);
  2479. }
  2480. }
  2481. }
  2482. // Shows or hides edit swatches button depending on if there are saved swatches
  2483. function setEditButtonVisibility(enableButton) {
  2484. if (enableButton) {
  2485. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2486. butEdit.width = buttonWidth;
  2487. butEdit.height = buttonHeight;
  2488. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2489. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2490. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2491. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2492. butEdit.thickness = 2;
  2493. butEdit.color = buttonColor;
  2494. butEdit.fontSize = buttonFontSize;
  2495. butEdit.background = buttonBackgroundColor;
  2496. butEdit.onPointerEnterObservable.add(function () {
  2497. butEdit.background = buttonBackgroundHoverColor;
  2498. });
  2499. butEdit.onPointerOutObservable.add(function () {
  2500. butEdit.background = buttonBackgroundColor;
  2501. });
  2502. butEdit.pointerDownAnimation = function () {
  2503. butEdit.background = buttonBackgroundClickColor;
  2504. };
  2505. butEdit.pointerUpAnimation = function () {
  2506. butEdit.background = buttonBackgroundHoverColor;
  2507. };
  2508. butEdit.onPointerClickObservable.add(function () {
  2509. if (editSwatchMode) {
  2510. editSwatchMode = false;
  2511. }
  2512. else {
  2513. editSwatchMode = true;
  2514. }
  2515. editSwatches();
  2516. });
  2517. pickerGrid.addControl(butEdit, 1, 0);
  2518. }
  2519. else {
  2520. pickerGrid.removeControl(butEdit);
  2521. }
  2522. }
  2523. // Called when the user hits the limit of saved colors in the drawer.
  2524. function disableButton(button, disabled) {
  2525. if (disabled) {
  2526. button.color = buttonDisabledColor;
  2527. button.background = buttonDisabledBackgroundColor;
  2528. }
  2529. else {
  2530. button.color = buttonColor;
  2531. button.background = buttonBackgroundColor;
  2532. }
  2533. }
  2534. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2535. function closePicker(color) {
  2536. if (options.savedColors && options.savedColors.length > 0) {
  2537. resolve({
  2538. savedColors: options.savedColors,
  2539. pickedColor: color
  2540. });
  2541. }
  2542. else {
  2543. resolve({
  2544. pickedColor: color
  2545. });
  2546. }
  2547. advancedTexture.removeControl(dialogContainer);
  2548. }
  2549. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2550. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2551. dialogContainer.name = "Dialog Container";
  2552. dialogContainer.width = options.pickerWidth;
  2553. if (options.savedColors) {
  2554. dialogContainer.height = containerSize;
  2555. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2556. dialogContainer.addRowDefinition(topRow, false);
  2557. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2558. }
  2559. else {
  2560. dialogContainer.height = options.pickerHeight;
  2561. dialogContainer.addRowDefinition(1.0, false);
  2562. }
  2563. advancedTexture.addControl(dialogContainer);
  2564. // Swatch drawer which contains all saved color buttons
  2565. if (options.savedColors) {
  2566. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2567. swatchDrawer.name = "Swatch Drawer";
  2568. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2569. swatchDrawer.background = buttonBackgroundColor;
  2570. swatchDrawer.width = options.pickerWidth;
  2571. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2572. if (initialRows == 0) {
  2573. var gutterCount = 0;
  2574. }
  2575. else {
  2576. var gutterCount = initialRows + 1;
  2577. }
  2578. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2579. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2580. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2581. if (i % 2 != 0) {
  2582. swatchDrawer.addRowDefinition(swatchSize, true);
  2583. }
  2584. else {
  2585. swatchDrawer.addRowDefinition(gutterSize, true);
  2586. }
  2587. }
  2588. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2589. if (i % 2 != 0) {
  2590. swatchDrawer.addColumnDefinition(swatchSize, true);
  2591. }
  2592. else {
  2593. swatchDrawer.addColumnDefinition(gutterSize, true);
  2594. }
  2595. }
  2596. dialogContainer.addControl(swatchDrawer, 1, 0);
  2597. }
  2598. // Picker container
  2599. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2600. pickerPanel.name = "Picker Panel";
  2601. pickerPanel.height = options.pickerHeight;
  2602. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2603. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2604. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2605. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2606. dialogContainer.addControl(pickerPanel, 0, 0);
  2607. // Picker container header
  2608. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2609. header.name = "Dialogue Header Bar";
  2610. header.background = "#cccccc";
  2611. header.thickness = 0;
  2612. pickerPanel.addControl(header, 0, 0);
  2613. // Header close button
  2614. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2615. closeButton.fontFamily = "BabylonJSglyphs";
  2616. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2617. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2618. closeButton.color = closeIconColor.toHexString();
  2619. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2620. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2621. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2622. closeButton.height = closeButton.width = options.headerHeight;
  2623. closeButton.background = header.background;
  2624. closeButton.thickness = 0;
  2625. closeButton.pointerDownAnimation = function () {
  2626. };
  2627. closeButton.pointerUpAnimation = function () {
  2628. closeButton.background = header.background;
  2629. };
  2630. closeButton.pointerEnterAnimation = function () {
  2631. closeButton.color = header.background;
  2632. closeButton.background = "red";
  2633. };
  2634. closeButton.pointerOutAnimation = function () {
  2635. closeButton.color = closeIconColor.toHexString();
  2636. closeButton.background = header.background;
  2637. };
  2638. closeButton.onPointerClickObservable.add(function () {
  2639. closePicker(currentSwatch.background);
  2640. });
  2641. pickerPanel.addControl(closeButton, 0, 0);
  2642. // Dialog container body
  2643. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2644. dialogBody.name = "Dialogue Body";
  2645. dialogBody.background = buttonBackgroundColor;
  2646. var dialogBodyCols = [0.4375, 0.5625];
  2647. dialogBody.addRowDefinition(1.0, false);
  2648. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2649. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2650. pickerPanel.addControl(dialogBody, 1, 0);
  2651. // Picker grid
  2652. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2653. pickerGrid.name = "Picker Grid";
  2654. pickerGrid.addRowDefinition(0.85, false);
  2655. pickerGrid.addRowDefinition(0.15, false);
  2656. dialogBody.addControl(pickerGrid, 0, 0);
  2657. // Picker control
  2658. picker = new ColorPicker();
  2659. picker.name = "GUI Color Picker";
  2660. if (options.pickerHeight < options.pickerWidth) {
  2661. picker.width = 0.89;
  2662. }
  2663. else {
  2664. picker.height = 0.89;
  2665. }
  2666. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2667. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2668. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2669. picker.onPointerDownObservable.add(function () {
  2670. activeField = picker.name;
  2671. lastVal = "";
  2672. editSwatches(false);
  2673. });
  2674. picker.onValueChangedObservable.add(function (value) {
  2675. if (activeField == picker.name) {
  2676. updateValues(value, picker.name);
  2677. }
  2678. });
  2679. pickerGrid.addControl(picker, 0, 0);
  2680. // Picker body right quarant
  2681. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2682. pickerBodyRight.name = "Dialogue Right Half";
  2683. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2684. var pickerBodyRightRows = [0.514, 0.486];
  2685. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2686. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2687. dialogBody.addControl(pickerBodyRight, 1, 1);
  2688. // Picker container swatches and buttons
  2689. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2690. pickerSwatchesButtons.name = "Swatches and Buttons";
  2691. var pickerButtonsCol = [0.417, 0.583];
  2692. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2693. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2694. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2695. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2696. // Picker Swatches quadrant
  2697. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2698. pickerSwatches.name = "New and Current Swatches";
  2699. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2700. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2701. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2702. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2703. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2704. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2705. // Active swatches
  2706. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2707. activeSwatches.name = "Active Swatches";
  2708. activeSwatches.width = 0.67;
  2709. activeSwatches.addRowDefinition(0.5, false);
  2710. activeSwatches.addRowDefinition(0.5, false);
  2711. pickerSwatches.addControl(activeSwatches, 2, 0);
  2712. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2713. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2714. if (options.pickerWidth > options.pickerHeight) {
  2715. var labelTextSize = labelHeight;
  2716. }
  2717. else {
  2718. var labelTextSize = labelWidth;
  2719. }
  2720. // New color swatch and previous color button
  2721. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2722. newText.text = "new";
  2723. newText.name = "New Color Label";
  2724. newText.color = buttonColor;
  2725. newText.fontSize = labelTextSize;
  2726. pickerSwatches.addControl(newText, 1, 0);
  2727. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2728. newSwatch.name = "New Color Swatch";
  2729. newSwatch.background = options.lastColor;
  2730. newSwatch.thickness = 0;
  2731. activeSwatches.addControl(newSwatch, 0, 0);
  2732. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2733. currentSwatch.background = options.lastColor;
  2734. currentSwatch.thickness = 0;
  2735. currentSwatch.onPointerClickObservable.add(function () {
  2736. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2737. updateValues(revertColor, currentSwatch.name);
  2738. editSwatches(false);
  2739. });
  2740. currentSwatch.pointerDownAnimation = function () { };
  2741. currentSwatch.pointerUpAnimation = function () { };
  2742. currentSwatch.pointerEnterAnimation = function () { };
  2743. currentSwatch.pointerOutAnimation = function () { };
  2744. activeSwatches.addControl(currentSwatch, 1, 0);
  2745. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2746. swatchOutline.name = "Swatch Outline";
  2747. swatchOutline.width = 0.67;
  2748. swatchOutline.thickness = 2;
  2749. swatchOutline.color = currentSwatchesOutlineColor;
  2750. swatchOutline.isHitTestVisible = false;
  2751. pickerSwatches.addControl(swatchOutline, 2, 0);
  2752. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2753. currentText.name = "Current Color Label";
  2754. currentText.text = "current";
  2755. currentText.color = buttonColor;
  2756. currentText.fontSize = labelTextSize;
  2757. pickerSwatches.addControl(currentText, 3, 0);
  2758. // Buttons grid
  2759. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2760. buttonGrid.name = "Button Grid";
  2761. buttonGrid.height = 0.8;
  2762. var buttonGridRows = 1 / 3;
  2763. buttonGrid.addRowDefinition(buttonGridRows, false);
  2764. buttonGrid.addRowDefinition(buttonGridRows, false);
  2765. buttonGrid.addRowDefinition(buttonGridRows, false);
  2766. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2767. // Determine pixel width and height for all buttons from overall panel dimensions
  2768. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2769. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2770. // Determine button type size
  2771. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2772. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2773. }
  2774. else {
  2775. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2776. }
  2777. // Panel Buttons
  2778. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2779. butOK.width = buttonWidth;
  2780. butOK.height = buttonHeight;
  2781. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2782. butOK.thickness = 2;
  2783. butOK.color = buttonColor;
  2784. butOK.fontSize = buttonFontSize;
  2785. butOK.background = buttonBackgroundColor;
  2786. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2787. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2788. butOK.pointerDownAnimation = function () {
  2789. butOK.background = buttonBackgroundClickColor;
  2790. };
  2791. butOK.pointerUpAnimation = function () {
  2792. butOK.background = buttonBackgroundHoverColor;
  2793. };
  2794. butOK.onPointerClickObservable.add(function () {
  2795. editSwatches(false);
  2796. closePicker(newSwatch.background);
  2797. });
  2798. buttonGrid.addControl(butOK, 0, 0);
  2799. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2800. butCancel.width = buttonWidth;
  2801. butCancel.height = buttonHeight;
  2802. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2803. butCancel.thickness = 2;
  2804. butCancel.color = buttonColor;
  2805. butCancel.fontSize = buttonFontSize;
  2806. butCancel.background = buttonBackgroundColor;
  2807. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2808. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2809. butCancel.pointerDownAnimation = function () {
  2810. butCancel.background = buttonBackgroundClickColor;
  2811. };
  2812. butCancel.pointerUpAnimation = function () {
  2813. butCancel.background = buttonBackgroundHoverColor;
  2814. };
  2815. butCancel.onPointerClickObservable.add(function () {
  2816. editSwatches(false);
  2817. closePicker(currentSwatch.background);
  2818. });
  2819. buttonGrid.addControl(butCancel, 1, 0);
  2820. if (options.savedColors) {
  2821. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2822. butSave.width = buttonWidth;
  2823. butSave.height = buttonHeight;
  2824. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2825. butSave.thickness = 2;
  2826. butSave.fontSize = buttonFontSize;
  2827. if (options.savedColors.length < options.swatchLimit) {
  2828. butSave.color = buttonColor;
  2829. butSave.background = buttonBackgroundColor;
  2830. }
  2831. else {
  2832. disableButton(butSave, true);
  2833. }
  2834. butSave.onPointerEnterObservable.add(function () {
  2835. if (options.savedColors) {
  2836. if (options.savedColors.length < options.swatchLimit) {
  2837. butSave.background = buttonBackgroundHoverColor;
  2838. }
  2839. }
  2840. });
  2841. butSave.onPointerOutObservable.add(function () {
  2842. if (options.savedColors) {
  2843. if (options.savedColors.length < options.swatchLimit) {
  2844. butSave.background = buttonBackgroundColor;
  2845. }
  2846. }
  2847. });
  2848. butSave.pointerDownAnimation = function () {
  2849. if (options.savedColors) {
  2850. if (options.savedColors.length < options.swatchLimit) {
  2851. butSave.background = buttonBackgroundClickColor;
  2852. }
  2853. }
  2854. };
  2855. butSave.pointerUpAnimation = function () {
  2856. if (options.savedColors) {
  2857. if (options.savedColors.length < options.swatchLimit) {
  2858. butSave.background = buttonBackgroundHoverColor;
  2859. }
  2860. }
  2861. };
  2862. butSave.onPointerClickObservable.add(function () {
  2863. if (options.savedColors) {
  2864. if (options.savedColors.length == 0) {
  2865. setEditButtonVisibility(true);
  2866. }
  2867. if (options.savedColors.length < options.swatchLimit) {
  2868. updateSwatches(newSwatch.background, butSave);
  2869. }
  2870. editSwatches(false);
  2871. }
  2872. });
  2873. if (options.savedColors.length > 0) {
  2874. setEditButtonVisibility(true);
  2875. }
  2876. buttonGrid.addControl(butSave, 2, 0);
  2877. }
  2878. // Picker color values input
  2879. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2880. pickerColorValues.name = "Dialog Lower Right";
  2881. pickerColorValues.addRowDefinition(0.02, false);
  2882. pickerColorValues.addRowDefinition(0.63, false);
  2883. pickerColorValues.addRowDefinition(0.21, false);
  2884. pickerColorValues.addRowDefinition(0.14, false);
  2885. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2886. // RGB values text boxes
  2887. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2888. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2889. rgbValuesQuadrant.name = "RGB Values";
  2890. rgbValuesQuadrant.width = 0.82;
  2891. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2892. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2893. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2894. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2895. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2896. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2897. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2898. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2899. for (var i = 0; i < inputFieldLabels.length; i++) {
  2900. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2901. labelText.text = inputFieldLabels[i];
  2902. labelText.color = buttonColor;
  2903. labelText.fontSize = buttonFontSize;
  2904. rgbValuesQuadrant.addControl(labelText, i, 0);
  2905. }
  2906. // Input fields for RGB values
  2907. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2908. rValInt.width = 0.83;
  2909. rValInt.height = 0.72;
  2910. rValInt.name = "rIntField";
  2911. rValInt.fontSize = buttonFontSize;
  2912. rValInt.text = (currentColor.r * 255).toString();
  2913. rValInt.color = inputTextColor;
  2914. rValInt.background = inputTextBackgroundColor;
  2915. rValInt.onFocusObservable.add(function () {
  2916. activeField = rValInt.name;
  2917. lastVal = rValInt.text;
  2918. editSwatches(false);
  2919. });
  2920. rValInt.onBlurObservable.add(function () {
  2921. if (rValInt.text == "") {
  2922. rValInt.text = "0";
  2923. }
  2924. updateInt(rValInt, "r");
  2925. if (activeField == rValInt.name) {
  2926. activeField = "";
  2927. }
  2928. });
  2929. rValInt.onTextChangedObservable.add(function () {
  2930. if (activeField == rValInt.name) {
  2931. updateInt(rValInt, "r");
  2932. }
  2933. });
  2934. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2935. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2936. gValInt.width = 0.83;
  2937. gValInt.height = 0.72;
  2938. gValInt.name = "gIntField";
  2939. gValInt.fontSize = buttonFontSize;
  2940. gValInt.text = (currentColor.g * 255).toString();
  2941. gValInt.color = inputTextColor;
  2942. gValInt.background = inputTextBackgroundColor;
  2943. gValInt.onFocusObservable.add(function () {
  2944. activeField = gValInt.name;
  2945. lastVal = gValInt.text;
  2946. editSwatches(false);
  2947. });
  2948. gValInt.onBlurObservable.add(function () {
  2949. if (gValInt.text == "") {
  2950. gValInt.text = "0";
  2951. }
  2952. updateInt(gValInt, "g");
  2953. if (activeField == gValInt.name) {
  2954. activeField = "";
  2955. }
  2956. });
  2957. gValInt.onTextChangedObservable.add(function () {
  2958. if (activeField == gValInt.name) {
  2959. updateInt(gValInt, "g");
  2960. }
  2961. });
  2962. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2963. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2964. bValInt.width = 0.83;
  2965. bValInt.height = 0.72;
  2966. bValInt.name = "bIntField";
  2967. bValInt.fontSize = buttonFontSize;
  2968. bValInt.text = (currentColor.b * 255).toString();
  2969. bValInt.color = inputTextColor;
  2970. bValInt.background = inputTextBackgroundColor;
  2971. bValInt.onFocusObservable.add(function () {
  2972. activeField = bValInt.name;
  2973. lastVal = bValInt.text;
  2974. editSwatches(false);
  2975. });
  2976. bValInt.onBlurObservable.add(function () {
  2977. if (bValInt.text == "") {
  2978. bValInt.text = "0";
  2979. }
  2980. updateInt(bValInt, "b");
  2981. if (activeField == bValInt.name) {
  2982. activeField = "";
  2983. }
  2984. });
  2985. bValInt.onTextChangedObservable.add(function () {
  2986. if (activeField == bValInt.name) {
  2987. updateInt(bValInt, "b");
  2988. }
  2989. });
  2990. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2991. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2992. rValDec.width = 0.95;
  2993. rValDec.height = 0.72;
  2994. rValDec.name = "rDecField";
  2995. rValDec.fontSize = buttonFontSize;
  2996. rValDec.text = currentColor.r.toString();
  2997. rValDec.color = inputTextColor;
  2998. rValDec.background = inputTextBackgroundColor;
  2999. rValDec.onFocusObservable.add(function () {
  3000. activeField = rValDec.name;
  3001. lastVal = rValDec.text;
  3002. editSwatches(false);
  3003. });
  3004. rValDec.onBlurObservable.add(function () {
  3005. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3006. rValDec.text = "0";
  3007. updateFloat(rValDec, "r");
  3008. }
  3009. if (activeField == rValDec.name) {
  3010. activeField = "";
  3011. }
  3012. });
  3013. rValDec.onTextChangedObservable.add(function () {
  3014. if (activeField == rValDec.name) {
  3015. updateFloat(rValDec, "r");
  3016. }
  3017. });
  3018. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3019. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3020. gValDec.width = 0.95;
  3021. gValDec.height = 0.72;
  3022. gValDec.name = "gDecField";
  3023. gValDec.fontSize = buttonFontSize;
  3024. gValDec.text = currentColor.g.toString();
  3025. gValDec.color = inputTextColor;
  3026. gValDec.background = inputTextBackgroundColor;
  3027. gValDec.onFocusObservable.add(function () {
  3028. activeField = gValDec.name;
  3029. lastVal = gValDec.text;
  3030. editSwatches(false);
  3031. });
  3032. gValDec.onBlurObservable.add(function () {
  3033. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3034. gValDec.text = "0";
  3035. updateFloat(gValDec, "g");
  3036. }
  3037. if (activeField == gValDec.name) {
  3038. activeField = "";
  3039. }
  3040. });
  3041. gValDec.onTextChangedObservable.add(function () {
  3042. if (activeField == gValDec.name) {
  3043. updateFloat(gValDec, "g");
  3044. }
  3045. });
  3046. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3047. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3048. bValDec.width = 0.95;
  3049. bValDec.height = 0.72;
  3050. bValDec.name = "bDecField";
  3051. bValDec.fontSize = buttonFontSize;
  3052. bValDec.text = currentColor.b.toString();
  3053. bValDec.color = inputTextColor;
  3054. bValDec.background = inputTextBackgroundColor;
  3055. bValDec.onFocusObservable.add(function () {
  3056. activeField = bValDec.name;
  3057. lastVal = bValDec.text;
  3058. editSwatches(false);
  3059. });
  3060. bValDec.onBlurObservable.add(function () {
  3061. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3062. bValDec.text = "0";
  3063. updateFloat(bValDec, "b");
  3064. }
  3065. if (activeField == bValDec.name) {
  3066. activeField = "";
  3067. }
  3068. });
  3069. bValDec.onTextChangedObservable.add(function () {
  3070. if (activeField == bValDec.name) {
  3071. updateFloat(bValDec, "b");
  3072. }
  3073. });
  3074. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3075. // Hex value input
  3076. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3077. hexValueQuadrant.name = "Hex Value";
  3078. hexValueQuadrant.width = 0.82;
  3079. hexValueQuadrant.addRowDefinition(1.0, false);
  3080. hexValueQuadrant.addColumnDefinition(0.1, false);
  3081. hexValueQuadrant.addColumnDefinition(0.9, false);
  3082. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3083. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3084. labelText.text = "#";
  3085. labelText.color = buttonColor;
  3086. labelText.fontSize = buttonFontSize;
  3087. hexValueQuadrant.addControl(labelText, 0, 0);
  3088. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3089. hexVal.width = 0.96;
  3090. hexVal.height = 0.72;
  3091. hexVal.name = "hexField";
  3092. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3093. hexVal.fontSize = buttonFontSize;
  3094. var minusPound = options.lastColor.split("#");
  3095. hexVal.text = minusPound[1];
  3096. hexVal.color = inputTextColor;
  3097. hexVal.background = inputTextBackgroundColor;
  3098. hexVal.onFocusObservable.add(function () {
  3099. activeField = hexVal.name;
  3100. lastVal = hexVal.text;
  3101. editSwatches(false);
  3102. });
  3103. hexVal.onBlurObservable.add(function () {
  3104. if (hexVal.text.length == 3) {
  3105. var val = hexVal.text.split("");
  3106. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3107. }
  3108. if (hexVal.text == "") {
  3109. hexVal.text = "000000";
  3110. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3111. }
  3112. if (activeField == hexVal.name) {
  3113. activeField = "";
  3114. }
  3115. });
  3116. hexVal.onTextChangedObservable.add(function () {
  3117. var newHexValue = hexVal.text;
  3118. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3119. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3120. hexVal.text = lastVal;
  3121. }
  3122. else {
  3123. if (hexVal.text.length < 6) {
  3124. var leadingZero = 6 - hexVal.text.length;
  3125. for (var i = 0; i < leadingZero; i++) {
  3126. newHexValue = "0" + newHexValue;
  3127. }
  3128. }
  3129. if (hexVal.text.length == 3) {
  3130. var val = hexVal.text.split("");
  3131. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3132. }
  3133. newHexValue = "#" + newHexValue;
  3134. if (activeField == hexVal.name) {
  3135. lastVal = hexVal.text;
  3136. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3137. }
  3138. }
  3139. });
  3140. hexValueQuadrant.addControl(hexVal, 0, 1);
  3141. if (options.savedColors && options.savedColors.length > 0) {
  3142. updateSwatches("", butSave);
  3143. }
  3144. });
  3145. };
  3146. ColorPicker._Epsilon = 0.000001;
  3147. return ColorPicker;
  3148. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3149. /***/ }),
  3150. /***/ "./2D/controls/container.ts":
  3151. /*!**********************************!*\
  3152. !*** ./2D/controls/container.ts ***!
  3153. \**********************************/
  3154. /*! exports provided: Container */
  3155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3156. "use strict";
  3157. __webpack_require__.r(__webpack_exports__);
  3158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3159. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3160. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/tools");
  3161. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3162. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3163. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3164. /**
  3165. * Root class for 2D containers
  3166. * @see http://doc.babylonjs.com/how_to/gui#containers
  3167. */
  3168. var Container = /** @class */ (function (_super) {
  3169. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3170. /**
  3171. * Creates a new Container
  3172. * @param name defines the name of the container
  3173. */
  3174. function Container(name) {
  3175. var _this = _super.call(this, name) || this;
  3176. _this.name = name;
  3177. /** @hidden */
  3178. _this._children = new Array();
  3179. /** @hidden */
  3180. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3181. /** @hidden */
  3182. _this._background = "";
  3183. /** @hidden */
  3184. _this._adaptWidthToChildren = false;
  3185. /** @hidden */
  3186. _this._adaptHeightToChildren = false;
  3187. return _this;
  3188. }
  3189. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3190. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3191. get: function () {
  3192. return this._adaptHeightToChildren;
  3193. },
  3194. set: function (value) {
  3195. if (this._adaptHeightToChildren === value) {
  3196. return;
  3197. }
  3198. this._adaptHeightToChildren = value;
  3199. if (value) {
  3200. this.height = "100%";
  3201. }
  3202. this._markAsDirty();
  3203. },
  3204. enumerable: true,
  3205. configurable: true
  3206. });
  3207. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3208. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3209. get: function () {
  3210. return this._adaptWidthToChildren;
  3211. },
  3212. set: function (value) {
  3213. if (this._adaptWidthToChildren === value) {
  3214. return;
  3215. }
  3216. this._adaptWidthToChildren = value;
  3217. if (value) {
  3218. this.width = "100%";
  3219. }
  3220. this._markAsDirty();
  3221. },
  3222. enumerable: true,
  3223. configurable: true
  3224. });
  3225. Object.defineProperty(Container.prototype, "background", {
  3226. /** Gets or sets background color */
  3227. get: function () {
  3228. return this._background;
  3229. },
  3230. set: function (value) {
  3231. if (this._background === value) {
  3232. return;
  3233. }
  3234. this._background = value;
  3235. this._markAsDirty();
  3236. },
  3237. enumerable: true,
  3238. configurable: true
  3239. });
  3240. Object.defineProperty(Container.prototype, "children", {
  3241. /** Gets the list of children */
  3242. get: function () {
  3243. return this._children;
  3244. },
  3245. enumerable: true,
  3246. configurable: true
  3247. });
  3248. Container.prototype._getTypeName = function () {
  3249. return "Container";
  3250. };
  3251. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3252. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3253. var child = _a[_i];
  3254. child._markMatrixAsDirty();
  3255. }
  3256. };
  3257. /**
  3258. * Gets a child using its name
  3259. * @param name defines the child name to look for
  3260. * @returns the child control if found
  3261. */
  3262. Container.prototype.getChildByName = function (name) {
  3263. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3264. var child = _a[_i];
  3265. if (child.name === name) {
  3266. return child;
  3267. }
  3268. }
  3269. return null;
  3270. };
  3271. /**
  3272. * Gets a child using its type and its name
  3273. * @param name defines the child name to look for
  3274. * @param type defines the child type to look for
  3275. * @returns the child control if found
  3276. */
  3277. Container.prototype.getChildByType = function (name, type) {
  3278. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3279. var child = _a[_i];
  3280. if (child.typeName === type) {
  3281. return child;
  3282. }
  3283. }
  3284. return null;
  3285. };
  3286. /**
  3287. * Search for a specific control in children
  3288. * @param control defines the control to look for
  3289. * @returns true if the control is in child list
  3290. */
  3291. Container.prototype.containsControl = function (control) {
  3292. return this.children.indexOf(control) !== -1;
  3293. };
  3294. /**
  3295. * Adds a new control to the current container
  3296. * @param control defines the control to add
  3297. * @returns the current container
  3298. */
  3299. Container.prototype.addControl = function (control) {
  3300. if (!control) {
  3301. return this;
  3302. }
  3303. var index = this._children.indexOf(control);
  3304. if (index !== -1) {
  3305. return this;
  3306. }
  3307. control._link(this._host);
  3308. control._markAllAsDirty();
  3309. this._reOrderControl(control);
  3310. this._markAsDirty();
  3311. return this;
  3312. };
  3313. /**
  3314. * Removes all controls from the current container
  3315. * @returns the current container
  3316. */
  3317. Container.prototype.clearControls = function () {
  3318. var children = this.children.slice();
  3319. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3320. var child = children_1[_i];
  3321. this.removeControl(child);
  3322. }
  3323. return this;
  3324. };
  3325. /**
  3326. * Removes a control from the current container
  3327. * @param control defines the control to remove
  3328. * @returns the current container
  3329. */
  3330. Container.prototype.removeControl = function (control) {
  3331. var index = this._children.indexOf(control);
  3332. if (index !== -1) {
  3333. this._children.splice(index, 1);
  3334. control.parent = null;
  3335. }
  3336. control.linkWithMesh(null);
  3337. if (this._host) {
  3338. this._host._cleanControlAfterRemoval(control);
  3339. }
  3340. this._markAsDirty();
  3341. return this;
  3342. };
  3343. /** @hidden */
  3344. Container.prototype._reOrderControl = function (control) {
  3345. this.removeControl(control);
  3346. var wasAdded = false;
  3347. for (var index = 0; index < this._children.length; index++) {
  3348. if (this._children[index].zIndex > control.zIndex) {
  3349. this._children.splice(index, 0, control);
  3350. wasAdded = true;
  3351. break;
  3352. }
  3353. }
  3354. if (!wasAdded) {
  3355. this._children.push(control);
  3356. }
  3357. control.parent = this;
  3358. this._markAsDirty();
  3359. };
  3360. /** @hidden */
  3361. Container.prototype._offsetLeft = function (offset) {
  3362. _super.prototype._offsetLeft.call(this, offset);
  3363. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3364. var child = _a[_i];
  3365. child._offsetLeft(offset);
  3366. }
  3367. };
  3368. /** @hidden */
  3369. Container.prototype._offsetTop = function (offset) {
  3370. _super.prototype._offsetTop.call(this, offset);
  3371. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3372. var child = _a[_i];
  3373. child._offsetTop(offset);
  3374. }
  3375. };
  3376. /** @hidden */
  3377. Container.prototype._markAllAsDirty = function () {
  3378. _super.prototype._markAllAsDirty.call(this);
  3379. for (var index = 0; index < this._children.length; index++) {
  3380. this._children[index]._markAllAsDirty();
  3381. }
  3382. };
  3383. /** @hidden */
  3384. Container.prototype._localDraw = function (context) {
  3385. if (this._background) {
  3386. context.save();
  3387. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3388. context.shadowColor = this.shadowColor;
  3389. context.shadowBlur = this.shadowBlur;
  3390. context.shadowOffsetX = this.shadowOffsetX;
  3391. context.shadowOffsetY = this.shadowOffsetY;
  3392. }
  3393. context.fillStyle = this._background;
  3394. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3395. context.restore();
  3396. }
  3397. };
  3398. /** @hidden */
  3399. Container.prototype._link = function (host) {
  3400. _super.prototype._link.call(this, host);
  3401. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3402. var child = _a[_i];
  3403. child._link(host);
  3404. }
  3405. };
  3406. /** @hidden */
  3407. Container.prototype._beforeLayout = function () {
  3408. // Do nothing
  3409. };
  3410. /** @hidden */
  3411. Container.prototype._processMeasures = function (parentMeasure, context) {
  3412. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3413. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3414. this._evaluateClippingState(parentMeasure);
  3415. }
  3416. };
  3417. /** @hidden */
  3418. Container.prototype._layout = function (parentMeasure, context) {
  3419. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3420. return false;
  3421. }
  3422. if (this._isDirty) {
  3423. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3424. }
  3425. var rebuildCount = 0;
  3426. context.save();
  3427. this._applyStates(context);
  3428. this._beforeLayout();
  3429. do {
  3430. var computedWidth = -1;
  3431. var computedHeight = -1;
  3432. this._rebuildLayout = false;
  3433. this._processMeasures(parentMeasure, context);
  3434. if (!this._isClipped) {
  3435. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3436. var child = _a[_i];
  3437. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3438. if (child._layout(this._measureForChildren, context)) {
  3439. if (this.adaptWidthToChildren && child._width.isPixel) {
  3440. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3441. }
  3442. if (this.adaptHeightToChildren && child._height.isPixel) {
  3443. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3444. }
  3445. }
  3446. }
  3447. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3448. if (this.width !== computedWidth + "px") {
  3449. this.width = computedWidth + "px";
  3450. this._rebuildLayout = true;
  3451. }
  3452. }
  3453. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3454. if (this.height !== computedHeight + "px") {
  3455. this.height = computedHeight + "px";
  3456. this._rebuildLayout = true;
  3457. }
  3458. }
  3459. this._postMeasure();
  3460. }
  3461. rebuildCount++;
  3462. } while (this._rebuildLayout && rebuildCount < 3);
  3463. if (rebuildCount >= 3) {
  3464. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3465. }
  3466. context.restore();
  3467. if (this._isDirty) {
  3468. this.invalidateRect();
  3469. this._isDirty = false;
  3470. }
  3471. return true;
  3472. };
  3473. Container.prototype._postMeasure = function () {
  3474. // Do nothing by default
  3475. };
  3476. /** @hidden */
  3477. Container.prototype._draw = function (context, invalidatedRectangle) {
  3478. this._localDraw(context);
  3479. if (this.clipChildren) {
  3480. this._clipForChildren(context);
  3481. }
  3482. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3483. var child = _a[_i];
  3484. // Only redraw parts of the screen that are invalidated
  3485. if (invalidatedRectangle) {
  3486. if (!child._intersectsRect(invalidatedRectangle)) {
  3487. continue;
  3488. }
  3489. }
  3490. child._render(context, invalidatedRectangle);
  3491. }
  3492. };
  3493. /** @hidden */
  3494. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3495. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3496. if (!this.children) {
  3497. return;
  3498. }
  3499. for (var index = 0; index < this.children.length; index++) {
  3500. var item = this.children[index];
  3501. if (!predicate || predicate(item)) {
  3502. results.push(item);
  3503. }
  3504. if (!directDescendantsOnly) {
  3505. item._getDescendants(results, false, predicate);
  3506. }
  3507. }
  3508. };
  3509. /** @hidden */
  3510. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3511. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3512. return false;
  3513. }
  3514. if (!_super.prototype.contains.call(this, x, y)) {
  3515. return false;
  3516. }
  3517. // Checking backwards to pick closest first
  3518. for (var index = this._children.length - 1; index >= 0; index--) {
  3519. var child = this._children[index];
  3520. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3521. if (child.hoverCursor) {
  3522. this._host._changeCursor(child.hoverCursor);
  3523. }
  3524. return true;
  3525. }
  3526. }
  3527. if (!this.isHitTestVisible) {
  3528. return false;
  3529. }
  3530. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3531. };
  3532. /** @hidden */
  3533. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3534. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3535. this._measureForChildren.copyFrom(this._currentMeasure);
  3536. };
  3537. /** Releases associated resources */
  3538. Container.prototype.dispose = function () {
  3539. _super.prototype.dispose.call(this);
  3540. for (var index = this.children.length - 1; index >= 0; index--) {
  3541. this.children[index].dispose();
  3542. }
  3543. };
  3544. return Container;
  3545. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3546. /***/ }),
  3547. /***/ "./2D/controls/control.ts":
  3548. /*!********************************!*\
  3549. !*** ./2D/controls/control.ts ***!
  3550. \********************************/
  3551. /*! exports provided: Control */
  3552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3553. "use strict";
  3554. __webpack_require__.r(__webpack_exports__);
  3555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3556. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  3557. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3558. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3559. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3560. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3561. /**
  3562. * Root class used for all 2D controls
  3563. * @see http://doc.babylonjs.com/how_to/gui#controls
  3564. */
  3565. var Control = /** @class */ (function () {
  3566. // Functions
  3567. /**
  3568. * Creates a new control
  3569. * @param name defines the name of the control
  3570. */
  3571. function Control(
  3572. /** defines the name of the control */
  3573. name) {
  3574. this.name = name;
  3575. this._alpha = 1;
  3576. this._alphaSet = false;
  3577. this._zIndex = 0;
  3578. /** @hidden */
  3579. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3580. this._fontFamily = "Arial";
  3581. this._fontStyle = "";
  3582. this._fontWeight = "";
  3583. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3584. /** @hidden */
  3585. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3586. /** @hidden */
  3587. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3588. this._color = "";
  3589. this._style = null;
  3590. /** @hidden */
  3591. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3592. /** @hidden */
  3593. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3594. /** @hidden */
  3595. this._isDirty = true;
  3596. /** @hidden */
  3597. this._wasDirty = false;
  3598. /** @hidden */
  3599. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3600. /** @hidden */
  3601. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3602. /** @hidden */
  3603. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3604. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3605. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3606. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3607. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3608. /** @hidden */
  3609. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3610. /** @hidden */
  3611. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3612. this._scaleX = 1.0;
  3613. this._scaleY = 1.0;
  3614. this._rotation = 0;
  3615. this._transformCenterX = 0.5;
  3616. this._transformCenterY = 0.5;
  3617. /** @hidden */
  3618. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3619. /** @hidden */
  3620. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3621. /** @hidden */
  3622. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3623. this._isMatrixDirty = true;
  3624. this._isVisible = true;
  3625. this._isHighlighted = false;
  3626. this._fontSet = false;
  3627. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3628. this._downCount = 0;
  3629. this._enterCount = -1;
  3630. this._doNotRender = false;
  3631. this._downPointerIds = {};
  3632. this._isEnabled = true;
  3633. this._disabledColor = "#9a9a9a";
  3634. /** @hidden */
  3635. this._rebuildLayout = false;
  3636. /** @hidden */
  3637. this._isClipped = false;
  3638. /**
  3639. * Gets or sets an object used to store user defined information for the node
  3640. */
  3641. this.metadata = null;
  3642. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3643. this.isHitTestVisible = true;
  3644. /** Gets or sets a boolean indicating if the control can block pointer events */
  3645. this.isPointerBlocker = false;
  3646. /** Gets or sets a boolean indicating if the control can be focusable */
  3647. this.isFocusInvisible = false;
  3648. /**
  3649. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3650. * 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
  3651. */
  3652. this.clipChildren = true;
  3653. /**
  3654. * Gets or sets a boolean indicating that control content must be clipped
  3655. * 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
  3656. */
  3657. this.clipContent = true;
  3658. /**
  3659. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3660. */
  3661. this.useBitmapCache = false;
  3662. this._shadowOffsetX = 0;
  3663. this._shadowOffsetY = 0;
  3664. this._shadowBlur = 0;
  3665. this._shadowColor = 'black';
  3666. /** Gets or sets the cursor to use when the control is hovered */
  3667. this.hoverCursor = "";
  3668. /** @hidden */
  3669. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3670. /** @hidden */
  3671. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3672. /**
  3673. * An event triggered when the pointer move over the control.
  3674. */
  3675. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3676. /**
  3677. * An event triggered when the pointer move out of the control.
  3678. */
  3679. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3680. /**
  3681. * An event triggered when the pointer taps the control
  3682. */
  3683. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3684. /**
  3685. * An event triggered when pointer up
  3686. */
  3687. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3688. /**
  3689. * An event triggered when a control is clicked on
  3690. */
  3691. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3692. /**
  3693. * An event triggered when pointer enters the control
  3694. */
  3695. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3696. /**
  3697. * An event triggered when the control is marked as dirty
  3698. */
  3699. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3700. /**
  3701. * An event triggered before drawing the control
  3702. */
  3703. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3704. /**
  3705. * An event triggered after the control was drawn
  3706. */
  3707. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3708. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3709. }
  3710. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3711. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3712. get: function () {
  3713. return this._shadowOffsetX;
  3714. },
  3715. set: function (value) {
  3716. if (this._shadowOffsetX === value) {
  3717. return;
  3718. }
  3719. this._shadowOffsetX = value;
  3720. this._markAsDirty();
  3721. },
  3722. enumerable: true,
  3723. configurable: true
  3724. });
  3725. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3726. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3727. get: function () {
  3728. return this._shadowOffsetY;
  3729. },
  3730. set: function (value) {
  3731. if (this._shadowOffsetY === value) {
  3732. return;
  3733. }
  3734. this._shadowOffsetY = value;
  3735. this._markAsDirty();
  3736. },
  3737. enumerable: true,
  3738. configurable: true
  3739. });
  3740. Object.defineProperty(Control.prototype, "shadowBlur", {
  3741. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3742. get: function () {
  3743. return this._shadowBlur;
  3744. },
  3745. set: function (value) {
  3746. if (this._shadowBlur === value) {
  3747. return;
  3748. }
  3749. this._shadowBlur = value;
  3750. this._markAsDirty();
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. Object.defineProperty(Control.prototype, "shadowColor", {
  3756. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3757. get: function () {
  3758. return this._shadowColor;
  3759. },
  3760. set: function (value) {
  3761. if (this._shadowColor === value) {
  3762. return;
  3763. }
  3764. this._shadowColor = value;
  3765. this._markAsDirty();
  3766. },
  3767. enumerable: true,
  3768. configurable: true
  3769. });
  3770. Object.defineProperty(Control.prototype, "typeName", {
  3771. // Properties
  3772. /** Gets the control type name */
  3773. get: function () {
  3774. return this._getTypeName();
  3775. },
  3776. enumerable: true,
  3777. configurable: true
  3778. });
  3779. /**
  3780. * Get the current class name of the control.
  3781. * @returns current class name
  3782. */
  3783. Control.prototype.getClassName = function () {
  3784. return this._getTypeName();
  3785. };
  3786. Object.defineProperty(Control.prototype, "host", {
  3787. /**
  3788. * Get the hosting AdvancedDynamicTexture
  3789. */
  3790. get: function () {
  3791. return this._host;
  3792. },
  3793. enumerable: true,
  3794. configurable: true
  3795. });
  3796. Object.defineProperty(Control.prototype, "fontOffset", {
  3797. /** Gets or set information about font offsets (used to render and align text) */
  3798. get: function () {
  3799. return this._fontOffset;
  3800. },
  3801. set: function (offset) {
  3802. this._fontOffset = offset;
  3803. },
  3804. enumerable: true,
  3805. configurable: true
  3806. });
  3807. Object.defineProperty(Control.prototype, "alpha", {
  3808. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3809. get: function () {
  3810. return this._alpha;
  3811. },
  3812. set: function (value) {
  3813. if (this._alpha === value) {
  3814. return;
  3815. }
  3816. this._alphaSet = true;
  3817. this._alpha = value;
  3818. this._markAsDirty();
  3819. },
  3820. enumerable: true,
  3821. configurable: true
  3822. });
  3823. Object.defineProperty(Control.prototype, "isHighlighted", {
  3824. /**
  3825. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3826. */
  3827. get: function () {
  3828. return this._isHighlighted;
  3829. },
  3830. set: function (value) {
  3831. if (this._isHighlighted === value) {
  3832. return;
  3833. }
  3834. this._isHighlighted = value;
  3835. this._markAsDirty();
  3836. },
  3837. enumerable: true,
  3838. configurable: true
  3839. });
  3840. Object.defineProperty(Control.prototype, "scaleX", {
  3841. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3842. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3843. */
  3844. get: function () {
  3845. return this._scaleX;
  3846. },
  3847. set: function (value) {
  3848. if (this._scaleX === value) {
  3849. return;
  3850. }
  3851. this._scaleX = value;
  3852. this._markAsDirty();
  3853. this._markMatrixAsDirty();
  3854. },
  3855. enumerable: true,
  3856. configurable: true
  3857. });
  3858. Object.defineProperty(Control.prototype, "scaleY", {
  3859. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3860. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3861. */
  3862. get: function () {
  3863. return this._scaleY;
  3864. },
  3865. set: function (value) {
  3866. if (this._scaleY === value) {
  3867. return;
  3868. }
  3869. this._scaleY = value;
  3870. this._markAsDirty();
  3871. this._markMatrixAsDirty();
  3872. },
  3873. enumerable: true,
  3874. configurable: true
  3875. });
  3876. Object.defineProperty(Control.prototype, "rotation", {
  3877. /** Gets or sets the rotation angle (0 by default)
  3878. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3879. */
  3880. get: function () {
  3881. return this._rotation;
  3882. },
  3883. set: function (value) {
  3884. if (this._rotation === value) {
  3885. return;
  3886. }
  3887. this._rotation = value;
  3888. this._markAsDirty();
  3889. this._markMatrixAsDirty();
  3890. },
  3891. enumerable: true,
  3892. configurable: true
  3893. });
  3894. Object.defineProperty(Control.prototype, "transformCenterY", {
  3895. /** Gets or sets the transformation center on Y axis (0 by default)
  3896. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3897. */
  3898. get: function () {
  3899. return this._transformCenterY;
  3900. },
  3901. set: function (value) {
  3902. if (this._transformCenterY === value) {
  3903. return;
  3904. }
  3905. this._transformCenterY = value;
  3906. this._markAsDirty();
  3907. this._markMatrixAsDirty();
  3908. },
  3909. enumerable: true,
  3910. configurable: true
  3911. });
  3912. Object.defineProperty(Control.prototype, "transformCenterX", {
  3913. /** Gets or sets the transformation center on X axis (0 by default)
  3914. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3915. */
  3916. get: function () {
  3917. return this._transformCenterX;
  3918. },
  3919. set: function (value) {
  3920. if (this._transformCenterX === value) {
  3921. return;
  3922. }
  3923. this._transformCenterX = value;
  3924. this._markAsDirty();
  3925. this._markMatrixAsDirty();
  3926. },
  3927. enumerable: true,
  3928. configurable: true
  3929. });
  3930. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3931. /**
  3932. * Gets or sets the horizontal alignment
  3933. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3934. */
  3935. get: function () {
  3936. return this._horizontalAlignment;
  3937. },
  3938. set: function (value) {
  3939. if (this._horizontalAlignment === value) {
  3940. return;
  3941. }
  3942. this._horizontalAlignment = value;
  3943. this._markAsDirty();
  3944. },
  3945. enumerable: true,
  3946. configurable: true
  3947. });
  3948. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3949. /**
  3950. * Gets or sets the vertical alignment
  3951. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3952. */
  3953. get: function () {
  3954. return this._verticalAlignment;
  3955. },
  3956. set: function (value) {
  3957. if (this._verticalAlignment === value) {
  3958. return;
  3959. }
  3960. this._verticalAlignment = value;
  3961. this._markAsDirty();
  3962. },
  3963. enumerable: true,
  3964. configurable: true
  3965. });
  3966. Object.defineProperty(Control.prototype, "width", {
  3967. /**
  3968. * Gets or sets control width
  3969. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3970. */
  3971. get: function () {
  3972. return this._width.toString(this._host);
  3973. },
  3974. set: function (value) {
  3975. if (this._width.toString(this._host) === value) {
  3976. return;
  3977. }
  3978. if (this._width.fromString(value)) {
  3979. this._markAsDirty();
  3980. }
  3981. },
  3982. enumerable: true,
  3983. configurable: true
  3984. });
  3985. Object.defineProperty(Control.prototype, "widthInPixels", {
  3986. /**
  3987. * Gets or sets the control width in pixel
  3988. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3989. */
  3990. get: function () {
  3991. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3992. },
  3993. set: function (value) {
  3994. if (isNaN(value)) {
  3995. return;
  3996. }
  3997. this.width = value + "px";
  3998. },
  3999. enumerable: true,
  4000. configurable: true
  4001. });
  4002. Object.defineProperty(Control.prototype, "height", {
  4003. /**
  4004. * Gets or sets control height
  4005. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4006. */
  4007. get: function () {
  4008. return this._height.toString(this._host);
  4009. },
  4010. set: function (value) {
  4011. if (this._height.toString(this._host) === value) {
  4012. return;
  4013. }
  4014. if (this._height.fromString(value)) {
  4015. this._markAsDirty();
  4016. }
  4017. },
  4018. enumerable: true,
  4019. configurable: true
  4020. });
  4021. Object.defineProperty(Control.prototype, "heightInPixels", {
  4022. /**
  4023. * Gets or sets control height in pixel
  4024. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4025. */
  4026. get: function () {
  4027. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4028. },
  4029. set: function (value) {
  4030. if (isNaN(value)) {
  4031. return;
  4032. }
  4033. this.height = value + "px";
  4034. },
  4035. enumerable: true,
  4036. configurable: true
  4037. });
  4038. Object.defineProperty(Control.prototype, "fontFamily", {
  4039. /** Gets or set font family */
  4040. get: function () {
  4041. if (!this._fontSet) {
  4042. return "";
  4043. }
  4044. return this._fontFamily;
  4045. },
  4046. set: function (value) {
  4047. if (this._fontFamily === value) {
  4048. return;
  4049. }
  4050. this._fontFamily = value;
  4051. this._resetFontCache();
  4052. },
  4053. enumerable: true,
  4054. configurable: true
  4055. });
  4056. Object.defineProperty(Control.prototype, "fontStyle", {
  4057. /** Gets or sets font style */
  4058. get: function () {
  4059. return this._fontStyle;
  4060. },
  4061. set: function (value) {
  4062. if (this._fontStyle === value) {
  4063. return;
  4064. }
  4065. this._fontStyle = value;
  4066. this._resetFontCache();
  4067. },
  4068. enumerable: true,
  4069. configurable: true
  4070. });
  4071. Object.defineProperty(Control.prototype, "fontWeight", {
  4072. /** Gets or sets font weight */
  4073. get: function () {
  4074. return this._fontWeight;
  4075. },
  4076. set: function (value) {
  4077. if (this._fontWeight === value) {
  4078. return;
  4079. }
  4080. this._fontWeight = value;
  4081. this._resetFontCache();
  4082. },
  4083. enumerable: true,
  4084. configurable: true
  4085. });
  4086. Object.defineProperty(Control.prototype, "style", {
  4087. /**
  4088. * Gets or sets style
  4089. * @see http://doc.babylonjs.com/how_to/gui#styles
  4090. */
  4091. get: function () {
  4092. return this._style;
  4093. },
  4094. set: function (value) {
  4095. var _this = this;
  4096. if (this._style) {
  4097. this._style.onChangedObservable.remove(this._styleObserver);
  4098. this._styleObserver = null;
  4099. }
  4100. this._style = value;
  4101. if (this._style) {
  4102. this._styleObserver = this._style.onChangedObservable.add(function () {
  4103. _this._markAsDirty();
  4104. _this._resetFontCache();
  4105. });
  4106. }
  4107. this._markAsDirty();
  4108. this._resetFontCache();
  4109. },
  4110. enumerable: true,
  4111. configurable: true
  4112. });
  4113. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4114. /** @hidden */
  4115. get: function () {
  4116. return this._fontSize.isPercentage;
  4117. },
  4118. enumerable: true,
  4119. configurable: true
  4120. });
  4121. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4122. /** Gets or sets font size in pixels */
  4123. get: function () {
  4124. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4125. if (fontSizeToUse.isPixel) {
  4126. return fontSizeToUse.getValue(this._host);
  4127. }
  4128. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4129. },
  4130. set: function (value) {
  4131. if (isNaN(value)) {
  4132. return;
  4133. }
  4134. this.fontSize = value + "px";
  4135. },
  4136. enumerable: true,
  4137. configurable: true
  4138. });
  4139. Object.defineProperty(Control.prototype, "fontSize", {
  4140. /** Gets or sets font size */
  4141. get: function () {
  4142. return this._fontSize.toString(this._host);
  4143. },
  4144. set: function (value) {
  4145. if (this._fontSize.toString(this._host) === value) {
  4146. return;
  4147. }
  4148. if (this._fontSize.fromString(value)) {
  4149. this._markAsDirty();
  4150. this._resetFontCache();
  4151. }
  4152. },
  4153. enumerable: true,
  4154. configurable: true
  4155. });
  4156. Object.defineProperty(Control.prototype, "color", {
  4157. /** Gets or sets foreground color */
  4158. get: function () {
  4159. return this._color;
  4160. },
  4161. set: function (value) {
  4162. if (this._color === value) {
  4163. return;
  4164. }
  4165. this._color = value;
  4166. this._markAsDirty();
  4167. },
  4168. enumerable: true,
  4169. configurable: true
  4170. });
  4171. Object.defineProperty(Control.prototype, "zIndex", {
  4172. /** Gets or sets z index which is used to reorder controls on the z axis */
  4173. get: function () {
  4174. return this._zIndex;
  4175. },
  4176. set: function (value) {
  4177. if (this.zIndex === value) {
  4178. return;
  4179. }
  4180. this._zIndex = value;
  4181. if (this.parent) {
  4182. this.parent._reOrderControl(this);
  4183. }
  4184. },
  4185. enumerable: true,
  4186. configurable: true
  4187. });
  4188. Object.defineProperty(Control.prototype, "notRenderable", {
  4189. /** Gets or sets a boolean indicating if the control can be rendered */
  4190. get: function () {
  4191. return this._doNotRender;
  4192. },
  4193. set: function (value) {
  4194. if (this._doNotRender === value) {
  4195. return;
  4196. }
  4197. this._doNotRender = value;
  4198. this._markAsDirty();
  4199. },
  4200. enumerable: true,
  4201. configurable: true
  4202. });
  4203. Object.defineProperty(Control.prototype, "isVisible", {
  4204. /** Gets or sets a boolean indicating if the control is visible */
  4205. get: function () {
  4206. return this._isVisible;
  4207. },
  4208. set: function (value) {
  4209. if (this._isVisible === value) {
  4210. return;
  4211. }
  4212. this._isVisible = value;
  4213. this._markAsDirty(true);
  4214. },
  4215. enumerable: true,
  4216. configurable: true
  4217. });
  4218. Object.defineProperty(Control.prototype, "isDirty", {
  4219. /** Gets a boolean indicating that the control needs to update its rendering */
  4220. get: function () {
  4221. return this._isDirty;
  4222. },
  4223. enumerable: true,
  4224. configurable: true
  4225. });
  4226. Object.defineProperty(Control.prototype, "linkedMesh", {
  4227. /**
  4228. * Gets the current linked mesh (or null if none)
  4229. */
  4230. get: function () {
  4231. return this._linkedMesh;
  4232. },
  4233. enumerable: true,
  4234. configurable: true
  4235. });
  4236. Object.defineProperty(Control.prototype, "paddingLeft", {
  4237. /**
  4238. * Gets or sets a value indicating the padding to use on the left of the control
  4239. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4240. */
  4241. get: function () {
  4242. return this._paddingLeft.toString(this._host);
  4243. },
  4244. set: function (value) {
  4245. if (this._paddingLeft.fromString(value)) {
  4246. this._markAsDirty();
  4247. }
  4248. },
  4249. enumerable: true,
  4250. configurable: true
  4251. });
  4252. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4253. /**
  4254. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4255. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4256. */
  4257. get: function () {
  4258. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4259. },
  4260. set: function (value) {
  4261. if (isNaN(value)) {
  4262. return;
  4263. }
  4264. this.paddingLeft = value + "px";
  4265. },
  4266. enumerable: true,
  4267. configurable: true
  4268. });
  4269. Object.defineProperty(Control.prototype, "paddingRight", {
  4270. /**
  4271. * Gets or sets a value indicating the padding to use on the right of the control
  4272. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4273. */
  4274. get: function () {
  4275. return this._paddingRight.toString(this._host);
  4276. },
  4277. set: function (value) {
  4278. if (this._paddingRight.fromString(value)) {
  4279. this._markAsDirty();
  4280. }
  4281. },
  4282. enumerable: true,
  4283. configurable: true
  4284. });
  4285. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4286. /**
  4287. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4288. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4289. */
  4290. get: function () {
  4291. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4292. },
  4293. set: function (value) {
  4294. if (isNaN(value)) {
  4295. return;
  4296. }
  4297. this.paddingRight = value + "px";
  4298. },
  4299. enumerable: true,
  4300. configurable: true
  4301. });
  4302. Object.defineProperty(Control.prototype, "paddingTop", {
  4303. /**
  4304. * Gets or sets a value indicating the padding to use on the top of the control
  4305. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4306. */
  4307. get: function () {
  4308. return this._paddingTop.toString(this._host);
  4309. },
  4310. set: function (value) {
  4311. if (this._paddingTop.fromString(value)) {
  4312. this._markAsDirty();
  4313. }
  4314. },
  4315. enumerable: true,
  4316. configurable: true
  4317. });
  4318. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4319. /**
  4320. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4321. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4322. */
  4323. get: function () {
  4324. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4325. },
  4326. set: function (value) {
  4327. if (isNaN(value)) {
  4328. return;
  4329. }
  4330. this.paddingTop = value + "px";
  4331. },
  4332. enumerable: true,
  4333. configurable: true
  4334. });
  4335. Object.defineProperty(Control.prototype, "paddingBottom", {
  4336. /**
  4337. * Gets or sets a value indicating the padding to use on the bottom of the control
  4338. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4339. */
  4340. get: function () {
  4341. return this._paddingBottom.toString(this._host);
  4342. },
  4343. set: function (value) {
  4344. if (this._paddingBottom.fromString(value)) {
  4345. this._markAsDirty();
  4346. }
  4347. },
  4348. enumerable: true,
  4349. configurable: true
  4350. });
  4351. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4352. /**
  4353. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4354. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4355. */
  4356. get: function () {
  4357. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4358. },
  4359. set: function (value) {
  4360. if (isNaN(value)) {
  4361. return;
  4362. }
  4363. this.paddingBottom = value + "px";
  4364. },
  4365. enumerable: true,
  4366. configurable: true
  4367. });
  4368. Object.defineProperty(Control.prototype, "left", {
  4369. /**
  4370. * Gets or sets a value indicating the left coordinate of the control
  4371. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4372. */
  4373. get: function () {
  4374. return this._left.toString(this._host);
  4375. },
  4376. set: function (value) {
  4377. if (this._left.fromString(value)) {
  4378. this._markAsDirty();
  4379. }
  4380. },
  4381. enumerable: true,
  4382. configurable: true
  4383. });
  4384. Object.defineProperty(Control.prototype, "leftInPixels", {
  4385. /**
  4386. * Gets or sets a value indicating the left coordinate in pixels of the control
  4387. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4388. */
  4389. get: function () {
  4390. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4391. },
  4392. set: function (value) {
  4393. if (isNaN(value)) {
  4394. return;
  4395. }
  4396. this.left = value + "px";
  4397. },
  4398. enumerable: true,
  4399. configurable: true
  4400. });
  4401. Object.defineProperty(Control.prototype, "top", {
  4402. /**
  4403. * Gets or sets a value indicating the top coordinate of the control
  4404. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4405. */
  4406. get: function () {
  4407. return this._top.toString(this._host);
  4408. },
  4409. set: function (value) {
  4410. if (this._top.fromString(value)) {
  4411. this._markAsDirty();
  4412. }
  4413. },
  4414. enumerable: true,
  4415. configurable: true
  4416. });
  4417. Object.defineProperty(Control.prototype, "topInPixels", {
  4418. /**
  4419. * Gets or sets a value indicating the top coordinate in pixels of the control
  4420. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4421. */
  4422. get: function () {
  4423. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4424. },
  4425. set: function (value) {
  4426. if (isNaN(value)) {
  4427. return;
  4428. }
  4429. this.top = value + "px";
  4430. },
  4431. enumerable: true,
  4432. configurable: true
  4433. });
  4434. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4435. /**
  4436. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4437. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4438. */
  4439. get: function () {
  4440. return this._linkOffsetX.toString(this._host);
  4441. },
  4442. set: function (value) {
  4443. if (this._linkOffsetX.fromString(value)) {
  4444. this._markAsDirty();
  4445. }
  4446. },
  4447. enumerable: true,
  4448. configurable: true
  4449. });
  4450. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4451. /**
  4452. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4453. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4454. */
  4455. get: function () {
  4456. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4457. },
  4458. set: function (value) {
  4459. if (isNaN(value)) {
  4460. return;
  4461. }
  4462. this.linkOffsetX = value + "px";
  4463. },
  4464. enumerable: true,
  4465. configurable: true
  4466. });
  4467. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4468. /**
  4469. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4470. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4471. */
  4472. get: function () {
  4473. return this._linkOffsetY.toString(this._host);
  4474. },
  4475. set: function (value) {
  4476. if (this._linkOffsetY.fromString(value)) {
  4477. this._markAsDirty();
  4478. }
  4479. },
  4480. enumerable: true,
  4481. configurable: true
  4482. });
  4483. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4484. /**
  4485. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4486. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4487. */
  4488. get: function () {
  4489. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4490. },
  4491. set: function (value) {
  4492. if (isNaN(value)) {
  4493. return;
  4494. }
  4495. this.linkOffsetY = value + "px";
  4496. },
  4497. enumerable: true,
  4498. configurable: true
  4499. });
  4500. Object.defineProperty(Control.prototype, "centerX", {
  4501. /** Gets the center coordinate on X axis */
  4502. get: function () {
  4503. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4504. },
  4505. enumerable: true,
  4506. configurable: true
  4507. });
  4508. Object.defineProperty(Control.prototype, "centerY", {
  4509. /** Gets the center coordinate on Y axis */
  4510. get: function () {
  4511. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4512. },
  4513. enumerable: true,
  4514. configurable: true
  4515. });
  4516. Object.defineProperty(Control.prototype, "isEnabled", {
  4517. /** Gets or sets if control is Enabled*/
  4518. get: function () {
  4519. return this._isEnabled;
  4520. },
  4521. set: function (value) {
  4522. if (this._isEnabled === value) {
  4523. return;
  4524. }
  4525. this._isEnabled = value;
  4526. this._markAsDirty();
  4527. },
  4528. enumerable: true,
  4529. configurable: true
  4530. });
  4531. Object.defineProperty(Control.prototype, "disabledColor", {
  4532. /** Gets or sets background color of control if it's disabled*/
  4533. get: function () {
  4534. return this._disabledColor;
  4535. },
  4536. set: function (value) {
  4537. if (this._disabledColor === value) {
  4538. return;
  4539. }
  4540. this._disabledColor = value;
  4541. this._markAsDirty();
  4542. },
  4543. enumerable: true,
  4544. configurable: true
  4545. });
  4546. /** @hidden */
  4547. Control.prototype._getTypeName = function () {
  4548. return "Control";
  4549. };
  4550. /**
  4551. * Gets the first ascendant in the hierarchy of the given type
  4552. * @param className defines the required type
  4553. * @returns the ascendant or null if not found
  4554. */
  4555. Control.prototype.getAscendantOfClass = function (className) {
  4556. if (!this.parent) {
  4557. return null;
  4558. }
  4559. if (this.parent.getClassName() === className) {
  4560. return this.parent;
  4561. }
  4562. return this.parent.getAscendantOfClass(className);
  4563. };
  4564. /** @hidden */
  4565. Control.prototype._resetFontCache = function () {
  4566. this._fontSet = true;
  4567. this._markAsDirty();
  4568. };
  4569. /**
  4570. * Determines if a container is an ascendant of the current control
  4571. * @param container defines the container to look for
  4572. * @returns true if the container is one of the ascendant of the control
  4573. */
  4574. Control.prototype.isAscendant = function (container) {
  4575. if (!this.parent) {
  4576. return false;
  4577. }
  4578. if (this.parent === container) {
  4579. return true;
  4580. }
  4581. return this.parent.isAscendant(container);
  4582. };
  4583. /**
  4584. * Gets coordinates in local control space
  4585. * @param globalCoordinates defines the coordinates to transform
  4586. * @returns the new coordinates in local space
  4587. */
  4588. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4589. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4590. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4591. return result;
  4592. };
  4593. /**
  4594. * Gets coordinates in local control space
  4595. * @param globalCoordinates defines the coordinates to transform
  4596. * @param result defines the target vector2 where to store the result
  4597. * @returns the current control
  4598. */
  4599. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4600. result.x = globalCoordinates.x - this._currentMeasure.left;
  4601. result.y = globalCoordinates.y - this._currentMeasure.top;
  4602. return this;
  4603. };
  4604. /**
  4605. * Gets coordinates in parent local control space
  4606. * @param globalCoordinates defines the coordinates to transform
  4607. * @returns the new coordinates in parent local space
  4608. */
  4609. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4610. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4611. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4612. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4613. return result;
  4614. };
  4615. /**
  4616. * Move the current control to a vector3 position projected onto the screen.
  4617. * @param position defines the target position
  4618. * @param scene defines the hosting scene
  4619. */
  4620. Control.prototype.moveToVector3 = function (position, scene) {
  4621. if (!this._host || this.parent !== this._host._rootContainer) {
  4622. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4623. return;
  4624. }
  4625. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4626. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4627. var globalViewport = this._host._getGlobalViewport(scene);
  4628. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4629. this._moveToProjectedPosition(projectedPosition);
  4630. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4631. this.notRenderable = true;
  4632. return;
  4633. }
  4634. this.notRenderable = false;
  4635. };
  4636. /** @hidden */
  4637. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4638. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4639. // Do nothing by default
  4640. };
  4641. /**
  4642. * Will return all controls that have this control as ascendant
  4643. * @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
  4644. * @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
  4645. * @return all child controls
  4646. */
  4647. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4648. var results = new Array();
  4649. this._getDescendants(results, directDescendantsOnly, predicate);
  4650. return results;
  4651. };
  4652. /**
  4653. * Link current control with a target mesh
  4654. * @param mesh defines the mesh to link with
  4655. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4656. */
  4657. Control.prototype.linkWithMesh = function (mesh) {
  4658. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4659. if (mesh) {
  4660. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4661. }
  4662. return;
  4663. }
  4664. var index = this._host._linkedControls.indexOf(this);
  4665. if (index !== -1) {
  4666. this._linkedMesh = mesh;
  4667. if (!mesh) {
  4668. this._host._linkedControls.splice(index, 1);
  4669. }
  4670. return;
  4671. }
  4672. else if (!mesh) {
  4673. return;
  4674. }
  4675. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4676. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4677. this._linkedMesh = mesh;
  4678. this._host._linkedControls.push(this);
  4679. };
  4680. /** @hidden */
  4681. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4682. var oldLeft = this._left.getValue(this._host);
  4683. var oldTop = this._top.getValue(this._host);
  4684. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4685. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4686. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4687. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4688. newLeft = oldLeft;
  4689. }
  4690. if (Math.abs(newTop - oldTop) < 0.5) {
  4691. newTop = oldTop;
  4692. }
  4693. }
  4694. this.left = newLeft + "px";
  4695. this.top = newTop + "px";
  4696. this._left.ignoreAdaptiveScaling = true;
  4697. this._top.ignoreAdaptiveScaling = true;
  4698. this._markAsDirty();
  4699. };
  4700. /** @hidden */
  4701. Control.prototype._offsetLeft = function (offset) {
  4702. this._isDirty = true;
  4703. this._currentMeasure.left += offset;
  4704. };
  4705. /** @hidden */
  4706. Control.prototype._offsetTop = function (offset) {
  4707. this._isDirty = true;
  4708. this._currentMeasure.top += offset;
  4709. };
  4710. /** @hidden */
  4711. Control.prototype._markMatrixAsDirty = function () {
  4712. this._isMatrixDirty = true;
  4713. this._flagDescendantsAsMatrixDirty();
  4714. };
  4715. /** @hidden */
  4716. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4717. // No child
  4718. };
  4719. /** @hidden */
  4720. Control.prototype._intersectsRect = function (rect) {
  4721. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4722. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4723. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4724. return false;
  4725. }
  4726. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4727. return false;
  4728. }
  4729. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4730. return false;
  4731. }
  4732. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4733. return false;
  4734. }
  4735. return true;
  4736. };
  4737. /** @hidden */
  4738. Control.prototype.invalidateRect = function () {
  4739. this._transform();
  4740. if (this.host && this.host.useInvalidateRectOptimization) {
  4741. // Rotate by transform to get the measure transformed to global space
  4742. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4743. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4744. // the previous measure is used to properly clear a control that is scaled down
  4745. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4746. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4747. // Expand rect based on shadows
  4748. var shadowOffsetX = this.shadowOffsetX;
  4749. var shadowOffsetY = this.shadowOffsetY;
  4750. var shadowBlur = this.shadowBlur;
  4751. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4752. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4753. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4754. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4755. 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));
  4756. }
  4757. else {
  4758. 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));
  4759. }
  4760. }
  4761. };
  4762. /** @hidden */
  4763. Control.prototype._markAsDirty = function (force) {
  4764. if (force === void 0) { force = false; }
  4765. if (!this._isVisible && !force) {
  4766. return;
  4767. }
  4768. this._isDirty = true;
  4769. // Redraw only this rectangle
  4770. if (this._host) {
  4771. this._host.markAsDirty();
  4772. }
  4773. };
  4774. /** @hidden */
  4775. Control.prototype._markAllAsDirty = function () {
  4776. this._markAsDirty();
  4777. if (this._font) {
  4778. this._prepareFont();
  4779. }
  4780. };
  4781. /** @hidden */
  4782. Control.prototype._link = function (host) {
  4783. this._host = host;
  4784. if (this._host) {
  4785. this.uniqueId = this._host.getScene().getUniqueId();
  4786. }
  4787. };
  4788. /** @hidden */
  4789. Control.prototype._transform = function (context) {
  4790. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4791. return;
  4792. }
  4793. // postTranslate
  4794. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4795. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4796. if (context) {
  4797. context.translate(offsetX, offsetY);
  4798. // rotate
  4799. context.rotate(this._rotation);
  4800. // scale
  4801. context.scale(this._scaleX, this._scaleY);
  4802. // preTranslate
  4803. context.translate(-offsetX, -offsetY);
  4804. }
  4805. // Need to update matrices?
  4806. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4807. this._cachedOffsetX = offsetX;
  4808. this._cachedOffsetY = offsetY;
  4809. this._isMatrixDirty = false;
  4810. this._flagDescendantsAsMatrixDirty();
  4811. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4812. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4813. }
  4814. };
  4815. /** @hidden */
  4816. Control.prototype._renderHighlight = function (context) {
  4817. if (!this.isHighlighted) {
  4818. return;
  4819. }
  4820. context.save();
  4821. context.strokeStyle = "#4affff";
  4822. context.lineWidth = 2;
  4823. this._renderHighlightSpecific(context);
  4824. context.restore();
  4825. };
  4826. /** @hidden */
  4827. Control.prototype._renderHighlightSpecific = function (context) {
  4828. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4829. };
  4830. /** @hidden */
  4831. Control.prototype._applyStates = function (context) {
  4832. if (this._isFontSizeInPercentage) {
  4833. this._fontSet = true;
  4834. }
  4835. if (this._fontSet) {
  4836. this._prepareFont();
  4837. this._fontSet = false;
  4838. }
  4839. if (this._font) {
  4840. context.font = this._font;
  4841. }
  4842. if (this._color) {
  4843. context.fillStyle = this._color;
  4844. }
  4845. if (Control.AllowAlphaInheritance) {
  4846. context.globalAlpha *= this._alpha;
  4847. }
  4848. else if (this._alphaSet) {
  4849. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4850. }
  4851. };
  4852. /** @hidden */
  4853. Control.prototype._layout = function (parentMeasure, context) {
  4854. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4855. return false;
  4856. }
  4857. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4858. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4859. context.save();
  4860. this._applyStates(context);
  4861. var rebuildCount = 0;
  4862. do {
  4863. this._rebuildLayout = false;
  4864. this._processMeasures(parentMeasure, context);
  4865. rebuildCount++;
  4866. } while (this._rebuildLayout && rebuildCount < 3);
  4867. if (rebuildCount >= 3) {
  4868. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4869. }
  4870. context.restore();
  4871. this.invalidateRect();
  4872. this._evaluateClippingState(parentMeasure);
  4873. }
  4874. this._wasDirty = this._isDirty;
  4875. this._isDirty = false;
  4876. return true;
  4877. };
  4878. /** @hidden */
  4879. Control.prototype._processMeasures = function (parentMeasure, context) {
  4880. this._currentMeasure.copyFrom(parentMeasure);
  4881. // Let children take some pre-measurement actions
  4882. this._preMeasure(parentMeasure, context);
  4883. this._measure();
  4884. this._computeAlignment(parentMeasure, context);
  4885. // Convert to int values
  4886. this._currentMeasure.left = this._currentMeasure.left | 0;
  4887. this._currentMeasure.top = this._currentMeasure.top | 0;
  4888. this._currentMeasure.width = this._currentMeasure.width | 0;
  4889. this._currentMeasure.height = this._currentMeasure.height | 0;
  4890. // Let children add more features
  4891. this._additionalProcessing(parentMeasure, context);
  4892. this._cachedParentMeasure.copyFrom(parentMeasure);
  4893. if (this.onDirtyObservable.hasObservers()) {
  4894. this.onDirtyObservable.notifyObservers(this);
  4895. }
  4896. };
  4897. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4898. if (this.parent && this.parent.clipChildren) {
  4899. // Early clip
  4900. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4901. this._isClipped = true;
  4902. return;
  4903. }
  4904. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4905. this._isClipped = true;
  4906. return;
  4907. }
  4908. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4909. this._isClipped = true;
  4910. return;
  4911. }
  4912. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4913. this._isClipped = true;
  4914. return;
  4915. }
  4916. }
  4917. this._isClipped = false;
  4918. };
  4919. /** @hidden */
  4920. Control.prototype._measure = function () {
  4921. // Width / Height
  4922. if (this._width.isPixel) {
  4923. this._currentMeasure.width = this._width.getValue(this._host);
  4924. }
  4925. else {
  4926. this._currentMeasure.width *= this._width.getValue(this._host);
  4927. }
  4928. if (this._height.isPixel) {
  4929. this._currentMeasure.height = this._height.getValue(this._host);
  4930. }
  4931. else {
  4932. this._currentMeasure.height *= this._height.getValue(this._host);
  4933. }
  4934. };
  4935. /** @hidden */
  4936. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4937. var width = this._currentMeasure.width;
  4938. var height = this._currentMeasure.height;
  4939. var parentWidth = parentMeasure.width;
  4940. var parentHeight = parentMeasure.height;
  4941. // Left / top
  4942. var x = 0;
  4943. var y = 0;
  4944. switch (this.horizontalAlignment) {
  4945. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4946. x = 0;
  4947. break;
  4948. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4949. x = parentWidth - width;
  4950. break;
  4951. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4952. x = (parentWidth - width) / 2;
  4953. break;
  4954. }
  4955. switch (this.verticalAlignment) {
  4956. case Control.VERTICAL_ALIGNMENT_TOP:
  4957. y = 0;
  4958. break;
  4959. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4960. y = parentHeight - height;
  4961. break;
  4962. case Control.VERTICAL_ALIGNMENT_CENTER:
  4963. y = (parentHeight - height) / 2;
  4964. break;
  4965. }
  4966. if (this._paddingLeft.isPixel) {
  4967. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4968. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4969. }
  4970. else {
  4971. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4972. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4973. }
  4974. if (this._paddingRight.isPixel) {
  4975. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4976. }
  4977. else {
  4978. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4979. }
  4980. if (this._paddingTop.isPixel) {
  4981. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4982. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4983. }
  4984. else {
  4985. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4986. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4987. }
  4988. if (this._paddingBottom.isPixel) {
  4989. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4990. }
  4991. else {
  4992. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4993. }
  4994. if (this._left.isPixel) {
  4995. this._currentMeasure.left += this._left.getValue(this._host);
  4996. }
  4997. else {
  4998. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4999. }
  5000. if (this._top.isPixel) {
  5001. this._currentMeasure.top += this._top.getValue(this._host);
  5002. }
  5003. else {
  5004. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5005. }
  5006. this._currentMeasure.left += x;
  5007. this._currentMeasure.top += y;
  5008. };
  5009. /** @hidden */
  5010. Control.prototype._preMeasure = function (parentMeasure, context) {
  5011. // Do nothing
  5012. };
  5013. /** @hidden */
  5014. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5015. // Do nothing
  5016. };
  5017. /** @hidden */
  5018. Control.prototype._clipForChildren = function (context) {
  5019. // DO nothing
  5020. };
  5021. Control.prototype._clip = function (context, invalidatedRectangle) {
  5022. context.beginPath();
  5023. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5024. if (invalidatedRectangle) {
  5025. // Rotate the invalidated rect into the control's space
  5026. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5027. // Get the intersection of the rect in context space and the current context
  5028. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5029. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5030. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5031. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5032. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5033. Control._ClipMeasure.copyFrom(intersection);
  5034. }
  5035. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5036. var shadowOffsetX = this.shadowOffsetX;
  5037. var shadowOffsetY = this.shadowOffsetY;
  5038. var shadowBlur = this.shadowBlur;
  5039. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5040. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5041. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5042. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5043. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5044. }
  5045. else {
  5046. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5047. }
  5048. context.clip();
  5049. };
  5050. /** @hidden */
  5051. Control.prototype._render = function (context, invalidatedRectangle) {
  5052. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5053. this._isDirty = false;
  5054. return false;
  5055. }
  5056. context.save();
  5057. this._applyStates(context);
  5058. // Transform
  5059. this._transform(context);
  5060. // Clip
  5061. if (this.clipContent) {
  5062. this._clip(context, invalidatedRectangle);
  5063. }
  5064. if (this.onBeforeDrawObservable.hasObservers()) {
  5065. this.onBeforeDrawObservable.notifyObservers(this);
  5066. }
  5067. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5068. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5069. }
  5070. else {
  5071. this._draw(context, invalidatedRectangle);
  5072. }
  5073. if (this.useBitmapCache && this._wasDirty) {
  5074. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5075. }
  5076. this._renderHighlight(context);
  5077. if (this.onAfterDrawObservable.hasObservers()) {
  5078. this.onAfterDrawObservable.notifyObservers(this);
  5079. }
  5080. context.restore();
  5081. return true;
  5082. };
  5083. /** @hidden */
  5084. Control.prototype._draw = function (context, invalidatedRectangle) {
  5085. // Do nothing
  5086. };
  5087. /**
  5088. * Tests if a given coordinates belong to the current control
  5089. * @param x defines x coordinate to test
  5090. * @param y defines y coordinate to test
  5091. * @returns true if the coordinates are inside the control
  5092. */
  5093. Control.prototype.contains = function (x, y) {
  5094. // Invert transform
  5095. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5096. x = this._transformedPosition.x;
  5097. y = this._transformedPosition.y;
  5098. // Check
  5099. if (x < this._currentMeasure.left) {
  5100. return false;
  5101. }
  5102. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5103. return false;
  5104. }
  5105. if (y < this._currentMeasure.top) {
  5106. return false;
  5107. }
  5108. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5109. return false;
  5110. }
  5111. if (this.isPointerBlocker) {
  5112. this._host._shouldBlockPointer = true;
  5113. }
  5114. return true;
  5115. };
  5116. /** @hidden */
  5117. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5118. if (!this._isEnabled) {
  5119. return false;
  5120. }
  5121. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5122. return false;
  5123. }
  5124. if (!this.contains(x, y)) {
  5125. return false;
  5126. }
  5127. this._processObservables(type, x, y, pointerId, buttonIndex);
  5128. return true;
  5129. };
  5130. /** @hidden */
  5131. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5132. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5133. if (canNotify && this.parent != null) {
  5134. this.parent._onPointerMove(target, coordinates, pointerId);
  5135. }
  5136. };
  5137. /** @hidden */
  5138. Control.prototype._onPointerEnter = function (target) {
  5139. if (!this._isEnabled) {
  5140. return false;
  5141. }
  5142. if (this._enterCount > 0) {
  5143. return false;
  5144. }
  5145. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5146. this._enterCount = 0;
  5147. }
  5148. this._enterCount++;
  5149. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5150. if (canNotify && this.parent != null) {
  5151. this.parent._onPointerEnter(target);
  5152. }
  5153. return true;
  5154. };
  5155. /** @hidden */
  5156. Control.prototype._onPointerOut = function (target, force) {
  5157. if (force === void 0) { force = false; }
  5158. if (!force && (!this._isEnabled || target === this)) {
  5159. return;
  5160. }
  5161. this._enterCount = 0;
  5162. var canNotify = true;
  5163. if (!target.isAscendant(this)) {
  5164. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5165. }
  5166. if (canNotify && this.parent != null) {
  5167. this.parent._onPointerOut(target, force);
  5168. }
  5169. };
  5170. /** @hidden */
  5171. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5172. // Prevent pointerout to lose control context.
  5173. // Event redundancy is checked inside the function.
  5174. this._onPointerEnter(this);
  5175. if (this._downCount !== 0) {
  5176. return false;
  5177. }
  5178. this._downCount++;
  5179. this._downPointerIds[pointerId] = true;
  5180. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5181. if (canNotify && this.parent != null) {
  5182. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5183. }
  5184. return true;
  5185. };
  5186. /** @hidden */
  5187. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5188. if (!this._isEnabled) {
  5189. return;
  5190. }
  5191. this._downCount = 0;
  5192. delete this._downPointerIds[pointerId];
  5193. var canNotifyClick = notifyClick;
  5194. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5195. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5196. }
  5197. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5198. if (canNotify && this.parent != null) {
  5199. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5200. }
  5201. };
  5202. /** @hidden */
  5203. Control.prototype._forcePointerUp = function (pointerId) {
  5204. if (pointerId === void 0) { pointerId = null; }
  5205. if (pointerId !== null) {
  5206. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5207. }
  5208. else {
  5209. for (var key in this._downPointerIds) {
  5210. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5211. }
  5212. }
  5213. };
  5214. /** @hidden */
  5215. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5216. if (!this._isEnabled) {
  5217. return false;
  5218. }
  5219. this._dummyVector2.copyFromFloats(x, y);
  5220. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5221. this._onPointerMove(this, this._dummyVector2, pointerId);
  5222. var previousControlOver = this._host._lastControlOver[pointerId];
  5223. if (previousControlOver && previousControlOver !== this) {
  5224. previousControlOver._onPointerOut(this);
  5225. }
  5226. if (previousControlOver !== this) {
  5227. this._onPointerEnter(this);
  5228. }
  5229. this._host._lastControlOver[pointerId] = this;
  5230. return true;
  5231. }
  5232. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5233. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5234. this._host._registerLastControlDown(this, pointerId);
  5235. this._host._lastPickedControl = this;
  5236. return true;
  5237. }
  5238. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5239. if (this._host._lastControlDown[pointerId]) {
  5240. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5241. }
  5242. delete this._host._lastControlDown[pointerId];
  5243. return true;
  5244. }
  5245. return false;
  5246. };
  5247. Control.prototype._prepareFont = function () {
  5248. if (!this._font && !this._fontSet) {
  5249. return;
  5250. }
  5251. if (this._style) {
  5252. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5253. }
  5254. else {
  5255. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5256. }
  5257. this._fontOffset = Control._GetFontOffset(this._font);
  5258. };
  5259. /** Releases associated resources */
  5260. Control.prototype.dispose = function () {
  5261. this.onDirtyObservable.clear();
  5262. this.onBeforeDrawObservable.clear();
  5263. this.onAfterDrawObservable.clear();
  5264. this.onPointerDownObservable.clear();
  5265. this.onPointerEnterObservable.clear();
  5266. this.onPointerMoveObservable.clear();
  5267. this.onPointerOutObservable.clear();
  5268. this.onPointerUpObservable.clear();
  5269. this.onPointerClickObservable.clear();
  5270. if (this._styleObserver && this._style) {
  5271. this._style.onChangedObservable.remove(this._styleObserver);
  5272. this._styleObserver = null;
  5273. }
  5274. if (this.parent) {
  5275. this.parent.removeControl(this);
  5276. this.parent = null;
  5277. }
  5278. if (this._host) {
  5279. var index = this._host._linkedControls.indexOf(this);
  5280. if (index > -1) {
  5281. this.linkWithMesh(null);
  5282. }
  5283. }
  5284. };
  5285. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5286. /** HORIZONTAL_ALIGNMENT_LEFT */
  5287. get: function () {
  5288. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5289. },
  5290. enumerable: true,
  5291. configurable: true
  5292. });
  5293. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5294. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5295. get: function () {
  5296. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5297. },
  5298. enumerable: true,
  5299. configurable: true
  5300. });
  5301. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5302. /** HORIZONTAL_ALIGNMENT_CENTER */
  5303. get: function () {
  5304. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5305. },
  5306. enumerable: true,
  5307. configurable: true
  5308. });
  5309. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5310. /** VERTICAL_ALIGNMENT_TOP */
  5311. get: function () {
  5312. return Control._VERTICAL_ALIGNMENT_TOP;
  5313. },
  5314. enumerable: true,
  5315. configurable: true
  5316. });
  5317. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5318. /** VERTICAL_ALIGNMENT_BOTTOM */
  5319. get: function () {
  5320. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5321. },
  5322. enumerable: true,
  5323. configurable: true
  5324. });
  5325. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5326. /** VERTICAL_ALIGNMENT_CENTER */
  5327. get: function () {
  5328. return Control._VERTICAL_ALIGNMENT_CENTER;
  5329. },
  5330. enumerable: true,
  5331. configurable: true
  5332. });
  5333. /** @hidden */
  5334. Control._GetFontOffset = function (font) {
  5335. if (Control._FontHeightSizes[font]) {
  5336. return Control._FontHeightSizes[font];
  5337. }
  5338. var text = document.createElement("span");
  5339. text.innerHTML = "Hg";
  5340. text.style.font = font;
  5341. var block = document.createElement("div");
  5342. block.style.display = "inline-block";
  5343. block.style.width = "1px";
  5344. block.style.height = "0px";
  5345. block.style.verticalAlign = "bottom";
  5346. var div = document.createElement("div");
  5347. div.appendChild(text);
  5348. div.appendChild(block);
  5349. document.body.appendChild(div);
  5350. var fontAscent = 0;
  5351. var fontHeight = 0;
  5352. try {
  5353. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5354. block.style.verticalAlign = "baseline";
  5355. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5356. }
  5357. finally {
  5358. document.body.removeChild(div);
  5359. }
  5360. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5361. Control._FontHeightSizes[font] = result;
  5362. return result;
  5363. };
  5364. /** @hidden */
  5365. Control.drawEllipse = function (x, y, width, height, context) {
  5366. context.translate(x, y);
  5367. context.scale(width, height);
  5368. context.beginPath();
  5369. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5370. context.closePath();
  5371. context.scale(1 / width, 1 / height);
  5372. context.translate(-x, -y);
  5373. };
  5374. /**
  5375. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5376. */
  5377. Control.AllowAlphaInheritance = false;
  5378. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5379. // Statics
  5380. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5381. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5382. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5383. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5384. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5385. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5386. Control._FontHeightSizes = {};
  5387. /**
  5388. * Creates a stack panel that can be used to render headers
  5389. * @param control defines the control to associate with the header
  5390. * @param text defines the text of the header
  5391. * @param size defines the size of the header
  5392. * @param options defines options used to configure the header
  5393. * @returns a new StackPanel
  5394. * @ignore
  5395. * @hidden
  5396. */
  5397. Control.AddHeader = function () { };
  5398. return Control;
  5399. }());
  5400. /***/ }),
  5401. /***/ "./2D/controls/displayGrid.ts":
  5402. /*!************************************!*\
  5403. !*** ./2D/controls/displayGrid.ts ***!
  5404. \************************************/
  5405. /*! exports provided: DisplayGrid */
  5406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5407. "use strict";
  5408. __webpack_require__.r(__webpack_exports__);
  5409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5410. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5411. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5412. /** Class used to render a grid */
  5413. var DisplayGrid = /** @class */ (function (_super) {
  5414. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5415. /**
  5416. * Creates a new GridDisplayRectangle
  5417. * @param name defines the control name
  5418. */
  5419. function DisplayGrid(name) {
  5420. var _this = _super.call(this, name) || this;
  5421. _this.name = name;
  5422. _this._cellWidth = 20;
  5423. _this._cellHeight = 20;
  5424. _this._minorLineTickness = 1;
  5425. _this._minorLineColor = "DarkGray";
  5426. _this._majorLineTickness = 2;
  5427. _this._majorLineColor = "White";
  5428. _this._majorLineFrequency = 5;
  5429. _this._background = "Black";
  5430. _this._displayMajorLines = true;
  5431. _this._displayMinorLines = true;
  5432. return _this;
  5433. }
  5434. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5435. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5436. get: function () {
  5437. return this._displayMinorLines;
  5438. },
  5439. set: function (value) {
  5440. if (this._displayMinorLines === value) {
  5441. return;
  5442. }
  5443. this._displayMinorLines = value;
  5444. this._markAsDirty();
  5445. },
  5446. enumerable: true,
  5447. configurable: true
  5448. });
  5449. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5450. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5451. get: function () {
  5452. return this._displayMajorLines;
  5453. },
  5454. set: function (value) {
  5455. if (this._displayMajorLines === value) {
  5456. return;
  5457. }
  5458. this._displayMajorLines = value;
  5459. this._markAsDirty();
  5460. },
  5461. enumerable: true,
  5462. configurable: true
  5463. });
  5464. Object.defineProperty(DisplayGrid.prototype, "background", {
  5465. /** Gets or sets background color (Black by default) */
  5466. get: function () {
  5467. return this._background;
  5468. },
  5469. set: function (value) {
  5470. if (this._background === value) {
  5471. return;
  5472. }
  5473. this._background = value;
  5474. this._markAsDirty();
  5475. },
  5476. enumerable: true,
  5477. configurable: true
  5478. });
  5479. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5480. /** Gets or sets the width of each cell (20 by default) */
  5481. get: function () {
  5482. return this._cellWidth;
  5483. },
  5484. set: function (value) {
  5485. this._cellWidth = value;
  5486. this._markAsDirty();
  5487. },
  5488. enumerable: true,
  5489. configurable: true
  5490. });
  5491. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5492. /** Gets or sets the height of each cell (20 by default) */
  5493. get: function () {
  5494. return this._cellHeight;
  5495. },
  5496. set: function (value) {
  5497. this._cellHeight = value;
  5498. this._markAsDirty();
  5499. },
  5500. enumerable: true,
  5501. configurable: true
  5502. });
  5503. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5504. /** Gets or sets the tickness of minor lines (1 by default) */
  5505. get: function () {
  5506. return this._minorLineTickness;
  5507. },
  5508. set: function (value) {
  5509. this._minorLineTickness = value;
  5510. this._markAsDirty();
  5511. },
  5512. enumerable: true,
  5513. configurable: true
  5514. });
  5515. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5516. /** Gets or sets the color of minor lines (DarkGray by default) */
  5517. get: function () {
  5518. return this._minorLineColor;
  5519. },
  5520. set: function (value) {
  5521. this._minorLineColor = value;
  5522. this._markAsDirty();
  5523. },
  5524. enumerable: true,
  5525. configurable: true
  5526. });
  5527. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5528. /** Gets or sets the tickness of major lines (2 by default) */
  5529. get: function () {
  5530. return this._majorLineTickness;
  5531. },
  5532. set: function (value) {
  5533. this._majorLineTickness = value;
  5534. this._markAsDirty();
  5535. },
  5536. enumerable: true,
  5537. configurable: true
  5538. });
  5539. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5540. /** Gets or sets the color of major lines (White by default) */
  5541. get: function () {
  5542. return this._majorLineColor;
  5543. },
  5544. set: function (value) {
  5545. this._majorLineColor = value;
  5546. this._markAsDirty();
  5547. },
  5548. enumerable: true,
  5549. configurable: true
  5550. });
  5551. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5552. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5553. get: function () {
  5554. return this._majorLineFrequency;
  5555. },
  5556. set: function (value) {
  5557. this._majorLineFrequency = value;
  5558. this._markAsDirty();
  5559. },
  5560. enumerable: true,
  5561. configurable: true
  5562. });
  5563. DisplayGrid.prototype._draw = function (context) {
  5564. context.save();
  5565. this._applyStates(context);
  5566. if (this._isEnabled) {
  5567. if (this._background) {
  5568. context.fillStyle = this._background;
  5569. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5570. }
  5571. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5572. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5573. // Minor lines
  5574. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5575. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5576. if (this._displayMinorLines) {
  5577. context.strokeStyle = this._minorLineColor;
  5578. context.lineWidth = this._minorLineTickness;
  5579. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5580. var cellX = left + x * this.cellWidth;
  5581. context.beginPath();
  5582. context.moveTo(cellX, this._currentMeasure.top);
  5583. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5584. context.stroke();
  5585. }
  5586. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5587. var cellY = top_1 + y * this.cellHeight;
  5588. context.beginPath();
  5589. context.moveTo(this._currentMeasure.left, cellY);
  5590. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5591. context.stroke();
  5592. }
  5593. }
  5594. // Major lines
  5595. if (this._displayMajorLines) {
  5596. context.strokeStyle = this._majorLineColor;
  5597. context.lineWidth = this._majorLineTickness;
  5598. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5599. var cellX = left + x * this.cellWidth;
  5600. context.beginPath();
  5601. context.moveTo(cellX, this._currentMeasure.top);
  5602. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5603. context.stroke();
  5604. }
  5605. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5606. var cellY = top_1 + y * this.cellHeight;
  5607. context.moveTo(this._currentMeasure.left, cellY);
  5608. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5609. context.closePath();
  5610. context.stroke();
  5611. }
  5612. }
  5613. }
  5614. context.restore();
  5615. };
  5616. DisplayGrid.prototype._getTypeName = function () {
  5617. return "DisplayGrid";
  5618. };
  5619. return DisplayGrid;
  5620. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5621. /***/ }),
  5622. /***/ "./2D/controls/ellipse.ts":
  5623. /*!********************************!*\
  5624. !*** ./2D/controls/ellipse.ts ***!
  5625. \********************************/
  5626. /*! exports provided: Ellipse */
  5627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5628. "use strict";
  5629. __webpack_require__.r(__webpack_exports__);
  5630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5631. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5632. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5633. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5634. /** Class used to create 2D ellipse containers */
  5635. var Ellipse = /** @class */ (function (_super) {
  5636. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5637. /**
  5638. * Creates a new Ellipse
  5639. * @param name defines the control name
  5640. */
  5641. function Ellipse(name) {
  5642. var _this = _super.call(this, name) || this;
  5643. _this.name = name;
  5644. _this._thickness = 1;
  5645. return _this;
  5646. }
  5647. Object.defineProperty(Ellipse.prototype, "thickness", {
  5648. /** Gets or sets border thickness */
  5649. get: function () {
  5650. return this._thickness;
  5651. },
  5652. set: function (value) {
  5653. if (this._thickness === value) {
  5654. return;
  5655. }
  5656. this._thickness = value;
  5657. this._markAsDirty();
  5658. },
  5659. enumerable: true,
  5660. configurable: true
  5661. });
  5662. Ellipse.prototype._getTypeName = function () {
  5663. return "Ellipse";
  5664. };
  5665. Ellipse.prototype._localDraw = function (context) {
  5666. context.save();
  5667. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5668. context.shadowColor = this.shadowColor;
  5669. context.shadowBlur = this.shadowBlur;
  5670. context.shadowOffsetX = this.shadowOffsetX;
  5671. context.shadowOffsetY = this.shadowOffsetY;
  5672. }
  5673. _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);
  5674. if (this._background) {
  5675. context.fillStyle = this._background;
  5676. context.fill();
  5677. }
  5678. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5679. context.shadowBlur = 0;
  5680. context.shadowOffsetX = 0;
  5681. context.shadowOffsetY = 0;
  5682. }
  5683. if (this._thickness) {
  5684. if (this.color) {
  5685. context.strokeStyle = this.color;
  5686. }
  5687. context.lineWidth = this._thickness;
  5688. context.stroke();
  5689. }
  5690. context.restore();
  5691. };
  5692. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5693. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5694. this._measureForChildren.width -= 2 * this._thickness;
  5695. this._measureForChildren.height -= 2 * this._thickness;
  5696. this._measureForChildren.left += this._thickness;
  5697. this._measureForChildren.top += this._thickness;
  5698. };
  5699. Ellipse.prototype._clipForChildren = function (context) {
  5700. _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);
  5701. context.clip();
  5702. };
  5703. return Ellipse;
  5704. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5705. /***/ }),
  5706. /***/ "./2D/controls/grid.ts":
  5707. /*!*****************************!*\
  5708. !*** ./2D/controls/grid.ts ***!
  5709. \*****************************/
  5710. /*! exports provided: Grid */
  5711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5712. "use strict";
  5713. __webpack_require__.r(__webpack_exports__);
  5714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5715. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5716. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5717. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5718. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5719. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  5720. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5721. /**
  5722. * Class used to create a 2D grid container
  5723. */
  5724. var Grid = /** @class */ (function (_super) {
  5725. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5726. /**
  5727. * Creates a new Grid
  5728. * @param name defines control name
  5729. */
  5730. function Grid(name) {
  5731. var _this = _super.call(this, name) || this;
  5732. _this.name = name;
  5733. _this._rowDefinitions = new Array();
  5734. _this._columnDefinitions = new Array();
  5735. _this._cells = {};
  5736. _this._childControls = new Array();
  5737. return _this;
  5738. }
  5739. Object.defineProperty(Grid.prototype, "columnCount", {
  5740. /**
  5741. * Gets the number of columns
  5742. */
  5743. get: function () {
  5744. return this._columnDefinitions.length;
  5745. },
  5746. enumerable: true,
  5747. configurable: true
  5748. });
  5749. Object.defineProperty(Grid.prototype, "rowCount", {
  5750. /**
  5751. * Gets the number of rows
  5752. */
  5753. get: function () {
  5754. return this._rowDefinitions.length;
  5755. },
  5756. enumerable: true,
  5757. configurable: true
  5758. });
  5759. Object.defineProperty(Grid.prototype, "children", {
  5760. /** Gets the list of children */
  5761. get: function () {
  5762. return this._childControls;
  5763. },
  5764. enumerable: true,
  5765. configurable: true
  5766. });
  5767. Object.defineProperty(Grid.prototype, "cells", {
  5768. /** Gets the list of cells (e.g. the containers) */
  5769. get: function () {
  5770. return this._cells;
  5771. },
  5772. enumerable: true,
  5773. configurable: true
  5774. });
  5775. /**
  5776. * Gets the definition of a specific row
  5777. * @param index defines the index of the row
  5778. * @returns the row definition
  5779. */
  5780. Grid.prototype.getRowDefinition = function (index) {
  5781. if (index < 0 || index >= this._rowDefinitions.length) {
  5782. return null;
  5783. }
  5784. return this._rowDefinitions[index];
  5785. };
  5786. /**
  5787. * Gets the definition of a specific column
  5788. * @param index defines the index of the column
  5789. * @returns the column definition
  5790. */
  5791. Grid.prototype.getColumnDefinition = function (index) {
  5792. if (index < 0 || index >= this._columnDefinitions.length) {
  5793. return null;
  5794. }
  5795. return this._columnDefinitions[index];
  5796. };
  5797. /**
  5798. * Adds a new row to the grid
  5799. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5800. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5801. * @returns the current grid
  5802. */
  5803. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5804. if (isPixel === void 0) { isPixel = false; }
  5805. 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));
  5806. this._markAsDirty();
  5807. return this;
  5808. };
  5809. /**
  5810. * Adds a new column to the grid
  5811. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5812. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5813. * @returns the current grid
  5814. */
  5815. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5816. if (isPixel === void 0) { isPixel = false; }
  5817. 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));
  5818. this._markAsDirty();
  5819. return this;
  5820. };
  5821. /**
  5822. * Update a row definition
  5823. * @param index defines the index of the row to update
  5824. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5825. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5826. * @returns the current grid
  5827. */
  5828. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5829. if (isPixel === void 0) { isPixel = false; }
  5830. if (index < 0 || index >= this._rowDefinitions.length) {
  5831. return this;
  5832. }
  5833. var current = this._rowDefinitions[index];
  5834. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5835. return this;
  5836. }
  5837. 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);
  5838. this._markAsDirty();
  5839. return this;
  5840. };
  5841. /**
  5842. * Update a column definition
  5843. * @param index defines the index of the column to update
  5844. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5845. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5846. * @returns the current grid
  5847. */
  5848. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5849. if (isPixel === void 0) { isPixel = false; }
  5850. if (index < 0 || index >= this._columnDefinitions.length) {
  5851. return this;
  5852. }
  5853. var current = this._columnDefinitions[index];
  5854. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5855. return this;
  5856. }
  5857. 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);
  5858. this._markAsDirty();
  5859. return this;
  5860. };
  5861. /**
  5862. * Gets the list of children stored in a specific cell
  5863. * @param row defines the row to check
  5864. * @param column defines the column to check
  5865. * @returns the list of controls
  5866. */
  5867. Grid.prototype.getChildrenAt = function (row, column) {
  5868. var cell = this._cells[row + ":" + column];
  5869. if (!cell) {
  5870. return null;
  5871. }
  5872. return cell.children;
  5873. };
  5874. /**
  5875. * Gets a string representing the child cell info (row x column)
  5876. * @param child defines the control to get info from
  5877. * @returns a string containing the child cell info (row x column)
  5878. */
  5879. Grid.prototype.getChildCellInfo = function (child) {
  5880. return child._tag;
  5881. };
  5882. Grid.prototype._removeCell = function (cell, key) {
  5883. if (!cell) {
  5884. return;
  5885. }
  5886. _super.prototype.removeControl.call(this, cell);
  5887. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5888. var control = _a[_i];
  5889. var childIndex = this._childControls.indexOf(control);
  5890. if (childIndex !== -1) {
  5891. this._childControls.splice(childIndex, 1);
  5892. }
  5893. }
  5894. delete this._cells[key];
  5895. };
  5896. Grid.prototype._offsetCell = function (previousKey, key) {
  5897. if (!this._cells[key]) {
  5898. return;
  5899. }
  5900. this._cells[previousKey] = this._cells[key];
  5901. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5902. var control = _a[_i];
  5903. control._tag = previousKey;
  5904. }
  5905. delete this._cells[key];
  5906. };
  5907. /**
  5908. * Remove a column definition at specified index
  5909. * @param index defines the index of the column to remove
  5910. * @returns the current grid
  5911. */
  5912. Grid.prototype.removeColumnDefinition = function (index) {
  5913. if (index < 0 || index >= this._columnDefinitions.length) {
  5914. return this;
  5915. }
  5916. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5917. var key = x + ":" + index;
  5918. var cell = this._cells[key];
  5919. this._removeCell(cell, key);
  5920. }
  5921. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5922. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5923. var previousKey = x + ":" + (y - 1);
  5924. var key = x + ":" + y;
  5925. this._offsetCell(previousKey, key);
  5926. }
  5927. }
  5928. this._columnDefinitions.splice(index, 1);
  5929. this._markAsDirty();
  5930. return this;
  5931. };
  5932. /**
  5933. * Remove a row definition at specified index
  5934. * @param index defines the index of the row to remove
  5935. * @returns the current grid
  5936. */
  5937. Grid.prototype.removeRowDefinition = function (index) {
  5938. if (index < 0 || index >= this._rowDefinitions.length) {
  5939. return this;
  5940. }
  5941. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5942. var key = index + ":" + y;
  5943. var cell = this._cells[key];
  5944. this._removeCell(cell, key);
  5945. }
  5946. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5947. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5948. var previousKey = x - 1 + ":" + y;
  5949. var key = x + ":" + y;
  5950. this._offsetCell(previousKey, key);
  5951. }
  5952. }
  5953. this._rowDefinitions.splice(index, 1);
  5954. this._markAsDirty();
  5955. return this;
  5956. };
  5957. /**
  5958. * Adds a new control to the current grid
  5959. * @param control defines the control to add
  5960. * @param row defines the row where to add the control (0 by default)
  5961. * @param column defines the column where to add the control (0 by default)
  5962. * @returns the current grid
  5963. */
  5964. Grid.prototype.addControl = function (control, row, column) {
  5965. if (row === void 0) { row = 0; }
  5966. if (column === void 0) { column = 0; }
  5967. if (this._rowDefinitions.length === 0) {
  5968. // Add default row definition
  5969. this.addRowDefinition(1, false);
  5970. }
  5971. if (this._columnDefinitions.length === 0) {
  5972. // Add default column definition
  5973. this.addColumnDefinition(1, false);
  5974. }
  5975. if (this._childControls.indexOf(control) !== -1) {
  5976. 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");
  5977. return this;
  5978. }
  5979. var x = Math.min(row, this._rowDefinitions.length - 1);
  5980. var y = Math.min(column, this._columnDefinitions.length - 1);
  5981. var key = x + ":" + y;
  5982. var goodContainer = this._cells[key];
  5983. if (!goodContainer) {
  5984. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5985. this._cells[key] = goodContainer;
  5986. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5987. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5988. _super.prototype.addControl.call(this, goodContainer);
  5989. }
  5990. goodContainer.addControl(control);
  5991. this._childControls.push(control);
  5992. control._tag = key;
  5993. control.parent = this;
  5994. this._markAsDirty();
  5995. return this;
  5996. };
  5997. /**
  5998. * Removes a control from the current container
  5999. * @param control defines the control to remove
  6000. * @returns the current container
  6001. */
  6002. Grid.prototype.removeControl = function (control) {
  6003. var index = this._childControls.indexOf(control);
  6004. if (index !== -1) {
  6005. this._childControls.splice(index, 1);
  6006. }
  6007. var cell = this._cells[control._tag];
  6008. if (cell) {
  6009. cell.removeControl(control);
  6010. control._tag = null;
  6011. }
  6012. this._markAsDirty();
  6013. return this;
  6014. };
  6015. Grid.prototype._getTypeName = function () {
  6016. return "Grid";
  6017. };
  6018. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6019. var widths = [];
  6020. var heights = [];
  6021. var lefts = [];
  6022. var tops = [];
  6023. var availableWidth = this._currentMeasure.width;
  6024. var globalWidthPercentage = 0;
  6025. var availableHeight = this._currentMeasure.height;
  6026. var globalHeightPercentage = 0;
  6027. // Heights
  6028. var index = 0;
  6029. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6030. var value = _a[_i];
  6031. if (value.isPixel) {
  6032. var height = value.getValue(this._host);
  6033. availableHeight -= height;
  6034. heights[index] = height;
  6035. }
  6036. else {
  6037. globalHeightPercentage += value.internalValue;
  6038. }
  6039. index++;
  6040. }
  6041. var top = 0;
  6042. index = 0;
  6043. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6044. var value = _c[_b];
  6045. tops.push(top);
  6046. if (!value.isPixel) {
  6047. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6048. top += height;
  6049. heights[index] = height;
  6050. }
  6051. else {
  6052. top += value.getValue(this._host);
  6053. }
  6054. index++;
  6055. }
  6056. // Widths
  6057. index = 0;
  6058. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6059. var value = _e[_d];
  6060. if (value.isPixel) {
  6061. var width = value.getValue(this._host);
  6062. availableWidth -= width;
  6063. widths[index] = width;
  6064. }
  6065. else {
  6066. globalWidthPercentage += value.internalValue;
  6067. }
  6068. index++;
  6069. }
  6070. var left = 0;
  6071. index = 0;
  6072. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6073. var value = _g[_f];
  6074. lefts.push(left);
  6075. if (!value.isPixel) {
  6076. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6077. left += width;
  6078. widths[index] = width;
  6079. }
  6080. else {
  6081. left += value.getValue(this._host);
  6082. }
  6083. index++;
  6084. }
  6085. definitionCallback(lefts, tops, widths, heights);
  6086. };
  6087. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6088. var _this = this;
  6089. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6090. // Setting child sizes
  6091. for (var key in _this._cells) {
  6092. if (!_this._cells.hasOwnProperty(key)) {
  6093. continue;
  6094. }
  6095. var split = key.split(":");
  6096. var x = parseInt(split[0]);
  6097. var y = parseInt(split[1]);
  6098. var cell = _this._cells[key];
  6099. cell.left = lefts[y] + "px";
  6100. cell.top = tops[x] + "px";
  6101. cell.width = widths[y] + "px";
  6102. cell.height = heights[x] + "px";
  6103. cell._left.ignoreAdaptiveScaling = true;
  6104. cell._top.ignoreAdaptiveScaling = true;
  6105. cell._width.ignoreAdaptiveScaling = true;
  6106. cell._height.ignoreAdaptiveScaling = true;
  6107. }
  6108. });
  6109. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6110. };
  6111. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6112. for (var key in this._cells) {
  6113. if (!this._cells.hasOwnProperty(key)) {
  6114. continue;
  6115. }
  6116. var child = this._cells[key];
  6117. child._markMatrixAsDirty();
  6118. }
  6119. };
  6120. Grid.prototype._renderHighlightSpecific = function (context) {
  6121. var _this = this;
  6122. _super.prototype._renderHighlightSpecific.call(this, context);
  6123. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6124. // Columns
  6125. for (var index = 0; index < lefts.length; index++) {
  6126. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6127. context.beginPath();
  6128. context.moveTo(left, _this._currentMeasure.top);
  6129. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6130. context.stroke();
  6131. }
  6132. // Rows
  6133. for (var index = 0; index < tops.length; index++) {
  6134. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6135. context.beginPath();
  6136. context.moveTo(_this._currentMeasure.left, top_1);
  6137. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6138. context.stroke();
  6139. }
  6140. });
  6141. context.restore();
  6142. };
  6143. /** Releases associated resources */
  6144. Grid.prototype.dispose = function () {
  6145. _super.prototype.dispose.call(this);
  6146. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6147. var control = _a[_i];
  6148. control.dispose();
  6149. }
  6150. this._childControls = [];
  6151. };
  6152. return Grid;
  6153. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6154. /***/ }),
  6155. /***/ "./2D/controls/image.ts":
  6156. /*!******************************!*\
  6157. !*** ./2D/controls/image.ts ***!
  6158. \******************************/
  6159. /*! exports provided: Image */
  6160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6161. "use strict";
  6162. __webpack_require__.r(__webpack_exports__);
  6163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6164. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6165. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  6166. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6167. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6168. /**
  6169. * Class used to create 2D images
  6170. */
  6171. var Image = /** @class */ (function (_super) {
  6172. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6173. /**
  6174. * Creates a new Image
  6175. * @param name defines the control name
  6176. * @param url defines the image url
  6177. */
  6178. function Image(name, url) {
  6179. if (url === void 0) { url = null; }
  6180. var _this = _super.call(this, name) || this;
  6181. _this.name = name;
  6182. _this._loaded = false;
  6183. _this._stretch = Image.STRETCH_FILL;
  6184. _this._autoScale = false;
  6185. _this._sourceLeft = 0;
  6186. _this._sourceTop = 0;
  6187. _this._sourceWidth = 0;
  6188. _this._sourceHeight = 0;
  6189. _this._cellWidth = 0;
  6190. _this._cellHeight = 0;
  6191. _this._cellId = -1;
  6192. _this._populateNinePatchSlicesFromImage = false;
  6193. /**
  6194. * Observable notified when the content is loaded
  6195. */
  6196. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6197. _this.source = url;
  6198. return _this;
  6199. }
  6200. Object.defineProperty(Image.prototype, "isLoaded", {
  6201. /**
  6202. * Gets a boolean indicating that the content is loaded
  6203. */
  6204. get: function () {
  6205. return this._loaded;
  6206. },
  6207. enumerable: true,
  6208. configurable: true
  6209. });
  6210. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6211. /**
  6212. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6213. */
  6214. get: function () {
  6215. return this._populateNinePatchSlicesFromImage;
  6216. },
  6217. set: function (value) {
  6218. if (this._populateNinePatchSlicesFromImage === value) {
  6219. return;
  6220. }
  6221. this._populateNinePatchSlicesFromImage = value;
  6222. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6223. this._extractNinePatchSliceDataFromImage();
  6224. }
  6225. },
  6226. enumerable: true,
  6227. configurable: true
  6228. });
  6229. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6230. /**
  6231. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6232. * Beware using this as this will comsume more memory as the image has to be stored twice
  6233. */
  6234. get: function () {
  6235. return this._detectPointerOnOpaqueOnly;
  6236. },
  6237. set: function (value) {
  6238. if (this._detectPointerOnOpaqueOnly === value) {
  6239. return;
  6240. }
  6241. this._detectPointerOnOpaqueOnly = value;
  6242. },
  6243. enumerable: true,
  6244. configurable: true
  6245. });
  6246. Object.defineProperty(Image.prototype, "sliceLeft", {
  6247. /**
  6248. * Gets or sets the left value for slicing (9-patch)
  6249. */
  6250. get: function () {
  6251. return this._sliceLeft;
  6252. },
  6253. set: function (value) {
  6254. if (this._sliceLeft === value) {
  6255. return;
  6256. }
  6257. this._sliceLeft = value;
  6258. this._markAsDirty();
  6259. },
  6260. enumerable: true,
  6261. configurable: true
  6262. });
  6263. Object.defineProperty(Image.prototype, "sliceRight", {
  6264. /**
  6265. * Gets or sets the right value for slicing (9-patch)
  6266. */
  6267. get: function () {
  6268. return this._sliceRight;
  6269. },
  6270. set: function (value) {
  6271. if (this._sliceRight === value) {
  6272. return;
  6273. }
  6274. this._sliceRight = value;
  6275. this._markAsDirty();
  6276. },
  6277. enumerable: true,
  6278. configurable: true
  6279. });
  6280. Object.defineProperty(Image.prototype, "sliceTop", {
  6281. /**
  6282. * Gets or sets the top value for slicing (9-patch)
  6283. */
  6284. get: function () {
  6285. return this._sliceTop;
  6286. },
  6287. set: function (value) {
  6288. if (this._sliceTop === value) {
  6289. return;
  6290. }
  6291. this._sliceTop = value;
  6292. this._markAsDirty();
  6293. },
  6294. enumerable: true,
  6295. configurable: true
  6296. });
  6297. Object.defineProperty(Image.prototype, "sliceBottom", {
  6298. /**
  6299. * Gets or sets the bottom value for slicing (9-patch)
  6300. */
  6301. get: function () {
  6302. return this._sliceBottom;
  6303. },
  6304. set: function (value) {
  6305. if (this._sliceBottom === value) {
  6306. return;
  6307. }
  6308. this._sliceBottom = value;
  6309. this._markAsDirty();
  6310. },
  6311. enumerable: true,
  6312. configurable: true
  6313. });
  6314. Object.defineProperty(Image.prototype, "sourceLeft", {
  6315. /**
  6316. * Gets or sets the left coordinate in the source image
  6317. */
  6318. get: function () {
  6319. return this._sourceLeft;
  6320. },
  6321. set: function (value) {
  6322. if (this._sourceLeft === value) {
  6323. return;
  6324. }
  6325. this._sourceLeft = value;
  6326. this._markAsDirty();
  6327. },
  6328. enumerable: true,
  6329. configurable: true
  6330. });
  6331. Object.defineProperty(Image.prototype, "sourceTop", {
  6332. /**
  6333. * Gets or sets the top coordinate in the source image
  6334. */
  6335. get: function () {
  6336. return this._sourceTop;
  6337. },
  6338. set: function (value) {
  6339. if (this._sourceTop === value) {
  6340. return;
  6341. }
  6342. this._sourceTop = value;
  6343. this._markAsDirty();
  6344. },
  6345. enumerable: true,
  6346. configurable: true
  6347. });
  6348. Object.defineProperty(Image.prototype, "sourceWidth", {
  6349. /**
  6350. * Gets or sets the width to capture in the source image
  6351. */
  6352. get: function () {
  6353. return this._sourceWidth;
  6354. },
  6355. set: function (value) {
  6356. if (this._sourceWidth === value) {
  6357. return;
  6358. }
  6359. this._sourceWidth = value;
  6360. this._markAsDirty();
  6361. },
  6362. enumerable: true,
  6363. configurable: true
  6364. });
  6365. Object.defineProperty(Image.prototype, "sourceHeight", {
  6366. /**
  6367. * Gets or sets the height to capture in the source image
  6368. */
  6369. get: function () {
  6370. return this._sourceHeight;
  6371. },
  6372. set: function (value) {
  6373. if (this._sourceHeight === value) {
  6374. return;
  6375. }
  6376. this._sourceHeight = value;
  6377. this._markAsDirty();
  6378. },
  6379. enumerable: true,
  6380. configurable: true
  6381. });
  6382. Object.defineProperty(Image.prototype, "autoScale", {
  6383. /**
  6384. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6385. * @see http://doc.babylonjs.com/how_to/gui#image
  6386. */
  6387. get: function () {
  6388. return this._autoScale;
  6389. },
  6390. set: function (value) {
  6391. if (this._autoScale === value) {
  6392. return;
  6393. }
  6394. this._autoScale = value;
  6395. if (value && this._loaded) {
  6396. this.synchronizeSizeWithContent();
  6397. }
  6398. },
  6399. enumerable: true,
  6400. configurable: true
  6401. });
  6402. Object.defineProperty(Image.prototype, "stretch", {
  6403. /** Gets or sets the streching mode used by the image */
  6404. get: function () {
  6405. return this._stretch;
  6406. },
  6407. set: function (value) {
  6408. if (this._stretch === value) {
  6409. return;
  6410. }
  6411. this._stretch = value;
  6412. this._markAsDirty();
  6413. },
  6414. enumerable: true,
  6415. configurable: true
  6416. });
  6417. Object.defineProperty(Image.prototype, "domImage", {
  6418. get: function () {
  6419. return this._domImage;
  6420. },
  6421. /**
  6422. * Gets or sets the internal DOM image used to render the control
  6423. */
  6424. set: function (value) {
  6425. var _this = this;
  6426. this._domImage = value;
  6427. this._loaded = false;
  6428. if (this._domImage.width) {
  6429. this._onImageLoaded();
  6430. }
  6431. else {
  6432. this._domImage.onload = function () {
  6433. _this._onImageLoaded();
  6434. };
  6435. }
  6436. },
  6437. enumerable: true,
  6438. configurable: true
  6439. });
  6440. Image.prototype._onImageLoaded = function () {
  6441. this._imageWidth = this._domImage.width;
  6442. this._imageHeight = this._domImage.height;
  6443. this._loaded = true;
  6444. if (this._populateNinePatchSlicesFromImage) {
  6445. this._extractNinePatchSliceDataFromImage();
  6446. }
  6447. if (this._autoScale) {
  6448. this.synchronizeSizeWithContent();
  6449. }
  6450. this.onImageLoadedObservable.notifyObservers(this);
  6451. this._markAsDirty();
  6452. };
  6453. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6454. if (!Image._WorkingCanvas) {
  6455. Image._WorkingCanvas = document.createElement('canvas');
  6456. }
  6457. var canvas = Image._WorkingCanvas;
  6458. var context = canvas.getContext('2d');
  6459. var width = this._domImage.width;
  6460. var height = this._domImage.height;
  6461. canvas.width = width;
  6462. canvas.height = height;
  6463. context.drawImage(this._domImage, 0, 0, width, height);
  6464. var imageData = context.getImageData(0, 0, width, height);
  6465. // Left and right
  6466. this._sliceLeft = -1;
  6467. this._sliceRight = -1;
  6468. for (var x = 0; x < width; x++) {
  6469. var alpha = imageData.data[x * 4 + 3];
  6470. if (alpha > 127 && this._sliceLeft === -1) {
  6471. this._sliceLeft = x;
  6472. continue;
  6473. }
  6474. if (alpha < 127 && this._sliceLeft > -1) {
  6475. this._sliceRight = x;
  6476. break;
  6477. }
  6478. }
  6479. // top and bottom
  6480. this._sliceTop = -1;
  6481. this._sliceBottom = -1;
  6482. for (var y = 0; y < height; y++) {
  6483. var alpha = imageData.data[y * width * 4 + 3];
  6484. if (alpha > 127 && this._sliceTop === -1) {
  6485. this._sliceTop = y;
  6486. continue;
  6487. }
  6488. if (alpha < 127 && this._sliceTop > -1) {
  6489. this._sliceBottom = y;
  6490. break;
  6491. }
  6492. }
  6493. };
  6494. Object.defineProperty(Image.prototype, "source", {
  6495. /**
  6496. * Gets or sets image source url
  6497. */
  6498. set: function (value) {
  6499. var _this = this;
  6500. if (this._source === value) {
  6501. return;
  6502. }
  6503. this._loaded = false;
  6504. this._source = value;
  6505. this._domImage = document.createElement("img");
  6506. this._domImage.onload = function () {
  6507. _this._onImageLoaded();
  6508. };
  6509. if (value) {
  6510. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6511. this._domImage.src = value;
  6512. }
  6513. },
  6514. enumerable: true,
  6515. configurable: true
  6516. });
  6517. Object.defineProperty(Image.prototype, "cellWidth", {
  6518. /**
  6519. * Gets or sets the cell width to use when animation sheet is enabled
  6520. * @see http://doc.babylonjs.com/how_to/gui#image
  6521. */
  6522. get: function () {
  6523. return this._cellWidth;
  6524. },
  6525. set: function (value) {
  6526. if (this._cellWidth === value) {
  6527. return;
  6528. }
  6529. this._cellWidth = value;
  6530. this._markAsDirty();
  6531. },
  6532. enumerable: true,
  6533. configurable: true
  6534. });
  6535. Object.defineProperty(Image.prototype, "cellHeight", {
  6536. /**
  6537. * Gets or sets the cell height to use when animation sheet is enabled
  6538. * @see http://doc.babylonjs.com/how_to/gui#image
  6539. */
  6540. get: function () {
  6541. return this._cellHeight;
  6542. },
  6543. set: function (value) {
  6544. if (this._cellHeight === value) {
  6545. return;
  6546. }
  6547. this._cellHeight = value;
  6548. this._markAsDirty();
  6549. },
  6550. enumerable: true,
  6551. configurable: true
  6552. });
  6553. Object.defineProperty(Image.prototype, "cellId", {
  6554. /**
  6555. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6556. * @see http://doc.babylonjs.com/how_to/gui#image
  6557. */
  6558. get: function () {
  6559. return this._cellId;
  6560. },
  6561. set: function (value) {
  6562. if (this._cellId === value) {
  6563. return;
  6564. }
  6565. this._cellId = value;
  6566. this._markAsDirty();
  6567. },
  6568. enumerable: true,
  6569. configurable: true
  6570. });
  6571. /**
  6572. * Tests if a given coordinates belong to the current control
  6573. * @param x defines x coordinate to test
  6574. * @param y defines y coordinate to test
  6575. * @returns true if the coordinates are inside the control
  6576. */
  6577. Image.prototype.contains = function (x, y) {
  6578. if (!_super.prototype.contains.call(this, x, y)) {
  6579. return false;
  6580. }
  6581. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6582. return true;
  6583. }
  6584. var canvas = Image._WorkingCanvas;
  6585. var context = canvas.getContext("2d");
  6586. var width = this._currentMeasure.width | 0;
  6587. var height = this._currentMeasure.height | 0;
  6588. var imageData = context.getImageData(0, 0, width, height).data;
  6589. x = (x - this._currentMeasure.left) | 0;
  6590. y = (y - this._currentMeasure.top) | 0;
  6591. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6592. return pickedPixel > 0;
  6593. };
  6594. Image.prototype._getTypeName = function () {
  6595. return "Image";
  6596. };
  6597. /** Force the control to synchronize with its content */
  6598. Image.prototype.synchronizeSizeWithContent = function () {
  6599. if (!this._loaded) {
  6600. return;
  6601. }
  6602. this.width = this._domImage.width + "px";
  6603. this.height = this._domImage.height + "px";
  6604. };
  6605. Image.prototype._processMeasures = function (parentMeasure, context) {
  6606. if (this._loaded) {
  6607. switch (this._stretch) {
  6608. case Image.STRETCH_NONE:
  6609. break;
  6610. case Image.STRETCH_FILL:
  6611. break;
  6612. case Image.STRETCH_UNIFORM:
  6613. break;
  6614. case Image.STRETCH_NINE_PATCH:
  6615. break;
  6616. case Image.STRETCH_EXTEND:
  6617. if (this._autoScale) {
  6618. this.synchronizeSizeWithContent();
  6619. }
  6620. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6621. this.parent.adaptWidthToChildren = true;
  6622. this.parent.adaptHeightToChildren = true;
  6623. }
  6624. break;
  6625. }
  6626. }
  6627. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6628. };
  6629. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6630. if (!this._detectPointerOnOpaqueOnly) {
  6631. return;
  6632. }
  6633. if (!Image._WorkingCanvas) {
  6634. Image._WorkingCanvas = document.createElement('canvas');
  6635. }
  6636. var canvas = Image._WorkingCanvas;
  6637. var width = this._currentMeasure.width;
  6638. var height = this._currentMeasure.height;
  6639. var context = canvas.getContext("2d");
  6640. canvas.width = width;
  6641. canvas.height = height;
  6642. context.clearRect(0, 0, width, height);
  6643. };
  6644. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6645. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6646. if (!this._detectPointerOnOpaqueOnly) {
  6647. return;
  6648. }
  6649. var canvas = Image._WorkingCanvas;
  6650. context = canvas.getContext("2d");
  6651. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6652. };
  6653. Image.prototype._draw = function (context) {
  6654. context.save();
  6655. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6656. context.shadowColor = this.shadowColor;
  6657. context.shadowBlur = this.shadowBlur;
  6658. context.shadowOffsetX = this.shadowOffsetX;
  6659. context.shadowOffsetY = this.shadowOffsetY;
  6660. }
  6661. var x, y, width, height;
  6662. if (this.cellId == -1) {
  6663. x = this._sourceLeft;
  6664. y = this._sourceTop;
  6665. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6666. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6667. }
  6668. else {
  6669. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6670. var column = (this.cellId / rowCount) >> 0;
  6671. var row = this.cellId % rowCount;
  6672. x = this.cellWidth * row;
  6673. y = this.cellHeight * column;
  6674. width = this.cellWidth;
  6675. height = this.cellHeight;
  6676. }
  6677. this._prepareWorkingCanvasForOpaqueDetection();
  6678. this._applyStates(context);
  6679. if (this._loaded) {
  6680. switch (this._stretch) {
  6681. case Image.STRETCH_NONE:
  6682. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6683. break;
  6684. case Image.STRETCH_FILL:
  6685. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6686. break;
  6687. case Image.STRETCH_UNIFORM:
  6688. var hRatio = this._currentMeasure.width / width;
  6689. var vRatio = this._currentMeasure.height / height;
  6690. var ratio = Math.min(hRatio, vRatio);
  6691. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6692. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6693. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6694. break;
  6695. case Image.STRETCH_EXTEND:
  6696. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6697. break;
  6698. case Image.STRETCH_NINE_PATCH:
  6699. this._renderNinePatch(context);
  6700. break;
  6701. }
  6702. }
  6703. context.restore();
  6704. };
  6705. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6706. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6707. };
  6708. Image.prototype._renderNinePatch = function (context) {
  6709. var height = this._imageHeight;
  6710. var leftWidth = this._sliceLeft;
  6711. var topHeight = this._sliceTop;
  6712. var bottomHeight = this._imageHeight - this._sliceBottom;
  6713. var rightWidth = this._imageWidth - this._sliceRight;
  6714. var left = 0;
  6715. var top = 0;
  6716. if (this._populateNinePatchSlicesFromImage) {
  6717. left = 1;
  6718. top = 1;
  6719. height -= 2;
  6720. leftWidth -= 1;
  6721. topHeight -= 1;
  6722. bottomHeight -= 1;
  6723. rightWidth -= 1;
  6724. }
  6725. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6726. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6727. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6728. // Corners
  6729. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6730. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6731. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6732. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6733. // Center
  6734. 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);
  6735. // Borders
  6736. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6737. 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);
  6738. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6739. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6740. };
  6741. Image.prototype.dispose = function () {
  6742. _super.prototype.dispose.call(this);
  6743. this.onImageLoadedObservable.clear();
  6744. };
  6745. Image._WorkingCanvas = null;
  6746. // Static
  6747. /** STRETCH_NONE */
  6748. Image.STRETCH_NONE = 0;
  6749. /** STRETCH_FILL */
  6750. Image.STRETCH_FILL = 1;
  6751. /** STRETCH_UNIFORM */
  6752. Image.STRETCH_UNIFORM = 2;
  6753. /** STRETCH_EXTEND */
  6754. Image.STRETCH_EXTEND = 3;
  6755. /** NINE_PATCH */
  6756. Image.STRETCH_NINE_PATCH = 4;
  6757. return Image;
  6758. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6759. /***/ }),
  6760. /***/ "./2D/controls/index.ts":
  6761. /*!******************************!*\
  6762. !*** ./2D/controls/index.ts ***!
  6763. \******************************/
  6764. /*! 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 */
  6765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6766. "use strict";
  6767. __webpack_require__.r(__webpack_exports__);
  6768. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6770. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6772. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6774. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6776. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6778. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6780. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6782. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6784. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6786. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6788. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6790. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6792. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6794. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6796. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6802. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6804. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6807. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6810. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6812. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6814. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6816. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6818. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6820. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6822. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6824. /***/ }),
  6825. /***/ "./2D/controls/inputPassword.ts":
  6826. /*!**************************************!*\
  6827. !*** ./2D/controls/inputPassword.ts ***!
  6828. \**************************************/
  6829. /*! exports provided: InputPassword */
  6830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6831. "use strict";
  6832. __webpack_require__.r(__webpack_exports__);
  6833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6834. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6835. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6836. /**
  6837. * Class used to create a password control
  6838. */
  6839. var InputPassword = /** @class */ (function (_super) {
  6840. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6841. function InputPassword() {
  6842. return _super !== null && _super.apply(this, arguments) || this;
  6843. }
  6844. InputPassword.prototype._beforeRenderText = function (text) {
  6845. var txt = "";
  6846. for (var i = 0; i < text.length; i++) {
  6847. txt += "\u2022";
  6848. }
  6849. return txt;
  6850. };
  6851. return InputPassword;
  6852. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6853. /***/ }),
  6854. /***/ "./2D/controls/inputText.ts":
  6855. /*!**********************************!*\
  6856. !*** ./2D/controls/inputText.ts ***!
  6857. \**********************************/
  6858. /*! exports provided: InputText */
  6859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6860. "use strict";
  6861. __webpack_require__.r(__webpack_exports__);
  6862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6863. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6864. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  6865. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6866. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6867. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6868. /**
  6869. * Class used to create input text control
  6870. */
  6871. var InputText = /** @class */ (function (_super) {
  6872. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6873. /**
  6874. * Creates a new InputText
  6875. * @param name defines the control name
  6876. * @param text defines the text of the control
  6877. */
  6878. function InputText(name, text) {
  6879. if (text === void 0) { text = ""; }
  6880. var _this = _super.call(this, name) || this;
  6881. _this.name = name;
  6882. _this._text = "";
  6883. _this._placeholderText = "";
  6884. _this._background = "#222222";
  6885. _this._focusedBackground = "#000000";
  6886. _this._focusedColor = "white";
  6887. _this._placeholderColor = "gray";
  6888. _this._thickness = 1;
  6889. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6890. _this._autoStretchWidth = true;
  6891. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6892. _this._isFocused = false;
  6893. _this._blinkIsEven = false;
  6894. _this._cursorOffset = 0;
  6895. _this._deadKey = false;
  6896. _this._addKey = true;
  6897. _this._currentKey = "";
  6898. _this._isTextHighlightOn = false;
  6899. _this._textHighlightColor = "#d5e0ff";
  6900. _this._highligherOpacity = 0.4;
  6901. _this._highlightedText = "";
  6902. _this._startHighlightIndex = 0;
  6903. _this._endHighlightIndex = 0;
  6904. _this._cursorIndex = -1;
  6905. _this._onFocusSelectAll = false;
  6906. _this._isPointerDown = false;
  6907. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6908. _this.promptMessage = "Please enter text:";
  6909. /** Observable raised when the text changes */
  6910. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6911. /** Observable raised just before an entered character is to be added */
  6912. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6913. /** Observable raised when the control gets the focus */
  6914. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6915. /** Observable raised when the control loses the focus */
  6916. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6917. /**Observable raised when the text is highlighted */
  6918. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6919. /**Observable raised when copy event is triggered */
  6920. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6921. /** Observable raised when cut event is triggered */
  6922. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6923. /** Observable raised when paste event is triggered */
  6924. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6925. /** Observable raised when a key event was processed */
  6926. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6927. _this.text = text;
  6928. _this.isPointerBlocker = true;
  6929. return _this;
  6930. }
  6931. Object.defineProperty(InputText.prototype, "maxWidth", {
  6932. /** Gets or sets the maximum width allowed by the control */
  6933. get: function () {
  6934. return this._maxWidth.toString(this._host);
  6935. },
  6936. set: function (value) {
  6937. if (this._maxWidth.toString(this._host) === value) {
  6938. return;
  6939. }
  6940. if (this._maxWidth.fromString(value)) {
  6941. this._markAsDirty();
  6942. }
  6943. },
  6944. enumerable: true,
  6945. configurable: true
  6946. });
  6947. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6948. /** Gets the maximum width allowed by the control in pixels */
  6949. get: function () {
  6950. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6951. },
  6952. enumerable: true,
  6953. configurable: true
  6954. });
  6955. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6956. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6957. get: function () {
  6958. return this._highligherOpacity;
  6959. },
  6960. set: function (value) {
  6961. if (this._highligherOpacity === value) {
  6962. return;
  6963. }
  6964. this._highligherOpacity = value;
  6965. this._markAsDirty();
  6966. },
  6967. enumerable: true,
  6968. configurable: true
  6969. });
  6970. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6971. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6972. get: function () {
  6973. return this._onFocusSelectAll;
  6974. },
  6975. set: function (value) {
  6976. if (this._onFocusSelectAll === value) {
  6977. return;
  6978. }
  6979. this._onFocusSelectAll = value;
  6980. this._markAsDirty();
  6981. },
  6982. enumerable: true,
  6983. configurable: true
  6984. });
  6985. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6986. /** Gets or sets the text hightlight color */
  6987. get: function () {
  6988. return this._textHighlightColor;
  6989. },
  6990. set: function (value) {
  6991. if (this._textHighlightColor === value) {
  6992. return;
  6993. }
  6994. this._textHighlightColor = value;
  6995. this._markAsDirty();
  6996. },
  6997. enumerable: true,
  6998. configurable: true
  6999. });
  7000. Object.defineProperty(InputText.prototype, "margin", {
  7001. /** Gets or sets control margin */
  7002. get: function () {
  7003. return this._margin.toString(this._host);
  7004. },
  7005. set: function (value) {
  7006. if (this._margin.toString(this._host) === value) {
  7007. return;
  7008. }
  7009. if (this._margin.fromString(value)) {
  7010. this._markAsDirty();
  7011. }
  7012. },
  7013. enumerable: true,
  7014. configurable: true
  7015. });
  7016. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7017. /** Gets control margin in pixels */
  7018. get: function () {
  7019. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7020. },
  7021. enumerable: true,
  7022. configurable: true
  7023. });
  7024. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7025. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7026. get: function () {
  7027. return this._autoStretchWidth;
  7028. },
  7029. set: function (value) {
  7030. if (this._autoStretchWidth === value) {
  7031. return;
  7032. }
  7033. this._autoStretchWidth = value;
  7034. this._markAsDirty();
  7035. },
  7036. enumerable: true,
  7037. configurable: true
  7038. });
  7039. Object.defineProperty(InputText.prototype, "thickness", {
  7040. /** Gets or sets border thickness */
  7041. get: function () {
  7042. return this._thickness;
  7043. },
  7044. set: function (value) {
  7045. if (this._thickness === value) {
  7046. return;
  7047. }
  7048. this._thickness = value;
  7049. this._markAsDirty();
  7050. },
  7051. enumerable: true,
  7052. configurable: true
  7053. });
  7054. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7055. /** Gets or sets the background color when focused */
  7056. get: function () {
  7057. return this._focusedBackground;
  7058. },
  7059. set: function (value) {
  7060. if (this._focusedBackground === value) {
  7061. return;
  7062. }
  7063. this._focusedBackground = value;
  7064. this._markAsDirty();
  7065. },
  7066. enumerable: true,
  7067. configurable: true
  7068. });
  7069. Object.defineProperty(InputText.prototype, "focusedColor", {
  7070. /** Gets or sets the background color when focused */
  7071. get: function () {
  7072. return this._focusedColor;
  7073. },
  7074. set: function (value) {
  7075. if (this._focusedColor === value) {
  7076. return;
  7077. }
  7078. this._focusedColor = value;
  7079. this._markAsDirty();
  7080. },
  7081. enumerable: true,
  7082. configurable: true
  7083. });
  7084. Object.defineProperty(InputText.prototype, "background", {
  7085. /** Gets or sets the background color */
  7086. get: function () {
  7087. return this._background;
  7088. },
  7089. set: function (value) {
  7090. if (this._background === value) {
  7091. return;
  7092. }
  7093. this._background = value;
  7094. this._markAsDirty();
  7095. },
  7096. enumerable: true,
  7097. configurable: true
  7098. });
  7099. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7100. /** Gets or sets the placeholder color */
  7101. get: function () {
  7102. return this._placeholderColor;
  7103. },
  7104. set: function (value) {
  7105. if (this._placeholderColor === value) {
  7106. return;
  7107. }
  7108. this._placeholderColor = value;
  7109. this._markAsDirty();
  7110. },
  7111. enumerable: true,
  7112. configurable: true
  7113. });
  7114. Object.defineProperty(InputText.prototype, "placeholderText", {
  7115. /** Gets or sets the text displayed when the control is empty */
  7116. get: function () {
  7117. return this._placeholderText;
  7118. },
  7119. set: function (value) {
  7120. if (this._placeholderText === value) {
  7121. return;
  7122. }
  7123. this._placeholderText = value;
  7124. this._markAsDirty();
  7125. },
  7126. enumerable: true,
  7127. configurable: true
  7128. });
  7129. Object.defineProperty(InputText.prototype, "deadKey", {
  7130. /** Gets or sets the dead key flag */
  7131. get: function () {
  7132. return this._deadKey;
  7133. },
  7134. set: function (flag) {
  7135. this._deadKey = flag;
  7136. },
  7137. enumerable: true,
  7138. configurable: true
  7139. });
  7140. Object.defineProperty(InputText.prototype, "highlightedText", {
  7141. /** Gets or sets the highlight text */
  7142. get: function () {
  7143. return this._highlightedText;
  7144. },
  7145. set: function (text) {
  7146. if (this._highlightedText === text) {
  7147. return;
  7148. }
  7149. this._highlightedText = text;
  7150. this._markAsDirty();
  7151. },
  7152. enumerable: true,
  7153. configurable: true
  7154. });
  7155. Object.defineProperty(InputText.prototype, "addKey", {
  7156. /** Gets or sets if the current key should be added */
  7157. get: function () {
  7158. return this._addKey;
  7159. },
  7160. set: function (flag) {
  7161. this._addKey = flag;
  7162. },
  7163. enumerable: true,
  7164. configurable: true
  7165. });
  7166. Object.defineProperty(InputText.prototype, "currentKey", {
  7167. /** Gets or sets the value of the current key being entered */
  7168. get: function () {
  7169. return this._currentKey;
  7170. },
  7171. set: function (key) {
  7172. this._currentKey = key;
  7173. },
  7174. enumerable: true,
  7175. configurable: true
  7176. });
  7177. Object.defineProperty(InputText.prototype, "text", {
  7178. /** Gets or sets the text displayed in the control */
  7179. get: function () {
  7180. return this._text;
  7181. },
  7182. set: function (value) {
  7183. var valueAsString = value.toString(); // Forcing convertion
  7184. if (this._text === valueAsString) {
  7185. return;
  7186. }
  7187. this._text = valueAsString;
  7188. this._markAsDirty();
  7189. this.onTextChangedObservable.notifyObservers(this);
  7190. },
  7191. enumerable: true,
  7192. configurable: true
  7193. });
  7194. Object.defineProperty(InputText.prototype, "width", {
  7195. /** Gets or sets control width */
  7196. get: function () {
  7197. return this._width.toString(this._host);
  7198. },
  7199. set: function (value) {
  7200. if (this._width.toString(this._host) === value) {
  7201. return;
  7202. }
  7203. if (this._width.fromString(value)) {
  7204. this._markAsDirty();
  7205. }
  7206. this.autoStretchWidth = false;
  7207. },
  7208. enumerable: true,
  7209. configurable: true
  7210. });
  7211. /** @hidden */
  7212. InputText.prototype.onBlur = function () {
  7213. this._isFocused = false;
  7214. this._scrollLeft = null;
  7215. this._cursorOffset = 0;
  7216. clearTimeout(this._blinkTimeout);
  7217. this._markAsDirty();
  7218. this.onBlurObservable.notifyObservers(this);
  7219. this._host.unRegisterClipboardEvents();
  7220. if (this._onClipboardObserver) {
  7221. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7222. }
  7223. var scene = this._host.getScene();
  7224. if (this._onPointerDblTapObserver && scene) {
  7225. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7226. }
  7227. };
  7228. /** @hidden */
  7229. InputText.prototype.onFocus = function () {
  7230. var _this = this;
  7231. if (!this._isEnabled) {
  7232. return;
  7233. }
  7234. this._scrollLeft = null;
  7235. this._isFocused = true;
  7236. this._blinkIsEven = false;
  7237. this._cursorOffset = 0;
  7238. this._markAsDirty();
  7239. this.onFocusObservable.notifyObservers(this);
  7240. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7241. var value = prompt(this.promptMessage);
  7242. if (value !== null) {
  7243. this.text = value;
  7244. }
  7245. this._host.focusedControl = null;
  7246. return;
  7247. }
  7248. this._host.registerClipboardEvents();
  7249. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7250. // process clipboard event, can be configured.
  7251. switch (clipboardInfo.type) {
  7252. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7253. _this._onCopyText(clipboardInfo.event);
  7254. _this.onTextCopyObservable.notifyObservers(_this);
  7255. break;
  7256. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7257. _this._onCutText(clipboardInfo.event);
  7258. _this.onTextCutObservable.notifyObservers(_this);
  7259. break;
  7260. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7261. _this._onPasteText(clipboardInfo.event);
  7262. _this.onTextPasteObservable.notifyObservers(_this);
  7263. break;
  7264. default: return;
  7265. }
  7266. });
  7267. var scene = this._host.getScene();
  7268. if (scene) {
  7269. //register the pointer double tap event
  7270. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7271. if (!_this._isFocused) {
  7272. return;
  7273. }
  7274. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7275. _this._processDblClick(pointerInfo);
  7276. }
  7277. });
  7278. }
  7279. if (this._onFocusSelectAll) {
  7280. this._selectAllText();
  7281. }
  7282. };
  7283. InputText.prototype._getTypeName = function () {
  7284. return "InputText";
  7285. };
  7286. /**
  7287. * Function called to get the list of controls that should not steal the focus from this control
  7288. * @returns an array of controls
  7289. */
  7290. InputText.prototype.keepsFocusWith = function () {
  7291. if (!this._connectedVirtualKeyboard) {
  7292. return null;
  7293. }
  7294. return [this._connectedVirtualKeyboard];
  7295. };
  7296. /** @hidden */
  7297. InputText.prototype.processKey = function (keyCode, key, evt) {
  7298. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7299. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7300. return;
  7301. }
  7302. //select all
  7303. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7304. this._selectAllText();
  7305. evt.preventDefault();
  7306. return;
  7307. }
  7308. // Specific cases
  7309. switch (keyCode) {
  7310. case 32: //SPACE
  7311. key = " "; //ie11 key for space is "Spacebar"
  7312. break;
  7313. case 191: //SLASH
  7314. if (evt) {
  7315. evt.preventDefault();
  7316. }
  7317. break;
  7318. case 8: // BACKSPACE
  7319. if (this._text && this._text.length > 0) {
  7320. //delete the highlighted text
  7321. if (this._isTextHighlightOn) {
  7322. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7323. this._isTextHighlightOn = false;
  7324. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7325. this._blinkIsEven = false;
  7326. if (evt) {
  7327. evt.preventDefault();
  7328. }
  7329. return;
  7330. }
  7331. //delete single character
  7332. if (this._cursorOffset === 0) {
  7333. this.text = this._text.substr(0, this._text.length - 1);
  7334. }
  7335. else {
  7336. var deletePosition = this._text.length - this._cursorOffset;
  7337. if (deletePosition > 0) {
  7338. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7339. }
  7340. }
  7341. }
  7342. if (evt) {
  7343. evt.preventDefault();
  7344. }
  7345. return;
  7346. case 46: // DELETE
  7347. if (this._isTextHighlightOn) {
  7348. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7349. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7350. while (decrementor > 0 && this._cursorOffset > 0) {
  7351. this._cursorOffset--;
  7352. }
  7353. this._isTextHighlightOn = false;
  7354. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7355. if (evt) {
  7356. evt.preventDefault();
  7357. }
  7358. return;
  7359. }
  7360. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7361. var deletePosition = this._text.length - this._cursorOffset;
  7362. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7363. this._cursorOffset--;
  7364. }
  7365. if (evt) {
  7366. evt.preventDefault();
  7367. }
  7368. return;
  7369. case 13: // RETURN
  7370. this._host.focusedControl = null;
  7371. this._isTextHighlightOn = false;
  7372. return;
  7373. case 35: // END
  7374. this._cursorOffset = 0;
  7375. this._blinkIsEven = false;
  7376. this._isTextHighlightOn = false;
  7377. this._markAsDirty();
  7378. return;
  7379. case 36: // HOME
  7380. this._cursorOffset = this._text.length;
  7381. this._blinkIsEven = false;
  7382. this._isTextHighlightOn = false;
  7383. this._markAsDirty();
  7384. return;
  7385. case 37: // LEFT
  7386. this._cursorOffset++;
  7387. if (this._cursorOffset > this._text.length) {
  7388. this._cursorOffset = this._text.length;
  7389. }
  7390. if (evt && evt.shiftKey) {
  7391. // update the cursor
  7392. this._blinkIsEven = false;
  7393. // shift + ctrl/cmd + <-
  7394. if (evt.ctrlKey || evt.metaKey) {
  7395. if (!this._isTextHighlightOn) {
  7396. if (this._text.length === this._cursorOffset) {
  7397. return;
  7398. }
  7399. else {
  7400. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7401. }
  7402. }
  7403. this._startHighlightIndex = 0;
  7404. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7405. this._cursorOffset = this._text.length;
  7406. this._isTextHighlightOn = true;
  7407. this._markAsDirty();
  7408. return;
  7409. }
  7410. //store the starting point
  7411. if (!this._isTextHighlightOn) {
  7412. this._isTextHighlightOn = true;
  7413. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7414. }
  7415. //if text is already highlighted
  7416. else if (this._cursorIndex === -1) {
  7417. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7418. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7419. }
  7420. //set the highlight indexes
  7421. if (this._cursorIndex < this._cursorOffset) {
  7422. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7423. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7424. }
  7425. else if (this._cursorIndex > this._cursorOffset) {
  7426. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7427. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7428. }
  7429. else {
  7430. this._isTextHighlightOn = false;
  7431. }
  7432. this._markAsDirty();
  7433. return;
  7434. }
  7435. if (this._isTextHighlightOn) {
  7436. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7437. this._isTextHighlightOn = false;
  7438. }
  7439. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7440. this._cursorOffset = this.text.length;
  7441. evt.preventDefault();
  7442. }
  7443. this._blinkIsEven = false;
  7444. this._isTextHighlightOn = false;
  7445. this._cursorIndex = -1;
  7446. this._markAsDirty();
  7447. return;
  7448. case 39: // RIGHT
  7449. this._cursorOffset--;
  7450. if (this._cursorOffset < 0) {
  7451. this._cursorOffset = 0;
  7452. }
  7453. if (evt && evt.shiftKey) {
  7454. //update the cursor
  7455. this._blinkIsEven = false;
  7456. //shift + ctrl/cmd + ->
  7457. if (evt.ctrlKey || evt.metaKey) {
  7458. if (!this._isTextHighlightOn) {
  7459. if (this._cursorOffset === 0) {
  7460. return;
  7461. }
  7462. else {
  7463. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7464. }
  7465. }
  7466. this._endHighlightIndex = this._text.length;
  7467. this._isTextHighlightOn = true;
  7468. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7469. this._cursorOffset = 0;
  7470. this._markAsDirty();
  7471. return;
  7472. }
  7473. if (!this._isTextHighlightOn) {
  7474. this._isTextHighlightOn = true;
  7475. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7476. }
  7477. //if text is already highlighted
  7478. else if (this._cursorIndex === -1) {
  7479. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7480. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7481. }
  7482. //set the highlight indexes
  7483. if (this._cursorIndex < this._cursorOffset) {
  7484. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7485. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7486. }
  7487. else if (this._cursorIndex > this._cursorOffset) {
  7488. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7489. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7490. }
  7491. else {
  7492. this._isTextHighlightOn = false;
  7493. }
  7494. this._markAsDirty();
  7495. return;
  7496. }
  7497. if (this._isTextHighlightOn) {
  7498. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7499. this._isTextHighlightOn = false;
  7500. }
  7501. //ctr + ->
  7502. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7503. this._cursorOffset = 0;
  7504. evt.preventDefault();
  7505. }
  7506. this._blinkIsEven = false;
  7507. this._isTextHighlightOn = false;
  7508. this._cursorIndex = -1;
  7509. this._markAsDirty();
  7510. return;
  7511. case 222: // Dead
  7512. if (evt) {
  7513. evt.preventDefault();
  7514. }
  7515. this._cursorIndex = -1;
  7516. this.deadKey = true;
  7517. break;
  7518. }
  7519. // Printable characters
  7520. if (key &&
  7521. ((keyCode === -1) || // Direct access
  7522. (keyCode === 32) || // Space
  7523. (keyCode > 47 && keyCode < 64) || // Numbers
  7524. (keyCode > 64 && keyCode < 91) || // Letters
  7525. (keyCode > 159 && keyCode < 193) || // Special characters
  7526. (keyCode > 218 && keyCode < 223) || // Special characters
  7527. (keyCode > 95 && keyCode < 112))) { // Numpad
  7528. this._currentKey = key;
  7529. this.onBeforeKeyAddObservable.notifyObservers(this);
  7530. key = this._currentKey;
  7531. if (this._addKey) {
  7532. if (this._isTextHighlightOn) {
  7533. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7534. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7535. this._isTextHighlightOn = false;
  7536. this._blinkIsEven = false;
  7537. this._markAsDirty();
  7538. }
  7539. else if (this._cursorOffset === 0) {
  7540. this.text += key;
  7541. }
  7542. else {
  7543. var insertPosition = this._text.length - this._cursorOffset;
  7544. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7545. }
  7546. }
  7547. }
  7548. };
  7549. /** @hidden */
  7550. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7551. //update the cursor
  7552. this._blinkIsEven = false;
  7553. if (this._cursorIndex === -1) {
  7554. this._cursorIndex = offset;
  7555. }
  7556. else {
  7557. if (this._cursorIndex < this._cursorOffset) {
  7558. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7559. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7560. }
  7561. else if (this._cursorIndex > this._cursorOffset) {
  7562. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7563. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7564. }
  7565. else {
  7566. this._isTextHighlightOn = false;
  7567. this._markAsDirty();
  7568. return;
  7569. }
  7570. }
  7571. this._isTextHighlightOn = true;
  7572. this._markAsDirty();
  7573. };
  7574. /** @hidden */
  7575. InputText.prototype._processDblClick = function (evt) {
  7576. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7577. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7578. this._endHighlightIndex = this._startHighlightIndex;
  7579. var rWord = /\w+/g, moveLeft, moveRight;
  7580. do {
  7581. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7582. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7583. } while (moveLeft || moveRight);
  7584. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7585. this.onTextHighlightObservable.notifyObservers(this);
  7586. this._isTextHighlightOn = true;
  7587. this._clickedCoordinate = null;
  7588. this._blinkIsEven = true;
  7589. this._cursorIndex = -1;
  7590. this._markAsDirty();
  7591. };
  7592. /** @hidden */
  7593. InputText.prototype._selectAllText = function () {
  7594. this._blinkIsEven = true;
  7595. this._isTextHighlightOn = true;
  7596. this._startHighlightIndex = 0;
  7597. this._endHighlightIndex = this._text.length;
  7598. this._cursorOffset = this._text.length;
  7599. this._cursorIndex = -1;
  7600. this._markAsDirty();
  7601. };
  7602. /**
  7603. * Handles the keyboard event
  7604. * @param evt Defines the KeyboardEvent
  7605. */
  7606. InputText.prototype.processKeyboard = function (evt) {
  7607. // process pressed key
  7608. this.processKey(evt.keyCode, evt.key, evt);
  7609. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7610. };
  7611. /** @hidden */
  7612. InputText.prototype._onCopyText = function (ev) {
  7613. this._isTextHighlightOn = false;
  7614. //when write permission to clipbaord data is denied
  7615. try {
  7616. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7617. }
  7618. catch (_a) { } //pass
  7619. this._host.clipboardData = this._highlightedText;
  7620. };
  7621. /** @hidden */
  7622. InputText.prototype._onCutText = function (ev) {
  7623. if (!this._highlightedText) {
  7624. return;
  7625. }
  7626. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7627. this._isTextHighlightOn = false;
  7628. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7629. //when write permission to clipbaord data is denied
  7630. try {
  7631. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7632. }
  7633. catch (_a) { } //pass
  7634. this._host.clipboardData = this._highlightedText;
  7635. this._highlightedText = "";
  7636. };
  7637. /** @hidden */
  7638. InputText.prototype._onPasteText = function (ev) {
  7639. var data = "";
  7640. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7641. data = ev.clipboardData.getData("text/plain");
  7642. }
  7643. else {
  7644. //get the cached data; returns blank string by default
  7645. data = this._host.clipboardData;
  7646. }
  7647. var insertPosition = this._text.length - this._cursorOffset;
  7648. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7649. };
  7650. InputText.prototype._draw = function (context) {
  7651. var _this = this;
  7652. context.save();
  7653. this._applyStates(context);
  7654. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7655. context.shadowColor = this.shadowColor;
  7656. context.shadowBlur = this.shadowBlur;
  7657. context.shadowOffsetX = this.shadowOffsetX;
  7658. context.shadowOffsetY = this.shadowOffsetY;
  7659. }
  7660. // Background
  7661. if (this._isFocused) {
  7662. if (this._focusedBackground) {
  7663. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7664. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7665. }
  7666. }
  7667. else if (this._background) {
  7668. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7669. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7670. }
  7671. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7672. context.shadowBlur = 0;
  7673. context.shadowOffsetX = 0;
  7674. context.shadowOffsetY = 0;
  7675. }
  7676. if (!this._fontOffset) {
  7677. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7678. }
  7679. // Text
  7680. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7681. if (this.color) {
  7682. context.fillStyle = this.color;
  7683. }
  7684. var text = this._beforeRenderText(this._text);
  7685. if (!this._isFocused && !this._text && this._placeholderText) {
  7686. text = this._placeholderText;
  7687. if (this._placeholderColor) {
  7688. context.fillStyle = this._placeholderColor;
  7689. }
  7690. }
  7691. this._textWidth = context.measureText(text).width;
  7692. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7693. if (this._autoStretchWidth) {
  7694. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7695. }
  7696. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7697. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7698. context.save();
  7699. context.beginPath();
  7700. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7701. context.clip();
  7702. if (this._isFocused && this._textWidth > availableWidth) {
  7703. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7704. if (!this._scrollLeft) {
  7705. this._scrollLeft = textLeft;
  7706. }
  7707. }
  7708. else {
  7709. this._scrollLeft = clipTextLeft;
  7710. }
  7711. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7712. // Cursor
  7713. if (this._isFocused) {
  7714. // Need to move cursor
  7715. if (this._clickedCoordinate) {
  7716. var rightPosition = this._scrollLeft + this._textWidth;
  7717. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7718. var currentSize = 0;
  7719. this._cursorOffset = 0;
  7720. var previousDist = 0;
  7721. do {
  7722. if (this._cursorOffset) {
  7723. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7724. }
  7725. this._cursorOffset++;
  7726. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7727. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7728. // Find closest move
  7729. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7730. this._cursorOffset--;
  7731. }
  7732. this._blinkIsEven = false;
  7733. this._clickedCoordinate = null;
  7734. }
  7735. // Render cursor
  7736. if (!this._blinkIsEven) {
  7737. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7738. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7739. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7740. if (cursorLeft < clipTextLeft) {
  7741. this._scrollLeft += (clipTextLeft - cursorLeft);
  7742. cursorLeft = clipTextLeft;
  7743. this._markAsDirty();
  7744. }
  7745. else if (cursorLeft > clipTextLeft + availableWidth) {
  7746. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7747. cursorLeft = clipTextLeft + availableWidth;
  7748. this._markAsDirty();
  7749. }
  7750. if (!this._isTextHighlightOn) {
  7751. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7752. }
  7753. }
  7754. clearTimeout(this._blinkTimeout);
  7755. this._blinkTimeout = setTimeout(function () {
  7756. _this._blinkIsEven = !_this._blinkIsEven;
  7757. _this._markAsDirty();
  7758. }, 500);
  7759. //show the highlighted text
  7760. if (this._isTextHighlightOn) {
  7761. clearTimeout(this._blinkTimeout);
  7762. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7763. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7764. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7765. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7766. if (highlightCursorLeft < clipTextLeft) {
  7767. width = width - (clipTextLeft - highlightCursorLeft);
  7768. if (!width) {
  7769. // when using left arrow on text.length > availableWidth;
  7770. // assigns the width of the first letter after clipTextLeft
  7771. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7772. }
  7773. highlightCursorLeft = clipTextLeft;
  7774. }
  7775. //for transparancy
  7776. context.globalAlpha = this._highligherOpacity;
  7777. context.fillStyle = this._textHighlightColor;
  7778. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7779. context.globalAlpha = 1.0;
  7780. }
  7781. }
  7782. context.restore();
  7783. // Border
  7784. if (this._thickness) {
  7785. if (this._isFocused) {
  7786. if (this.focusedColor) {
  7787. context.strokeStyle = this.focusedColor;
  7788. }
  7789. }
  7790. else {
  7791. if (this.color) {
  7792. context.strokeStyle = this.color;
  7793. }
  7794. }
  7795. context.lineWidth = this._thickness;
  7796. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7797. }
  7798. context.restore();
  7799. };
  7800. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7801. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7802. return false;
  7803. }
  7804. this._clickedCoordinate = coordinates.x;
  7805. this._isTextHighlightOn = false;
  7806. this._highlightedText = "";
  7807. this._cursorIndex = -1;
  7808. this._isPointerDown = true;
  7809. this._host._capturingControl[pointerId] = this;
  7810. if (this._host.focusedControl === this) {
  7811. // Move cursor
  7812. clearTimeout(this._blinkTimeout);
  7813. this._markAsDirty();
  7814. return true;
  7815. }
  7816. if (!this._isEnabled) {
  7817. return false;
  7818. }
  7819. this._host.focusedControl = this;
  7820. return true;
  7821. };
  7822. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7823. if (this._host.focusedControl === this && this._isPointerDown) {
  7824. this._clickedCoordinate = coordinates.x;
  7825. this._markAsDirty();
  7826. this._updateValueFromCursorIndex(this._cursorOffset);
  7827. }
  7828. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7829. };
  7830. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7831. this._isPointerDown = false;
  7832. delete this._host._capturingControl[pointerId];
  7833. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7834. };
  7835. InputText.prototype._beforeRenderText = function (text) {
  7836. return text;
  7837. };
  7838. InputText.prototype.dispose = function () {
  7839. _super.prototype.dispose.call(this);
  7840. this.onBlurObservable.clear();
  7841. this.onFocusObservable.clear();
  7842. this.onTextChangedObservable.clear();
  7843. this.onTextCopyObservable.clear();
  7844. this.onTextCutObservable.clear();
  7845. this.onTextPasteObservable.clear();
  7846. this.onTextHighlightObservable.clear();
  7847. this.onKeyboardEventProcessedObservable.clear();
  7848. };
  7849. return InputText;
  7850. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7851. /***/ }),
  7852. /***/ "./2D/controls/line.ts":
  7853. /*!*****************************!*\
  7854. !*** ./2D/controls/line.ts ***!
  7855. \*****************************/
  7856. /*! exports provided: Line */
  7857. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7858. "use strict";
  7859. __webpack_require__.r(__webpack_exports__);
  7860. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7861. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7862. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  7863. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7864. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7865. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7866. /** Class used to render 2D lines */
  7867. var Line = /** @class */ (function (_super) {
  7868. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7869. /**
  7870. * Creates a new Line
  7871. * @param name defines the control name
  7872. */
  7873. function Line(name) {
  7874. var _this = _super.call(this, name) || this;
  7875. _this.name = name;
  7876. _this._lineWidth = 1;
  7877. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7878. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7879. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7880. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7881. _this._dash = new Array();
  7882. _this.isHitTestVisible = false;
  7883. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7884. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7885. return _this;
  7886. }
  7887. Object.defineProperty(Line.prototype, "dash", {
  7888. /** Gets or sets the dash pattern */
  7889. get: function () {
  7890. return this._dash;
  7891. },
  7892. set: function (value) {
  7893. if (this._dash === value) {
  7894. return;
  7895. }
  7896. this._dash = value;
  7897. this._markAsDirty();
  7898. },
  7899. enumerable: true,
  7900. configurable: true
  7901. });
  7902. Object.defineProperty(Line.prototype, "connectedControl", {
  7903. /** Gets or sets the control connected with the line end */
  7904. get: function () {
  7905. return this._connectedControl;
  7906. },
  7907. set: function (value) {
  7908. var _this = this;
  7909. if (this._connectedControl === value) {
  7910. return;
  7911. }
  7912. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7913. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7914. this._connectedControlDirtyObserver = null;
  7915. }
  7916. if (value) {
  7917. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7918. }
  7919. this._connectedControl = value;
  7920. this._markAsDirty();
  7921. },
  7922. enumerable: true,
  7923. configurable: true
  7924. });
  7925. Object.defineProperty(Line.prototype, "x1", {
  7926. /** Gets or sets start coordinates on X axis */
  7927. get: function () {
  7928. return this._x1.toString(this._host);
  7929. },
  7930. set: function (value) {
  7931. if (this._x1.toString(this._host) === value) {
  7932. return;
  7933. }
  7934. if (this._x1.fromString(value)) {
  7935. this._markAsDirty();
  7936. }
  7937. },
  7938. enumerable: true,
  7939. configurable: true
  7940. });
  7941. Object.defineProperty(Line.prototype, "y1", {
  7942. /** Gets or sets start coordinates on Y axis */
  7943. get: function () {
  7944. return this._y1.toString(this._host);
  7945. },
  7946. set: function (value) {
  7947. if (this._y1.toString(this._host) === value) {
  7948. return;
  7949. }
  7950. if (this._y1.fromString(value)) {
  7951. this._markAsDirty();
  7952. }
  7953. },
  7954. enumerable: true,
  7955. configurable: true
  7956. });
  7957. Object.defineProperty(Line.prototype, "x2", {
  7958. /** Gets or sets end coordinates on X axis */
  7959. get: function () {
  7960. return this._x2.toString(this._host);
  7961. },
  7962. set: function (value) {
  7963. if (this._x2.toString(this._host) === value) {
  7964. return;
  7965. }
  7966. if (this._x2.fromString(value)) {
  7967. this._markAsDirty();
  7968. }
  7969. },
  7970. enumerable: true,
  7971. configurable: true
  7972. });
  7973. Object.defineProperty(Line.prototype, "y2", {
  7974. /** Gets or sets end coordinates on Y axis */
  7975. get: function () {
  7976. return this._y2.toString(this._host);
  7977. },
  7978. set: function (value) {
  7979. if (this._y2.toString(this._host) === value) {
  7980. return;
  7981. }
  7982. if (this._y2.fromString(value)) {
  7983. this._markAsDirty();
  7984. }
  7985. },
  7986. enumerable: true,
  7987. configurable: true
  7988. });
  7989. Object.defineProperty(Line.prototype, "lineWidth", {
  7990. /** Gets or sets line width */
  7991. get: function () {
  7992. return this._lineWidth;
  7993. },
  7994. set: function (value) {
  7995. if (this._lineWidth === value) {
  7996. return;
  7997. }
  7998. this._lineWidth = value;
  7999. this._markAsDirty();
  8000. },
  8001. enumerable: true,
  8002. configurable: true
  8003. });
  8004. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8005. /** Gets or sets horizontal alignment */
  8006. set: function (value) {
  8007. return;
  8008. },
  8009. enumerable: true,
  8010. configurable: true
  8011. });
  8012. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8013. /** Gets or sets vertical alignment */
  8014. set: function (value) {
  8015. return;
  8016. },
  8017. enumerable: true,
  8018. configurable: true
  8019. });
  8020. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8021. get: function () {
  8022. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8023. },
  8024. enumerable: true,
  8025. configurable: true
  8026. });
  8027. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8028. get: function () {
  8029. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8030. },
  8031. enumerable: true,
  8032. configurable: true
  8033. });
  8034. Line.prototype._getTypeName = function () {
  8035. return "Line";
  8036. };
  8037. Line.prototype._draw = function (context) {
  8038. context.save();
  8039. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8040. context.shadowColor = this.shadowColor;
  8041. context.shadowBlur = this.shadowBlur;
  8042. context.shadowOffsetX = this.shadowOffsetX;
  8043. context.shadowOffsetY = this.shadowOffsetY;
  8044. }
  8045. this._applyStates(context);
  8046. context.strokeStyle = this.color;
  8047. context.lineWidth = this._lineWidth;
  8048. context.setLineDash(this._dash);
  8049. context.beginPath();
  8050. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.left + this._y1.getValue(this._host));
  8051. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.left + this._effectiveY2);
  8052. context.stroke();
  8053. context.restore();
  8054. };
  8055. Line.prototype._measure = function () {
  8056. // Width / Height
  8057. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8058. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8059. };
  8060. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8061. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8062. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8063. };
  8064. /**
  8065. * Move one end of the line given 3D cartesian coordinates.
  8066. * @param position Targeted world position
  8067. * @param scene Scene
  8068. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8069. */
  8070. Line.prototype.moveToVector3 = function (position, scene, end) {
  8071. if (end === void 0) { end = false; }
  8072. if (!this._host || this.parent !== this._host._rootContainer) {
  8073. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8074. return;
  8075. }
  8076. var globalViewport = this._host._getGlobalViewport(scene);
  8077. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8078. this._moveToProjectedPosition(projectedPosition, end);
  8079. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8080. this.notRenderable = true;
  8081. return;
  8082. }
  8083. this.notRenderable = false;
  8084. };
  8085. /**
  8086. * Move one end of the line to a position in screen absolute space.
  8087. * @param projectedPosition Position in screen absolute space (X, Y)
  8088. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8089. */
  8090. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8091. if (end === void 0) { end = false; }
  8092. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8093. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8094. if (end) {
  8095. this.x2 = x;
  8096. this.y2 = y;
  8097. this._x2.ignoreAdaptiveScaling = true;
  8098. this._y2.ignoreAdaptiveScaling = true;
  8099. }
  8100. else {
  8101. this.x1 = x;
  8102. this.y1 = y;
  8103. this._x1.ignoreAdaptiveScaling = true;
  8104. this._y1.ignoreAdaptiveScaling = true;
  8105. }
  8106. };
  8107. return Line;
  8108. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8109. /***/ }),
  8110. /***/ "./2D/controls/multiLine.ts":
  8111. /*!**********************************!*\
  8112. !*** ./2D/controls/multiLine.ts ***!
  8113. \**********************************/
  8114. /*! exports provided: MultiLine */
  8115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8116. "use strict";
  8117. __webpack_require__.r(__webpack_exports__);
  8118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8119. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8120. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/tools");
  8121. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8122. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8123. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8124. /**
  8125. * Class used to create multi line control
  8126. */
  8127. var MultiLine = /** @class */ (function (_super) {
  8128. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8129. /**
  8130. * Creates a new MultiLine
  8131. * @param name defines the control name
  8132. */
  8133. function MultiLine(name) {
  8134. var _this = _super.call(this, name) || this;
  8135. _this.name = name;
  8136. _this._lineWidth = 1;
  8137. /** Function called when a point is updated */
  8138. _this.onPointUpdate = function () {
  8139. _this._markAsDirty();
  8140. };
  8141. _this.isHitTestVisible = false;
  8142. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8143. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8144. _this._dash = [];
  8145. _this._points = [];
  8146. return _this;
  8147. }
  8148. Object.defineProperty(MultiLine.prototype, "dash", {
  8149. /** Gets or sets dash pattern */
  8150. get: function () {
  8151. return this._dash;
  8152. },
  8153. set: function (value) {
  8154. if (this._dash === value) {
  8155. return;
  8156. }
  8157. this._dash = value;
  8158. this._markAsDirty();
  8159. },
  8160. enumerable: true,
  8161. configurable: true
  8162. });
  8163. /**
  8164. * Gets point stored at specified index
  8165. * @param index defines the index to look for
  8166. * @returns the requested point if found
  8167. */
  8168. MultiLine.prototype.getAt = function (index) {
  8169. if (!this._points[index]) {
  8170. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8171. }
  8172. return this._points[index];
  8173. };
  8174. /**
  8175. * Adds new points to the point collection
  8176. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8177. * @returns the list of created MultiLinePoint
  8178. */
  8179. MultiLine.prototype.add = function () {
  8180. var _this = this;
  8181. var items = [];
  8182. for (var _i = 0; _i < arguments.length; _i++) {
  8183. items[_i] = arguments[_i];
  8184. }
  8185. return items.map(function (item) { return _this.push(item); });
  8186. };
  8187. /**
  8188. * Adds a new point to the point collection
  8189. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8190. * @returns the created MultiLinePoint
  8191. */
  8192. MultiLine.prototype.push = function (item) {
  8193. var point = this.getAt(this._points.length);
  8194. if (item == null) {
  8195. return point;
  8196. }
  8197. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8198. point.mesh = item;
  8199. }
  8200. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8201. point.control = item;
  8202. }
  8203. else if (item.x != null && item.y != null) {
  8204. point.x = item.x;
  8205. point.y = item.y;
  8206. }
  8207. return point;
  8208. };
  8209. /**
  8210. * Remove a specific value or point from the active point collection
  8211. * @param value defines the value or point to remove
  8212. */
  8213. MultiLine.prototype.remove = function (value) {
  8214. var index;
  8215. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8216. index = this._points.indexOf(value);
  8217. if (index === -1) {
  8218. return;
  8219. }
  8220. }
  8221. else {
  8222. index = value;
  8223. }
  8224. var point = this._points[index];
  8225. if (!point) {
  8226. return;
  8227. }
  8228. point.dispose();
  8229. this._points.splice(index, 1);
  8230. };
  8231. /**
  8232. * Resets this object to initial state (no point)
  8233. */
  8234. MultiLine.prototype.reset = function () {
  8235. while (this._points.length > 0) {
  8236. this.remove(this._points.length - 1);
  8237. }
  8238. };
  8239. /**
  8240. * Resets all links
  8241. */
  8242. MultiLine.prototype.resetLinks = function () {
  8243. this._points.forEach(function (point) {
  8244. if (point != null) {
  8245. point.resetLinks();
  8246. }
  8247. });
  8248. };
  8249. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8250. /** Gets or sets line width */
  8251. get: function () {
  8252. return this._lineWidth;
  8253. },
  8254. set: function (value) {
  8255. if (this._lineWidth === value) {
  8256. return;
  8257. }
  8258. this._lineWidth = value;
  8259. this._markAsDirty();
  8260. },
  8261. enumerable: true,
  8262. configurable: true
  8263. });
  8264. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8265. set: function (value) {
  8266. return;
  8267. },
  8268. enumerable: true,
  8269. configurable: true
  8270. });
  8271. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8272. set: function (value) {
  8273. return;
  8274. },
  8275. enumerable: true,
  8276. configurable: true
  8277. });
  8278. MultiLine.prototype._getTypeName = function () {
  8279. return "MultiLine";
  8280. };
  8281. MultiLine.prototype._draw = function (context) {
  8282. context.save();
  8283. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8284. context.shadowColor = this.shadowColor;
  8285. context.shadowBlur = this.shadowBlur;
  8286. context.shadowOffsetX = this.shadowOffsetX;
  8287. context.shadowOffsetY = this.shadowOffsetY;
  8288. }
  8289. this._applyStates(context);
  8290. context.strokeStyle = this.color;
  8291. context.lineWidth = this._lineWidth;
  8292. context.setLineDash(this._dash);
  8293. context.beginPath();
  8294. var first = true; //first index is not necessarily 0
  8295. this._points.forEach(function (point) {
  8296. if (!point) {
  8297. return;
  8298. }
  8299. if (first) {
  8300. context.moveTo(point._point.x, point._point.y);
  8301. first = false;
  8302. }
  8303. else {
  8304. context.lineTo(point._point.x, point._point.y);
  8305. }
  8306. });
  8307. context.stroke();
  8308. context.restore();
  8309. };
  8310. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8311. var _this = this;
  8312. this._minX = null;
  8313. this._minY = null;
  8314. this._maxX = null;
  8315. this._maxY = null;
  8316. this._points.forEach(function (point, index) {
  8317. if (!point) {
  8318. return;
  8319. }
  8320. point.translate();
  8321. if (_this._minX == null || point._point.x < _this._minX) {
  8322. _this._minX = point._point.x;
  8323. }
  8324. if (_this._minY == null || point._point.y < _this._minY) {
  8325. _this._minY = point._point.y;
  8326. }
  8327. if (_this._maxX == null || point._point.x > _this._maxX) {
  8328. _this._maxX = point._point.x;
  8329. }
  8330. if (_this._maxY == null || point._point.y > _this._maxY) {
  8331. _this._maxY = point._point.y;
  8332. }
  8333. });
  8334. if (this._minX == null) {
  8335. this._minX = 0;
  8336. }
  8337. if (this._minY == null) {
  8338. this._minY = 0;
  8339. }
  8340. if (this._maxX == null) {
  8341. this._maxX = 0;
  8342. }
  8343. if (this._maxY == null) {
  8344. this._maxY = 0;
  8345. }
  8346. };
  8347. MultiLine.prototype._measure = function () {
  8348. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8349. return;
  8350. }
  8351. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8352. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8353. };
  8354. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8355. if (this._minX == null || this._minY == null) {
  8356. return;
  8357. }
  8358. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8359. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8360. };
  8361. MultiLine.prototype.dispose = function () {
  8362. this.reset();
  8363. _super.prototype.dispose.call(this);
  8364. };
  8365. return MultiLine;
  8366. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8367. /***/ }),
  8368. /***/ "./2D/controls/radioButton.ts":
  8369. /*!************************************!*\
  8370. !*** ./2D/controls/radioButton.ts ***!
  8371. \************************************/
  8372. /*! exports provided: RadioButton */
  8373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8374. "use strict";
  8375. __webpack_require__.r(__webpack_exports__);
  8376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8377. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8378. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  8379. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8380. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8381. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8382. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8383. /**
  8384. * Class used to create radio button controls
  8385. */
  8386. var RadioButton = /** @class */ (function (_super) {
  8387. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8388. /**
  8389. * Creates a new RadioButton
  8390. * @param name defines the control name
  8391. */
  8392. function RadioButton(name) {
  8393. var _this = _super.call(this, name) || this;
  8394. _this.name = name;
  8395. _this._isChecked = false;
  8396. _this._background = "black";
  8397. _this._checkSizeRatio = 0.8;
  8398. _this._thickness = 1;
  8399. /** Gets or sets group name */
  8400. _this.group = "";
  8401. /** Observable raised when isChecked is changed */
  8402. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8403. _this.isPointerBlocker = true;
  8404. return _this;
  8405. }
  8406. Object.defineProperty(RadioButton.prototype, "thickness", {
  8407. /** Gets or sets border thickness */
  8408. get: function () {
  8409. return this._thickness;
  8410. },
  8411. set: function (value) {
  8412. if (this._thickness === value) {
  8413. return;
  8414. }
  8415. this._thickness = value;
  8416. this._markAsDirty();
  8417. },
  8418. enumerable: true,
  8419. configurable: true
  8420. });
  8421. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8422. /** Gets or sets a value indicating the ratio between overall size and check size */
  8423. get: function () {
  8424. return this._checkSizeRatio;
  8425. },
  8426. set: function (value) {
  8427. value = Math.max(Math.min(1, value), 0);
  8428. if (this._checkSizeRatio === value) {
  8429. return;
  8430. }
  8431. this._checkSizeRatio = value;
  8432. this._markAsDirty();
  8433. },
  8434. enumerable: true,
  8435. configurable: true
  8436. });
  8437. Object.defineProperty(RadioButton.prototype, "background", {
  8438. /** Gets or sets background color */
  8439. get: function () {
  8440. return this._background;
  8441. },
  8442. set: function (value) {
  8443. if (this._background === value) {
  8444. return;
  8445. }
  8446. this._background = value;
  8447. this._markAsDirty();
  8448. },
  8449. enumerable: true,
  8450. configurable: true
  8451. });
  8452. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8453. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8454. get: function () {
  8455. return this._isChecked;
  8456. },
  8457. set: function (value) {
  8458. var _this = this;
  8459. if (this._isChecked === value) {
  8460. return;
  8461. }
  8462. this._isChecked = value;
  8463. this._markAsDirty();
  8464. this.onIsCheckedChangedObservable.notifyObservers(value);
  8465. if (this._isChecked && this._host) {
  8466. // Update all controls from same group
  8467. this._host.executeOnAllControls(function (control) {
  8468. if (control === _this) {
  8469. return;
  8470. }
  8471. if (control.group === undefined) {
  8472. return;
  8473. }
  8474. var childRadio = control;
  8475. if (childRadio.group === _this.group) {
  8476. childRadio.isChecked = false;
  8477. }
  8478. });
  8479. }
  8480. },
  8481. enumerable: true,
  8482. configurable: true
  8483. });
  8484. RadioButton.prototype._getTypeName = function () {
  8485. return "RadioButton";
  8486. };
  8487. RadioButton.prototype._draw = function (context) {
  8488. context.save();
  8489. this._applyStates(context);
  8490. var actualWidth = this._currentMeasure.width - this._thickness;
  8491. var actualHeight = this._currentMeasure.height - this._thickness;
  8492. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8493. context.shadowColor = this.shadowColor;
  8494. context.shadowBlur = this.shadowBlur;
  8495. context.shadowOffsetX = this.shadowOffsetX;
  8496. context.shadowOffsetY = this.shadowOffsetY;
  8497. }
  8498. // Outer
  8499. _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);
  8500. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8501. context.fill();
  8502. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8503. context.shadowBlur = 0;
  8504. context.shadowOffsetX = 0;
  8505. context.shadowOffsetY = 0;
  8506. }
  8507. context.strokeStyle = this.color;
  8508. context.lineWidth = this._thickness;
  8509. context.stroke();
  8510. // Inner
  8511. if (this._isChecked) {
  8512. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8513. var offsetWidth = actualWidth * this._checkSizeRatio;
  8514. var offseHeight = actualHeight * this._checkSizeRatio;
  8515. _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);
  8516. context.fill();
  8517. }
  8518. context.restore();
  8519. };
  8520. // Events
  8521. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8522. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8523. return false;
  8524. }
  8525. if (!this.isChecked) {
  8526. this.isChecked = true;
  8527. }
  8528. return true;
  8529. };
  8530. /**
  8531. * Utility function to easily create a radio button with a header
  8532. * @param title defines the label to use for the header
  8533. * @param group defines the group to use for the radio button
  8534. * @param isChecked defines the initial state of the radio button
  8535. * @param onValueChanged defines the callback to call when value changes
  8536. * @returns a StackPanel containing the radio button and a textBlock
  8537. */
  8538. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8539. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8540. panel.isVertical = false;
  8541. panel.height = "30px";
  8542. var radio = new RadioButton();
  8543. radio.width = "20px";
  8544. radio.height = "20px";
  8545. radio.isChecked = isChecked;
  8546. radio.color = "green";
  8547. radio.group = group;
  8548. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8549. panel.addControl(radio);
  8550. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8551. header.text = title;
  8552. header.width = "180px";
  8553. header.paddingLeft = "5px";
  8554. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8555. header.color = "white";
  8556. panel.addControl(header);
  8557. return panel;
  8558. };
  8559. return RadioButton;
  8560. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8561. /***/ }),
  8562. /***/ "./2D/controls/rectangle.ts":
  8563. /*!**********************************!*\
  8564. !*** ./2D/controls/rectangle.ts ***!
  8565. \**********************************/
  8566. /*! exports provided: Rectangle */
  8567. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8568. "use strict";
  8569. __webpack_require__.r(__webpack_exports__);
  8570. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8571. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8572. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8573. /** Class used to create rectangle container */
  8574. var Rectangle = /** @class */ (function (_super) {
  8575. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8576. /**
  8577. * Creates a new Rectangle
  8578. * @param name defines the control name
  8579. */
  8580. function Rectangle(name) {
  8581. var _this = _super.call(this, name) || this;
  8582. _this.name = name;
  8583. _this._thickness = 1;
  8584. _this._cornerRadius = 0;
  8585. return _this;
  8586. }
  8587. Object.defineProperty(Rectangle.prototype, "thickness", {
  8588. /** Gets or sets border thickness */
  8589. get: function () {
  8590. return this._thickness;
  8591. },
  8592. set: function (value) {
  8593. if (this._thickness === value) {
  8594. return;
  8595. }
  8596. this._thickness = value;
  8597. this._markAsDirty();
  8598. },
  8599. enumerable: true,
  8600. configurable: true
  8601. });
  8602. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8603. /** Gets or sets the corner radius angle */
  8604. get: function () {
  8605. return this._cornerRadius;
  8606. },
  8607. set: function (value) {
  8608. if (value < 0) {
  8609. value = 0;
  8610. }
  8611. if (this._cornerRadius === value) {
  8612. return;
  8613. }
  8614. this._cornerRadius = value;
  8615. this._markAsDirty();
  8616. },
  8617. enumerable: true,
  8618. configurable: true
  8619. });
  8620. Rectangle.prototype._getTypeName = function () {
  8621. return "Rectangle";
  8622. };
  8623. Rectangle.prototype._localDraw = function (context) {
  8624. context.save();
  8625. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8626. context.shadowColor = this.shadowColor;
  8627. context.shadowBlur = this.shadowBlur;
  8628. context.shadowOffsetX = this.shadowOffsetX;
  8629. context.shadowOffsetY = this.shadowOffsetY;
  8630. }
  8631. if (this._background) {
  8632. context.fillStyle = this._background;
  8633. if (this._cornerRadius) {
  8634. this._drawRoundedRect(context, this._thickness / 2);
  8635. context.fill();
  8636. }
  8637. else {
  8638. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8639. }
  8640. }
  8641. if (this._thickness) {
  8642. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8643. context.shadowBlur = 0;
  8644. context.shadowOffsetX = 0;
  8645. context.shadowOffsetY = 0;
  8646. }
  8647. if (this.color) {
  8648. context.strokeStyle = this.color;
  8649. }
  8650. context.lineWidth = this._thickness;
  8651. if (this._cornerRadius) {
  8652. this._drawRoundedRect(context, this._thickness / 2);
  8653. context.stroke();
  8654. }
  8655. else {
  8656. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8657. }
  8658. }
  8659. context.restore();
  8660. };
  8661. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8662. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8663. this._measureForChildren.width -= 2 * this._thickness;
  8664. this._measureForChildren.height -= 2 * this._thickness;
  8665. this._measureForChildren.left += this._thickness;
  8666. this._measureForChildren.top += this._thickness;
  8667. };
  8668. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8669. if (offset === void 0) { offset = 0; }
  8670. var x = this._currentMeasure.left + offset;
  8671. var y = this._currentMeasure.top + offset;
  8672. var width = this._currentMeasure.width - offset * 2;
  8673. var height = this._currentMeasure.height - offset * 2;
  8674. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8675. context.beginPath();
  8676. context.moveTo(x + radius, y);
  8677. context.lineTo(x + width - radius, y);
  8678. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8679. context.lineTo(x + width, y + height - radius);
  8680. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8681. context.lineTo(x + radius, y + height);
  8682. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8683. context.lineTo(x, y + radius);
  8684. context.quadraticCurveTo(x, y, x + radius, y);
  8685. context.closePath();
  8686. };
  8687. Rectangle.prototype._clipForChildren = function (context) {
  8688. if (this._cornerRadius) {
  8689. this._drawRoundedRect(context, this._thickness);
  8690. context.clip();
  8691. }
  8692. };
  8693. return Rectangle;
  8694. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8695. /***/ }),
  8696. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8697. /*!***************************************************!*\
  8698. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8699. \***************************************************/
  8700. /*! exports provided: ScrollViewer */
  8701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8702. "use strict";
  8703. __webpack_require__.r(__webpack_exports__);
  8704. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8705. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8706. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/tools");
  8707. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8708. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8709. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8710. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8711. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8712. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8713. /**
  8714. * Class used to hold a viewer window and sliders in a grid
  8715. */
  8716. var ScrollViewer = /** @class */ (function (_super) {
  8717. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8718. /**
  8719. * Creates a new ScrollViewer
  8720. * @param name of ScrollViewer
  8721. */
  8722. function ScrollViewer(name) {
  8723. var _this = _super.call(this, name) || this;
  8724. _this._barSize = 20;
  8725. _this._pointerIsOver = false;
  8726. _this._wheelPrecision = 0.05;
  8727. _this.onDirtyObservable.add(function () {
  8728. _this._horizontalBarSpace.color = _this.color;
  8729. _this._verticalBarSpace.color = _this.color;
  8730. _this._dragSpace.color = _this.color;
  8731. });
  8732. _this.onPointerEnterObservable.add(function () {
  8733. _this._pointerIsOver = true;
  8734. });
  8735. _this.onPointerOutObservable.add(function () {
  8736. _this._pointerIsOver = false;
  8737. });
  8738. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8739. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8740. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8741. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8742. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8743. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8744. _this._grid.addColumnDefinition(1);
  8745. _this._grid.addColumnDefinition(0, true);
  8746. _this._grid.addRowDefinition(1);
  8747. _this._grid.addRowDefinition(0, true);
  8748. _super.prototype.addControl.call(_this, _this._grid);
  8749. _this._grid.addControl(_this._window, 0, 0);
  8750. _this._verticalBar.paddingLeft = 0;
  8751. _this._verticalBar.width = "100%";
  8752. _this._verticalBar.height = "100%";
  8753. _this._verticalBar.barOffset = 0;
  8754. _this._verticalBar.value = 0;
  8755. _this._verticalBar.maximum = 1;
  8756. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8757. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8758. _this._verticalBar.isVertical = true;
  8759. _this._verticalBar.rotation = Math.PI;
  8760. _this._verticalBar.isVisible = false;
  8761. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8762. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8763. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8764. _this._verticalBarSpace.thickness = 1;
  8765. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8766. _this._verticalBarSpace.addControl(_this._verticalBar);
  8767. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8768. _this._window.top = value * _this._endTop + "px";
  8769. });
  8770. _this._horizontalBar.paddingLeft = 0;
  8771. _this._horizontalBar.width = "100%";
  8772. _this._horizontalBar.height = "100%";
  8773. _this._horizontalBar.barOffset = 0;
  8774. _this._horizontalBar.value = 0;
  8775. _this._horizontalBar.maximum = 1;
  8776. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8777. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8778. _this._horizontalBar.isVisible = false;
  8779. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8780. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8781. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8782. _this._horizontalBarSpace.thickness = 1;
  8783. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8784. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8785. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8786. _this._window.left = value * _this._endLeft + "px";
  8787. });
  8788. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8789. _this._dragSpace.thickness = 1;
  8790. _this._grid.addControl(_this._dragSpace, 1, 1);
  8791. // Colors
  8792. _this.barColor = "grey";
  8793. _this.barBackground = "transparent";
  8794. return _this;
  8795. }
  8796. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8797. /**
  8798. * Gets the horizontal scrollbar
  8799. */
  8800. get: function () {
  8801. return this._horizontalBar;
  8802. },
  8803. enumerable: true,
  8804. configurable: true
  8805. });
  8806. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8807. /**
  8808. * Gets the vertical scrollbar
  8809. */
  8810. get: function () {
  8811. return this._verticalBar;
  8812. },
  8813. enumerable: true,
  8814. configurable: true
  8815. });
  8816. /**
  8817. * Adds a new control to the current container
  8818. * @param control defines the control to add
  8819. * @returns the current container
  8820. */
  8821. ScrollViewer.prototype.addControl = function (control) {
  8822. if (!control) {
  8823. return this;
  8824. }
  8825. this._window.addControl(control);
  8826. return this;
  8827. };
  8828. /**
  8829. * Removes a control from the current container
  8830. * @param control defines the control to remove
  8831. * @returns the current container
  8832. */
  8833. ScrollViewer.prototype.removeControl = function (control) {
  8834. this._window.removeControl(control);
  8835. return this;
  8836. };
  8837. Object.defineProperty(ScrollViewer.prototype, "children", {
  8838. /** Gets the list of children */
  8839. get: function () {
  8840. return this._window.children;
  8841. },
  8842. enumerable: true,
  8843. configurable: true
  8844. });
  8845. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8846. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8847. var child = _a[_i];
  8848. child._markMatrixAsDirty();
  8849. }
  8850. };
  8851. /** Reset the scroll viewer window to initial size */
  8852. ScrollViewer.prototype.resetWindow = function () {
  8853. this._window.width = "100%";
  8854. this._window.height = "100%";
  8855. };
  8856. ScrollViewer.prototype._getTypeName = function () {
  8857. return "ScrollViewer";
  8858. };
  8859. ScrollViewer.prototype._buildClientSizes = function () {
  8860. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8861. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8862. this._clientWidth = this._window.parentClientWidth;
  8863. this._clientHeight = this._window.parentClientHeight;
  8864. };
  8865. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8866. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8867. this._buildClientSizes();
  8868. };
  8869. ScrollViewer.prototype._postMeasure = function () {
  8870. _super.prototype._postMeasure.call(this);
  8871. this._updateScroller();
  8872. };
  8873. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8874. /**
  8875. * Gets or sets the mouse wheel precision
  8876. * from 0 to 1 with a default value of 0.05
  8877. * */
  8878. get: function () {
  8879. return this._wheelPrecision;
  8880. },
  8881. set: function (value) {
  8882. if (this._wheelPrecision === value) {
  8883. return;
  8884. }
  8885. if (value < 0) {
  8886. value = 0;
  8887. }
  8888. if (value > 1) {
  8889. value = 1;
  8890. }
  8891. this._wheelPrecision = value;
  8892. },
  8893. enumerable: true,
  8894. configurable: true
  8895. });
  8896. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8897. /** Gets or sets the bar color */
  8898. get: function () {
  8899. return this._barColor;
  8900. },
  8901. set: function (color) {
  8902. if (this._barColor === color) {
  8903. return;
  8904. }
  8905. this._barColor = color;
  8906. this._horizontalBar.color = color;
  8907. this._verticalBar.color = color;
  8908. },
  8909. enumerable: true,
  8910. configurable: true
  8911. });
  8912. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8913. /** Gets or sets the size of the bar */
  8914. get: function () {
  8915. return this._barSize;
  8916. },
  8917. set: function (value) {
  8918. if (this._barSize === value) {
  8919. return;
  8920. }
  8921. this._barSize = value;
  8922. this._markAsDirty();
  8923. if (this._horizontalBar.isVisible) {
  8924. this._grid.setRowDefinition(1, this._barSize, true);
  8925. }
  8926. if (this._verticalBar.isVisible) {
  8927. this._grid.setColumnDefinition(1, this._barSize, true);
  8928. }
  8929. },
  8930. enumerable: true,
  8931. configurable: true
  8932. });
  8933. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8934. /** Gets or sets the bar background */
  8935. get: function () {
  8936. return this._barBackground;
  8937. },
  8938. set: function (color) {
  8939. if (this._barBackground === color) {
  8940. return;
  8941. }
  8942. this._barBackground = color;
  8943. this._horizontalBar.background = color;
  8944. this._verticalBar.background = color;
  8945. this._dragSpace.background = color;
  8946. },
  8947. enumerable: true,
  8948. configurable: true
  8949. });
  8950. /** @hidden */
  8951. ScrollViewer.prototype._updateScroller = function () {
  8952. var windowContentsWidth = this._window._currentMeasure.width;
  8953. var windowContentsHeight = this._window._currentMeasure.height;
  8954. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8955. this._grid.setRowDefinition(1, 0, true);
  8956. this._horizontalBar.isVisible = false;
  8957. this._horizontalBar.value = 0;
  8958. this._rebuildLayout = true;
  8959. }
  8960. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8961. this._grid.setRowDefinition(1, this._barSize, true);
  8962. this._horizontalBar.isVisible = true;
  8963. this._rebuildLayout = true;
  8964. }
  8965. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8966. this._grid.setColumnDefinition(1, 0, true);
  8967. this._verticalBar.isVisible = false;
  8968. this._verticalBar.value = 0;
  8969. this._rebuildLayout = true;
  8970. }
  8971. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8972. this._grid.setColumnDefinition(1, this._barSize, true);
  8973. this._verticalBar.isVisible = true;
  8974. this._rebuildLayout = true;
  8975. }
  8976. this._buildClientSizes();
  8977. this._endLeft = this._clientWidth - windowContentsWidth;
  8978. this._endTop = this._clientHeight - windowContentsHeight;
  8979. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8980. var newTop = this._verticalBar.value * this._endTop + "px";
  8981. if (newLeft !== this._window.left) {
  8982. this._window.left = newLeft;
  8983. this._rebuildLayout = true;
  8984. }
  8985. if (newTop !== this._window.top) {
  8986. this._window.top = newTop;
  8987. this._rebuildLayout = true;
  8988. }
  8989. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8990. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8991. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8992. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8993. };
  8994. ScrollViewer.prototype._link = function (host) {
  8995. _super.prototype._link.call(this, host);
  8996. this._attachWheel();
  8997. };
  8998. /** @hidden */
  8999. ScrollViewer.prototype._attachWheel = function () {
  9000. var _this = this;
  9001. if (!this._host || this._onPointerObserver) {
  9002. return;
  9003. }
  9004. var scene = this._host.getScene();
  9005. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9006. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9007. return;
  9008. }
  9009. if (_this._verticalBar.isVisible == true) {
  9010. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9011. _this._verticalBar.value -= _this._wheelPrecision;
  9012. }
  9013. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9014. _this._verticalBar.value += _this._wheelPrecision;
  9015. }
  9016. }
  9017. if (_this._horizontalBar.isVisible == true) {
  9018. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9019. _this._horizontalBar.value += _this._wheelPrecision;
  9020. }
  9021. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9022. _this._horizontalBar.value -= _this._wheelPrecision;
  9023. }
  9024. }
  9025. });
  9026. };
  9027. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9028. if (!this.isHighlighted) {
  9029. return;
  9030. }
  9031. _super.prototype._renderHighlightSpecific.call(this, context);
  9032. this._grid._renderHighlightSpecific(context);
  9033. context.restore();
  9034. };
  9035. /** Releases associated resources */
  9036. ScrollViewer.prototype.dispose = function () {
  9037. var scene = this._host.getScene();
  9038. if (scene && this._onPointerObserver) {
  9039. scene.onPointerObservable.remove(this._onPointerObserver);
  9040. this._onPointerObserver = null;
  9041. }
  9042. _super.prototype.dispose.call(this);
  9043. };
  9044. return ScrollViewer;
  9045. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9046. /***/ }),
  9047. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9048. /*!*********************************************************!*\
  9049. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9050. \*********************************************************/
  9051. /*! exports provided: _ScrollViewerWindow */
  9052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9053. "use strict";
  9054. __webpack_require__.r(__webpack_exports__);
  9055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9056. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9057. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9058. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9059. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9060. /**
  9061. * Class used to hold a the container for ScrollViewer
  9062. * @hidden
  9063. */
  9064. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9065. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  9066. /**
  9067. * Creates a new ScrollViewerWindow
  9068. * @param name of ScrollViewerWindow
  9069. */
  9070. function _ScrollViewerWindow(name) {
  9071. return _super.call(this, name) || this;
  9072. }
  9073. _ScrollViewerWindow.prototype._getTypeName = function () {
  9074. return "ScrollViewerWindow";
  9075. };
  9076. /** @hidden */
  9077. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9078. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9079. this._measureForChildren.left = this._currentMeasure.left;
  9080. this._measureForChildren.top = this._currentMeasure.top;
  9081. this._measureForChildren.width = parentMeasure.width;
  9082. this._measureForChildren.height = parentMeasure.height;
  9083. };
  9084. _ScrollViewerWindow.prototype._postMeasure = function () {
  9085. var maxWidth = this.parentClientWidth;
  9086. var maxHeight = this.parentClientHeight;
  9087. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9088. var child = _a[_i];
  9089. if (!child.isVisible || child.notRenderable) {
  9090. continue;
  9091. }
  9092. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9093. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9094. }
  9095. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9096. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9097. }
  9098. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9099. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9100. }
  9101. if (this._currentMeasure.width !== maxWidth) {
  9102. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9103. this._currentMeasure.width = maxWidth;
  9104. this._rebuildLayout = true;
  9105. this._isDirty = true;
  9106. }
  9107. if (this._currentMeasure.height !== maxHeight) {
  9108. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9109. this._currentMeasure.height = maxHeight;
  9110. this._rebuildLayout = true;
  9111. this._isDirty = true;
  9112. }
  9113. _super.prototype._postMeasure.call(this);
  9114. };
  9115. return _ScrollViewerWindow;
  9116. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9117. /***/ }),
  9118. /***/ "./2D/controls/selector.ts":
  9119. /*!*********************************!*\
  9120. !*** ./2D/controls/selector.ts ***!
  9121. \*********************************/
  9122. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9124. "use strict";
  9125. __webpack_require__.r(__webpack_exports__);
  9126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9132. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9133. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9134. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9135. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9136. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9137. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9138. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9139. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9140. /** Class used to create a RadioGroup
  9141. * which contains groups of radio buttons
  9142. */
  9143. var SelectorGroup = /** @class */ (function () {
  9144. /**
  9145. * Creates a new SelectorGroup
  9146. * @param name of group, used as a group heading
  9147. */
  9148. function SelectorGroup(
  9149. /** name of SelectorGroup */
  9150. name) {
  9151. this.name = name;
  9152. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9153. this._selectors = new Array();
  9154. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9155. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9156. this._groupHeader = this._addGroupHeader(name);
  9157. }
  9158. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9159. /** Gets the groupPanel of the SelectorGroup */
  9160. get: function () {
  9161. return this._groupPanel;
  9162. },
  9163. enumerable: true,
  9164. configurable: true
  9165. });
  9166. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9167. /** Gets the selectors array */
  9168. get: function () {
  9169. return this._selectors;
  9170. },
  9171. enumerable: true,
  9172. configurable: true
  9173. });
  9174. Object.defineProperty(SelectorGroup.prototype, "header", {
  9175. /** Gets and sets the group header */
  9176. get: function () {
  9177. return this._groupHeader.text;
  9178. },
  9179. set: function (label) {
  9180. if (this._groupHeader.text === "label") {
  9181. return;
  9182. }
  9183. this._groupHeader.text = label;
  9184. },
  9185. enumerable: true,
  9186. configurable: true
  9187. });
  9188. /** @hidden */
  9189. SelectorGroup.prototype._addGroupHeader = function (text) {
  9190. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9191. groupHeading.width = 0.9;
  9192. groupHeading.height = "30px";
  9193. groupHeading.textWrapping = true;
  9194. groupHeading.color = "black";
  9195. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9196. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9197. groupHeading.left = "2px";
  9198. this._groupPanel.addControl(groupHeading);
  9199. return groupHeading;
  9200. };
  9201. /** @hidden*/
  9202. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9203. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9204. return;
  9205. }
  9206. return this._selectors[selectorNb];
  9207. };
  9208. /** Removes the selector at the given position
  9209. * @param selectorNb the position of the selector within the group
  9210. */
  9211. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9212. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9213. return;
  9214. }
  9215. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9216. this._selectors.splice(selectorNb, 1);
  9217. };
  9218. return SelectorGroup;
  9219. }());
  9220. /** Class used to create a CheckboxGroup
  9221. * which contains groups of checkbox buttons
  9222. */
  9223. var CheckboxGroup = /** @class */ (function (_super) {
  9224. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9225. function CheckboxGroup() {
  9226. return _super !== null && _super.apply(this, arguments) || this;
  9227. }
  9228. /** Adds a checkbox as a control
  9229. * @param text is the label for the selector
  9230. * @param func is the function called when the Selector is checked
  9231. * @param checked is true when Selector is checked
  9232. */
  9233. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9234. if (func === void 0) { func = function (s) { }; }
  9235. if (checked === void 0) { checked = false; }
  9236. var checked = checked || false;
  9237. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9238. button.width = "20px";
  9239. button.height = "20px";
  9240. button.color = "#364249";
  9241. button.background = "#CCCCCC";
  9242. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9243. button.onIsCheckedChangedObservable.add(function (state) {
  9244. func(state);
  9245. });
  9246. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9247. _selector.height = "30px";
  9248. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9249. _selector.left = "4px";
  9250. this.groupPanel.addControl(_selector);
  9251. this.selectors.push(_selector);
  9252. button.isChecked = checked;
  9253. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9254. button.color = this.groupPanel.parent.parent.buttonColor;
  9255. button.background = this.groupPanel.parent.parent.buttonBackground;
  9256. }
  9257. };
  9258. /** @hidden */
  9259. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9260. this.selectors[selectorNb].children[1].text = label;
  9261. };
  9262. /** @hidden */
  9263. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9264. this.selectors[selectorNb].children[1].color = color;
  9265. };
  9266. /** @hidden */
  9267. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9268. this.selectors[selectorNb].children[0].color = color;
  9269. };
  9270. /** @hidden */
  9271. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9272. this.selectors[selectorNb].children[0].background = color;
  9273. };
  9274. return CheckboxGroup;
  9275. }(SelectorGroup));
  9276. /** Class used to create a RadioGroup
  9277. * which contains groups of radio buttons
  9278. */
  9279. var RadioGroup = /** @class */ (function (_super) {
  9280. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9281. function RadioGroup() {
  9282. var _this = _super !== null && _super.apply(this, arguments) || this;
  9283. _this._selectNb = 0;
  9284. return _this;
  9285. }
  9286. /** Adds a radio button as a control
  9287. * @param label is the label for the selector
  9288. * @param func is the function called when the Selector is checked
  9289. * @param checked is true when Selector is checked
  9290. */
  9291. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9292. if (func === void 0) { func = function (n) { }; }
  9293. if (checked === void 0) { checked = false; }
  9294. var nb = this._selectNb++;
  9295. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9296. button.name = label;
  9297. button.width = "20px";
  9298. button.height = "20px";
  9299. button.color = "#364249";
  9300. button.background = "#CCCCCC";
  9301. button.group = this.name;
  9302. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9303. button.onIsCheckedChangedObservable.add(function (state) {
  9304. if (state) {
  9305. func(nb);
  9306. }
  9307. });
  9308. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9309. _selector.height = "30px";
  9310. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9311. _selector.left = "4px";
  9312. this.groupPanel.addControl(_selector);
  9313. this.selectors.push(_selector);
  9314. button.isChecked = checked;
  9315. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9316. button.color = this.groupPanel.parent.parent.buttonColor;
  9317. button.background = this.groupPanel.parent.parent.buttonBackground;
  9318. }
  9319. };
  9320. /** @hidden */
  9321. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9322. this.selectors[selectorNb].children[1].text = label;
  9323. };
  9324. /** @hidden */
  9325. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9326. this.selectors[selectorNb].children[1].color = color;
  9327. };
  9328. /** @hidden */
  9329. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9330. this.selectors[selectorNb].children[0].color = color;
  9331. };
  9332. /** @hidden */
  9333. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9334. this.selectors[selectorNb].children[0].background = color;
  9335. };
  9336. return RadioGroup;
  9337. }(SelectorGroup));
  9338. /** Class used to create a SliderGroup
  9339. * which contains groups of slider buttons
  9340. */
  9341. var SliderGroup = /** @class */ (function (_super) {
  9342. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9343. function SliderGroup() {
  9344. return _super !== null && _super.apply(this, arguments) || this;
  9345. }
  9346. /**
  9347. * Adds a slider to the SelectorGroup
  9348. * @param label is the label for the SliderBar
  9349. * @param func is the function called when the Slider moves
  9350. * @param unit is a string describing the units used, eg degrees or metres
  9351. * @param min is the minimum value for the Slider
  9352. * @param max is the maximum value for the Slider
  9353. * @param value is the start value for the Slider between min and max
  9354. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9355. */
  9356. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9357. if (func === void 0) { func = function (v) { }; }
  9358. if (unit === void 0) { unit = "Units"; }
  9359. if (min === void 0) { min = 0; }
  9360. if (max === void 0) { max = 0; }
  9361. if (value === void 0) { value = 0; }
  9362. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9363. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9364. button.name = unit;
  9365. button.value = value;
  9366. button.minimum = min;
  9367. button.maximum = max;
  9368. button.width = 0.9;
  9369. button.height = "20px";
  9370. button.color = "#364249";
  9371. button.background = "#CCCCCC";
  9372. button.borderColor = "black";
  9373. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9374. button.left = "4px";
  9375. button.paddingBottom = "4px";
  9376. button.onValueChangedObservable.add(function (value) {
  9377. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9378. func(value);
  9379. });
  9380. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9381. _selector.height = "60px";
  9382. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9383. _selector.left = "4px";
  9384. _selector.children[0].name = label;
  9385. this.groupPanel.addControl(_selector);
  9386. this.selectors.push(_selector);
  9387. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9388. button.color = this.groupPanel.parent.parent.buttonColor;
  9389. button.background = this.groupPanel.parent.parent.buttonBackground;
  9390. }
  9391. };
  9392. /** @hidden */
  9393. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9394. this.selectors[selectorNb].children[0].name = label;
  9395. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9396. };
  9397. /** @hidden */
  9398. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9399. this.selectors[selectorNb].children[0].color = color;
  9400. };
  9401. /** @hidden */
  9402. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9403. this.selectors[selectorNb].children[1].color = color;
  9404. };
  9405. /** @hidden */
  9406. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9407. this.selectors[selectorNb].children[1].background = color;
  9408. };
  9409. return SliderGroup;
  9410. }(SelectorGroup));
  9411. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9412. * @see http://doc.babylonjs.com/how_to/selector
  9413. */
  9414. var SelectionPanel = /** @class */ (function (_super) {
  9415. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9416. /**
  9417. * Creates a new SelectionPanel
  9418. * @param name of SelectionPanel
  9419. * @param groups is an array of SelectionGroups
  9420. */
  9421. function SelectionPanel(
  9422. /** name of SelectionPanel */
  9423. name,
  9424. /** an array of SelectionGroups */
  9425. groups) {
  9426. if (groups === void 0) { groups = []; }
  9427. var _this = _super.call(this, name) || this;
  9428. _this.name = name;
  9429. _this.groups = groups;
  9430. _this._buttonColor = "#364249";
  9431. _this._buttonBackground = "#CCCCCC";
  9432. _this._headerColor = "black";
  9433. _this._barColor = "white";
  9434. _this._barHeight = "2px";
  9435. _this._spacerHeight = "20px";
  9436. _this._bars = new Array();
  9437. _this._groups = groups;
  9438. _this.thickness = 2;
  9439. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9440. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9441. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9442. _this._panel.top = 5;
  9443. _this._panel.left = 5;
  9444. _this._panel.width = 0.95;
  9445. if (groups.length > 0) {
  9446. for (var i = 0; i < groups.length - 1; i++) {
  9447. _this._panel.addControl(groups[i].groupPanel);
  9448. _this._addSpacer();
  9449. }
  9450. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9451. }
  9452. _this.addControl(_this._panel);
  9453. return _this;
  9454. }
  9455. SelectionPanel.prototype._getTypeName = function () {
  9456. return "SelectionPanel";
  9457. };
  9458. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9459. /** Gets or sets the headerColor */
  9460. get: function () {
  9461. return this._headerColor;
  9462. },
  9463. set: function (color) {
  9464. if (this._headerColor === color) {
  9465. return;
  9466. }
  9467. this._headerColor = color;
  9468. this._setHeaderColor();
  9469. },
  9470. enumerable: true,
  9471. configurable: true
  9472. });
  9473. SelectionPanel.prototype._setHeaderColor = function () {
  9474. for (var i = 0; i < this._groups.length; i++) {
  9475. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9476. }
  9477. };
  9478. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9479. /** Gets or sets the button color */
  9480. get: function () {
  9481. return this._buttonColor;
  9482. },
  9483. set: function (color) {
  9484. if (this._buttonColor === color) {
  9485. return;
  9486. }
  9487. this._buttonColor = color;
  9488. this._setbuttonColor();
  9489. },
  9490. enumerable: true,
  9491. configurable: true
  9492. });
  9493. SelectionPanel.prototype._setbuttonColor = function () {
  9494. for (var i = 0; i < this._groups.length; i++) {
  9495. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9496. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9497. }
  9498. }
  9499. };
  9500. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9501. /** Gets or sets the label color */
  9502. get: function () {
  9503. return this._labelColor;
  9504. },
  9505. set: function (color) {
  9506. if (this._labelColor === color) {
  9507. return;
  9508. }
  9509. this._labelColor = color;
  9510. this._setLabelColor();
  9511. },
  9512. enumerable: true,
  9513. configurable: true
  9514. });
  9515. SelectionPanel.prototype._setLabelColor = function () {
  9516. for (var i = 0; i < this._groups.length; i++) {
  9517. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9518. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9519. }
  9520. }
  9521. };
  9522. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9523. /** Gets or sets the button background */
  9524. get: function () {
  9525. return this._buttonBackground;
  9526. },
  9527. set: function (color) {
  9528. if (this._buttonBackground === color) {
  9529. return;
  9530. }
  9531. this._buttonBackground = color;
  9532. this._setButtonBackground();
  9533. },
  9534. enumerable: true,
  9535. configurable: true
  9536. });
  9537. SelectionPanel.prototype._setButtonBackground = function () {
  9538. for (var i = 0; i < this._groups.length; i++) {
  9539. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9540. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9541. }
  9542. }
  9543. };
  9544. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9545. /** Gets or sets the color of separator bar */
  9546. get: function () {
  9547. return this._barColor;
  9548. },
  9549. set: function (color) {
  9550. if (this._barColor === color) {
  9551. return;
  9552. }
  9553. this._barColor = color;
  9554. this._setBarColor();
  9555. },
  9556. enumerable: true,
  9557. configurable: true
  9558. });
  9559. SelectionPanel.prototype._setBarColor = function () {
  9560. for (var i = 0; i < this._bars.length; i++) {
  9561. this._bars[i].children[0].background = this._barColor;
  9562. }
  9563. };
  9564. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9565. /** Gets or sets the height of separator bar */
  9566. get: function () {
  9567. return this._barHeight;
  9568. },
  9569. set: function (value) {
  9570. if (this._barHeight === value) {
  9571. return;
  9572. }
  9573. this._barHeight = value;
  9574. this._setBarHeight();
  9575. },
  9576. enumerable: true,
  9577. configurable: true
  9578. });
  9579. SelectionPanel.prototype._setBarHeight = function () {
  9580. for (var i = 0; i < this._bars.length; i++) {
  9581. this._bars[i].children[0].height = this._barHeight;
  9582. }
  9583. };
  9584. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9585. /** Gets or sets the height of spacers*/
  9586. get: function () {
  9587. return this._spacerHeight;
  9588. },
  9589. set: function (value) {
  9590. if (this._spacerHeight === value) {
  9591. return;
  9592. }
  9593. this._spacerHeight = value;
  9594. this._setSpacerHeight();
  9595. },
  9596. enumerable: true,
  9597. configurable: true
  9598. });
  9599. SelectionPanel.prototype._setSpacerHeight = function () {
  9600. for (var i = 0; i < this._bars.length; i++) {
  9601. this._bars[i].height = this._spacerHeight;
  9602. }
  9603. };
  9604. /** Adds a bar between groups */
  9605. SelectionPanel.prototype._addSpacer = function () {
  9606. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9607. separator.width = 1;
  9608. separator.height = this._spacerHeight;
  9609. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9610. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9611. bar.width = 1;
  9612. bar.height = this._barHeight;
  9613. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9614. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9615. bar.background = this._barColor;
  9616. bar.color = "transparent";
  9617. separator.addControl(bar);
  9618. this._panel.addControl(separator);
  9619. this._bars.push(separator);
  9620. };
  9621. /** Add a group to the selection panel
  9622. * @param group is the selector group to add
  9623. */
  9624. SelectionPanel.prototype.addGroup = function (group) {
  9625. if (this._groups.length > 0) {
  9626. this._addSpacer();
  9627. }
  9628. this._panel.addControl(group.groupPanel);
  9629. this._groups.push(group);
  9630. group.groupPanel.children[0].color = this._headerColor;
  9631. for (var j = 0; j < group.selectors.length; j++) {
  9632. group._setSelectorButtonColor(j, this._buttonColor);
  9633. group._setSelectorButtonBackground(j, this._buttonBackground);
  9634. }
  9635. };
  9636. /** Remove the group from the given position
  9637. * @param groupNb is the position of the group in the list
  9638. */
  9639. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9640. if (groupNb < 0 || groupNb >= this._groups.length) {
  9641. return;
  9642. }
  9643. var group = this._groups[groupNb];
  9644. this._panel.removeControl(group.groupPanel);
  9645. this._groups.splice(groupNb, 1);
  9646. if (groupNb < this._bars.length) {
  9647. this._panel.removeControl(this._bars[groupNb]);
  9648. this._bars.splice(groupNb, 1);
  9649. }
  9650. };
  9651. /** Change a group header label
  9652. * @param label is the new group header label
  9653. * @param groupNb is the number of the group to relabel
  9654. * */
  9655. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9656. if (groupNb < 0 || groupNb >= this._groups.length) {
  9657. return;
  9658. }
  9659. var group = this._groups[groupNb];
  9660. group.groupPanel.children[0].text = label;
  9661. };
  9662. /** Change selector label to the one given
  9663. * @param label is the new selector label
  9664. * @param groupNb is the number of the groupcontaining the selector
  9665. * @param selectorNb is the number of the selector within a group to relabel
  9666. * */
  9667. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9668. if (groupNb < 0 || groupNb >= this._groups.length) {
  9669. return;
  9670. }
  9671. var group = this._groups[groupNb];
  9672. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9673. return;
  9674. }
  9675. group._setSelectorLabel(selectorNb, label);
  9676. };
  9677. /** For a given group position remove the selector at the given position
  9678. * @param groupNb is the number of the group to remove the selector from
  9679. * @param selectorNb is the number of the selector within the group
  9680. */
  9681. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9682. if (groupNb < 0 || groupNb >= this._groups.length) {
  9683. return;
  9684. }
  9685. var group = this._groups[groupNb];
  9686. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9687. return;
  9688. }
  9689. group.removeSelector(selectorNb);
  9690. };
  9691. /** For a given group position of correct type add a checkbox button
  9692. * @param groupNb is the number of the group to remove the selector from
  9693. * @param label is the label for the selector
  9694. * @param func is the function called when the Selector is checked
  9695. * @param checked is true when Selector is checked
  9696. */
  9697. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9698. if (func === void 0) { func = function () { }; }
  9699. if (checked === void 0) { checked = false; }
  9700. if (groupNb < 0 || groupNb >= this._groups.length) {
  9701. return;
  9702. }
  9703. var group = this._groups[groupNb];
  9704. group.addCheckbox(label, func, checked);
  9705. };
  9706. /** For a given group position of correct type add a radio button
  9707. * @param groupNb is the number of the group to remove the selector from
  9708. * @param label is the label for the selector
  9709. * @param func is the function called when the Selector is checked
  9710. * @param checked is true when Selector is checked
  9711. */
  9712. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9713. if (func === void 0) { func = function () { }; }
  9714. if (checked === void 0) { checked = false; }
  9715. if (groupNb < 0 || groupNb >= this._groups.length) {
  9716. return;
  9717. }
  9718. var group = this._groups[groupNb];
  9719. group.addRadio(label, func, checked);
  9720. };
  9721. /**
  9722. * For a given slider group add a slider
  9723. * @param groupNb is the number of the group to add the slider to
  9724. * @param label is the label for the Slider
  9725. * @param func is the function called when the Slider moves
  9726. * @param unit is a string describing the units used, eg degrees or metres
  9727. * @param min is the minimum value for the Slider
  9728. * @param max is the maximum value for the Slider
  9729. * @param value is the start value for the Slider between min and max
  9730. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9731. */
  9732. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9733. if (func === void 0) { func = function () { }; }
  9734. if (unit === void 0) { unit = "Units"; }
  9735. if (min === void 0) { min = 0; }
  9736. if (max === void 0) { max = 0; }
  9737. if (value === void 0) { value = 0; }
  9738. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9739. if (groupNb < 0 || groupNb >= this._groups.length) {
  9740. return;
  9741. }
  9742. var group = this._groups[groupNb];
  9743. group.addSlider(label, func, unit, min, max, value, onVal);
  9744. };
  9745. return SelectionPanel;
  9746. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9747. /***/ }),
  9748. /***/ "./2D/controls/sliders/baseSlider.ts":
  9749. /*!*******************************************!*\
  9750. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9751. \*******************************************/
  9752. /*! exports provided: BaseSlider */
  9753. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9754. "use strict";
  9755. __webpack_require__.r(__webpack_exports__);
  9756. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9757. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9758. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  9759. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9760. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9761. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9762. /**
  9763. * Class used to create slider controls
  9764. */
  9765. var BaseSlider = /** @class */ (function (_super) {
  9766. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9767. /**
  9768. * Creates a new BaseSlider
  9769. * @param name defines the control name
  9770. */
  9771. function BaseSlider(name) {
  9772. var _this = _super.call(this, name) || this;
  9773. _this.name = name;
  9774. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9775. _this._minimum = 0;
  9776. _this._maximum = 100;
  9777. _this._value = 50;
  9778. _this._isVertical = false;
  9779. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9780. _this._isThumbClamped = false;
  9781. _this._displayThumb = true;
  9782. _this._step = 0;
  9783. _this._lastPointerDownID = -1;
  9784. // Shared rendering info
  9785. _this._effectiveBarOffset = 0;
  9786. /** Observable raised when the sldier value changes */
  9787. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9788. // Events
  9789. _this._pointerIsDown = false;
  9790. _this.isPointerBlocker = true;
  9791. return _this;
  9792. }
  9793. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9794. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9795. get: function () {
  9796. return this._displayThumb;
  9797. },
  9798. set: function (value) {
  9799. if (this._displayThumb === value) {
  9800. return;
  9801. }
  9802. this._displayThumb = value;
  9803. this._markAsDirty();
  9804. },
  9805. enumerable: true,
  9806. configurable: true
  9807. });
  9808. Object.defineProperty(BaseSlider.prototype, "step", {
  9809. /** Gets or sets a step to apply to values (0 by default) */
  9810. get: function () {
  9811. return this._step;
  9812. },
  9813. set: function (value) {
  9814. if (this._step === value) {
  9815. return;
  9816. }
  9817. this._step = value;
  9818. this._markAsDirty();
  9819. },
  9820. enumerable: true,
  9821. configurable: true
  9822. });
  9823. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9824. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9825. get: function () {
  9826. return this._barOffset.toString(this._host);
  9827. },
  9828. set: function (value) {
  9829. if (this._barOffset.toString(this._host) === value) {
  9830. return;
  9831. }
  9832. if (this._barOffset.fromString(value)) {
  9833. this._markAsDirty();
  9834. }
  9835. },
  9836. enumerable: true,
  9837. configurable: true
  9838. });
  9839. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9840. /** Gets main bar offset in pixels*/
  9841. get: function () {
  9842. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9843. },
  9844. enumerable: true,
  9845. configurable: true
  9846. });
  9847. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9848. /** Gets or sets thumb width */
  9849. get: function () {
  9850. return this._thumbWidth.toString(this._host);
  9851. },
  9852. set: function (value) {
  9853. if (this._thumbWidth.toString(this._host) === value) {
  9854. return;
  9855. }
  9856. if (this._thumbWidth.fromString(value)) {
  9857. this._markAsDirty();
  9858. }
  9859. },
  9860. enumerable: true,
  9861. configurable: true
  9862. });
  9863. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9864. /** Gets thumb width in pixels */
  9865. get: function () {
  9866. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9867. },
  9868. enumerable: true,
  9869. configurable: true
  9870. });
  9871. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9872. /** Gets or sets minimum value */
  9873. get: function () {
  9874. return this._minimum;
  9875. },
  9876. set: function (value) {
  9877. if (this._minimum === value) {
  9878. return;
  9879. }
  9880. this._minimum = value;
  9881. this._markAsDirty();
  9882. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9883. },
  9884. enumerable: true,
  9885. configurable: true
  9886. });
  9887. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9888. /** Gets or sets maximum value */
  9889. get: function () {
  9890. return this._maximum;
  9891. },
  9892. set: function (value) {
  9893. if (this._maximum === value) {
  9894. return;
  9895. }
  9896. this._maximum = value;
  9897. this._markAsDirty();
  9898. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9899. },
  9900. enumerable: true,
  9901. configurable: true
  9902. });
  9903. Object.defineProperty(BaseSlider.prototype, "value", {
  9904. /** Gets or sets current value */
  9905. get: function () {
  9906. return this._value;
  9907. },
  9908. set: function (value) {
  9909. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9910. if (this._value === value) {
  9911. return;
  9912. }
  9913. this._value = value;
  9914. this._markAsDirty();
  9915. this.onValueChangedObservable.notifyObservers(this._value);
  9916. },
  9917. enumerable: true,
  9918. configurable: true
  9919. });
  9920. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9921. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9922. get: function () {
  9923. return this._isVertical;
  9924. },
  9925. set: function (value) {
  9926. if (this._isVertical === value) {
  9927. return;
  9928. }
  9929. this._isVertical = value;
  9930. this._markAsDirty();
  9931. },
  9932. enumerable: true,
  9933. configurable: true
  9934. });
  9935. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9936. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9937. get: function () {
  9938. return this._isThumbClamped;
  9939. },
  9940. set: function (value) {
  9941. if (this._isThumbClamped === value) {
  9942. return;
  9943. }
  9944. this._isThumbClamped = value;
  9945. this._markAsDirty();
  9946. },
  9947. enumerable: true,
  9948. configurable: true
  9949. });
  9950. BaseSlider.prototype._getTypeName = function () {
  9951. return "BaseSlider";
  9952. };
  9953. BaseSlider.prototype._getThumbPosition = function () {
  9954. if (this.isVertical) {
  9955. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9956. }
  9957. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9958. };
  9959. BaseSlider.prototype._getThumbThickness = function (type) {
  9960. var thumbThickness = 0;
  9961. switch (type) {
  9962. case "circle":
  9963. if (this._thumbWidth.isPixel) {
  9964. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9965. }
  9966. else {
  9967. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9968. }
  9969. break;
  9970. case "rectangle":
  9971. if (this._thumbWidth.isPixel) {
  9972. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9973. }
  9974. else {
  9975. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9976. }
  9977. }
  9978. return thumbThickness;
  9979. };
  9980. BaseSlider.prototype._prepareRenderingData = function (type) {
  9981. // Main bar
  9982. this._effectiveBarOffset = 0;
  9983. this._renderLeft = this._currentMeasure.left;
  9984. this._renderTop = this._currentMeasure.top;
  9985. this._renderWidth = this._currentMeasure.width;
  9986. this._renderHeight = this._currentMeasure.height;
  9987. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9988. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9989. this._effectiveThumbThickness = this._getThumbThickness(type);
  9990. if (this.displayThumb) {
  9991. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9992. }
  9993. //throw error when height is less than width for vertical slider
  9994. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9995. console.error("Height should be greater than width");
  9996. return;
  9997. }
  9998. if (this._barOffset.isPixel) {
  9999. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10000. }
  10001. else {
  10002. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10003. }
  10004. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10005. if (this.isVertical) {
  10006. this._renderLeft += this._effectiveBarOffset;
  10007. if (!this.isThumbClamped && this.displayThumb) {
  10008. this._renderTop += (this._effectiveThumbThickness / 2);
  10009. }
  10010. this._renderHeight = this._backgroundBoxLength;
  10011. this._renderWidth = this._backgroundBoxThickness;
  10012. }
  10013. else {
  10014. this._renderTop += this._effectiveBarOffset;
  10015. if (!this.isThumbClamped && this.displayThumb) {
  10016. this._renderLeft += (this._effectiveThumbThickness / 2);
  10017. }
  10018. this._renderHeight = this._backgroundBoxThickness;
  10019. this._renderWidth = this._backgroundBoxLength;
  10020. }
  10021. };
  10022. /** @hidden */
  10023. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10024. if (this.rotation != 0) {
  10025. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10026. x = this._transformedPosition.x;
  10027. y = this._transformedPosition.y;
  10028. }
  10029. var value;
  10030. if (this._isVertical) {
  10031. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10032. }
  10033. else {
  10034. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10035. }
  10036. var mult = (1 / this._step) | 0;
  10037. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10038. };
  10039. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10040. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10041. return false;
  10042. }
  10043. this._pointerIsDown = true;
  10044. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10045. this._host._capturingControl[pointerId] = this;
  10046. this._lastPointerDownID = pointerId;
  10047. return true;
  10048. };
  10049. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10050. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10051. if (pointerId != this._lastPointerDownID) {
  10052. return;
  10053. }
  10054. if (this._pointerIsDown) {
  10055. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10056. }
  10057. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10058. };
  10059. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10060. this._pointerIsDown = false;
  10061. delete this._host._capturingControl[pointerId];
  10062. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10063. };
  10064. return BaseSlider;
  10065. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10066. /***/ }),
  10067. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10068. /*!*************************************************!*\
  10069. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10070. \*************************************************/
  10071. /*! exports provided: ImageBasedSlider */
  10072. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10073. "use strict";
  10074. __webpack_require__.r(__webpack_exports__);
  10075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10076. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10077. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10078. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10079. /**
  10080. * Class used to create slider controls based on images
  10081. */
  10082. var ImageBasedSlider = /** @class */ (function (_super) {
  10083. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  10084. /**
  10085. * Creates a new ImageBasedSlider
  10086. * @param name defines the control name
  10087. */
  10088. function ImageBasedSlider(name) {
  10089. var _this = _super.call(this, name) || this;
  10090. _this.name = name;
  10091. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10092. return _this;
  10093. }
  10094. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10095. get: function () {
  10096. return this._displayThumb && this.thumbImage != null;
  10097. },
  10098. set: function (value) {
  10099. if (this._displayThumb === value) {
  10100. return;
  10101. }
  10102. this._displayThumb = value;
  10103. this._markAsDirty();
  10104. },
  10105. enumerable: true,
  10106. configurable: true
  10107. });
  10108. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10109. /**
  10110. * Gets or sets the image used to render the background
  10111. */
  10112. get: function () {
  10113. return this._backgroundImage;
  10114. },
  10115. set: function (value) {
  10116. var _this = this;
  10117. if (this._backgroundImage === value) {
  10118. return;
  10119. }
  10120. this._backgroundImage = value;
  10121. if (value && !value.isLoaded) {
  10122. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10123. }
  10124. this._markAsDirty();
  10125. },
  10126. enumerable: true,
  10127. configurable: true
  10128. });
  10129. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10130. /**
  10131. * Gets or sets the image used to render the value bar
  10132. */
  10133. get: function () {
  10134. return this._valueBarImage;
  10135. },
  10136. set: function (value) {
  10137. var _this = this;
  10138. if (this._valueBarImage === value) {
  10139. return;
  10140. }
  10141. this._valueBarImage = value;
  10142. if (value && !value.isLoaded) {
  10143. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10144. }
  10145. this._markAsDirty();
  10146. },
  10147. enumerable: true,
  10148. configurable: true
  10149. });
  10150. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10151. /**
  10152. * Gets or sets the image used to render the thumb
  10153. */
  10154. get: function () {
  10155. return this._thumbImage;
  10156. },
  10157. set: function (value) {
  10158. var _this = this;
  10159. if (this._thumbImage === value) {
  10160. return;
  10161. }
  10162. this._thumbImage = value;
  10163. if (value && !value.isLoaded) {
  10164. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10165. }
  10166. this._markAsDirty();
  10167. },
  10168. enumerable: true,
  10169. configurable: true
  10170. });
  10171. ImageBasedSlider.prototype._getTypeName = function () {
  10172. return "ImageBasedSlider";
  10173. };
  10174. ImageBasedSlider.prototype._draw = function (context) {
  10175. context.save();
  10176. this._applyStates(context);
  10177. this._prepareRenderingData("rectangle");
  10178. var thumbPosition = this._getThumbPosition();
  10179. var left = this._renderLeft;
  10180. var top = this._renderTop;
  10181. var width = this._renderWidth;
  10182. var height = this._renderHeight;
  10183. // Background
  10184. if (this._backgroundImage) {
  10185. this._tempMeasure.copyFromFloats(left, top, width, height);
  10186. if (this.isThumbClamped && this.displayThumb) {
  10187. if (this.isVertical) {
  10188. this._tempMeasure.height += this._effectiveThumbThickness;
  10189. }
  10190. else {
  10191. this._tempMeasure.width += this._effectiveThumbThickness;
  10192. }
  10193. }
  10194. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10195. this._backgroundImage._draw(context);
  10196. }
  10197. // Bar
  10198. if (this._valueBarImage) {
  10199. if (this.isVertical) {
  10200. if (this.isThumbClamped && this.displayThumb) {
  10201. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10202. }
  10203. else {
  10204. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10205. }
  10206. }
  10207. else {
  10208. if (this.isThumbClamped && this.displayThumb) {
  10209. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10210. }
  10211. else {
  10212. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10213. }
  10214. }
  10215. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10216. this._valueBarImage._draw(context);
  10217. }
  10218. // Thumb
  10219. if (this.displayThumb) {
  10220. if (this.isVertical) {
  10221. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10222. }
  10223. else {
  10224. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10225. }
  10226. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10227. this._thumbImage._draw(context);
  10228. }
  10229. context.restore();
  10230. };
  10231. return ImageBasedSlider;
  10232. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10233. /***/ }),
  10234. /***/ "./2D/controls/sliders/scrollBar.ts":
  10235. /*!******************************************!*\
  10236. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10237. \******************************************/
  10238. /*! exports provided: ScrollBar */
  10239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10240. "use strict";
  10241. __webpack_require__.r(__webpack_exports__);
  10242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10243. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10244. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10245. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10246. /**
  10247. * Class used to create slider controls
  10248. */
  10249. var ScrollBar = /** @class */ (function (_super) {
  10250. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10251. /**
  10252. * Creates a new Slider
  10253. * @param name defines the control name
  10254. */
  10255. function ScrollBar(name) {
  10256. var _this = _super.call(this, name) || this;
  10257. _this.name = name;
  10258. _this._background = "black";
  10259. _this._borderColor = "white";
  10260. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10261. return _this;
  10262. }
  10263. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10264. /** Gets or sets border color */
  10265. get: function () {
  10266. return this._borderColor;
  10267. },
  10268. set: function (value) {
  10269. if (this._borderColor === value) {
  10270. return;
  10271. }
  10272. this._borderColor = value;
  10273. this._markAsDirty();
  10274. },
  10275. enumerable: true,
  10276. configurable: true
  10277. });
  10278. Object.defineProperty(ScrollBar.prototype, "background", {
  10279. /** Gets or sets background color */
  10280. get: function () {
  10281. return this._background;
  10282. },
  10283. set: function (value) {
  10284. if (this._background === value) {
  10285. return;
  10286. }
  10287. this._background = value;
  10288. this._markAsDirty();
  10289. },
  10290. enumerable: true,
  10291. configurable: true
  10292. });
  10293. ScrollBar.prototype._getTypeName = function () {
  10294. return "Scrollbar";
  10295. };
  10296. ScrollBar.prototype._getThumbThickness = function () {
  10297. var thumbThickness = 0;
  10298. if (this._thumbWidth.isPixel) {
  10299. thumbThickness = this._thumbWidth.getValue(this._host);
  10300. }
  10301. else {
  10302. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10303. }
  10304. return thumbThickness;
  10305. };
  10306. ScrollBar.prototype._draw = function (context) {
  10307. context.save();
  10308. this._applyStates(context);
  10309. this._prepareRenderingData("rectangle");
  10310. var left = this._renderLeft;
  10311. var thumbPosition = this._getThumbPosition();
  10312. context.fillStyle = this._background;
  10313. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10314. // Value bar
  10315. context.fillStyle = this.color;
  10316. // Thumb
  10317. if (this.isVertical) {
  10318. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10319. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10320. this._thumbMeasure.width = this._currentMeasure.width;
  10321. this._thumbMeasure.height = this._effectiveThumbThickness;
  10322. }
  10323. else {
  10324. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10325. this._thumbMeasure.top = this._currentMeasure.top;
  10326. this._thumbMeasure.width = this._effectiveThumbThickness;
  10327. this._thumbMeasure.height = this._currentMeasure.height;
  10328. }
  10329. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10330. context.restore();
  10331. };
  10332. /** @hidden */
  10333. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10334. if (this.rotation != 0) {
  10335. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10336. x = this._transformedPosition.x;
  10337. y = this._transformedPosition.y;
  10338. }
  10339. if (this._first) {
  10340. this._first = false;
  10341. this._originX = x;
  10342. this._originY = y;
  10343. // Check if move is required
  10344. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10345. if (this.isVertical) {
  10346. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10347. }
  10348. else {
  10349. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10350. }
  10351. }
  10352. }
  10353. // Delta mode
  10354. var delta = 0;
  10355. if (this.isVertical) {
  10356. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10357. }
  10358. else {
  10359. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10360. }
  10361. this.value += delta * (this.maximum - this.minimum);
  10362. this._originX = x;
  10363. this._originY = y;
  10364. };
  10365. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10366. this._first = true;
  10367. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10368. };
  10369. return ScrollBar;
  10370. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10371. /***/ }),
  10372. /***/ "./2D/controls/sliders/slider.ts":
  10373. /*!***************************************!*\
  10374. !*** ./2D/controls/sliders/slider.ts ***!
  10375. \***************************************/
  10376. /*! exports provided: Slider */
  10377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10378. "use strict";
  10379. __webpack_require__.r(__webpack_exports__);
  10380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10381. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10382. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10383. /**
  10384. * Class used to create slider controls
  10385. */
  10386. var Slider = /** @class */ (function (_super) {
  10387. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10388. /**
  10389. * Creates a new Slider
  10390. * @param name defines the control name
  10391. */
  10392. function Slider(name) {
  10393. var _this = _super.call(this, name) || this;
  10394. _this.name = name;
  10395. _this._background = "black";
  10396. _this._borderColor = "white";
  10397. _this._isThumbCircle = false;
  10398. _this._displayValueBar = true;
  10399. return _this;
  10400. }
  10401. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10402. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10403. get: function () {
  10404. return this._displayValueBar;
  10405. },
  10406. set: function (value) {
  10407. if (this._displayValueBar === value) {
  10408. return;
  10409. }
  10410. this._displayValueBar = value;
  10411. this._markAsDirty();
  10412. },
  10413. enumerable: true,
  10414. configurable: true
  10415. });
  10416. Object.defineProperty(Slider.prototype, "borderColor", {
  10417. /** Gets or sets border color */
  10418. get: function () {
  10419. return this._borderColor;
  10420. },
  10421. set: function (value) {
  10422. if (this._borderColor === value) {
  10423. return;
  10424. }
  10425. this._borderColor = value;
  10426. this._markAsDirty();
  10427. },
  10428. enumerable: true,
  10429. configurable: true
  10430. });
  10431. Object.defineProperty(Slider.prototype, "background", {
  10432. /** Gets or sets background color */
  10433. get: function () {
  10434. return this._background;
  10435. },
  10436. set: function (value) {
  10437. if (this._background === value) {
  10438. return;
  10439. }
  10440. this._background = value;
  10441. this._markAsDirty();
  10442. },
  10443. enumerable: true,
  10444. configurable: true
  10445. });
  10446. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10447. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10448. get: function () {
  10449. return this._isThumbCircle;
  10450. },
  10451. set: function (value) {
  10452. if (this._isThumbCircle === value) {
  10453. return;
  10454. }
  10455. this._isThumbCircle = value;
  10456. this._markAsDirty();
  10457. },
  10458. enumerable: true,
  10459. configurable: true
  10460. });
  10461. Slider.prototype._getTypeName = function () {
  10462. return "Slider";
  10463. };
  10464. Slider.prototype._draw = function (context) {
  10465. context.save();
  10466. this._applyStates(context);
  10467. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10468. var left = this._renderLeft;
  10469. var top = this._renderTop;
  10470. var width = this._renderWidth;
  10471. var height = this._renderHeight;
  10472. var radius = 0;
  10473. if (this.isThumbClamped && this.isThumbCircle) {
  10474. if (this.isVertical) {
  10475. top += (this._effectiveThumbThickness / 2);
  10476. }
  10477. else {
  10478. left += (this._effectiveThumbThickness / 2);
  10479. }
  10480. radius = this._backgroundBoxThickness / 2;
  10481. }
  10482. else {
  10483. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10484. }
  10485. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10486. context.shadowColor = this.shadowColor;
  10487. context.shadowBlur = this.shadowBlur;
  10488. context.shadowOffsetX = this.shadowOffsetX;
  10489. context.shadowOffsetY = this.shadowOffsetY;
  10490. }
  10491. var thumbPosition = this._getThumbPosition();
  10492. context.fillStyle = this._background;
  10493. if (this.isVertical) {
  10494. if (this.isThumbClamped) {
  10495. if (this.isThumbCircle) {
  10496. context.beginPath();
  10497. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10498. context.fill();
  10499. context.fillRect(left, top, width, height);
  10500. }
  10501. else {
  10502. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10503. }
  10504. }
  10505. else {
  10506. context.fillRect(left, top, width, height);
  10507. }
  10508. }
  10509. else {
  10510. if (this.isThumbClamped) {
  10511. if (this.isThumbCircle) {
  10512. context.beginPath();
  10513. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10514. context.fill();
  10515. context.fillRect(left, top, width, height);
  10516. }
  10517. else {
  10518. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10519. }
  10520. }
  10521. else {
  10522. context.fillRect(left, top, width, height);
  10523. }
  10524. }
  10525. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10526. context.shadowBlur = 0;
  10527. context.shadowOffsetX = 0;
  10528. context.shadowOffsetY = 0;
  10529. }
  10530. // Value bar
  10531. context.fillStyle = this.color;
  10532. if (this._displayValueBar) {
  10533. if (this.isVertical) {
  10534. if (this.isThumbClamped) {
  10535. if (this.isThumbCircle) {
  10536. context.beginPath();
  10537. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10538. context.fill();
  10539. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10540. }
  10541. else {
  10542. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10543. }
  10544. }
  10545. else {
  10546. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10547. }
  10548. }
  10549. else {
  10550. if (this.isThumbClamped) {
  10551. if (this.isThumbCircle) {
  10552. context.beginPath();
  10553. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10554. context.fill();
  10555. context.fillRect(left, top, thumbPosition, height);
  10556. }
  10557. else {
  10558. context.fillRect(left, top, thumbPosition, height);
  10559. }
  10560. }
  10561. else {
  10562. context.fillRect(left, top, thumbPosition, height);
  10563. }
  10564. }
  10565. }
  10566. // Thumb
  10567. if (this.displayThumb) {
  10568. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10569. context.shadowColor = this.shadowColor;
  10570. context.shadowBlur = this.shadowBlur;
  10571. context.shadowOffsetX = this.shadowOffsetX;
  10572. context.shadowOffsetY = this.shadowOffsetY;
  10573. }
  10574. if (this._isThumbCircle) {
  10575. context.beginPath();
  10576. if (this.isVertical) {
  10577. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10578. }
  10579. else {
  10580. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10581. }
  10582. context.fill();
  10583. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10584. context.shadowBlur = 0;
  10585. context.shadowOffsetX = 0;
  10586. context.shadowOffsetY = 0;
  10587. }
  10588. context.strokeStyle = this._borderColor;
  10589. context.stroke();
  10590. }
  10591. else {
  10592. if (this.isVertical) {
  10593. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10594. }
  10595. else {
  10596. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10597. }
  10598. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10599. context.shadowBlur = 0;
  10600. context.shadowOffsetX = 0;
  10601. context.shadowOffsetY = 0;
  10602. }
  10603. context.strokeStyle = this._borderColor;
  10604. if (this.isVertical) {
  10605. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10606. }
  10607. else {
  10608. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10609. }
  10610. }
  10611. }
  10612. context.restore();
  10613. };
  10614. return Slider;
  10615. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10616. /***/ }),
  10617. /***/ "./2D/controls/stackPanel.ts":
  10618. /*!***********************************!*\
  10619. !*** ./2D/controls/stackPanel.ts ***!
  10620. \***********************************/
  10621. /*! exports provided: StackPanel */
  10622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10623. "use strict";
  10624. __webpack_require__.r(__webpack_exports__);
  10625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10626. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10627. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  10628. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10629. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10630. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10631. /**
  10632. * Class used to create a 2D stack panel container
  10633. */
  10634. var StackPanel = /** @class */ (function (_super) {
  10635. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10636. /**
  10637. * Creates a new StackPanel
  10638. * @param name defines control name
  10639. */
  10640. function StackPanel(name) {
  10641. var _this = _super.call(this, name) || this;
  10642. _this.name = name;
  10643. _this._isVertical = true;
  10644. _this._manualWidth = false;
  10645. _this._manualHeight = false;
  10646. _this._doNotTrackManualChanges = false;
  10647. return _this;
  10648. }
  10649. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10650. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10651. get: function () {
  10652. return this._isVertical;
  10653. },
  10654. set: function (value) {
  10655. if (this._isVertical === value) {
  10656. return;
  10657. }
  10658. this._isVertical = value;
  10659. this._markAsDirty();
  10660. },
  10661. enumerable: true,
  10662. configurable: true
  10663. });
  10664. Object.defineProperty(StackPanel.prototype, "width", {
  10665. get: function () {
  10666. return this._width.toString(this._host);
  10667. },
  10668. /**
  10669. * Gets or sets panel width.
  10670. * This value should not be set when in horizontal mode as it will be computed automatically
  10671. */
  10672. set: function (value) {
  10673. if (!this._doNotTrackManualChanges) {
  10674. this._manualWidth = true;
  10675. }
  10676. if (this._width.toString(this._host) === value) {
  10677. return;
  10678. }
  10679. if (this._width.fromString(value)) {
  10680. this._markAsDirty();
  10681. }
  10682. },
  10683. enumerable: true,
  10684. configurable: true
  10685. });
  10686. Object.defineProperty(StackPanel.prototype, "height", {
  10687. get: function () {
  10688. return this._height.toString(this._host);
  10689. },
  10690. /**
  10691. * Gets or sets panel height.
  10692. * This value should not be set when in vertical mode as it will be computed automatically
  10693. */
  10694. set: function (value) {
  10695. if (!this._doNotTrackManualChanges) {
  10696. this._manualHeight = true;
  10697. }
  10698. if (this._height.toString(this._host) === value) {
  10699. return;
  10700. }
  10701. if (this._height.fromString(value)) {
  10702. this._markAsDirty();
  10703. }
  10704. },
  10705. enumerable: true,
  10706. configurable: true
  10707. });
  10708. StackPanel.prototype._getTypeName = function () {
  10709. return "StackPanel";
  10710. };
  10711. /** @hidden */
  10712. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10713. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10714. var child = _a[_i];
  10715. if (this._isVertical) {
  10716. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10717. }
  10718. else {
  10719. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10720. }
  10721. }
  10722. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10723. };
  10724. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10725. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10726. this._measureForChildren.copyFrom(parentMeasure);
  10727. this._measureForChildren.left = this._currentMeasure.left;
  10728. this._measureForChildren.top = this._currentMeasure.top;
  10729. if (!this.isVertical || this._manualWidth) {
  10730. this._measureForChildren.width = this._currentMeasure.width;
  10731. }
  10732. if (this.isVertical || this._manualHeight) {
  10733. this._measureForChildren.height = this._currentMeasure.height;
  10734. }
  10735. };
  10736. StackPanel.prototype._postMeasure = function () {
  10737. var stackWidth = 0;
  10738. var stackHeight = 0;
  10739. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10740. var child = _a[_i];
  10741. if (!child.isVisible || child.notRenderable) {
  10742. continue;
  10743. }
  10744. if (this._isVertical) {
  10745. if (child.top !== stackHeight + "px") {
  10746. child.top = stackHeight + "px";
  10747. this._rebuildLayout = true;
  10748. child._top.ignoreAdaptiveScaling = true;
  10749. }
  10750. if (child._height.isPercentage) {
  10751. 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");
  10752. }
  10753. else {
  10754. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10755. }
  10756. }
  10757. else {
  10758. if (child.left !== stackWidth + "px") {
  10759. child.left = stackWidth + "px";
  10760. this._rebuildLayout = true;
  10761. child._left.ignoreAdaptiveScaling = true;
  10762. }
  10763. if (child._width.isPercentage) {
  10764. 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");
  10765. }
  10766. else {
  10767. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10768. }
  10769. }
  10770. }
  10771. this._doNotTrackManualChanges = true;
  10772. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10773. // User can now define their own height and width for stack panel.
  10774. var panelWidthChanged = false;
  10775. var panelHeightChanged = false;
  10776. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10777. var previousHeight = this.height;
  10778. this.height = stackHeight + "px";
  10779. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10780. }
  10781. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10782. var previousWidth = this.width;
  10783. this.width = stackWidth + "px";
  10784. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10785. }
  10786. if (panelHeightChanged) {
  10787. this._height.ignoreAdaptiveScaling = true;
  10788. }
  10789. if (panelWidthChanged) {
  10790. this._width.ignoreAdaptiveScaling = true;
  10791. }
  10792. this._doNotTrackManualChanges = false;
  10793. if (panelWidthChanged || panelHeightChanged) {
  10794. this._rebuildLayout = true;
  10795. }
  10796. _super.prototype._postMeasure.call(this);
  10797. };
  10798. return StackPanel;
  10799. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10800. /***/ }),
  10801. /***/ "./2D/controls/statics.ts":
  10802. /*!********************************!*\
  10803. !*** ./2D/controls/statics.ts ***!
  10804. \********************************/
  10805. /*! exports provided: name */
  10806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10807. "use strict";
  10808. __webpack_require__.r(__webpack_exports__);
  10809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10810. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10811. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10812. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10813. /**
  10814. * Forcing an export so that this code will execute
  10815. * @hidden
  10816. */
  10817. var name = "Statics";
  10818. /**
  10819. * Creates a stack panel that can be used to render headers
  10820. * @param control defines the control to associate with the header
  10821. * @param text defines the text of the header
  10822. * @param size defines the size of the header
  10823. * @param options defines options used to configure the header
  10824. * @returns a new StackPanel
  10825. */
  10826. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10827. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10828. var isHorizontal = options ? options.isHorizontal : true;
  10829. var controlFirst = options ? options.controlFirst : true;
  10830. panel.isVertical = !isHorizontal;
  10831. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10832. header.text = text;
  10833. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10834. if (isHorizontal) {
  10835. header.width = size;
  10836. }
  10837. else {
  10838. header.height = size;
  10839. }
  10840. if (controlFirst) {
  10841. panel.addControl(control);
  10842. panel.addControl(header);
  10843. header.paddingLeft = "5px";
  10844. }
  10845. else {
  10846. panel.addControl(header);
  10847. panel.addControl(control);
  10848. header.paddingRight = "5px";
  10849. }
  10850. header.shadowBlur = control.shadowBlur;
  10851. header.shadowColor = control.shadowColor;
  10852. header.shadowOffsetX = control.shadowOffsetX;
  10853. header.shadowOffsetY = control.shadowOffsetY;
  10854. return panel;
  10855. };
  10856. /***/ }),
  10857. /***/ "./2D/controls/textBlock.ts":
  10858. /*!**********************************!*\
  10859. !*** ./2D/controls/textBlock.ts ***!
  10860. \**********************************/
  10861. /*! exports provided: TextWrapping, TextBlock */
  10862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10863. "use strict";
  10864. __webpack_require__.r(__webpack_exports__);
  10865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10867. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10868. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  10869. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10870. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10871. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10872. /**
  10873. * Enum that determines the text-wrapping mode to use.
  10874. */
  10875. var TextWrapping;
  10876. (function (TextWrapping) {
  10877. /**
  10878. * Clip the text when it's larger than Control.width; this is the default mode.
  10879. */
  10880. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10881. /**
  10882. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10883. */
  10884. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10885. /**
  10886. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10887. */
  10888. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10889. })(TextWrapping || (TextWrapping = {}));
  10890. /**
  10891. * Class used to create text block control
  10892. */
  10893. var TextBlock = /** @class */ (function (_super) {
  10894. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10895. /**
  10896. * Creates a new TextBlock object
  10897. * @param name defines the name of the control
  10898. * @param text defines the text to display (emptry string by default)
  10899. */
  10900. function TextBlock(
  10901. /**
  10902. * Defines the name of the control
  10903. */
  10904. name, text) {
  10905. if (text === void 0) { text = ""; }
  10906. var _this = _super.call(this, name) || this;
  10907. _this.name = name;
  10908. _this._text = "";
  10909. _this._textWrapping = TextWrapping.Clip;
  10910. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10911. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10912. _this._resizeToFit = false;
  10913. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10914. _this._outlineWidth = 0;
  10915. _this._outlineColor = "white";
  10916. /**
  10917. * An event triggered after the text is changed
  10918. */
  10919. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10920. /**
  10921. * An event triggered after the text was broken up into lines
  10922. */
  10923. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10924. _this.text = text;
  10925. return _this;
  10926. }
  10927. Object.defineProperty(TextBlock.prototype, "lines", {
  10928. /**
  10929. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10930. */
  10931. get: function () {
  10932. return this._lines;
  10933. },
  10934. enumerable: true,
  10935. configurable: true
  10936. });
  10937. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10938. /**
  10939. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10940. */
  10941. get: function () {
  10942. return this._resizeToFit;
  10943. },
  10944. /**
  10945. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10946. */
  10947. set: function (value) {
  10948. if (this._resizeToFit === value) {
  10949. return;
  10950. }
  10951. this._resizeToFit = value;
  10952. if (this._resizeToFit) {
  10953. this._width.ignoreAdaptiveScaling = true;
  10954. this._height.ignoreAdaptiveScaling = true;
  10955. }
  10956. this._markAsDirty();
  10957. },
  10958. enumerable: true,
  10959. configurable: true
  10960. });
  10961. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10962. /**
  10963. * Gets or sets a boolean indicating if text must be wrapped
  10964. */
  10965. get: function () {
  10966. return this._textWrapping;
  10967. },
  10968. /**
  10969. * Gets or sets a boolean indicating if text must be wrapped
  10970. */
  10971. set: function (value) {
  10972. if (this._textWrapping === value) {
  10973. return;
  10974. }
  10975. this._textWrapping = +value;
  10976. this._markAsDirty();
  10977. },
  10978. enumerable: true,
  10979. configurable: true
  10980. });
  10981. Object.defineProperty(TextBlock.prototype, "text", {
  10982. /**
  10983. * Gets or sets text to display
  10984. */
  10985. get: function () {
  10986. return this._text;
  10987. },
  10988. /**
  10989. * Gets or sets text to display
  10990. */
  10991. set: function (value) {
  10992. if (this._text === value) {
  10993. return;
  10994. }
  10995. this._text = value;
  10996. this._markAsDirty();
  10997. this.onTextChangedObservable.notifyObservers(this);
  10998. },
  10999. enumerable: true,
  11000. configurable: true
  11001. });
  11002. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11003. /**
  11004. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11005. */
  11006. get: function () {
  11007. return this._textHorizontalAlignment;
  11008. },
  11009. /**
  11010. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11011. */
  11012. set: function (value) {
  11013. if (this._textHorizontalAlignment === value) {
  11014. return;
  11015. }
  11016. this._textHorizontalAlignment = value;
  11017. this._markAsDirty();
  11018. },
  11019. enumerable: true,
  11020. configurable: true
  11021. });
  11022. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11023. /**
  11024. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11025. */
  11026. get: function () {
  11027. return this._textVerticalAlignment;
  11028. },
  11029. /**
  11030. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11031. */
  11032. set: function (value) {
  11033. if (this._textVerticalAlignment === value) {
  11034. return;
  11035. }
  11036. this._textVerticalAlignment = value;
  11037. this._markAsDirty();
  11038. },
  11039. enumerable: true,
  11040. configurable: true
  11041. });
  11042. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11043. /**
  11044. * Gets or sets line spacing value
  11045. */
  11046. get: function () {
  11047. return this._lineSpacing.toString(this._host);
  11048. },
  11049. /**
  11050. * Gets or sets line spacing value
  11051. */
  11052. set: function (value) {
  11053. if (this._lineSpacing.fromString(value)) {
  11054. this._markAsDirty();
  11055. }
  11056. },
  11057. enumerable: true,
  11058. configurable: true
  11059. });
  11060. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11061. /**
  11062. * Gets or sets outlineWidth of the text to display
  11063. */
  11064. get: function () {
  11065. return this._outlineWidth;
  11066. },
  11067. /**
  11068. * Gets or sets outlineWidth of the text to display
  11069. */
  11070. set: function (value) {
  11071. if (this._outlineWidth === value) {
  11072. return;
  11073. }
  11074. this._outlineWidth = value;
  11075. this._markAsDirty();
  11076. },
  11077. enumerable: true,
  11078. configurable: true
  11079. });
  11080. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11081. /**
  11082. * Gets or sets outlineColor of the text to display
  11083. */
  11084. get: function () {
  11085. return this._outlineColor;
  11086. },
  11087. /**
  11088. * Gets or sets outlineColor of the text to display
  11089. */
  11090. set: function (value) {
  11091. if (this._outlineColor === value) {
  11092. return;
  11093. }
  11094. this._outlineColor = value;
  11095. this._markAsDirty();
  11096. },
  11097. enumerable: true,
  11098. configurable: true
  11099. });
  11100. TextBlock.prototype._getTypeName = function () {
  11101. return "TextBlock";
  11102. };
  11103. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11104. if (!this._fontOffset) {
  11105. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11106. }
  11107. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11108. // Prepare lines
  11109. this._lines = this._breakLines(this._currentMeasure.width, context);
  11110. this.onLinesReadyObservable.notifyObservers(this);
  11111. var maxLineWidth = 0;
  11112. for (var i = 0; i < this._lines.length; i++) {
  11113. var line = this._lines[i];
  11114. if (line.width > maxLineWidth) {
  11115. maxLineWidth = line.width;
  11116. }
  11117. }
  11118. if (this._resizeToFit) {
  11119. if (this._textWrapping === TextWrapping.Clip) {
  11120. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11121. if (newWidth !== this._width.internalValue) {
  11122. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11123. this._rebuildLayout = true;
  11124. }
  11125. }
  11126. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11127. if (newHeight !== this._height.internalValue) {
  11128. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11129. this._rebuildLayout = true;
  11130. }
  11131. }
  11132. };
  11133. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11134. var width = this._currentMeasure.width;
  11135. var x = 0;
  11136. switch (this._textHorizontalAlignment) {
  11137. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11138. x = 0;
  11139. break;
  11140. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11141. x = width - textWidth;
  11142. break;
  11143. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11144. x = (width - textWidth) / 2;
  11145. break;
  11146. }
  11147. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11148. context.shadowColor = this.shadowColor;
  11149. context.shadowBlur = this.shadowBlur;
  11150. context.shadowOffsetX = this.shadowOffsetX;
  11151. context.shadowOffsetY = this.shadowOffsetY;
  11152. }
  11153. if (this.outlineWidth) {
  11154. context.strokeText(text, this._currentMeasure.left + x, y);
  11155. }
  11156. context.fillText(text, this._currentMeasure.left + x, y);
  11157. };
  11158. /** @hidden */
  11159. TextBlock.prototype._draw = function (context) {
  11160. context.save();
  11161. this._applyStates(context);
  11162. // Render lines
  11163. this._renderLines(context);
  11164. context.restore();
  11165. };
  11166. TextBlock.prototype._applyStates = function (context) {
  11167. _super.prototype._applyStates.call(this, context);
  11168. if (this.outlineWidth) {
  11169. context.lineWidth = this.outlineWidth;
  11170. context.strokeStyle = this.outlineColor;
  11171. }
  11172. };
  11173. TextBlock.prototype._breakLines = function (refWidth, context) {
  11174. var lines = [];
  11175. var _lines = this.text.split("\n");
  11176. if (this._textWrapping === TextWrapping.Ellipsis) {
  11177. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11178. var _line = _lines_1[_i];
  11179. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11180. }
  11181. }
  11182. else if (this._textWrapping === TextWrapping.WordWrap) {
  11183. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11184. var _line = _lines_2[_a];
  11185. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11186. }
  11187. }
  11188. else {
  11189. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11190. var _line = _lines_3[_b];
  11191. lines.push(this._parseLine(_line, context));
  11192. }
  11193. }
  11194. return lines;
  11195. };
  11196. TextBlock.prototype._parseLine = function (line, context) {
  11197. if (line === void 0) { line = ''; }
  11198. return { text: line, width: context.measureText(line).width };
  11199. };
  11200. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11201. if (line === void 0) { line = ''; }
  11202. var lineWidth = context.measureText(line).width;
  11203. if (lineWidth > width) {
  11204. line += '…';
  11205. }
  11206. while (line.length > 2 && lineWidth > width) {
  11207. line = line.slice(0, -2) + '…';
  11208. lineWidth = context.measureText(line).width;
  11209. }
  11210. return { text: line, width: lineWidth };
  11211. };
  11212. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11213. if (line === void 0) { line = ''; }
  11214. var lines = [];
  11215. var words = line.split(' ');
  11216. var lineWidth = 0;
  11217. for (var n = 0; n < words.length; n++) {
  11218. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11219. var metrics = context.measureText(testLine);
  11220. var testWidth = metrics.width;
  11221. if (testWidth > width && n > 0) {
  11222. lines.push({ text: line, width: lineWidth });
  11223. line = words[n];
  11224. lineWidth = context.measureText(line).width;
  11225. }
  11226. else {
  11227. lineWidth = testWidth;
  11228. line = testLine;
  11229. }
  11230. }
  11231. lines.push({ text: line, width: lineWidth });
  11232. return lines;
  11233. };
  11234. TextBlock.prototype._renderLines = function (context) {
  11235. var height = this._currentMeasure.height;
  11236. var rootY = 0;
  11237. switch (this._textVerticalAlignment) {
  11238. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11239. rootY = this._fontOffset.ascent;
  11240. break;
  11241. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11242. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11243. break;
  11244. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11245. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11246. break;
  11247. }
  11248. rootY += this._currentMeasure.top;
  11249. for (var i = 0; i < this._lines.length; i++) {
  11250. var line = this._lines[i];
  11251. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11252. if (this._lineSpacing.isPixel) {
  11253. rootY += this._lineSpacing.getValue(this._host);
  11254. }
  11255. else {
  11256. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11257. }
  11258. }
  11259. this._drawText(line.text, line.width, rootY, context);
  11260. rootY += this._fontOffset.height;
  11261. }
  11262. };
  11263. /**
  11264. * Given a width constraint applied on the text block, find the expected height
  11265. * @returns expected height
  11266. */
  11267. TextBlock.prototype.computeExpectedHeight = function () {
  11268. if (this.text && this.widthInPixels) {
  11269. var context_1 = document.createElement('canvas').getContext('2d');
  11270. if (context_1) {
  11271. this._applyStates(context_1);
  11272. if (!this._fontOffset) {
  11273. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11274. }
  11275. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11276. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  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/tools");
  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/tools");
  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/tools");
  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/tools");
  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/tools");
  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/tools");
  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/tools");
  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/tools");
  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/tools");
  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/tools");
  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__["Tmp"].Matrix[0]);
  13196. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].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/tools");
  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/tools");
  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__["Tmp"].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/tools");
  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__["Tmp"].Vector2[0];
  13762. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].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/tools");
  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__["Tmp"].Matrix[0]);
  13858. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].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/tools");
  13874. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13875. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13876. /**
  13877. * 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__["Tmp"].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__["Tmp"].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/tools");
  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__["Tmp"].Vector3[0];
  14101. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].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/tools");
  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.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/tools");
  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__["Tmp"].Vector3[0]);
  14589. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].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/tools");
  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/tools");
  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/tools");
  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/tools":
  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_tools__;
  14909. /***/ })
  14910. /******/ });
  14911. });
  14912. //# sourceMappingURL=babylon.gui.js.map