babylon.gui.js 681 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709
  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_Maths_math__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** E:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../../node_modules/webpack/buildin/global.js":
  291. /*!***********************************!*\
  292. !*** (webpack)/buildin/global.js ***!
  293. \***********************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./2D/adtInstrumentation.ts":
  314. /*!**********************************!*\
  315. !*** ./2D/adtInstrumentation.ts ***!
  316. \**********************************/
  317. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  322. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Maths/math");
  323. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__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_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  341. this._captureLayoutTime = false;
  342. this._layoutTime = new babylonjs_Misc_perfCounter__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/Maths/math");
  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 : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  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. /**
  1362. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1363. */
  1364. _this.delegatePickingToChildren = false;
  1365. _this.thickness = 1;
  1366. _this.isPointerBlocker = true;
  1367. var alphaStore = null;
  1368. _this.pointerEnterAnimation = function () {
  1369. alphaStore = _this.alpha;
  1370. _this.alpha -= 0.1;
  1371. };
  1372. _this.pointerOutAnimation = function () {
  1373. if (alphaStore !== null) {
  1374. _this.alpha = alphaStore;
  1375. }
  1376. };
  1377. _this.pointerDownAnimation = function () {
  1378. _this.scaleX -= 0.05;
  1379. _this.scaleY -= 0.05;
  1380. };
  1381. _this.pointerUpAnimation = function () {
  1382. _this.scaleX += 0.05;
  1383. _this.scaleY += 0.05;
  1384. };
  1385. return _this;
  1386. }
  1387. Object.defineProperty(Button.prototype, "image", {
  1388. /**
  1389. * Returns the image part of the button (if any)
  1390. */
  1391. get: function () {
  1392. return this._image;
  1393. },
  1394. enumerable: true,
  1395. configurable: true
  1396. });
  1397. Object.defineProperty(Button.prototype, "textBlock", {
  1398. /**
  1399. * Returns the image part of the button (if any)
  1400. */
  1401. get: function () {
  1402. return this._textBlock;
  1403. },
  1404. enumerable: true,
  1405. configurable: true
  1406. });
  1407. Button.prototype._getTypeName = function () {
  1408. return "Button";
  1409. };
  1410. // While being a container, the button behaves like a control.
  1411. /** @hidden */
  1412. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1413. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1414. return false;
  1415. }
  1416. if (!_super.prototype.contains.call(this, x, y)) {
  1417. return false;
  1418. }
  1419. if (this.delegatePickingToChildren) {
  1420. var contains = false;
  1421. for (var index = this._children.length - 1; index >= 0; index--) {
  1422. var child = this._children[index];
  1423. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1424. contains = true;
  1425. break;
  1426. }
  1427. }
  1428. if (!contains) {
  1429. return false;
  1430. }
  1431. }
  1432. this._processObservables(type, x, y, pointerId, buttonIndex);
  1433. return true;
  1434. };
  1435. /** @hidden */
  1436. Button.prototype._onPointerEnter = function (target) {
  1437. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1438. return false;
  1439. }
  1440. if (this.pointerEnterAnimation) {
  1441. this.pointerEnterAnimation();
  1442. }
  1443. return true;
  1444. };
  1445. /** @hidden */
  1446. Button.prototype._onPointerOut = function (target, force) {
  1447. if (force === void 0) { force = false; }
  1448. if (this.pointerOutAnimation) {
  1449. this.pointerOutAnimation();
  1450. }
  1451. _super.prototype._onPointerOut.call(this, target, force);
  1452. };
  1453. /** @hidden */
  1454. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1455. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1456. return false;
  1457. }
  1458. if (this.pointerDownAnimation) {
  1459. this.pointerDownAnimation();
  1460. }
  1461. return true;
  1462. };
  1463. /** @hidden */
  1464. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1465. if (this.pointerUpAnimation) {
  1466. this.pointerUpAnimation();
  1467. }
  1468. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1469. };
  1470. // Statics
  1471. /**
  1472. * Creates a new button made with an image and a text
  1473. * @param name defines the name of the button
  1474. * @param text defines the text of the button
  1475. * @param imageUrl defines the url of the image
  1476. * @returns a new Button
  1477. */
  1478. Button.CreateImageButton = function (name, text, imageUrl) {
  1479. var result = new Button(name);
  1480. // Adding text
  1481. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1482. textBlock.textWrapping = true;
  1483. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1484. textBlock.paddingLeft = "20%";
  1485. result.addControl(textBlock);
  1486. // Adding image
  1487. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1488. iconImage.width = "20%";
  1489. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1490. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1491. result.addControl(iconImage);
  1492. // Store
  1493. result._image = iconImage;
  1494. result._textBlock = textBlock;
  1495. return result;
  1496. };
  1497. /**
  1498. * Creates a new button made with an image
  1499. * @param name defines the name of the button
  1500. * @param imageUrl defines the url of the image
  1501. * @returns a new Button
  1502. */
  1503. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1504. var result = new Button(name);
  1505. // Adding image
  1506. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1507. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1508. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1509. result.addControl(iconImage);
  1510. // Store
  1511. result._image = iconImage;
  1512. return result;
  1513. };
  1514. /**
  1515. * Creates a new button made with a text
  1516. * @param name defines the name of the button
  1517. * @param text defines the text of the button
  1518. * @returns a new Button
  1519. */
  1520. Button.CreateSimpleButton = function (name, text) {
  1521. var result = new Button(name);
  1522. // Adding text
  1523. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1524. textBlock.textWrapping = true;
  1525. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1526. result.addControl(textBlock);
  1527. // Store
  1528. result._textBlock = textBlock;
  1529. return result;
  1530. };
  1531. /**
  1532. * Creates a new button made with an image and a centered text
  1533. * @param name defines the name of the button
  1534. * @param text defines the text of the button
  1535. * @param imageUrl defines the url of the image
  1536. * @returns a new Button
  1537. */
  1538. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1539. var result = new Button(name);
  1540. // Adding image
  1541. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1542. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1543. result.addControl(iconImage);
  1544. // Adding text
  1545. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1546. textBlock.textWrapping = true;
  1547. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1548. result.addControl(textBlock);
  1549. // Store
  1550. result._image = iconImage;
  1551. result._textBlock = textBlock;
  1552. return result;
  1553. };
  1554. return Button;
  1555. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1556. /***/ }),
  1557. /***/ "./2D/controls/checkbox.ts":
  1558. /*!*********************************!*\
  1559. !*** ./2D/controls/checkbox.ts ***!
  1560. \*********************************/
  1561. /*! exports provided: Checkbox */
  1562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1563. "use strict";
  1564. __webpack_require__.r(__webpack_exports__);
  1565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1566. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1567. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1568. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1569. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1570. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1571. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1572. /**
  1573. * Class used to represent a 2D checkbox
  1574. */
  1575. var Checkbox = /** @class */ (function (_super) {
  1576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1577. /**
  1578. * Creates a new CheckBox
  1579. * @param name defines the control name
  1580. */
  1581. function Checkbox(name) {
  1582. var _this = _super.call(this, name) || this;
  1583. _this.name = name;
  1584. _this._isChecked = false;
  1585. _this._background = "black";
  1586. _this._checkSizeRatio = 0.8;
  1587. _this._thickness = 1;
  1588. /**
  1589. * Observable raised when isChecked property changes
  1590. */
  1591. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1592. _this.isPointerBlocker = true;
  1593. return _this;
  1594. }
  1595. Object.defineProperty(Checkbox.prototype, "thickness", {
  1596. /** Gets or sets border thickness */
  1597. get: function () {
  1598. return this._thickness;
  1599. },
  1600. set: function (value) {
  1601. if (this._thickness === value) {
  1602. return;
  1603. }
  1604. this._thickness = value;
  1605. this._markAsDirty();
  1606. },
  1607. enumerable: true,
  1608. configurable: true
  1609. });
  1610. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1611. /** Gets or sets a value indicating the ratio between overall size and check size */
  1612. get: function () {
  1613. return this._checkSizeRatio;
  1614. },
  1615. set: function (value) {
  1616. value = Math.max(Math.min(1, value), 0);
  1617. if (this._checkSizeRatio === value) {
  1618. return;
  1619. }
  1620. this._checkSizeRatio = value;
  1621. this._markAsDirty();
  1622. },
  1623. enumerable: true,
  1624. configurable: true
  1625. });
  1626. Object.defineProperty(Checkbox.prototype, "background", {
  1627. /** Gets or sets background color */
  1628. get: function () {
  1629. return this._background;
  1630. },
  1631. set: function (value) {
  1632. if (this._background === value) {
  1633. return;
  1634. }
  1635. this._background = value;
  1636. this._markAsDirty();
  1637. },
  1638. enumerable: true,
  1639. configurable: true
  1640. });
  1641. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1642. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1643. get: function () {
  1644. return this._isChecked;
  1645. },
  1646. set: function (value) {
  1647. if (this._isChecked === value) {
  1648. return;
  1649. }
  1650. this._isChecked = value;
  1651. this._markAsDirty();
  1652. this.onIsCheckedChangedObservable.notifyObservers(value);
  1653. },
  1654. enumerable: true,
  1655. configurable: true
  1656. });
  1657. Checkbox.prototype._getTypeName = function () {
  1658. return "Checkbox";
  1659. };
  1660. /** @hidden */
  1661. Checkbox.prototype._draw = function (context) {
  1662. context.save();
  1663. this._applyStates(context);
  1664. var actualWidth = this._currentMeasure.width - this._thickness;
  1665. var actualHeight = this._currentMeasure.height - this._thickness;
  1666. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1667. context.shadowColor = this.shadowColor;
  1668. context.shadowBlur = this.shadowBlur;
  1669. context.shadowOffsetX = this.shadowOffsetX;
  1670. context.shadowOffsetY = this.shadowOffsetY;
  1671. }
  1672. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1673. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1674. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1675. context.shadowBlur = 0;
  1676. context.shadowOffsetX = 0;
  1677. context.shadowOffsetY = 0;
  1678. }
  1679. if (this._isChecked) {
  1680. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1681. var offsetWidth = actualWidth * this._checkSizeRatio;
  1682. var offseHeight = actualHeight * this._checkSizeRatio;
  1683. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1684. }
  1685. context.strokeStyle = this.color;
  1686. context.lineWidth = this._thickness;
  1687. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1688. context.restore();
  1689. };
  1690. // Events
  1691. /** @hidden */
  1692. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1693. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1694. return false;
  1695. }
  1696. this.isChecked = !this.isChecked;
  1697. return true;
  1698. };
  1699. /**
  1700. * Utility function to easily create a checkbox with a header
  1701. * @param title defines the label to use for the header
  1702. * @param onValueChanged defines the callback to call when value changes
  1703. * @returns a StackPanel containing the checkbox and a textBlock
  1704. */
  1705. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1706. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1707. panel.isVertical = false;
  1708. panel.height = "30px";
  1709. var checkbox = new Checkbox();
  1710. checkbox.width = "20px";
  1711. checkbox.height = "20px";
  1712. checkbox.isChecked = true;
  1713. checkbox.color = "green";
  1714. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1715. panel.addControl(checkbox);
  1716. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1717. header.text = title;
  1718. header.width = "180px";
  1719. header.paddingLeft = "5px";
  1720. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1721. header.color = "white";
  1722. panel.addControl(header);
  1723. return panel;
  1724. };
  1725. return Checkbox;
  1726. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1727. /***/ }),
  1728. /***/ "./2D/controls/colorpicker.ts":
  1729. /*!************************************!*\
  1730. !*** ./2D/controls/colorpicker.ts ***!
  1731. \************************************/
  1732. /*! exports provided: ColorPicker */
  1733. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1734. "use strict";
  1735. __webpack_require__.r(__webpack_exports__);
  1736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1737. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1738. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1739. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1740. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1741. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1742. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1743. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1744. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1745. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1746. /** Class used to create color pickers */
  1747. var ColorPicker = /** @class */ (function (_super) {
  1748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1749. /**
  1750. * Creates a new ColorPicker
  1751. * @param name defines the control name
  1752. */
  1753. function ColorPicker(name) {
  1754. var _this = _super.call(this, name) || this;
  1755. _this.name = name;
  1756. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1757. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1758. _this._pointerStartedOnSquare = false;
  1759. _this._pointerStartedOnWheel = false;
  1760. _this._squareLeft = 0;
  1761. _this._squareTop = 0;
  1762. _this._squareSize = 0;
  1763. _this._h = 360;
  1764. _this._s = 1;
  1765. _this._v = 1;
  1766. _this._lastPointerDownID = -1;
  1767. /**
  1768. * Observable raised when the value changes
  1769. */
  1770. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1771. // Events
  1772. _this._pointerIsDown = false;
  1773. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1774. _this.size = "200px";
  1775. _this.isPointerBlocker = true;
  1776. return _this;
  1777. }
  1778. Object.defineProperty(ColorPicker.prototype, "value", {
  1779. /** Gets or sets the color of the color picker */
  1780. get: function () {
  1781. return this._value;
  1782. },
  1783. set: function (value) {
  1784. if (this._value.equals(value)) {
  1785. return;
  1786. }
  1787. this._value.copyFrom(value);
  1788. this._value.toHSVToRef(this._tmpColor);
  1789. this._h = this._tmpColor.r;
  1790. this._s = Math.max(this._tmpColor.g, 0.00001);
  1791. this._v = Math.max(this._tmpColor.b, 0.00001);
  1792. this._markAsDirty();
  1793. if (this._value.r <= ColorPicker._Epsilon) {
  1794. this._value.r = 0;
  1795. }
  1796. if (this._value.g <= ColorPicker._Epsilon) {
  1797. this._value.g = 0;
  1798. }
  1799. if (this._value.b <= ColorPicker._Epsilon) {
  1800. this._value.b = 0;
  1801. }
  1802. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1803. this._value.r = 1.0;
  1804. }
  1805. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1806. this._value.g = 1.0;
  1807. }
  1808. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1809. this._value.b = 1.0;
  1810. }
  1811. this.onValueChangedObservable.notifyObservers(this._value);
  1812. },
  1813. enumerable: true,
  1814. configurable: true
  1815. });
  1816. Object.defineProperty(ColorPicker.prototype, "width", {
  1817. /**
  1818. * Gets or sets control width
  1819. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1820. */
  1821. get: function () {
  1822. return this._width.toString(this._host);
  1823. },
  1824. set: function (value) {
  1825. if (this._width.toString(this._host) === value) {
  1826. return;
  1827. }
  1828. if (this._width.fromString(value)) {
  1829. this._height.fromString(value);
  1830. this._markAsDirty();
  1831. }
  1832. },
  1833. enumerable: true,
  1834. configurable: true
  1835. });
  1836. Object.defineProperty(ColorPicker.prototype, "height", {
  1837. /**
  1838. * Gets or sets control height
  1839. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1840. */
  1841. get: function () {
  1842. return this._height.toString(this._host);
  1843. },
  1844. /** Gets or sets control height */
  1845. set: function (value) {
  1846. if (this._height.toString(this._host) === value) {
  1847. return;
  1848. }
  1849. if (this._height.fromString(value)) {
  1850. this._width.fromString(value);
  1851. this._markAsDirty();
  1852. }
  1853. },
  1854. enumerable: true,
  1855. configurable: true
  1856. });
  1857. Object.defineProperty(ColorPicker.prototype, "size", {
  1858. /** Gets or sets control size */
  1859. get: function () {
  1860. return this.width;
  1861. },
  1862. set: function (value) {
  1863. this.width = value;
  1864. },
  1865. enumerable: true,
  1866. configurable: true
  1867. });
  1868. ColorPicker.prototype._getTypeName = function () {
  1869. return "ColorPicker";
  1870. };
  1871. /** @hidden */
  1872. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1873. if (parentMeasure.width < parentMeasure.height) {
  1874. this._currentMeasure.height = parentMeasure.width;
  1875. }
  1876. else {
  1877. this._currentMeasure.width = parentMeasure.height;
  1878. }
  1879. };
  1880. ColorPicker.prototype._updateSquareProps = function () {
  1881. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1882. var wheelThickness = radius * .2;
  1883. var innerDiameter = (radius - wheelThickness) * 2;
  1884. var squareSize = innerDiameter / (Math.sqrt(2));
  1885. var offset = radius - squareSize * .5;
  1886. this._squareLeft = this._currentMeasure.left + offset;
  1887. this._squareTop = this._currentMeasure.top + offset;
  1888. this._squareSize = squareSize;
  1889. };
  1890. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1891. var lgh = context.createLinearGradient(left, top, width + left, top);
  1892. lgh.addColorStop(0, '#fff');
  1893. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1894. context.fillStyle = lgh;
  1895. context.fillRect(left, top, width, height);
  1896. var lgv = context.createLinearGradient(left, top, left, height + top);
  1897. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1898. lgv.addColorStop(1, '#000');
  1899. context.fillStyle = lgv;
  1900. context.fillRect(left, top, width, height);
  1901. };
  1902. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1903. context.beginPath();
  1904. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1905. context.lineWidth = 3;
  1906. context.strokeStyle = '#333333';
  1907. context.stroke();
  1908. context.beginPath();
  1909. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1910. context.lineWidth = 3;
  1911. context.strokeStyle = '#ffffff';
  1912. context.stroke();
  1913. };
  1914. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1915. var canvas = document.createElement("canvas");
  1916. canvas.width = radius * 2;
  1917. canvas.height = radius * 2;
  1918. var context = canvas.getContext("2d");
  1919. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1920. var data = image.data;
  1921. var color = this._tmpColor;
  1922. var maxDistSq = radius * radius;
  1923. var innerRadius = radius - thickness;
  1924. var minDistSq = innerRadius * innerRadius;
  1925. for (var x = -radius; x < radius; x++) {
  1926. for (var y = -radius; y < radius; y++) {
  1927. var distSq = x * x + y * y;
  1928. if (distSq > maxDistSq || distSq < minDistSq) {
  1929. continue;
  1930. }
  1931. var dist = Math.sqrt(distSq);
  1932. var ang = Math.atan2(y, x);
  1933. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1934. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1935. data[index] = color.r * 255;
  1936. data[index + 1] = color.g * 255;
  1937. data[index + 2] = color.b * 255;
  1938. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1939. //apply less alpha to bigger color pickers
  1940. var alphaAmount = .2;
  1941. var maxAlpha = .2;
  1942. var minAlpha = .04;
  1943. var lowerRadius = 50;
  1944. var upperRadius = 150;
  1945. if (radius < lowerRadius) {
  1946. alphaAmount = maxAlpha;
  1947. }
  1948. else if (radius > upperRadius) {
  1949. alphaAmount = minAlpha;
  1950. }
  1951. else {
  1952. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1953. }
  1954. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1955. if (alphaRatio < alphaAmount) {
  1956. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1957. }
  1958. else if (alphaRatio > 1 - alphaAmount) {
  1959. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1960. }
  1961. else {
  1962. data[index + 3] = 255;
  1963. }
  1964. }
  1965. }
  1966. context.putImageData(image, 0, 0);
  1967. return canvas;
  1968. };
  1969. /** @hidden */
  1970. ColorPicker.prototype._draw = function (context) {
  1971. context.save();
  1972. this._applyStates(context);
  1973. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1974. var wheelThickness = radius * .2;
  1975. var left = this._currentMeasure.left;
  1976. var top = this._currentMeasure.top;
  1977. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1978. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1979. }
  1980. this._updateSquareProps();
  1981. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1982. context.shadowColor = this.shadowColor;
  1983. context.shadowBlur = this.shadowBlur;
  1984. context.shadowOffsetX = this.shadowOffsetX;
  1985. context.shadowOffsetY = this.shadowOffsetY;
  1986. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  1987. }
  1988. context.drawImage(this._colorWheelCanvas, left, top);
  1989. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1990. context.shadowBlur = 0;
  1991. context.shadowOffsetX = 0;
  1992. context.shadowOffsetY = 0;
  1993. }
  1994. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  1995. var cx = this._squareLeft + this._squareSize * this._s;
  1996. var cy = this._squareTop + this._squareSize * (1 - this._v);
  1997. this._drawCircle(cx, cy, radius * .04, context);
  1998. var dist = radius - wheelThickness * .5;
  1999. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2000. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2001. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2002. context.restore();
  2003. };
  2004. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2005. if (this._pointerStartedOnWheel) {
  2006. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2007. var centerX = radius + this._currentMeasure.left;
  2008. var centerY = radius + this._currentMeasure.top;
  2009. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2010. }
  2011. else if (this._pointerStartedOnSquare) {
  2012. this._updateSquareProps();
  2013. this._s = (x - this._squareLeft) / this._squareSize;
  2014. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2015. this._s = Math.min(this._s, 1);
  2016. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2017. this._v = Math.min(this._v, 1);
  2018. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2019. }
  2020. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2021. this.value = this._tmpColor;
  2022. };
  2023. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2024. this._updateSquareProps();
  2025. var left = this._squareLeft;
  2026. var top = this._squareTop;
  2027. var size = this._squareSize;
  2028. if (x >= left && x <= left + size &&
  2029. y >= top && y <= top + size) {
  2030. return true;
  2031. }
  2032. return false;
  2033. };
  2034. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2035. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2036. var centerX = radius + this._currentMeasure.left;
  2037. var centerY = radius + this._currentMeasure.top;
  2038. var wheelThickness = radius * .2;
  2039. var innerRadius = radius - wheelThickness;
  2040. var radiusSq = radius * radius;
  2041. var innerRadiusSq = innerRadius * innerRadius;
  2042. var dx = x - centerX;
  2043. var dy = y - centerY;
  2044. var distSq = dx * dx + dy * dy;
  2045. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2046. return true;
  2047. }
  2048. return false;
  2049. };
  2050. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2051. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2052. return false;
  2053. }
  2054. this._pointerIsDown = true;
  2055. this._pointerStartedOnSquare = false;
  2056. this._pointerStartedOnWheel = false;
  2057. // Invert transform
  2058. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2059. var x = this._transformedPosition.x;
  2060. var y = this._transformedPosition.y;
  2061. if (this._isPointOnSquare(x, y)) {
  2062. this._pointerStartedOnSquare = true;
  2063. }
  2064. else if (this._isPointOnWheel(x, y)) {
  2065. this._pointerStartedOnWheel = true;
  2066. }
  2067. this._updateValueFromPointer(x, y);
  2068. this._host._capturingControl[pointerId] = this;
  2069. this._lastPointerDownID = pointerId;
  2070. return true;
  2071. };
  2072. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2073. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2074. if (pointerId != this._lastPointerDownID) {
  2075. return;
  2076. }
  2077. // Invert transform
  2078. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2079. var x = this._transformedPosition.x;
  2080. var y = this._transformedPosition.y;
  2081. if (this._pointerIsDown) {
  2082. this._updateValueFromPointer(x, y);
  2083. }
  2084. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2085. };
  2086. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2087. this._pointerIsDown = false;
  2088. delete this._host._capturingControl[pointerId];
  2089. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2090. };
  2091. /**
  2092. * This function expands the color picker by creating a color picker dialog with manual
  2093. * color value input and the ability to save colors into an array to be used later in
  2094. * subsequent launches of the dialogue.
  2095. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2096. * @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.
  2097. * @returns picked color as a hex string and the saved colors array as hex strings.
  2098. */
  2099. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2100. return new Promise(function (resolve, reject) {
  2101. // Default options
  2102. options.pickerWidth = options.pickerWidth || "640px";
  2103. options.pickerHeight = options.pickerHeight || "400px";
  2104. options.headerHeight = options.headerHeight || "35px";
  2105. options.lastColor = options.lastColor || "#000000";
  2106. options.swatchLimit = options.swatchLimit || 20;
  2107. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2108. // Window size settings
  2109. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2110. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2111. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2112. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2113. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2114. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2115. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2116. // Button Colors
  2117. var buttonColor = "#c0c0c0";
  2118. var buttonBackgroundColor = "#535353";
  2119. var buttonBackgroundHoverColor = "#414141";
  2120. var buttonBackgroundClickColor = "515151";
  2121. var buttonDisabledColor = "#555555";
  2122. var buttonDisabledBackgroundColor = "#454545";
  2123. var currentSwatchesOutlineColor = "#404040";
  2124. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2125. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2126. var iconColorDark = "#aaaaaa";
  2127. var iconColorLight = "#ffffff";
  2128. var closeIconColor;
  2129. // Button settings
  2130. var buttonFontSize;
  2131. var butEdit;
  2132. var buttonWidth;
  2133. var buttonHeight;
  2134. // Input Text Colors
  2135. var inputFieldLabels = ["R", "G", "B"];
  2136. var inputTextBackgroundColor = "#454545";
  2137. var inputTextColor = "#f0f0f0";
  2138. // This is the current color as set by either the picker or by entering a value
  2139. var currentColor;
  2140. // This int is used for naming swatches and serves as the index for calling them from the list
  2141. var swatchNumber;
  2142. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2143. var swatchDrawer;
  2144. var editSwatchMode = false;
  2145. // Color InputText fields that will be updated upon value change
  2146. var picker;
  2147. var rValInt;
  2148. var gValInt;
  2149. var bValInt;
  2150. var rValDec;
  2151. var gValDec;
  2152. var bValDec;
  2153. var hexVal;
  2154. var newSwatch;
  2155. var lastVal;
  2156. var activeField;
  2157. /**
  2158. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2159. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2160. * are will receive no update. This is to prevent the input from the user being overwritten.
  2161. */
  2162. function updateValues(value, inputField) {
  2163. activeField = inputField;
  2164. var pickedColor = value.toHexString();
  2165. newSwatch.background = pickedColor;
  2166. if (rValInt.name != activeField) {
  2167. rValInt.text = Math.floor(value.r * 255).toString();
  2168. }
  2169. if (gValInt.name != activeField) {
  2170. gValInt.text = Math.floor(value.g * 255).toString();
  2171. }
  2172. if (bValInt.name != activeField) {
  2173. bValInt.text = Math.floor(value.b * 255).toString();
  2174. }
  2175. if (rValDec.name != activeField) {
  2176. rValDec.text = value.r.toString();
  2177. }
  2178. if (gValDec.name != activeField) {
  2179. gValDec.text = value.g.toString();
  2180. }
  2181. if (bValDec.name != activeField) {
  2182. bValDec.text = value.b.toString();
  2183. }
  2184. if (hexVal.name != activeField) {
  2185. var minusPound = pickedColor.split("#");
  2186. hexVal.text = minusPound[1];
  2187. }
  2188. if (picker.name != activeField) {
  2189. picker.value = value;
  2190. }
  2191. }
  2192. // 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.
  2193. function updateInt(field, channel) {
  2194. var newValue = field.text;
  2195. var checkVal = /[^0-9]/g.test(newValue);
  2196. if (checkVal) {
  2197. field.text = lastVal;
  2198. return;
  2199. }
  2200. else {
  2201. if (newValue != "") {
  2202. if (Math.floor(parseInt(newValue)) < 0) {
  2203. newValue = "0";
  2204. }
  2205. else if (Math.floor(parseInt(newValue)) > 255) {
  2206. newValue = "255";
  2207. }
  2208. else if (isNaN(parseInt(newValue))) {
  2209. newValue = "0";
  2210. }
  2211. }
  2212. if (activeField == field.name) {
  2213. lastVal = newValue;
  2214. }
  2215. }
  2216. if (newValue != "") {
  2217. newValue = parseInt(newValue).toString();
  2218. field.text = newValue;
  2219. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2220. if (activeField == field.name) {
  2221. if (channel == "r") {
  2222. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2223. }
  2224. else if (channel == "g") {
  2225. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2226. }
  2227. else {
  2228. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2229. }
  2230. }
  2231. }
  2232. }
  2233. // 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.
  2234. function updateFloat(field, channel) {
  2235. var newValue = field.text;
  2236. var checkVal = /[^0-9\.]/g.test(newValue);
  2237. if (checkVal) {
  2238. field.text = lastVal;
  2239. return;
  2240. }
  2241. else {
  2242. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2243. if (parseFloat(newValue) < 0.0) {
  2244. newValue = "0.0";
  2245. }
  2246. else if (parseFloat(newValue) > 1.0) {
  2247. newValue = "1.0";
  2248. }
  2249. else if (isNaN(parseFloat(newValue))) {
  2250. newValue = "0.0";
  2251. }
  2252. }
  2253. if (activeField == field.name) {
  2254. lastVal = newValue;
  2255. }
  2256. }
  2257. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2258. newValue = parseFloat(newValue).toString();
  2259. field.text = newValue;
  2260. }
  2261. else {
  2262. newValue = "0.0";
  2263. }
  2264. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2265. if (activeField == field.name) {
  2266. if (channel == "r") {
  2267. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2268. }
  2269. else if (channel == "g") {
  2270. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2271. }
  2272. else {
  2273. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2274. }
  2275. }
  2276. }
  2277. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2278. function deleteSwatch(index) {
  2279. if (options.savedColors) {
  2280. options.savedColors.splice(index, 1);
  2281. }
  2282. if (options.savedColors && options.savedColors.length == 0) {
  2283. setEditButtonVisibility(false);
  2284. editSwatchMode = false;
  2285. }
  2286. }
  2287. // Creates and styles an individual swatch when updateSwatches is called.
  2288. function createSwatch() {
  2289. if (options.savedColors && options.savedColors[swatchNumber]) {
  2290. if (editSwatchMode) {
  2291. var icon = "b";
  2292. }
  2293. else {
  2294. var icon = "";
  2295. }
  2296. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2297. swatch.fontFamily = "BabylonJSglyphs";
  2298. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2299. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2300. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2301. if (swatchLuminence > luminanceLimit) {
  2302. swatch.color = iconColorDark;
  2303. }
  2304. else {
  2305. swatch.color = iconColorLight;
  2306. }
  2307. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2308. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2309. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2310. swatch.background = options.savedColors[swatchNumber];
  2311. swatch.thickness = 2;
  2312. var metadata_1 = swatchNumber;
  2313. swatch.pointerDownAnimation = function () {
  2314. swatch.thickness = 4;
  2315. };
  2316. swatch.pointerUpAnimation = function () {
  2317. swatch.thickness = 3;
  2318. };
  2319. swatch.pointerEnterAnimation = function () {
  2320. swatch.thickness = 3;
  2321. };
  2322. swatch.pointerOutAnimation = function () {
  2323. swatch.thickness = 2;
  2324. };
  2325. swatch.onPointerClickObservable.add(function () {
  2326. if (!editSwatchMode) {
  2327. if (options.savedColors) {
  2328. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2329. }
  2330. }
  2331. else {
  2332. deleteSwatch(metadata_1);
  2333. updateSwatches("", butSave);
  2334. }
  2335. });
  2336. return swatch;
  2337. }
  2338. else {
  2339. return null;
  2340. }
  2341. }
  2342. // Mode switch to render button text and close symbols on swatch controls
  2343. function editSwatches(mode) {
  2344. if (mode !== undefined) {
  2345. editSwatchMode = mode;
  2346. }
  2347. if (editSwatchMode) {
  2348. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2349. var thisButton = swatchDrawer.children[i];
  2350. thisButton.textBlock.text = "b";
  2351. }
  2352. if (butEdit !== undefined) {
  2353. butEdit.textBlock.text = "Done";
  2354. }
  2355. }
  2356. else {
  2357. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2358. var thisButton = swatchDrawer.children[i];
  2359. thisButton.textBlock.text = "";
  2360. }
  2361. if (butEdit !== undefined) {
  2362. butEdit.textBlock.text = "Edit";
  2363. }
  2364. }
  2365. }
  2366. /**
  2367. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2368. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2369. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2370. * saved colors there are and how many can be stored per row.
  2371. */
  2372. function updateSwatches(color, button) {
  2373. if (options.savedColors) {
  2374. if (color != "") {
  2375. options.savedColors.push(color);
  2376. }
  2377. swatchNumber = 0;
  2378. swatchDrawer.clearControls();
  2379. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2380. if (rowCount == 0) {
  2381. var gutterCount = 0;
  2382. }
  2383. else {
  2384. var gutterCount = rowCount + 1;
  2385. }
  2386. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2387. var currentRows = swatchDrawer.rowCount;
  2388. for (var i = 0; i < currentRows; i++) {
  2389. swatchDrawer.removeRowDefinition(0);
  2390. }
  2391. for (var i = 0; i < rowCount + gutterCount; i++) {
  2392. if (i % 2) {
  2393. swatchDrawer.addRowDefinition(swatchSize, true);
  2394. }
  2395. else {
  2396. swatchDrawer.addRowDefinition(gutterSize, true);
  2397. }
  2398. }
  2399. }
  2400. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2401. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2402. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2403. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2404. var totalButtonsThisRow = options.numSwatchesPerLine;
  2405. }
  2406. else {
  2407. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2408. }
  2409. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2410. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2411. if (x > options.numSwatchesPerLine) {
  2412. continue;
  2413. }
  2414. var swatch = createSwatch();
  2415. if (swatch != null) {
  2416. swatchDrawer.addControl(swatch, y, w);
  2417. w += 2;
  2418. swatchNumber++;
  2419. }
  2420. else {
  2421. continue;
  2422. }
  2423. }
  2424. }
  2425. if (options.savedColors.length >= options.swatchLimit) {
  2426. disableButton(button, true);
  2427. }
  2428. else {
  2429. disableButton(button, false);
  2430. }
  2431. }
  2432. }
  2433. // Shows or hides edit swatches button depending on if there are saved swatches
  2434. function setEditButtonVisibility(enableButton) {
  2435. if (enableButton) {
  2436. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2437. butEdit.width = buttonWidth;
  2438. butEdit.height = buttonHeight;
  2439. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2440. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2441. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2442. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2443. butEdit.thickness = 2;
  2444. butEdit.color = buttonColor;
  2445. butEdit.fontSize = buttonFontSize;
  2446. butEdit.background = buttonBackgroundColor;
  2447. butEdit.onPointerEnterObservable.add(function () {
  2448. butEdit.background = buttonBackgroundHoverColor;
  2449. });
  2450. butEdit.onPointerOutObservable.add(function () {
  2451. butEdit.background = buttonBackgroundColor;
  2452. });
  2453. butEdit.pointerDownAnimation = function () {
  2454. butEdit.background = buttonBackgroundClickColor;
  2455. };
  2456. butEdit.pointerUpAnimation = function () {
  2457. butEdit.background = buttonBackgroundHoverColor;
  2458. };
  2459. butEdit.onPointerClickObservable.add(function () {
  2460. if (editSwatchMode) {
  2461. editSwatchMode = false;
  2462. }
  2463. else {
  2464. editSwatchMode = true;
  2465. }
  2466. editSwatches();
  2467. });
  2468. pickerGrid.addControl(butEdit, 1, 0);
  2469. }
  2470. else {
  2471. pickerGrid.removeControl(butEdit);
  2472. }
  2473. }
  2474. // Called when the user hits the limit of saved colors in the drawer.
  2475. function disableButton(button, disabled) {
  2476. if (disabled) {
  2477. button.color = buttonDisabledColor;
  2478. button.background = buttonDisabledBackgroundColor;
  2479. }
  2480. else {
  2481. button.color = buttonColor;
  2482. button.background = buttonBackgroundColor;
  2483. }
  2484. }
  2485. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2486. function closePicker(color) {
  2487. if (options.savedColors && options.savedColors.length > 0) {
  2488. resolve({
  2489. savedColors: options.savedColors,
  2490. pickedColor: color
  2491. });
  2492. }
  2493. else {
  2494. resolve({
  2495. pickedColor: color
  2496. });
  2497. }
  2498. advancedTexture.removeControl(dialogContainer);
  2499. }
  2500. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2501. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2502. dialogContainer.name = "Dialog Container";
  2503. dialogContainer.width = options.pickerWidth;
  2504. if (options.savedColors) {
  2505. dialogContainer.height = containerSize;
  2506. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2507. dialogContainer.addRowDefinition(topRow, false);
  2508. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2509. }
  2510. else {
  2511. dialogContainer.height = options.pickerHeight;
  2512. dialogContainer.addRowDefinition(1.0, false);
  2513. }
  2514. advancedTexture.addControl(dialogContainer);
  2515. // Swatch drawer which contains all saved color buttons
  2516. if (options.savedColors) {
  2517. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2518. swatchDrawer.name = "Swatch Drawer";
  2519. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2520. swatchDrawer.background = buttonBackgroundColor;
  2521. swatchDrawer.width = options.pickerWidth;
  2522. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2523. if (initialRows == 0) {
  2524. var gutterCount = 0;
  2525. }
  2526. else {
  2527. var gutterCount = initialRows + 1;
  2528. }
  2529. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2530. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2531. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2532. if (i % 2 != 0) {
  2533. swatchDrawer.addRowDefinition(swatchSize, true);
  2534. }
  2535. else {
  2536. swatchDrawer.addRowDefinition(gutterSize, true);
  2537. }
  2538. }
  2539. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2540. if (i % 2 != 0) {
  2541. swatchDrawer.addColumnDefinition(swatchSize, true);
  2542. }
  2543. else {
  2544. swatchDrawer.addColumnDefinition(gutterSize, true);
  2545. }
  2546. }
  2547. dialogContainer.addControl(swatchDrawer, 1, 0);
  2548. }
  2549. // Picker container
  2550. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2551. pickerPanel.name = "Picker Panel";
  2552. pickerPanel.height = options.pickerHeight;
  2553. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2554. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2555. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2556. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2557. dialogContainer.addControl(pickerPanel, 0, 0);
  2558. // Picker container header
  2559. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2560. header.name = "Dialogue Header Bar";
  2561. header.background = "#cccccc";
  2562. header.thickness = 0;
  2563. pickerPanel.addControl(header, 0, 0);
  2564. // Header close button
  2565. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2566. closeButton.fontFamily = "BabylonJSglyphs";
  2567. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2568. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2569. closeButton.color = closeIconColor.toHexString();
  2570. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2571. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2572. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2573. closeButton.height = closeButton.width = options.headerHeight;
  2574. closeButton.background = header.background;
  2575. closeButton.thickness = 0;
  2576. closeButton.pointerDownAnimation = function () {
  2577. };
  2578. closeButton.pointerUpAnimation = function () {
  2579. closeButton.background = header.background;
  2580. };
  2581. closeButton.pointerEnterAnimation = function () {
  2582. closeButton.color = header.background;
  2583. closeButton.background = "red";
  2584. };
  2585. closeButton.pointerOutAnimation = function () {
  2586. closeButton.color = closeIconColor.toHexString();
  2587. closeButton.background = header.background;
  2588. };
  2589. closeButton.onPointerClickObservable.add(function () {
  2590. closePicker(currentSwatch.background);
  2591. });
  2592. pickerPanel.addControl(closeButton, 0, 0);
  2593. // Dialog container body
  2594. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2595. dialogBody.name = "Dialogue Body";
  2596. dialogBody.background = buttonBackgroundColor;
  2597. var dialogBodyCols = [0.4375, 0.5625];
  2598. dialogBody.addRowDefinition(1.0, false);
  2599. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2600. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2601. pickerPanel.addControl(dialogBody, 1, 0);
  2602. // Picker grid
  2603. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2604. pickerGrid.name = "Picker Grid";
  2605. pickerGrid.addRowDefinition(0.85, false);
  2606. pickerGrid.addRowDefinition(0.15, false);
  2607. dialogBody.addControl(pickerGrid, 0, 0);
  2608. // Picker control
  2609. picker = new ColorPicker();
  2610. picker.name = "GUI Color Picker";
  2611. if (options.pickerHeight < options.pickerWidth) {
  2612. picker.width = 0.89;
  2613. }
  2614. else {
  2615. picker.height = 0.89;
  2616. }
  2617. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2618. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2619. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2620. picker.onPointerDownObservable.add(function () {
  2621. activeField = picker.name;
  2622. lastVal = "";
  2623. editSwatches(false);
  2624. });
  2625. picker.onValueChangedObservable.add(function (value) {
  2626. if (activeField == picker.name) {
  2627. updateValues(value, picker.name);
  2628. }
  2629. });
  2630. pickerGrid.addControl(picker, 0, 0);
  2631. // Picker body right quarant
  2632. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2633. pickerBodyRight.name = "Dialogue Right Half";
  2634. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2635. var pickerBodyRightRows = [0.514, 0.486];
  2636. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2637. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2638. dialogBody.addControl(pickerBodyRight, 1, 1);
  2639. // Picker container swatches and buttons
  2640. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2641. pickerSwatchesButtons.name = "Swatches and Buttons";
  2642. var pickerButtonsCol = [0.417, 0.583];
  2643. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2644. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2645. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2646. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2647. // Picker Swatches quadrant
  2648. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2649. pickerSwatches.name = "New and Current Swatches";
  2650. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2651. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2652. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2653. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2654. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2655. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2656. // Active swatches
  2657. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2658. activeSwatches.name = "Active Swatches";
  2659. activeSwatches.width = 0.67;
  2660. activeSwatches.addRowDefinition(0.5, false);
  2661. activeSwatches.addRowDefinition(0.5, false);
  2662. pickerSwatches.addControl(activeSwatches, 2, 0);
  2663. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2664. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2665. if (options.pickerWidth > options.pickerHeight) {
  2666. var labelTextSize = labelHeight;
  2667. }
  2668. else {
  2669. var labelTextSize = labelWidth;
  2670. }
  2671. // New color swatch and previous color button
  2672. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2673. newText.text = "new";
  2674. newText.name = "New Color Label";
  2675. newText.color = buttonColor;
  2676. newText.fontSize = labelTextSize;
  2677. pickerSwatches.addControl(newText, 1, 0);
  2678. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2679. newSwatch.name = "New Color Swatch";
  2680. newSwatch.background = options.lastColor;
  2681. newSwatch.thickness = 0;
  2682. activeSwatches.addControl(newSwatch, 0, 0);
  2683. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2684. currentSwatch.background = options.lastColor;
  2685. currentSwatch.thickness = 0;
  2686. currentSwatch.onPointerClickObservable.add(function () {
  2687. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2688. updateValues(revertColor, currentSwatch.name);
  2689. editSwatches(false);
  2690. });
  2691. currentSwatch.pointerDownAnimation = function () { };
  2692. currentSwatch.pointerUpAnimation = function () { };
  2693. currentSwatch.pointerEnterAnimation = function () { };
  2694. currentSwatch.pointerOutAnimation = function () { };
  2695. activeSwatches.addControl(currentSwatch, 1, 0);
  2696. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2697. swatchOutline.name = "Swatch Outline";
  2698. swatchOutline.width = 0.67;
  2699. swatchOutline.thickness = 2;
  2700. swatchOutline.color = currentSwatchesOutlineColor;
  2701. swatchOutline.isHitTestVisible = false;
  2702. pickerSwatches.addControl(swatchOutline, 2, 0);
  2703. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2704. currentText.name = "Current Color Label";
  2705. currentText.text = "current";
  2706. currentText.color = buttonColor;
  2707. currentText.fontSize = labelTextSize;
  2708. pickerSwatches.addControl(currentText, 3, 0);
  2709. // Buttons grid
  2710. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2711. buttonGrid.name = "Button Grid";
  2712. buttonGrid.height = 0.8;
  2713. var buttonGridRows = 1 / 3;
  2714. buttonGrid.addRowDefinition(buttonGridRows, false);
  2715. buttonGrid.addRowDefinition(buttonGridRows, false);
  2716. buttonGrid.addRowDefinition(buttonGridRows, false);
  2717. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2718. // Determine pixel width and height for all buttons from overall panel dimensions
  2719. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2720. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2721. // Determine button type size
  2722. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2723. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2724. }
  2725. else {
  2726. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2727. }
  2728. // Panel Buttons
  2729. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2730. butOK.width = buttonWidth;
  2731. butOK.height = buttonHeight;
  2732. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2733. butOK.thickness = 2;
  2734. butOK.color = buttonColor;
  2735. butOK.fontSize = buttonFontSize;
  2736. butOK.background = buttonBackgroundColor;
  2737. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2738. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2739. butOK.pointerDownAnimation = function () {
  2740. butOK.background = buttonBackgroundClickColor;
  2741. };
  2742. butOK.pointerUpAnimation = function () {
  2743. butOK.background = buttonBackgroundHoverColor;
  2744. };
  2745. butOK.onPointerClickObservable.add(function () {
  2746. editSwatches(false);
  2747. closePicker(newSwatch.background);
  2748. });
  2749. buttonGrid.addControl(butOK, 0, 0);
  2750. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2751. butCancel.width = buttonWidth;
  2752. butCancel.height = buttonHeight;
  2753. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2754. butCancel.thickness = 2;
  2755. butCancel.color = buttonColor;
  2756. butCancel.fontSize = buttonFontSize;
  2757. butCancel.background = buttonBackgroundColor;
  2758. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2759. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2760. butCancel.pointerDownAnimation = function () {
  2761. butCancel.background = buttonBackgroundClickColor;
  2762. };
  2763. butCancel.pointerUpAnimation = function () {
  2764. butCancel.background = buttonBackgroundHoverColor;
  2765. };
  2766. butCancel.onPointerClickObservable.add(function () {
  2767. editSwatches(false);
  2768. closePicker(currentSwatch.background);
  2769. });
  2770. buttonGrid.addControl(butCancel, 1, 0);
  2771. if (options.savedColors) {
  2772. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2773. butSave.width = buttonWidth;
  2774. butSave.height = buttonHeight;
  2775. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2776. butSave.thickness = 2;
  2777. butSave.fontSize = buttonFontSize;
  2778. if (options.savedColors.length < options.swatchLimit) {
  2779. butSave.color = buttonColor;
  2780. butSave.background = buttonBackgroundColor;
  2781. }
  2782. else {
  2783. disableButton(butSave, true);
  2784. }
  2785. butSave.onPointerEnterObservable.add(function () {
  2786. if (options.savedColors) {
  2787. if (options.savedColors.length < options.swatchLimit) {
  2788. butSave.background = buttonBackgroundHoverColor;
  2789. }
  2790. }
  2791. });
  2792. butSave.onPointerOutObservable.add(function () {
  2793. if (options.savedColors) {
  2794. if (options.savedColors.length < options.swatchLimit) {
  2795. butSave.background = buttonBackgroundColor;
  2796. }
  2797. }
  2798. });
  2799. butSave.pointerDownAnimation = function () {
  2800. if (options.savedColors) {
  2801. if (options.savedColors.length < options.swatchLimit) {
  2802. butSave.background = buttonBackgroundClickColor;
  2803. }
  2804. }
  2805. };
  2806. butSave.pointerUpAnimation = function () {
  2807. if (options.savedColors) {
  2808. if (options.savedColors.length < options.swatchLimit) {
  2809. butSave.background = buttonBackgroundHoverColor;
  2810. }
  2811. }
  2812. };
  2813. butSave.onPointerClickObservable.add(function () {
  2814. if (options.savedColors) {
  2815. if (options.savedColors.length == 0) {
  2816. setEditButtonVisibility(true);
  2817. }
  2818. if (options.savedColors.length < options.swatchLimit) {
  2819. updateSwatches(newSwatch.background, butSave);
  2820. }
  2821. editSwatches(false);
  2822. }
  2823. });
  2824. if (options.savedColors.length > 0) {
  2825. setEditButtonVisibility(true);
  2826. }
  2827. buttonGrid.addControl(butSave, 2, 0);
  2828. }
  2829. // Picker color values input
  2830. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2831. pickerColorValues.name = "Dialog Lower Right";
  2832. pickerColorValues.addRowDefinition(0.02, false);
  2833. pickerColorValues.addRowDefinition(0.63, false);
  2834. pickerColorValues.addRowDefinition(0.21, false);
  2835. pickerColorValues.addRowDefinition(0.14, false);
  2836. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2837. // RGB values text boxes
  2838. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2839. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2840. rgbValuesQuadrant.name = "RGB Values";
  2841. rgbValuesQuadrant.width = 0.82;
  2842. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2843. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2844. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2845. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2846. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2847. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2848. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2849. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2850. for (var i = 0; i < inputFieldLabels.length; i++) {
  2851. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2852. labelText.text = inputFieldLabels[i];
  2853. labelText.color = buttonColor;
  2854. labelText.fontSize = buttonFontSize;
  2855. rgbValuesQuadrant.addControl(labelText, i, 0);
  2856. }
  2857. // Input fields for RGB values
  2858. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2859. rValInt.width = 0.83;
  2860. rValInt.height = 0.72;
  2861. rValInt.name = "rIntField";
  2862. rValInt.fontSize = buttonFontSize;
  2863. rValInt.text = (currentColor.r * 255).toString();
  2864. rValInt.color = inputTextColor;
  2865. rValInt.background = inputTextBackgroundColor;
  2866. rValInt.onFocusObservable.add(function () {
  2867. activeField = rValInt.name;
  2868. lastVal = rValInt.text;
  2869. editSwatches(false);
  2870. });
  2871. rValInt.onBlurObservable.add(function () {
  2872. if (rValInt.text == "") {
  2873. rValInt.text = "0";
  2874. }
  2875. updateInt(rValInt, "r");
  2876. if (activeField == rValInt.name) {
  2877. activeField = "";
  2878. }
  2879. });
  2880. rValInt.onTextChangedObservable.add(function () {
  2881. if (activeField == rValInt.name) {
  2882. updateInt(rValInt, "r");
  2883. }
  2884. });
  2885. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2886. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2887. gValInt.width = 0.83;
  2888. gValInt.height = 0.72;
  2889. gValInt.name = "gIntField";
  2890. gValInt.fontSize = buttonFontSize;
  2891. gValInt.text = (currentColor.g * 255).toString();
  2892. gValInt.color = inputTextColor;
  2893. gValInt.background = inputTextBackgroundColor;
  2894. gValInt.onFocusObservable.add(function () {
  2895. activeField = gValInt.name;
  2896. lastVal = gValInt.text;
  2897. editSwatches(false);
  2898. });
  2899. gValInt.onBlurObservable.add(function () {
  2900. if (gValInt.text == "") {
  2901. gValInt.text = "0";
  2902. }
  2903. updateInt(gValInt, "g");
  2904. if (activeField == gValInt.name) {
  2905. activeField = "";
  2906. }
  2907. });
  2908. gValInt.onTextChangedObservable.add(function () {
  2909. if (activeField == gValInt.name) {
  2910. updateInt(gValInt, "g");
  2911. }
  2912. });
  2913. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2914. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2915. bValInt.width = 0.83;
  2916. bValInt.height = 0.72;
  2917. bValInt.name = "bIntField";
  2918. bValInt.fontSize = buttonFontSize;
  2919. bValInt.text = (currentColor.b * 255).toString();
  2920. bValInt.color = inputTextColor;
  2921. bValInt.background = inputTextBackgroundColor;
  2922. bValInt.onFocusObservable.add(function () {
  2923. activeField = bValInt.name;
  2924. lastVal = bValInt.text;
  2925. editSwatches(false);
  2926. });
  2927. bValInt.onBlurObservable.add(function () {
  2928. if (bValInt.text == "") {
  2929. bValInt.text = "0";
  2930. }
  2931. updateInt(bValInt, "b");
  2932. if (activeField == bValInt.name) {
  2933. activeField = "";
  2934. }
  2935. });
  2936. bValInt.onTextChangedObservable.add(function () {
  2937. if (activeField == bValInt.name) {
  2938. updateInt(bValInt, "b");
  2939. }
  2940. });
  2941. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2942. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2943. rValDec.width = 0.95;
  2944. rValDec.height = 0.72;
  2945. rValDec.name = "rDecField";
  2946. rValDec.fontSize = buttonFontSize;
  2947. rValDec.text = currentColor.r.toString();
  2948. rValDec.color = inputTextColor;
  2949. rValDec.background = inputTextBackgroundColor;
  2950. rValDec.onFocusObservable.add(function () {
  2951. activeField = rValDec.name;
  2952. lastVal = rValDec.text;
  2953. editSwatches(false);
  2954. });
  2955. rValDec.onBlurObservable.add(function () {
  2956. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2957. rValDec.text = "0";
  2958. updateFloat(rValDec, "r");
  2959. }
  2960. if (activeField == rValDec.name) {
  2961. activeField = "";
  2962. }
  2963. });
  2964. rValDec.onTextChangedObservable.add(function () {
  2965. if (activeField == rValDec.name) {
  2966. updateFloat(rValDec, "r");
  2967. }
  2968. });
  2969. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2970. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2971. gValDec.width = 0.95;
  2972. gValDec.height = 0.72;
  2973. gValDec.name = "gDecField";
  2974. gValDec.fontSize = buttonFontSize;
  2975. gValDec.text = currentColor.g.toString();
  2976. gValDec.color = inputTextColor;
  2977. gValDec.background = inputTextBackgroundColor;
  2978. gValDec.onFocusObservable.add(function () {
  2979. activeField = gValDec.name;
  2980. lastVal = gValDec.text;
  2981. editSwatches(false);
  2982. });
  2983. gValDec.onBlurObservable.add(function () {
  2984. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2985. gValDec.text = "0";
  2986. updateFloat(gValDec, "g");
  2987. }
  2988. if (activeField == gValDec.name) {
  2989. activeField = "";
  2990. }
  2991. });
  2992. gValDec.onTextChangedObservable.add(function () {
  2993. if (activeField == gValDec.name) {
  2994. updateFloat(gValDec, "g");
  2995. }
  2996. });
  2997. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  2998. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2999. bValDec.width = 0.95;
  3000. bValDec.height = 0.72;
  3001. bValDec.name = "bDecField";
  3002. bValDec.fontSize = buttonFontSize;
  3003. bValDec.text = currentColor.b.toString();
  3004. bValDec.color = inputTextColor;
  3005. bValDec.background = inputTextBackgroundColor;
  3006. bValDec.onFocusObservable.add(function () {
  3007. activeField = bValDec.name;
  3008. lastVal = bValDec.text;
  3009. editSwatches(false);
  3010. });
  3011. bValDec.onBlurObservable.add(function () {
  3012. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3013. bValDec.text = "0";
  3014. updateFloat(bValDec, "b");
  3015. }
  3016. if (activeField == bValDec.name) {
  3017. activeField = "";
  3018. }
  3019. });
  3020. bValDec.onTextChangedObservable.add(function () {
  3021. if (activeField == bValDec.name) {
  3022. updateFloat(bValDec, "b");
  3023. }
  3024. });
  3025. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3026. // Hex value input
  3027. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3028. hexValueQuadrant.name = "Hex Value";
  3029. hexValueQuadrant.width = 0.82;
  3030. hexValueQuadrant.addRowDefinition(1.0, false);
  3031. hexValueQuadrant.addColumnDefinition(0.1, false);
  3032. hexValueQuadrant.addColumnDefinition(0.9, false);
  3033. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3034. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3035. labelText.text = "#";
  3036. labelText.color = buttonColor;
  3037. labelText.fontSize = buttonFontSize;
  3038. hexValueQuadrant.addControl(labelText, 0, 0);
  3039. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3040. hexVal.width = 0.96;
  3041. hexVal.height = 0.72;
  3042. hexVal.name = "hexField";
  3043. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3044. hexVal.fontSize = buttonFontSize;
  3045. var minusPound = options.lastColor.split("#");
  3046. hexVal.text = minusPound[1];
  3047. hexVal.color = inputTextColor;
  3048. hexVal.background = inputTextBackgroundColor;
  3049. hexVal.onFocusObservable.add(function () {
  3050. activeField = hexVal.name;
  3051. lastVal = hexVal.text;
  3052. editSwatches(false);
  3053. });
  3054. hexVal.onBlurObservable.add(function () {
  3055. if (hexVal.text.length == 3) {
  3056. var val = hexVal.text.split("");
  3057. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3058. }
  3059. if (hexVal.text == "") {
  3060. hexVal.text = "000000";
  3061. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3062. }
  3063. if (activeField == hexVal.name) {
  3064. activeField = "";
  3065. }
  3066. });
  3067. hexVal.onTextChangedObservable.add(function () {
  3068. var newHexValue = hexVal.text;
  3069. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3070. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3071. hexVal.text = lastVal;
  3072. }
  3073. else {
  3074. if (hexVal.text.length < 6) {
  3075. var leadingZero = 6 - hexVal.text.length;
  3076. for (var i = 0; i < leadingZero; i++) {
  3077. newHexValue = "0" + newHexValue;
  3078. }
  3079. }
  3080. if (hexVal.text.length == 3) {
  3081. var val = hexVal.text.split("");
  3082. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3083. }
  3084. newHexValue = "#" + newHexValue;
  3085. if (activeField == hexVal.name) {
  3086. lastVal = hexVal.text;
  3087. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3088. }
  3089. }
  3090. });
  3091. hexValueQuadrant.addControl(hexVal, 0, 1);
  3092. if (options.savedColors && options.savedColors.length > 0) {
  3093. updateSwatches("", butSave);
  3094. }
  3095. });
  3096. };
  3097. ColorPicker._Epsilon = 0.000001;
  3098. return ColorPicker;
  3099. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3100. /***/ }),
  3101. /***/ "./2D/controls/container.ts":
  3102. /*!**********************************!*\
  3103. !*** ./2D/controls/container.ts ***!
  3104. \**********************************/
  3105. /*! exports provided: Container */
  3106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3107. "use strict";
  3108. __webpack_require__.r(__webpack_exports__);
  3109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3110. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3111. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math");
  3112. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3113. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3114. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3115. /**
  3116. * Root class for 2D containers
  3117. * @see http://doc.babylonjs.com/how_to/gui#containers
  3118. */
  3119. var Container = /** @class */ (function (_super) {
  3120. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3121. /**
  3122. * Creates a new Container
  3123. * @param name defines the name of the container
  3124. */
  3125. function Container(name) {
  3126. var _this = _super.call(this, name) || this;
  3127. _this.name = name;
  3128. /** @hidden */
  3129. _this._children = new Array();
  3130. /** @hidden */
  3131. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3132. /** @hidden */
  3133. _this._background = "";
  3134. /** @hidden */
  3135. _this._adaptWidthToChildren = false;
  3136. /** @hidden */
  3137. _this._adaptHeightToChildren = false;
  3138. /**
  3139. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3140. */
  3141. _this.logLayoutCycleErrors = false;
  3142. /**
  3143. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3144. */
  3145. _this.maxLayoutCycle = 3;
  3146. return _this;
  3147. }
  3148. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3149. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3150. get: function () {
  3151. return this._adaptHeightToChildren;
  3152. },
  3153. set: function (value) {
  3154. if (this._adaptHeightToChildren === value) {
  3155. return;
  3156. }
  3157. this._adaptHeightToChildren = value;
  3158. if (value) {
  3159. this.height = "100%";
  3160. }
  3161. this._markAsDirty();
  3162. },
  3163. enumerable: true,
  3164. configurable: true
  3165. });
  3166. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3167. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3168. get: function () {
  3169. return this._adaptWidthToChildren;
  3170. },
  3171. set: function (value) {
  3172. if (this._adaptWidthToChildren === value) {
  3173. return;
  3174. }
  3175. this._adaptWidthToChildren = value;
  3176. if (value) {
  3177. this.width = "100%";
  3178. }
  3179. this._markAsDirty();
  3180. },
  3181. enumerable: true,
  3182. configurable: true
  3183. });
  3184. Object.defineProperty(Container.prototype, "background", {
  3185. /** Gets or sets background color */
  3186. get: function () {
  3187. return this._background;
  3188. },
  3189. set: function (value) {
  3190. if (this._background === value) {
  3191. return;
  3192. }
  3193. this._background = value;
  3194. this._markAsDirty();
  3195. },
  3196. enumerable: true,
  3197. configurable: true
  3198. });
  3199. Object.defineProperty(Container.prototype, "children", {
  3200. /** Gets the list of children */
  3201. get: function () {
  3202. return this._children;
  3203. },
  3204. enumerable: true,
  3205. configurable: true
  3206. });
  3207. Container.prototype._getTypeName = function () {
  3208. return "Container";
  3209. };
  3210. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3211. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3212. var child = _a[_i];
  3213. child._markMatrixAsDirty();
  3214. }
  3215. };
  3216. /**
  3217. * Gets a child using its name
  3218. * @param name defines the child name to look for
  3219. * @returns the child control if found
  3220. */
  3221. Container.prototype.getChildByName = function (name) {
  3222. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3223. var child = _a[_i];
  3224. if (child.name === name) {
  3225. return child;
  3226. }
  3227. }
  3228. return null;
  3229. };
  3230. /**
  3231. * Gets a child using its type and its name
  3232. * @param name defines the child name to look for
  3233. * @param type defines the child type to look for
  3234. * @returns the child control if found
  3235. */
  3236. Container.prototype.getChildByType = function (name, type) {
  3237. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3238. var child = _a[_i];
  3239. if (child.typeName === type) {
  3240. return child;
  3241. }
  3242. }
  3243. return null;
  3244. };
  3245. /**
  3246. * Search for a specific control in children
  3247. * @param control defines the control to look for
  3248. * @returns true if the control is in child list
  3249. */
  3250. Container.prototype.containsControl = function (control) {
  3251. return this.children.indexOf(control) !== -1;
  3252. };
  3253. /**
  3254. * Adds a new control to the current container
  3255. * @param control defines the control to add
  3256. * @returns the current container
  3257. */
  3258. Container.prototype.addControl = function (control) {
  3259. if (!control) {
  3260. return this;
  3261. }
  3262. var index = this._children.indexOf(control);
  3263. if (index !== -1) {
  3264. return this;
  3265. }
  3266. control._link(this._host);
  3267. control._markAllAsDirty();
  3268. this._reOrderControl(control);
  3269. this._markAsDirty();
  3270. return this;
  3271. };
  3272. /**
  3273. * Removes all controls from the current container
  3274. * @returns the current container
  3275. */
  3276. Container.prototype.clearControls = function () {
  3277. var children = this.children.slice();
  3278. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3279. var child = children_1[_i];
  3280. this.removeControl(child);
  3281. }
  3282. return this;
  3283. };
  3284. /**
  3285. * Removes a control from the current container
  3286. * @param control defines the control to remove
  3287. * @returns the current container
  3288. */
  3289. Container.prototype.removeControl = function (control) {
  3290. var index = this._children.indexOf(control);
  3291. if (index !== -1) {
  3292. this._children.splice(index, 1);
  3293. control.parent = null;
  3294. }
  3295. control.linkWithMesh(null);
  3296. if (this._host) {
  3297. this._host._cleanControlAfterRemoval(control);
  3298. }
  3299. this._markAsDirty();
  3300. return this;
  3301. };
  3302. /** @hidden */
  3303. Container.prototype._reOrderControl = function (control) {
  3304. this.removeControl(control);
  3305. var wasAdded = false;
  3306. for (var index = 0; index < this._children.length; index++) {
  3307. if (this._children[index].zIndex > control.zIndex) {
  3308. this._children.splice(index, 0, control);
  3309. wasAdded = true;
  3310. break;
  3311. }
  3312. }
  3313. if (!wasAdded) {
  3314. this._children.push(control);
  3315. }
  3316. control.parent = this;
  3317. this._markAsDirty();
  3318. };
  3319. /** @hidden */
  3320. Container.prototype._offsetLeft = function (offset) {
  3321. _super.prototype._offsetLeft.call(this, offset);
  3322. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3323. var child = _a[_i];
  3324. child._offsetLeft(offset);
  3325. }
  3326. };
  3327. /** @hidden */
  3328. Container.prototype._offsetTop = function (offset) {
  3329. _super.prototype._offsetTop.call(this, offset);
  3330. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3331. var child = _a[_i];
  3332. child._offsetTop(offset);
  3333. }
  3334. };
  3335. /** @hidden */
  3336. Container.prototype._markAllAsDirty = function () {
  3337. _super.prototype._markAllAsDirty.call(this);
  3338. for (var index = 0; index < this._children.length; index++) {
  3339. this._children[index]._markAllAsDirty();
  3340. }
  3341. };
  3342. /** @hidden */
  3343. Container.prototype._localDraw = function (context) {
  3344. if (this._background) {
  3345. context.save();
  3346. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3347. context.shadowColor = this.shadowColor;
  3348. context.shadowBlur = this.shadowBlur;
  3349. context.shadowOffsetX = this.shadowOffsetX;
  3350. context.shadowOffsetY = this.shadowOffsetY;
  3351. }
  3352. context.fillStyle = this._background;
  3353. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3354. context.restore();
  3355. }
  3356. };
  3357. /** @hidden */
  3358. Container.prototype._link = function (host) {
  3359. _super.prototype._link.call(this, host);
  3360. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3361. var child = _a[_i];
  3362. child._link(host);
  3363. }
  3364. };
  3365. /** @hidden */
  3366. Container.prototype._beforeLayout = function () {
  3367. // Do nothing
  3368. };
  3369. /** @hidden */
  3370. Container.prototype._processMeasures = function (parentMeasure, context) {
  3371. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3372. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3373. this._evaluateClippingState(parentMeasure);
  3374. }
  3375. };
  3376. /** @hidden */
  3377. Container.prototype._layout = function (parentMeasure, context) {
  3378. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3379. return false;
  3380. }
  3381. if (this._isDirty) {
  3382. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3383. }
  3384. var rebuildCount = 0;
  3385. context.save();
  3386. this._applyStates(context);
  3387. this._beforeLayout();
  3388. do {
  3389. var computedWidth = -1;
  3390. var computedHeight = -1;
  3391. this._rebuildLayout = false;
  3392. this._processMeasures(parentMeasure, context);
  3393. if (!this._isClipped) {
  3394. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3395. var child = _a[_i];
  3396. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3397. if (child._layout(this._measureForChildren, context)) {
  3398. if (this.adaptWidthToChildren && child._width.isPixel) {
  3399. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3400. }
  3401. if (this.adaptHeightToChildren && child._height.isPixel) {
  3402. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3403. }
  3404. }
  3405. }
  3406. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3407. if (this.width !== computedWidth + "px") {
  3408. this.width = computedWidth + "px";
  3409. this._rebuildLayout = true;
  3410. }
  3411. }
  3412. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3413. if (this.height !== computedHeight + "px") {
  3414. this.height = computedHeight + "px";
  3415. this._rebuildLayout = true;
  3416. }
  3417. }
  3418. this._postMeasure();
  3419. }
  3420. rebuildCount++;
  3421. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3422. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3423. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3424. }
  3425. context.restore();
  3426. if (this._isDirty) {
  3427. this.invalidateRect();
  3428. this._isDirty = false;
  3429. }
  3430. return true;
  3431. };
  3432. Container.prototype._postMeasure = function () {
  3433. // Do nothing by default
  3434. };
  3435. /** @hidden */
  3436. Container.prototype._draw = function (context, invalidatedRectangle) {
  3437. this._localDraw(context);
  3438. if (this.clipChildren) {
  3439. this._clipForChildren(context);
  3440. }
  3441. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3442. var child = _a[_i];
  3443. // Only redraw parts of the screen that are invalidated
  3444. if (invalidatedRectangle) {
  3445. if (!child._intersectsRect(invalidatedRectangle)) {
  3446. continue;
  3447. }
  3448. }
  3449. child._render(context, invalidatedRectangle);
  3450. }
  3451. };
  3452. /** @hidden */
  3453. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3454. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3455. if (!this.children) {
  3456. return;
  3457. }
  3458. for (var index = 0; index < this.children.length; index++) {
  3459. var item = this.children[index];
  3460. if (!predicate || predicate(item)) {
  3461. results.push(item);
  3462. }
  3463. if (!directDescendantsOnly) {
  3464. item._getDescendants(results, false, predicate);
  3465. }
  3466. }
  3467. };
  3468. /** @hidden */
  3469. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3470. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3471. return false;
  3472. }
  3473. if (!_super.prototype.contains.call(this, x, y)) {
  3474. return false;
  3475. }
  3476. // Checking backwards to pick closest first
  3477. for (var index = this._children.length - 1; index >= 0; index--) {
  3478. var child = this._children[index];
  3479. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3480. if (child.hoverCursor) {
  3481. this._host._changeCursor(child.hoverCursor);
  3482. }
  3483. return true;
  3484. }
  3485. }
  3486. if (!this.isHitTestVisible) {
  3487. return false;
  3488. }
  3489. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3490. };
  3491. /** @hidden */
  3492. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3493. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3494. this._measureForChildren.copyFrom(this._currentMeasure);
  3495. };
  3496. /** Releases associated resources */
  3497. Container.prototype.dispose = function () {
  3498. _super.prototype.dispose.call(this);
  3499. for (var index = this.children.length - 1; index >= 0; index--) {
  3500. this.children[index].dispose();
  3501. }
  3502. };
  3503. return Container;
  3504. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3505. /***/ }),
  3506. /***/ "./2D/controls/control.ts":
  3507. /*!********************************!*\
  3508. !*** ./2D/controls/control.ts ***!
  3509. \********************************/
  3510. /*! exports provided: Control */
  3511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3512. "use strict";
  3513. __webpack_require__.r(__webpack_exports__);
  3514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3515. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  3516. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3517. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3518. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3519. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3520. /**
  3521. * Root class used for all 2D controls
  3522. * @see http://doc.babylonjs.com/how_to/gui#controls
  3523. */
  3524. var Control = /** @class */ (function () {
  3525. // Functions
  3526. /**
  3527. * Creates a new control
  3528. * @param name defines the name of the control
  3529. */
  3530. function Control(
  3531. /** defines the name of the control */
  3532. name) {
  3533. this.name = name;
  3534. this._alpha = 1;
  3535. this._alphaSet = false;
  3536. this._zIndex = 0;
  3537. /** @hidden */
  3538. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3539. this._fontFamily = "Arial";
  3540. this._fontStyle = "";
  3541. this._fontWeight = "";
  3542. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3543. /** @hidden */
  3544. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3545. /** @hidden */
  3546. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3547. this._color = "";
  3548. this._style = null;
  3549. /** @hidden */
  3550. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3551. /** @hidden */
  3552. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3553. /** @hidden */
  3554. this._isDirty = true;
  3555. /** @hidden */
  3556. this._wasDirty = false;
  3557. /** @hidden */
  3558. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3559. /** @hidden */
  3560. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3561. /** @hidden */
  3562. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3563. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3564. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3565. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3566. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3567. /** @hidden */
  3568. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3569. /** @hidden */
  3570. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3571. this._scaleX = 1.0;
  3572. this._scaleY = 1.0;
  3573. this._rotation = 0;
  3574. this._transformCenterX = 0.5;
  3575. this._transformCenterY = 0.5;
  3576. /** @hidden */
  3577. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3578. /** @hidden */
  3579. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3580. /** @hidden */
  3581. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3582. this._isMatrixDirty = true;
  3583. this._isVisible = true;
  3584. this._isHighlighted = false;
  3585. this._fontSet = false;
  3586. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3587. this._downCount = 0;
  3588. this._enterCount = -1;
  3589. this._doNotRender = false;
  3590. this._downPointerIds = {};
  3591. this._isEnabled = true;
  3592. this._disabledColor = "#9a9a9a";
  3593. /** @hidden */
  3594. this._rebuildLayout = false;
  3595. /** @hidden */
  3596. this._isClipped = false;
  3597. /**
  3598. * Gets or sets an object used to store user defined information for the node
  3599. */
  3600. this.metadata = null;
  3601. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3602. this.isHitTestVisible = true;
  3603. /** Gets or sets a boolean indicating if the control can block pointer events */
  3604. this.isPointerBlocker = false;
  3605. /** Gets or sets a boolean indicating if the control can be focusable */
  3606. this.isFocusInvisible = false;
  3607. /**
  3608. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3609. * 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
  3610. */
  3611. this.clipChildren = true;
  3612. /**
  3613. * Gets or sets a boolean indicating that control content must be clipped
  3614. * 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
  3615. */
  3616. this.clipContent = true;
  3617. /**
  3618. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3619. */
  3620. this.useBitmapCache = false;
  3621. this._shadowOffsetX = 0;
  3622. this._shadowOffsetY = 0;
  3623. this._shadowBlur = 0;
  3624. this._shadowColor = 'black';
  3625. /** Gets or sets the cursor to use when the control is hovered */
  3626. this.hoverCursor = "";
  3627. /** @hidden */
  3628. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3629. /** @hidden */
  3630. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3631. /**
  3632. * An event triggered when the pointer move over the control.
  3633. */
  3634. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3635. /**
  3636. * An event triggered when the pointer move out of the control.
  3637. */
  3638. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3639. /**
  3640. * An event triggered when the pointer taps the control
  3641. */
  3642. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3643. /**
  3644. * An event triggered when pointer up
  3645. */
  3646. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3647. /**
  3648. * An event triggered when a control is clicked on
  3649. */
  3650. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3651. /**
  3652. * An event triggered when pointer enters the control
  3653. */
  3654. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3655. /**
  3656. * An event triggered when the control is marked as dirty
  3657. */
  3658. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3659. /**
  3660. * An event triggered before drawing the control
  3661. */
  3662. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3663. /**
  3664. * An event triggered after the control was drawn
  3665. */
  3666. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3667. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3668. }
  3669. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3670. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3671. get: function () {
  3672. return this._shadowOffsetX;
  3673. },
  3674. set: function (value) {
  3675. if (this._shadowOffsetX === value) {
  3676. return;
  3677. }
  3678. this._shadowOffsetX = value;
  3679. this._markAsDirty();
  3680. },
  3681. enumerable: true,
  3682. configurable: true
  3683. });
  3684. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3685. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3686. get: function () {
  3687. return this._shadowOffsetY;
  3688. },
  3689. set: function (value) {
  3690. if (this._shadowOffsetY === value) {
  3691. return;
  3692. }
  3693. this._shadowOffsetY = value;
  3694. this._markAsDirty();
  3695. },
  3696. enumerable: true,
  3697. configurable: true
  3698. });
  3699. Object.defineProperty(Control.prototype, "shadowBlur", {
  3700. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3701. get: function () {
  3702. return this._shadowBlur;
  3703. },
  3704. set: function (value) {
  3705. if (this._shadowBlur === value) {
  3706. return;
  3707. }
  3708. this._shadowBlur = value;
  3709. this._markAsDirty();
  3710. },
  3711. enumerable: true,
  3712. configurable: true
  3713. });
  3714. Object.defineProperty(Control.prototype, "shadowColor", {
  3715. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3716. get: function () {
  3717. return this._shadowColor;
  3718. },
  3719. set: function (value) {
  3720. if (this._shadowColor === value) {
  3721. return;
  3722. }
  3723. this._shadowColor = value;
  3724. this._markAsDirty();
  3725. },
  3726. enumerable: true,
  3727. configurable: true
  3728. });
  3729. Object.defineProperty(Control.prototype, "typeName", {
  3730. // Properties
  3731. /** Gets the control type name */
  3732. get: function () {
  3733. return this._getTypeName();
  3734. },
  3735. enumerable: true,
  3736. configurable: true
  3737. });
  3738. /**
  3739. * Get the current class name of the control.
  3740. * @returns current class name
  3741. */
  3742. Control.prototype.getClassName = function () {
  3743. return this._getTypeName();
  3744. };
  3745. Object.defineProperty(Control.prototype, "host", {
  3746. /**
  3747. * Get the hosting AdvancedDynamicTexture
  3748. */
  3749. get: function () {
  3750. return this._host;
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. Object.defineProperty(Control.prototype, "fontOffset", {
  3756. /** Gets or set information about font offsets (used to render and align text) */
  3757. get: function () {
  3758. return this._fontOffset;
  3759. },
  3760. set: function (offset) {
  3761. this._fontOffset = offset;
  3762. },
  3763. enumerable: true,
  3764. configurable: true
  3765. });
  3766. Object.defineProperty(Control.prototype, "alpha", {
  3767. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3768. get: function () {
  3769. return this._alpha;
  3770. },
  3771. set: function (value) {
  3772. if (this._alpha === value) {
  3773. return;
  3774. }
  3775. this._alphaSet = true;
  3776. this._alpha = value;
  3777. this._markAsDirty();
  3778. },
  3779. enumerable: true,
  3780. configurable: true
  3781. });
  3782. Object.defineProperty(Control.prototype, "isHighlighted", {
  3783. /**
  3784. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3785. */
  3786. get: function () {
  3787. return this._isHighlighted;
  3788. },
  3789. set: function (value) {
  3790. if (this._isHighlighted === value) {
  3791. return;
  3792. }
  3793. this._isHighlighted = value;
  3794. this._markAsDirty();
  3795. },
  3796. enumerable: true,
  3797. configurable: true
  3798. });
  3799. Object.defineProperty(Control.prototype, "scaleX", {
  3800. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3801. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3802. */
  3803. get: function () {
  3804. return this._scaleX;
  3805. },
  3806. set: function (value) {
  3807. if (this._scaleX === value) {
  3808. return;
  3809. }
  3810. this._scaleX = value;
  3811. this._markAsDirty();
  3812. this._markMatrixAsDirty();
  3813. },
  3814. enumerable: true,
  3815. configurable: true
  3816. });
  3817. Object.defineProperty(Control.prototype, "scaleY", {
  3818. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3819. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3820. */
  3821. get: function () {
  3822. return this._scaleY;
  3823. },
  3824. set: function (value) {
  3825. if (this._scaleY === value) {
  3826. return;
  3827. }
  3828. this._scaleY = value;
  3829. this._markAsDirty();
  3830. this._markMatrixAsDirty();
  3831. },
  3832. enumerable: true,
  3833. configurable: true
  3834. });
  3835. Object.defineProperty(Control.prototype, "rotation", {
  3836. /** Gets or sets the rotation angle (0 by default)
  3837. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3838. */
  3839. get: function () {
  3840. return this._rotation;
  3841. },
  3842. set: function (value) {
  3843. if (this._rotation === value) {
  3844. return;
  3845. }
  3846. this._rotation = value;
  3847. this._markAsDirty();
  3848. this._markMatrixAsDirty();
  3849. },
  3850. enumerable: true,
  3851. configurable: true
  3852. });
  3853. Object.defineProperty(Control.prototype, "transformCenterY", {
  3854. /** Gets or sets the transformation center on Y axis (0 by default)
  3855. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3856. */
  3857. get: function () {
  3858. return this._transformCenterY;
  3859. },
  3860. set: function (value) {
  3861. if (this._transformCenterY === value) {
  3862. return;
  3863. }
  3864. this._transformCenterY = value;
  3865. this._markAsDirty();
  3866. this._markMatrixAsDirty();
  3867. },
  3868. enumerable: true,
  3869. configurable: true
  3870. });
  3871. Object.defineProperty(Control.prototype, "transformCenterX", {
  3872. /** Gets or sets the transformation center on X axis (0 by default)
  3873. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3874. */
  3875. get: function () {
  3876. return this._transformCenterX;
  3877. },
  3878. set: function (value) {
  3879. if (this._transformCenterX === value) {
  3880. return;
  3881. }
  3882. this._transformCenterX = value;
  3883. this._markAsDirty();
  3884. this._markMatrixAsDirty();
  3885. },
  3886. enumerable: true,
  3887. configurable: true
  3888. });
  3889. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3890. /**
  3891. * Gets or sets the horizontal alignment
  3892. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3893. */
  3894. get: function () {
  3895. return this._horizontalAlignment;
  3896. },
  3897. set: function (value) {
  3898. if (this._horizontalAlignment === value) {
  3899. return;
  3900. }
  3901. this._horizontalAlignment = value;
  3902. this._markAsDirty();
  3903. },
  3904. enumerable: true,
  3905. configurable: true
  3906. });
  3907. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3908. /**
  3909. * Gets or sets the vertical alignment
  3910. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3911. */
  3912. get: function () {
  3913. return this._verticalAlignment;
  3914. },
  3915. set: function (value) {
  3916. if (this._verticalAlignment === value) {
  3917. return;
  3918. }
  3919. this._verticalAlignment = value;
  3920. this._markAsDirty();
  3921. },
  3922. enumerable: true,
  3923. configurable: true
  3924. });
  3925. Object.defineProperty(Control.prototype, "width", {
  3926. /**
  3927. * Gets or sets control width
  3928. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3929. */
  3930. get: function () {
  3931. return this._width.toString(this._host);
  3932. },
  3933. set: function (value) {
  3934. if (this._width.toString(this._host) === value) {
  3935. return;
  3936. }
  3937. if (this._width.fromString(value)) {
  3938. this._markAsDirty();
  3939. }
  3940. },
  3941. enumerable: true,
  3942. configurable: true
  3943. });
  3944. Object.defineProperty(Control.prototype, "widthInPixels", {
  3945. /**
  3946. * Gets or sets the control width in pixel
  3947. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3948. */
  3949. get: function () {
  3950. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3951. },
  3952. set: function (value) {
  3953. if (isNaN(value)) {
  3954. return;
  3955. }
  3956. this.width = value + "px";
  3957. },
  3958. enumerable: true,
  3959. configurable: true
  3960. });
  3961. Object.defineProperty(Control.prototype, "height", {
  3962. /**
  3963. * Gets or sets control height
  3964. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3965. */
  3966. get: function () {
  3967. return this._height.toString(this._host);
  3968. },
  3969. set: function (value) {
  3970. if (this._height.toString(this._host) === value) {
  3971. return;
  3972. }
  3973. if (this._height.fromString(value)) {
  3974. this._markAsDirty();
  3975. }
  3976. },
  3977. enumerable: true,
  3978. configurable: true
  3979. });
  3980. Object.defineProperty(Control.prototype, "heightInPixels", {
  3981. /**
  3982. * Gets or sets control height in pixel
  3983. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3984. */
  3985. get: function () {
  3986. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  3987. },
  3988. set: function (value) {
  3989. if (isNaN(value)) {
  3990. return;
  3991. }
  3992. this.height = value + "px";
  3993. },
  3994. enumerable: true,
  3995. configurable: true
  3996. });
  3997. Object.defineProperty(Control.prototype, "fontFamily", {
  3998. /** Gets or set font family */
  3999. get: function () {
  4000. if (!this._fontSet) {
  4001. return "";
  4002. }
  4003. return this._fontFamily;
  4004. },
  4005. set: function (value) {
  4006. if (this._fontFamily === value) {
  4007. return;
  4008. }
  4009. this._fontFamily = value;
  4010. this._resetFontCache();
  4011. },
  4012. enumerable: true,
  4013. configurable: true
  4014. });
  4015. Object.defineProperty(Control.prototype, "fontStyle", {
  4016. /** Gets or sets font style */
  4017. get: function () {
  4018. return this._fontStyle;
  4019. },
  4020. set: function (value) {
  4021. if (this._fontStyle === value) {
  4022. return;
  4023. }
  4024. this._fontStyle = value;
  4025. this._resetFontCache();
  4026. },
  4027. enumerable: true,
  4028. configurable: true
  4029. });
  4030. Object.defineProperty(Control.prototype, "fontWeight", {
  4031. /** Gets or sets font weight */
  4032. get: function () {
  4033. return this._fontWeight;
  4034. },
  4035. set: function (value) {
  4036. if (this._fontWeight === value) {
  4037. return;
  4038. }
  4039. this._fontWeight = value;
  4040. this._resetFontCache();
  4041. },
  4042. enumerable: true,
  4043. configurable: true
  4044. });
  4045. Object.defineProperty(Control.prototype, "style", {
  4046. /**
  4047. * Gets or sets style
  4048. * @see http://doc.babylonjs.com/how_to/gui#styles
  4049. */
  4050. get: function () {
  4051. return this._style;
  4052. },
  4053. set: function (value) {
  4054. var _this = this;
  4055. if (this._style) {
  4056. this._style.onChangedObservable.remove(this._styleObserver);
  4057. this._styleObserver = null;
  4058. }
  4059. this._style = value;
  4060. if (this._style) {
  4061. this._styleObserver = this._style.onChangedObservable.add(function () {
  4062. _this._markAsDirty();
  4063. _this._resetFontCache();
  4064. });
  4065. }
  4066. this._markAsDirty();
  4067. this._resetFontCache();
  4068. },
  4069. enumerable: true,
  4070. configurable: true
  4071. });
  4072. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4073. /** @hidden */
  4074. get: function () {
  4075. return this._fontSize.isPercentage;
  4076. },
  4077. enumerable: true,
  4078. configurable: true
  4079. });
  4080. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4081. /** Gets or sets font size in pixels */
  4082. get: function () {
  4083. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4084. if (fontSizeToUse.isPixel) {
  4085. return fontSizeToUse.getValue(this._host);
  4086. }
  4087. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4088. },
  4089. set: function (value) {
  4090. if (isNaN(value)) {
  4091. return;
  4092. }
  4093. this.fontSize = value + "px";
  4094. },
  4095. enumerable: true,
  4096. configurable: true
  4097. });
  4098. Object.defineProperty(Control.prototype, "fontSize", {
  4099. /** Gets or sets font size */
  4100. get: function () {
  4101. return this._fontSize.toString(this._host);
  4102. },
  4103. set: function (value) {
  4104. if (this._fontSize.toString(this._host) === value) {
  4105. return;
  4106. }
  4107. if (this._fontSize.fromString(value)) {
  4108. this._markAsDirty();
  4109. this._resetFontCache();
  4110. }
  4111. },
  4112. enumerable: true,
  4113. configurable: true
  4114. });
  4115. Object.defineProperty(Control.prototype, "color", {
  4116. /** Gets or sets foreground color */
  4117. get: function () {
  4118. return this._color;
  4119. },
  4120. set: function (value) {
  4121. if (this._color === value) {
  4122. return;
  4123. }
  4124. this._color = value;
  4125. this._markAsDirty();
  4126. },
  4127. enumerable: true,
  4128. configurable: true
  4129. });
  4130. Object.defineProperty(Control.prototype, "zIndex", {
  4131. /** Gets or sets z index which is used to reorder controls on the z axis */
  4132. get: function () {
  4133. return this._zIndex;
  4134. },
  4135. set: function (value) {
  4136. if (this.zIndex === value) {
  4137. return;
  4138. }
  4139. this._zIndex = value;
  4140. if (this.parent) {
  4141. this.parent._reOrderControl(this);
  4142. }
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(Control.prototype, "notRenderable", {
  4148. /** Gets or sets a boolean indicating if the control can be rendered */
  4149. get: function () {
  4150. return this._doNotRender;
  4151. },
  4152. set: function (value) {
  4153. if (this._doNotRender === value) {
  4154. return;
  4155. }
  4156. this._doNotRender = value;
  4157. this._markAsDirty();
  4158. },
  4159. enumerable: true,
  4160. configurable: true
  4161. });
  4162. Object.defineProperty(Control.prototype, "isVisible", {
  4163. /** Gets or sets a boolean indicating if the control is visible */
  4164. get: function () {
  4165. return this._isVisible;
  4166. },
  4167. set: function (value) {
  4168. if (this._isVisible === value) {
  4169. return;
  4170. }
  4171. this._isVisible = value;
  4172. this._markAsDirty(true);
  4173. },
  4174. enumerable: true,
  4175. configurable: true
  4176. });
  4177. Object.defineProperty(Control.prototype, "isDirty", {
  4178. /** Gets a boolean indicating that the control needs to update its rendering */
  4179. get: function () {
  4180. return this._isDirty;
  4181. },
  4182. enumerable: true,
  4183. configurable: true
  4184. });
  4185. Object.defineProperty(Control.prototype, "linkedMesh", {
  4186. /**
  4187. * Gets the current linked mesh (or null if none)
  4188. */
  4189. get: function () {
  4190. return this._linkedMesh;
  4191. },
  4192. enumerable: true,
  4193. configurable: true
  4194. });
  4195. Object.defineProperty(Control.prototype, "paddingLeft", {
  4196. /**
  4197. * Gets or sets a value indicating the padding to use on the left of the control
  4198. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4199. */
  4200. get: function () {
  4201. return this._paddingLeft.toString(this._host);
  4202. },
  4203. set: function (value) {
  4204. if (this._paddingLeft.fromString(value)) {
  4205. this._markAsDirty();
  4206. }
  4207. },
  4208. enumerable: true,
  4209. configurable: true
  4210. });
  4211. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4212. /**
  4213. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4214. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4215. */
  4216. get: function () {
  4217. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4218. },
  4219. set: function (value) {
  4220. if (isNaN(value)) {
  4221. return;
  4222. }
  4223. this.paddingLeft = value + "px";
  4224. },
  4225. enumerable: true,
  4226. configurable: true
  4227. });
  4228. Object.defineProperty(Control.prototype, "paddingRight", {
  4229. /**
  4230. * Gets or sets a value indicating the padding to use on the right of the control
  4231. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4232. */
  4233. get: function () {
  4234. return this._paddingRight.toString(this._host);
  4235. },
  4236. set: function (value) {
  4237. if (this._paddingRight.fromString(value)) {
  4238. this._markAsDirty();
  4239. }
  4240. },
  4241. enumerable: true,
  4242. configurable: true
  4243. });
  4244. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4245. /**
  4246. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4247. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4248. */
  4249. get: function () {
  4250. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4251. },
  4252. set: function (value) {
  4253. if (isNaN(value)) {
  4254. return;
  4255. }
  4256. this.paddingRight = value + "px";
  4257. },
  4258. enumerable: true,
  4259. configurable: true
  4260. });
  4261. Object.defineProperty(Control.prototype, "paddingTop", {
  4262. /**
  4263. * Gets or sets a value indicating the padding to use on the top of the control
  4264. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4265. */
  4266. get: function () {
  4267. return this._paddingTop.toString(this._host);
  4268. },
  4269. set: function (value) {
  4270. if (this._paddingTop.fromString(value)) {
  4271. this._markAsDirty();
  4272. }
  4273. },
  4274. enumerable: true,
  4275. configurable: true
  4276. });
  4277. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4278. /**
  4279. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4280. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4281. */
  4282. get: function () {
  4283. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4284. },
  4285. set: function (value) {
  4286. if (isNaN(value)) {
  4287. return;
  4288. }
  4289. this.paddingTop = value + "px";
  4290. },
  4291. enumerable: true,
  4292. configurable: true
  4293. });
  4294. Object.defineProperty(Control.prototype, "paddingBottom", {
  4295. /**
  4296. * Gets or sets a value indicating the padding to use on the bottom of the control
  4297. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4298. */
  4299. get: function () {
  4300. return this._paddingBottom.toString(this._host);
  4301. },
  4302. set: function (value) {
  4303. if (this._paddingBottom.fromString(value)) {
  4304. this._markAsDirty();
  4305. }
  4306. },
  4307. enumerable: true,
  4308. configurable: true
  4309. });
  4310. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4311. /**
  4312. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4313. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4314. */
  4315. get: function () {
  4316. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4317. },
  4318. set: function (value) {
  4319. if (isNaN(value)) {
  4320. return;
  4321. }
  4322. this.paddingBottom = value + "px";
  4323. },
  4324. enumerable: true,
  4325. configurable: true
  4326. });
  4327. Object.defineProperty(Control.prototype, "left", {
  4328. /**
  4329. * Gets or sets a value indicating the left coordinate of the control
  4330. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4331. */
  4332. get: function () {
  4333. return this._left.toString(this._host);
  4334. },
  4335. set: function (value) {
  4336. if (this._left.fromString(value)) {
  4337. this._markAsDirty();
  4338. }
  4339. },
  4340. enumerable: true,
  4341. configurable: true
  4342. });
  4343. Object.defineProperty(Control.prototype, "leftInPixels", {
  4344. /**
  4345. * Gets or sets a value indicating the left coordinate in pixels of the control
  4346. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4347. */
  4348. get: function () {
  4349. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4350. },
  4351. set: function (value) {
  4352. if (isNaN(value)) {
  4353. return;
  4354. }
  4355. this.left = value + "px";
  4356. },
  4357. enumerable: true,
  4358. configurable: true
  4359. });
  4360. Object.defineProperty(Control.prototype, "top", {
  4361. /**
  4362. * Gets or sets a value indicating the top coordinate of the control
  4363. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4364. */
  4365. get: function () {
  4366. return this._top.toString(this._host);
  4367. },
  4368. set: function (value) {
  4369. if (this._top.fromString(value)) {
  4370. this._markAsDirty();
  4371. }
  4372. },
  4373. enumerable: true,
  4374. configurable: true
  4375. });
  4376. Object.defineProperty(Control.prototype, "topInPixels", {
  4377. /**
  4378. * Gets or sets a value indicating the top coordinate in pixels of the control
  4379. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4380. */
  4381. get: function () {
  4382. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4383. },
  4384. set: function (value) {
  4385. if (isNaN(value)) {
  4386. return;
  4387. }
  4388. this.top = value + "px";
  4389. },
  4390. enumerable: true,
  4391. configurable: true
  4392. });
  4393. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4394. /**
  4395. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4396. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4397. */
  4398. get: function () {
  4399. return this._linkOffsetX.toString(this._host);
  4400. },
  4401. set: function (value) {
  4402. if (this._linkOffsetX.fromString(value)) {
  4403. this._markAsDirty();
  4404. }
  4405. },
  4406. enumerable: true,
  4407. configurable: true
  4408. });
  4409. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4410. /**
  4411. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4412. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4413. */
  4414. get: function () {
  4415. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4416. },
  4417. set: function (value) {
  4418. if (isNaN(value)) {
  4419. return;
  4420. }
  4421. this.linkOffsetX = value + "px";
  4422. },
  4423. enumerable: true,
  4424. configurable: true
  4425. });
  4426. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4427. /**
  4428. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4429. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4430. */
  4431. get: function () {
  4432. return this._linkOffsetY.toString(this._host);
  4433. },
  4434. set: function (value) {
  4435. if (this._linkOffsetY.fromString(value)) {
  4436. this._markAsDirty();
  4437. }
  4438. },
  4439. enumerable: true,
  4440. configurable: true
  4441. });
  4442. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4443. /**
  4444. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4445. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4446. */
  4447. get: function () {
  4448. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4449. },
  4450. set: function (value) {
  4451. if (isNaN(value)) {
  4452. return;
  4453. }
  4454. this.linkOffsetY = value + "px";
  4455. },
  4456. enumerable: true,
  4457. configurable: true
  4458. });
  4459. Object.defineProperty(Control.prototype, "centerX", {
  4460. /** Gets the center coordinate on X axis */
  4461. get: function () {
  4462. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4463. },
  4464. enumerable: true,
  4465. configurable: true
  4466. });
  4467. Object.defineProperty(Control.prototype, "centerY", {
  4468. /** Gets the center coordinate on Y axis */
  4469. get: function () {
  4470. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4471. },
  4472. enumerable: true,
  4473. configurable: true
  4474. });
  4475. Object.defineProperty(Control.prototype, "isEnabled", {
  4476. /** Gets or sets if control is Enabled*/
  4477. get: function () {
  4478. return this._isEnabled;
  4479. },
  4480. set: function (value) {
  4481. if (this._isEnabled === value) {
  4482. return;
  4483. }
  4484. this._isEnabled = value;
  4485. this._markAsDirty();
  4486. },
  4487. enumerable: true,
  4488. configurable: true
  4489. });
  4490. Object.defineProperty(Control.prototype, "disabledColor", {
  4491. /** Gets or sets background color of control if it's disabled*/
  4492. get: function () {
  4493. return this._disabledColor;
  4494. },
  4495. set: function (value) {
  4496. if (this._disabledColor === value) {
  4497. return;
  4498. }
  4499. this._disabledColor = value;
  4500. this._markAsDirty();
  4501. },
  4502. enumerable: true,
  4503. configurable: true
  4504. });
  4505. /** @hidden */
  4506. Control.prototype._getTypeName = function () {
  4507. return "Control";
  4508. };
  4509. /**
  4510. * Gets the first ascendant in the hierarchy of the given type
  4511. * @param className defines the required type
  4512. * @returns the ascendant or null if not found
  4513. */
  4514. Control.prototype.getAscendantOfClass = function (className) {
  4515. if (!this.parent) {
  4516. return null;
  4517. }
  4518. if (this.parent.getClassName() === className) {
  4519. return this.parent;
  4520. }
  4521. return this.parent.getAscendantOfClass(className);
  4522. };
  4523. /** @hidden */
  4524. Control.prototype._resetFontCache = function () {
  4525. this._fontSet = true;
  4526. this._markAsDirty();
  4527. };
  4528. /**
  4529. * Determines if a container is an ascendant of the current control
  4530. * @param container defines the container to look for
  4531. * @returns true if the container is one of the ascendant of the control
  4532. */
  4533. Control.prototype.isAscendant = function (container) {
  4534. if (!this.parent) {
  4535. return false;
  4536. }
  4537. if (this.parent === container) {
  4538. return true;
  4539. }
  4540. return this.parent.isAscendant(container);
  4541. };
  4542. /**
  4543. * Gets coordinates in local control space
  4544. * @param globalCoordinates defines the coordinates to transform
  4545. * @returns the new coordinates in local space
  4546. */
  4547. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4548. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4549. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4550. return result;
  4551. };
  4552. /**
  4553. * Gets coordinates in local control space
  4554. * @param globalCoordinates defines the coordinates to transform
  4555. * @param result defines the target vector2 where to store the result
  4556. * @returns the current control
  4557. */
  4558. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4559. result.x = globalCoordinates.x - this._currentMeasure.left;
  4560. result.y = globalCoordinates.y - this._currentMeasure.top;
  4561. return this;
  4562. };
  4563. /**
  4564. * Gets coordinates in parent local control space
  4565. * @param globalCoordinates defines the coordinates to transform
  4566. * @returns the new coordinates in parent local space
  4567. */
  4568. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4569. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4570. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4571. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4572. return result;
  4573. };
  4574. /**
  4575. * Move the current control to a vector3 position projected onto the screen.
  4576. * @param position defines the target position
  4577. * @param scene defines the hosting scene
  4578. */
  4579. Control.prototype.moveToVector3 = function (position, scene) {
  4580. if (!this._host || this.parent !== this._host._rootContainer) {
  4581. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4582. return;
  4583. }
  4584. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4585. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4586. var globalViewport = this._host._getGlobalViewport(scene);
  4587. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4588. this._moveToProjectedPosition(projectedPosition);
  4589. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4590. this.notRenderable = true;
  4591. return;
  4592. }
  4593. this.notRenderable = false;
  4594. };
  4595. /** @hidden */
  4596. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4597. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4598. // Do nothing by default
  4599. };
  4600. /**
  4601. * Will return all controls that have this control as ascendant
  4602. * @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
  4603. * @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
  4604. * @return all child controls
  4605. */
  4606. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4607. var results = new Array();
  4608. this._getDescendants(results, directDescendantsOnly, predicate);
  4609. return results;
  4610. };
  4611. /**
  4612. * Link current control with a target mesh
  4613. * @param mesh defines the mesh to link with
  4614. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4615. */
  4616. Control.prototype.linkWithMesh = function (mesh) {
  4617. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4618. if (mesh) {
  4619. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4620. }
  4621. return;
  4622. }
  4623. var index = this._host._linkedControls.indexOf(this);
  4624. if (index !== -1) {
  4625. this._linkedMesh = mesh;
  4626. if (!mesh) {
  4627. this._host._linkedControls.splice(index, 1);
  4628. }
  4629. return;
  4630. }
  4631. else if (!mesh) {
  4632. return;
  4633. }
  4634. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4635. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4636. this._linkedMesh = mesh;
  4637. this._host._linkedControls.push(this);
  4638. };
  4639. /** @hidden */
  4640. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4641. var oldLeft = this._left.getValue(this._host);
  4642. var oldTop = this._top.getValue(this._host);
  4643. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4644. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4645. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4646. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4647. newLeft = oldLeft;
  4648. }
  4649. if (Math.abs(newTop - oldTop) < 0.5) {
  4650. newTop = oldTop;
  4651. }
  4652. }
  4653. this.left = newLeft + "px";
  4654. this.top = newTop + "px";
  4655. this._left.ignoreAdaptiveScaling = true;
  4656. this._top.ignoreAdaptiveScaling = true;
  4657. this._markAsDirty();
  4658. };
  4659. /** @hidden */
  4660. Control.prototype._offsetLeft = function (offset) {
  4661. this._isDirty = true;
  4662. this._currentMeasure.left += offset;
  4663. };
  4664. /** @hidden */
  4665. Control.prototype._offsetTop = function (offset) {
  4666. this._isDirty = true;
  4667. this._currentMeasure.top += offset;
  4668. };
  4669. /** @hidden */
  4670. Control.prototype._markMatrixAsDirty = function () {
  4671. this._isMatrixDirty = true;
  4672. this._flagDescendantsAsMatrixDirty();
  4673. };
  4674. /** @hidden */
  4675. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4676. // No child
  4677. };
  4678. /** @hidden */
  4679. Control.prototype._intersectsRect = function (rect) {
  4680. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4681. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4682. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4683. return false;
  4684. }
  4685. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4686. return false;
  4687. }
  4688. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4689. return false;
  4690. }
  4691. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4692. return false;
  4693. }
  4694. return true;
  4695. };
  4696. /** @hidden */
  4697. Control.prototype.invalidateRect = function () {
  4698. this._transform();
  4699. if (this.host && this.host.useInvalidateRectOptimization) {
  4700. // Rotate by transform to get the measure transformed to global space
  4701. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4702. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4703. // the previous measure is used to properly clear a control that is scaled down
  4704. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4705. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4706. // Expand rect based on shadows
  4707. var shadowOffsetX = this.shadowOffsetX;
  4708. var shadowOffsetY = this.shadowOffsetY;
  4709. var shadowBlur = this.shadowBlur;
  4710. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4711. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4712. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4713. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4714. 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));
  4715. }
  4716. else {
  4717. 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));
  4718. }
  4719. }
  4720. };
  4721. /** @hidden */
  4722. Control.prototype._markAsDirty = function (force) {
  4723. if (force === void 0) { force = false; }
  4724. if (!this._isVisible && !force) {
  4725. return;
  4726. }
  4727. this._isDirty = true;
  4728. // Redraw only this rectangle
  4729. if (this._host) {
  4730. this._host.markAsDirty();
  4731. }
  4732. };
  4733. /** @hidden */
  4734. Control.prototype._markAllAsDirty = function () {
  4735. this._markAsDirty();
  4736. if (this._font) {
  4737. this._prepareFont();
  4738. }
  4739. };
  4740. /** @hidden */
  4741. Control.prototype._link = function (host) {
  4742. this._host = host;
  4743. if (this._host) {
  4744. this.uniqueId = this._host.getScene().getUniqueId();
  4745. }
  4746. };
  4747. /** @hidden */
  4748. Control.prototype._transform = function (context) {
  4749. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4750. return;
  4751. }
  4752. // postTranslate
  4753. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4754. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4755. if (context) {
  4756. context.translate(offsetX, offsetY);
  4757. // rotate
  4758. context.rotate(this._rotation);
  4759. // scale
  4760. context.scale(this._scaleX, this._scaleY);
  4761. // preTranslate
  4762. context.translate(-offsetX, -offsetY);
  4763. }
  4764. // Need to update matrices?
  4765. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4766. this._cachedOffsetX = offsetX;
  4767. this._cachedOffsetY = offsetY;
  4768. this._isMatrixDirty = false;
  4769. this._flagDescendantsAsMatrixDirty();
  4770. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4771. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4772. }
  4773. };
  4774. /** @hidden */
  4775. Control.prototype._renderHighlight = function (context) {
  4776. if (!this.isHighlighted) {
  4777. return;
  4778. }
  4779. context.save();
  4780. context.strokeStyle = "#4affff";
  4781. context.lineWidth = 2;
  4782. this._renderHighlightSpecific(context);
  4783. context.restore();
  4784. };
  4785. /** @hidden */
  4786. Control.prototype._renderHighlightSpecific = function (context) {
  4787. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4788. };
  4789. /** @hidden */
  4790. Control.prototype._applyStates = function (context) {
  4791. if (this._isFontSizeInPercentage) {
  4792. this._fontSet = true;
  4793. }
  4794. if (this._fontSet) {
  4795. this._prepareFont();
  4796. this._fontSet = false;
  4797. }
  4798. if (this._font) {
  4799. context.font = this._font;
  4800. }
  4801. if (this._color) {
  4802. context.fillStyle = this._color;
  4803. }
  4804. if (Control.AllowAlphaInheritance) {
  4805. context.globalAlpha *= this._alpha;
  4806. }
  4807. else if (this._alphaSet) {
  4808. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4809. }
  4810. };
  4811. /** @hidden */
  4812. Control.prototype._layout = function (parentMeasure, context) {
  4813. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4814. return false;
  4815. }
  4816. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4817. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4818. context.save();
  4819. this._applyStates(context);
  4820. var rebuildCount = 0;
  4821. do {
  4822. this._rebuildLayout = false;
  4823. this._processMeasures(parentMeasure, context);
  4824. rebuildCount++;
  4825. } while (this._rebuildLayout && rebuildCount < 3);
  4826. if (rebuildCount >= 3) {
  4827. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4828. }
  4829. context.restore();
  4830. this.invalidateRect();
  4831. this._evaluateClippingState(parentMeasure);
  4832. }
  4833. this._wasDirty = this._isDirty;
  4834. this._isDirty = false;
  4835. return true;
  4836. };
  4837. /** @hidden */
  4838. Control.prototype._processMeasures = function (parentMeasure, context) {
  4839. this._currentMeasure.copyFrom(parentMeasure);
  4840. // Let children take some pre-measurement actions
  4841. this._preMeasure(parentMeasure, context);
  4842. this._measure();
  4843. this._computeAlignment(parentMeasure, context);
  4844. // Convert to int values
  4845. this._currentMeasure.left = this._currentMeasure.left | 0;
  4846. this._currentMeasure.top = this._currentMeasure.top | 0;
  4847. this._currentMeasure.width = this._currentMeasure.width | 0;
  4848. this._currentMeasure.height = this._currentMeasure.height | 0;
  4849. // Let children add more features
  4850. this._additionalProcessing(parentMeasure, context);
  4851. this._cachedParentMeasure.copyFrom(parentMeasure);
  4852. if (this.onDirtyObservable.hasObservers()) {
  4853. this.onDirtyObservable.notifyObservers(this);
  4854. }
  4855. };
  4856. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4857. if (this.parent && this.parent.clipChildren) {
  4858. // Early clip
  4859. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4860. this._isClipped = true;
  4861. return;
  4862. }
  4863. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4864. this._isClipped = true;
  4865. return;
  4866. }
  4867. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4868. this._isClipped = true;
  4869. return;
  4870. }
  4871. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4872. this._isClipped = true;
  4873. return;
  4874. }
  4875. }
  4876. this._isClipped = false;
  4877. };
  4878. /** @hidden */
  4879. Control.prototype._measure = function () {
  4880. // Width / Height
  4881. if (this._width.isPixel) {
  4882. this._currentMeasure.width = this._width.getValue(this._host);
  4883. }
  4884. else {
  4885. this._currentMeasure.width *= this._width.getValue(this._host);
  4886. }
  4887. if (this._height.isPixel) {
  4888. this._currentMeasure.height = this._height.getValue(this._host);
  4889. }
  4890. else {
  4891. this._currentMeasure.height *= this._height.getValue(this._host);
  4892. }
  4893. };
  4894. /** @hidden */
  4895. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4896. var width = this._currentMeasure.width;
  4897. var height = this._currentMeasure.height;
  4898. var parentWidth = parentMeasure.width;
  4899. var parentHeight = parentMeasure.height;
  4900. // Left / top
  4901. var x = 0;
  4902. var y = 0;
  4903. switch (this.horizontalAlignment) {
  4904. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4905. x = 0;
  4906. break;
  4907. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4908. x = parentWidth - width;
  4909. break;
  4910. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4911. x = (parentWidth - width) / 2;
  4912. break;
  4913. }
  4914. switch (this.verticalAlignment) {
  4915. case Control.VERTICAL_ALIGNMENT_TOP:
  4916. y = 0;
  4917. break;
  4918. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4919. y = parentHeight - height;
  4920. break;
  4921. case Control.VERTICAL_ALIGNMENT_CENTER:
  4922. y = (parentHeight - height) / 2;
  4923. break;
  4924. }
  4925. if (this._paddingLeft.isPixel) {
  4926. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4927. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4928. }
  4929. else {
  4930. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4931. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4932. }
  4933. if (this._paddingRight.isPixel) {
  4934. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4935. }
  4936. else {
  4937. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4938. }
  4939. if (this._paddingTop.isPixel) {
  4940. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4941. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4942. }
  4943. else {
  4944. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4945. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4946. }
  4947. if (this._paddingBottom.isPixel) {
  4948. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4949. }
  4950. else {
  4951. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4952. }
  4953. if (this._left.isPixel) {
  4954. this._currentMeasure.left += this._left.getValue(this._host);
  4955. }
  4956. else {
  4957. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4958. }
  4959. if (this._top.isPixel) {
  4960. this._currentMeasure.top += this._top.getValue(this._host);
  4961. }
  4962. else {
  4963. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4964. }
  4965. this._currentMeasure.left += x;
  4966. this._currentMeasure.top += y;
  4967. };
  4968. /** @hidden */
  4969. Control.prototype._preMeasure = function (parentMeasure, context) {
  4970. // Do nothing
  4971. };
  4972. /** @hidden */
  4973. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4974. // Do nothing
  4975. };
  4976. /** @hidden */
  4977. Control.prototype._clipForChildren = function (context) {
  4978. // DO nothing
  4979. };
  4980. Control.prototype._clip = function (context, invalidatedRectangle) {
  4981. context.beginPath();
  4982. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4983. if (invalidatedRectangle) {
  4984. // Rotate the invalidated rect into the control's space
  4985. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4986. // Get the intersection of the rect in context space and the current context
  4987. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4988. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4989. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4990. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4991. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4992. Control._ClipMeasure.copyFrom(intersection);
  4993. }
  4994. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4995. var shadowOffsetX = this.shadowOffsetX;
  4996. var shadowOffsetY = this.shadowOffsetY;
  4997. var shadowBlur = this.shadowBlur;
  4998. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4999. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5000. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5001. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5002. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5003. }
  5004. else {
  5005. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5006. }
  5007. context.clip();
  5008. };
  5009. /** @hidden */
  5010. Control.prototype._render = function (context, invalidatedRectangle) {
  5011. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5012. this._isDirty = false;
  5013. return false;
  5014. }
  5015. context.save();
  5016. this._applyStates(context);
  5017. // Transform
  5018. this._transform(context);
  5019. // Clip
  5020. if (this.clipContent) {
  5021. this._clip(context, invalidatedRectangle);
  5022. }
  5023. if (this.onBeforeDrawObservable.hasObservers()) {
  5024. this.onBeforeDrawObservable.notifyObservers(this);
  5025. }
  5026. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5027. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5028. }
  5029. else {
  5030. this._draw(context, invalidatedRectangle);
  5031. }
  5032. if (this.useBitmapCache && this._wasDirty) {
  5033. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5034. }
  5035. this._renderHighlight(context);
  5036. if (this.onAfterDrawObservable.hasObservers()) {
  5037. this.onAfterDrawObservable.notifyObservers(this);
  5038. }
  5039. context.restore();
  5040. return true;
  5041. };
  5042. /** @hidden */
  5043. Control.prototype._draw = function (context, invalidatedRectangle) {
  5044. // Do nothing
  5045. };
  5046. /**
  5047. * Tests if a given coordinates belong to the current control
  5048. * @param x defines x coordinate to test
  5049. * @param y defines y coordinate to test
  5050. * @returns true if the coordinates are inside the control
  5051. */
  5052. Control.prototype.contains = function (x, y) {
  5053. // Invert transform
  5054. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5055. x = this._transformedPosition.x;
  5056. y = this._transformedPosition.y;
  5057. // Check
  5058. if (x < this._currentMeasure.left) {
  5059. return false;
  5060. }
  5061. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5062. return false;
  5063. }
  5064. if (y < this._currentMeasure.top) {
  5065. return false;
  5066. }
  5067. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5068. return false;
  5069. }
  5070. if (this.isPointerBlocker) {
  5071. this._host._shouldBlockPointer = true;
  5072. }
  5073. return true;
  5074. };
  5075. /** @hidden */
  5076. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5077. if (!this._isEnabled) {
  5078. return false;
  5079. }
  5080. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5081. return false;
  5082. }
  5083. if (!this.contains(x, y)) {
  5084. return false;
  5085. }
  5086. this._processObservables(type, x, y, pointerId, buttonIndex);
  5087. return true;
  5088. };
  5089. /** @hidden */
  5090. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5091. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5092. if (canNotify && this.parent != null) {
  5093. this.parent._onPointerMove(target, coordinates, pointerId);
  5094. }
  5095. };
  5096. /** @hidden */
  5097. Control.prototype._onPointerEnter = function (target) {
  5098. if (!this._isEnabled) {
  5099. return false;
  5100. }
  5101. if (this._enterCount > 0) {
  5102. return false;
  5103. }
  5104. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5105. this._enterCount = 0;
  5106. }
  5107. this._enterCount++;
  5108. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5109. if (canNotify && this.parent != null) {
  5110. this.parent._onPointerEnter(target);
  5111. }
  5112. return true;
  5113. };
  5114. /** @hidden */
  5115. Control.prototype._onPointerOut = function (target, force) {
  5116. if (force === void 0) { force = false; }
  5117. if (!force && (!this._isEnabled || target === this)) {
  5118. return;
  5119. }
  5120. this._enterCount = 0;
  5121. var canNotify = true;
  5122. if (!target.isAscendant(this)) {
  5123. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5124. }
  5125. if (canNotify && this.parent != null) {
  5126. this.parent._onPointerOut(target, force);
  5127. }
  5128. };
  5129. /** @hidden */
  5130. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5131. // Prevent pointerout to lose control context.
  5132. // Event redundancy is checked inside the function.
  5133. this._onPointerEnter(this);
  5134. if (this._downCount !== 0) {
  5135. return false;
  5136. }
  5137. this._downCount++;
  5138. this._downPointerIds[pointerId] = true;
  5139. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5140. if (canNotify && this.parent != null) {
  5141. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5142. }
  5143. return true;
  5144. };
  5145. /** @hidden */
  5146. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5147. if (!this._isEnabled) {
  5148. return;
  5149. }
  5150. this._downCount = 0;
  5151. delete this._downPointerIds[pointerId];
  5152. var canNotifyClick = notifyClick;
  5153. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5154. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5155. }
  5156. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5157. if (canNotify && this.parent != null) {
  5158. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5159. }
  5160. };
  5161. /** @hidden */
  5162. Control.prototype._forcePointerUp = function (pointerId) {
  5163. if (pointerId === void 0) { pointerId = null; }
  5164. if (pointerId !== null) {
  5165. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5166. }
  5167. else {
  5168. for (var key in this._downPointerIds) {
  5169. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5170. }
  5171. }
  5172. };
  5173. /** @hidden */
  5174. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5175. if (!this._isEnabled) {
  5176. return false;
  5177. }
  5178. this._dummyVector2.copyFromFloats(x, y);
  5179. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5180. this._onPointerMove(this, this._dummyVector2, pointerId);
  5181. var previousControlOver = this._host._lastControlOver[pointerId];
  5182. if (previousControlOver && previousControlOver !== this) {
  5183. previousControlOver._onPointerOut(this);
  5184. }
  5185. if (previousControlOver !== this) {
  5186. this._onPointerEnter(this);
  5187. }
  5188. this._host._lastControlOver[pointerId] = this;
  5189. return true;
  5190. }
  5191. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5192. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5193. this._host._registerLastControlDown(this, pointerId);
  5194. this._host._lastPickedControl = this;
  5195. return true;
  5196. }
  5197. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5198. if (this._host._lastControlDown[pointerId]) {
  5199. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5200. }
  5201. delete this._host._lastControlDown[pointerId];
  5202. return true;
  5203. }
  5204. return false;
  5205. };
  5206. Control.prototype._prepareFont = function () {
  5207. if (!this._font && !this._fontSet) {
  5208. return;
  5209. }
  5210. if (this._style) {
  5211. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5212. }
  5213. else {
  5214. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5215. }
  5216. this._fontOffset = Control._GetFontOffset(this._font);
  5217. };
  5218. /** Releases associated resources */
  5219. Control.prototype.dispose = function () {
  5220. this.onDirtyObservable.clear();
  5221. this.onBeforeDrawObservable.clear();
  5222. this.onAfterDrawObservable.clear();
  5223. this.onPointerDownObservable.clear();
  5224. this.onPointerEnterObservable.clear();
  5225. this.onPointerMoveObservable.clear();
  5226. this.onPointerOutObservable.clear();
  5227. this.onPointerUpObservable.clear();
  5228. this.onPointerClickObservable.clear();
  5229. if (this._styleObserver && this._style) {
  5230. this._style.onChangedObservable.remove(this._styleObserver);
  5231. this._styleObserver = null;
  5232. }
  5233. if (this.parent) {
  5234. this.parent.removeControl(this);
  5235. this.parent = null;
  5236. }
  5237. if (this._host) {
  5238. var index = this._host._linkedControls.indexOf(this);
  5239. if (index > -1) {
  5240. this.linkWithMesh(null);
  5241. }
  5242. }
  5243. };
  5244. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5245. /** HORIZONTAL_ALIGNMENT_LEFT */
  5246. get: function () {
  5247. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5248. },
  5249. enumerable: true,
  5250. configurable: true
  5251. });
  5252. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5253. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5254. get: function () {
  5255. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5256. },
  5257. enumerable: true,
  5258. configurable: true
  5259. });
  5260. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5261. /** HORIZONTAL_ALIGNMENT_CENTER */
  5262. get: function () {
  5263. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5264. },
  5265. enumerable: true,
  5266. configurable: true
  5267. });
  5268. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5269. /** VERTICAL_ALIGNMENT_TOP */
  5270. get: function () {
  5271. return Control._VERTICAL_ALIGNMENT_TOP;
  5272. },
  5273. enumerable: true,
  5274. configurable: true
  5275. });
  5276. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5277. /** VERTICAL_ALIGNMENT_BOTTOM */
  5278. get: function () {
  5279. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5280. },
  5281. enumerable: true,
  5282. configurable: true
  5283. });
  5284. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5285. /** VERTICAL_ALIGNMENT_CENTER */
  5286. get: function () {
  5287. return Control._VERTICAL_ALIGNMENT_CENTER;
  5288. },
  5289. enumerable: true,
  5290. configurable: true
  5291. });
  5292. /** @hidden */
  5293. Control._GetFontOffset = function (font) {
  5294. if (Control._FontHeightSizes[font]) {
  5295. return Control._FontHeightSizes[font];
  5296. }
  5297. var text = document.createElement("span");
  5298. text.innerHTML = "Hg";
  5299. text.style.font = font;
  5300. var block = document.createElement("div");
  5301. block.style.display = "inline-block";
  5302. block.style.width = "1px";
  5303. block.style.height = "0px";
  5304. block.style.verticalAlign = "bottom";
  5305. var div = document.createElement("div");
  5306. div.appendChild(text);
  5307. div.appendChild(block);
  5308. document.body.appendChild(div);
  5309. var fontAscent = 0;
  5310. var fontHeight = 0;
  5311. try {
  5312. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5313. block.style.verticalAlign = "baseline";
  5314. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5315. }
  5316. finally {
  5317. document.body.removeChild(div);
  5318. }
  5319. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5320. Control._FontHeightSizes[font] = result;
  5321. return result;
  5322. };
  5323. /** @hidden */
  5324. Control.drawEllipse = function (x, y, width, height, context) {
  5325. context.translate(x, y);
  5326. context.scale(width, height);
  5327. context.beginPath();
  5328. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5329. context.closePath();
  5330. context.scale(1 / width, 1 / height);
  5331. context.translate(-x, -y);
  5332. };
  5333. /**
  5334. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5335. */
  5336. Control.AllowAlphaInheritance = false;
  5337. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5338. // Statics
  5339. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5340. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5341. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5342. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5343. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5344. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5345. Control._FontHeightSizes = {};
  5346. /**
  5347. * Creates a stack panel that can be used to render headers
  5348. * @param control defines the control to associate with the header
  5349. * @param text defines the text of the header
  5350. * @param size defines the size of the header
  5351. * @param options defines options used to configure the header
  5352. * @returns a new StackPanel
  5353. * @ignore
  5354. * @hidden
  5355. */
  5356. Control.AddHeader = function () { };
  5357. return Control;
  5358. }());
  5359. /***/ }),
  5360. /***/ "./2D/controls/displayGrid.ts":
  5361. /*!************************************!*\
  5362. !*** ./2D/controls/displayGrid.ts ***!
  5363. \************************************/
  5364. /*! exports provided: DisplayGrid */
  5365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5366. "use strict";
  5367. __webpack_require__.r(__webpack_exports__);
  5368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5369. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5370. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5371. /** Class used to render a grid */
  5372. var DisplayGrid = /** @class */ (function (_super) {
  5373. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5374. /**
  5375. * Creates a new GridDisplayRectangle
  5376. * @param name defines the control name
  5377. */
  5378. function DisplayGrid(name) {
  5379. var _this = _super.call(this, name) || this;
  5380. _this.name = name;
  5381. _this._cellWidth = 20;
  5382. _this._cellHeight = 20;
  5383. _this._minorLineTickness = 1;
  5384. _this._minorLineColor = "DarkGray";
  5385. _this._majorLineTickness = 2;
  5386. _this._majorLineColor = "White";
  5387. _this._majorLineFrequency = 5;
  5388. _this._background = "Black";
  5389. _this._displayMajorLines = true;
  5390. _this._displayMinorLines = true;
  5391. return _this;
  5392. }
  5393. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5394. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5395. get: function () {
  5396. return this._displayMinorLines;
  5397. },
  5398. set: function (value) {
  5399. if (this._displayMinorLines === value) {
  5400. return;
  5401. }
  5402. this._displayMinorLines = value;
  5403. this._markAsDirty();
  5404. },
  5405. enumerable: true,
  5406. configurable: true
  5407. });
  5408. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5409. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5410. get: function () {
  5411. return this._displayMajorLines;
  5412. },
  5413. set: function (value) {
  5414. if (this._displayMajorLines === value) {
  5415. return;
  5416. }
  5417. this._displayMajorLines = value;
  5418. this._markAsDirty();
  5419. },
  5420. enumerable: true,
  5421. configurable: true
  5422. });
  5423. Object.defineProperty(DisplayGrid.prototype, "background", {
  5424. /** Gets or sets background color (Black by default) */
  5425. get: function () {
  5426. return this._background;
  5427. },
  5428. set: function (value) {
  5429. if (this._background === value) {
  5430. return;
  5431. }
  5432. this._background = value;
  5433. this._markAsDirty();
  5434. },
  5435. enumerable: true,
  5436. configurable: true
  5437. });
  5438. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5439. /** Gets or sets the width of each cell (20 by default) */
  5440. get: function () {
  5441. return this._cellWidth;
  5442. },
  5443. set: function (value) {
  5444. this._cellWidth = value;
  5445. this._markAsDirty();
  5446. },
  5447. enumerable: true,
  5448. configurable: true
  5449. });
  5450. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5451. /** Gets or sets the height of each cell (20 by default) */
  5452. get: function () {
  5453. return this._cellHeight;
  5454. },
  5455. set: function (value) {
  5456. this._cellHeight = value;
  5457. this._markAsDirty();
  5458. },
  5459. enumerable: true,
  5460. configurable: true
  5461. });
  5462. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5463. /** Gets or sets the tickness of minor lines (1 by default) */
  5464. get: function () {
  5465. return this._minorLineTickness;
  5466. },
  5467. set: function (value) {
  5468. this._minorLineTickness = value;
  5469. this._markAsDirty();
  5470. },
  5471. enumerable: true,
  5472. configurable: true
  5473. });
  5474. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5475. /** Gets or sets the color of minor lines (DarkGray by default) */
  5476. get: function () {
  5477. return this._minorLineColor;
  5478. },
  5479. set: function (value) {
  5480. this._minorLineColor = value;
  5481. this._markAsDirty();
  5482. },
  5483. enumerable: true,
  5484. configurable: true
  5485. });
  5486. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5487. /** Gets or sets the tickness of major lines (2 by default) */
  5488. get: function () {
  5489. return this._majorLineTickness;
  5490. },
  5491. set: function (value) {
  5492. this._majorLineTickness = value;
  5493. this._markAsDirty();
  5494. },
  5495. enumerable: true,
  5496. configurable: true
  5497. });
  5498. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5499. /** Gets or sets the color of major lines (White by default) */
  5500. get: function () {
  5501. return this._majorLineColor;
  5502. },
  5503. set: function (value) {
  5504. this._majorLineColor = value;
  5505. this._markAsDirty();
  5506. },
  5507. enumerable: true,
  5508. configurable: true
  5509. });
  5510. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5511. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5512. get: function () {
  5513. return this._majorLineFrequency;
  5514. },
  5515. set: function (value) {
  5516. this._majorLineFrequency = value;
  5517. this._markAsDirty();
  5518. },
  5519. enumerable: true,
  5520. configurable: true
  5521. });
  5522. DisplayGrid.prototype._draw = function (context) {
  5523. context.save();
  5524. this._applyStates(context);
  5525. if (this._isEnabled) {
  5526. if (this._background) {
  5527. context.fillStyle = this._background;
  5528. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5529. }
  5530. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5531. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5532. // Minor lines
  5533. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5534. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5535. if (this._displayMinorLines) {
  5536. context.strokeStyle = this._minorLineColor;
  5537. context.lineWidth = this._minorLineTickness;
  5538. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5539. var cellX = left + x * this.cellWidth;
  5540. context.beginPath();
  5541. context.moveTo(cellX, this._currentMeasure.top);
  5542. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5543. context.stroke();
  5544. }
  5545. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5546. var cellY = top_1 + y * this.cellHeight;
  5547. context.beginPath();
  5548. context.moveTo(this._currentMeasure.left, cellY);
  5549. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5550. context.stroke();
  5551. }
  5552. }
  5553. // Major lines
  5554. if (this._displayMajorLines) {
  5555. context.strokeStyle = this._majorLineColor;
  5556. context.lineWidth = this._majorLineTickness;
  5557. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5558. var cellX = left + x * this.cellWidth;
  5559. context.beginPath();
  5560. context.moveTo(cellX, this._currentMeasure.top);
  5561. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5562. context.stroke();
  5563. }
  5564. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5565. var cellY = top_1 + y * this.cellHeight;
  5566. context.moveTo(this._currentMeasure.left, cellY);
  5567. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5568. context.closePath();
  5569. context.stroke();
  5570. }
  5571. }
  5572. }
  5573. context.restore();
  5574. };
  5575. DisplayGrid.prototype._getTypeName = function () {
  5576. return "DisplayGrid";
  5577. };
  5578. return DisplayGrid;
  5579. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5580. /***/ }),
  5581. /***/ "./2D/controls/ellipse.ts":
  5582. /*!********************************!*\
  5583. !*** ./2D/controls/ellipse.ts ***!
  5584. \********************************/
  5585. /*! exports provided: Ellipse */
  5586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5587. "use strict";
  5588. __webpack_require__.r(__webpack_exports__);
  5589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5590. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5591. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5592. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5593. /** Class used to create 2D ellipse containers */
  5594. var Ellipse = /** @class */ (function (_super) {
  5595. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5596. /**
  5597. * Creates a new Ellipse
  5598. * @param name defines the control name
  5599. */
  5600. function Ellipse(name) {
  5601. var _this = _super.call(this, name) || this;
  5602. _this.name = name;
  5603. _this._thickness = 1;
  5604. return _this;
  5605. }
  5606. Object.defineProperty(Ellipse.prototype, "thickness", {
  5607. /** Gets or sets border thickness */
  5608. get: function () {
  5609. return this._thickness;
  5610. },
  5611. set: function (value) {
  5612. if (this._thickness === value) {
  5613. return;
  5614. }
  5615. this._thickness = value;
  5616. this._markAsDirty();
  5617. },
  5618. enumerable: true,
  5619. configurable: true
  5620. });
  5621. Ellipse.prototype._getTypeName = function () {
  5622. return "Ellipse";
  5623. };
  5624. Ellipse.prototype._localDraw = function (context) {
  5625. context.save();
  5626. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5627. context.shadowColor = this.shadowColor;
  5628. context.shadowBlur = this.shadowBlur;
  5629. context.shadowOffsetX = this.shadowOffsetX;
  5630. context.shadowOffsetY = this.shadowOffsetY;
  5631. }
  5632. _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);
  5633. if (this._background) {
  5634. context.fillStyle = this._background;
  5635. context.fill();
  5636. }
  5637. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5638. context.shadowBlur = 0;
  5639. context.shadowOffsetX = 0;
  5640. context.shadowOffsetY = 0;
  5641. }
  5642. if (this._thickness) {
  5643. if (this.color) {
  5644. context.strokeStyle = this.color;
  5645. }
  5646. context.lineWidth = this._thickness;
  5647. context.stroke();
  5648. }
  5649. context.restore();
  5650. };
  5651. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5652. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5653. this._measureForChildren.width -= 2 * this._thickness;
  5654. this._measureForChildren.height -= 2 * this._thickness;
  5655. this._measureForChildren.left += this._thickness;
  5656. this._measureForChildren.top += this._thickness;
  5657. };
  5658. Ellipse.prototype._clipForChildren = function (context) {
  5659. _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);
  5660. context.clip();
  5661. };
  5662. return Ellipse;
  5663. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5664. /***/ }),
  5665. /***/ "./2D/controls/grid.ts":
  5666. /*!*****************************!*\
  5667. !*** ./2D/controls/grid.ts ***!
  5668. \*****************************/
  5669. /*! exports provided: Grid */
  5670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5671. "use strict";
  5672. __webpack_require__.r(__webpack_exports__);
  5673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5674. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5675. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5676. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5677. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5678. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  5679. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5680. /**
  5681. * Class used to create a 2D grid container
  5682. */
  5683. var Grid = /** @class */ (function (_super) {
  5684. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5685. /**
  5686. * Creates a new Grid
  5687. * @param name defines control name
  5688. */
  5689. function Grid(name) {
  5690. var _this = _super.call(this, name) || this;
  5691. _this.name = name;
  5692. _this._rowDefinitions = new Array();
  5693. _this._columnDefinitions = new Array();
  5694. _this._cells = {};
  5695. _this._childControls = new Array();
  5696. return _this;
  5697. }
  5698. Object.defineProperty(Grid.prototype, "columnCount", {
  5699. /**
  5700. * Gets the number of columns
  5701. */
  5702. get: function () {
  5703. return this._columnDefinitions.length;
  5704. },
  5705. enumerable: true,
  5706. configurable: true
  5707. });
  5708. Object.defineProperty(Grid.prototype, "rowCount", {
  5709. /**
  5710. * Gets the number of rows
  5711. */
  5712. get: function () {
  5713. return this._rowDefinitions.length;
  5714. },
  5715. enumerable: true,
  5716. configurable: true
  5717. });
  5718. Object.defineProperty(Grid.prototype, "children", {
  5719. /** Gets the list of children */
  5720. get: function () {
  5721. return this._childControls;
  5722. },
  5723. enumerable: true,
  5724. configurable: true
  5725. });
  5726. Object.defineProperty(Grid.prototype, "cells", {
  5727. /** Gets the list of cells (e.g. the containers) */
  5728. get: function () {
  5729. return this._cells;
  5730. },
  5731. enumerable: true,
  5732. configurable: true
  5733. });
  5734. /**
  5735. * Gets the definition of a specific row
  5736. * @param index defines the index of the row
  5737. * @returns the row definition
  5738. */
  5739. Grid.prototype.getRowDefinition = function (index) {
  5740. if (index < 0 || index >= this._rowDefinitions.length) {
  5741. return null;
  5742. }
  5743. return this._rowDefinitions[index];
  5744. };
  5745. /**
  5746. * Gets the definition of a specific column
  5747. * @param index defines the index of the column
  5748. * @returns the column definition
  5749. */
  5750. Grid.prototype.getColumnDefinition = function (index) {
  5751. if (index < 0 || index >= this._columnDefinitions.length) {
  5752. return null;
  5753. }
  5754. return this._columnDefinitions[index];
  5755. };
  5756. /**
  5757. * Adds a new row to the grid
  5758. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5759. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5760. * @returns the current grid
  5761. */
  5762. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5763. if (isPixel === void 0) { isPixel = false; }
  5764. 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));
  5765. this._markAsDirty();
  5766. return this;
  5767. };
  5768. /**
  5769. * Adds a new column to the grid
  5770. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5771. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5772. * @returns the current grid
  5773. */
  5774. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5775. if (isPixel === void 0) { isPixel = false; }
  5776. 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));
  5777. this._markAsDirty();
  5778. return this;
  5779. };
  5780. /**
  5781. * Update a row definition
  5782. * @param index defines the index of the row to update
  5783. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5784. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5785. * @returns the current grid
  5786. */
  5787. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5788. if (isPixel === void 0) { isPixel = false; }
  5789. if (index < 0 || index >= this._rowDefinitions.length) {
  5790. return this;
  5791. }
  5792. var current = this._rowDefinitions[index];
  5793. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5794. return this;
  5795. }
  5796. 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);
  5797. this._markAsDirty();
  5798. return this;
  5799. };
  5800. /**
  5801. * Update a column definition
  5802. * @param index defines the index of the column to update
  5803. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5804. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5805. * @returns the current grid
  5806. */
  5807. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5808. if (isPixel === void 0) { isPixel = false; }
  5809. if (index < 0 || index >= this._columnDefinitions.length) {
  5810. return this;
  5811. }
  5812. var current = this._columnDefinitions[index];
  5813. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5814. return this;
  5815. }
  5816. 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);
  5817. this._markAsDirty();
  5818. return this;
  5819. };
  5820. /**
  5821. * Gets the list of children stored in a specific cell
  5822. * @param row defines the row to check
  5823. * @param column defines the column to check
  5824. * @returns the list of controls
  5825. */
  5826. Grid.prototype.getChildrenAt = function (row, column) {
  5827. var cell = this._cells[row + ":" + column];
  5828. if (!cell) {
  5829. return null;
  5830. }
  5831. return cell.children;
  5832. };
  5833. /**
  5834. * Gets a string representing the child cell info (row x column)
  5835. * @param child defines the control to get info from
  5836. * @returns a string containing the child cell info (row x column)
  5837. */
  5838. Grid.prototype.getChildCellInfo = function (child) {
  5839. return child._tag;
  5840. };
  5841. Grid.prototype._removeCell = function (cell, key) {
  5842. if (!cell) {
  5843. return;
  5844. }
  5845. _super.prototype.removeControl.call(this, cell);
  5846. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5847. var control = _a[_i];
  5848. var childIndex = this._childControls.indexOf(control);
  5849. if (childIndex !== -1) {
  5850. this._childControls.splice(childIndex, 1);
  5851. }
  5852. }
  5853. delete this._cells[key];
  5854. };
  5855. Grid.prototype._offsetCell = function (previousKey, key) {
  5856. if (!this._cells[key]) {
  5857. return;
  5858. }
  5859. this._cells[previousKey] = this._cells[key];
  5860. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5861. var control = _a[_i];
  5862. control._tag = previousKey;
  5863. }
  5864. delete this._cells[key];
  5865. };
  5866. /**
  5867. * Remove a column definition at specified index
  5868. * @param index defines the index of the column to remove
  5869. * @returns the current grid
  5870. */
  5871. Grid.prototype.removeColumnDefinition = function (index) {
  5872. if (index < 0 || index >= this._columnDefinitions.length) {
  5873. return this;
  5874. }
  5875. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5876. var key = x + ":" + index;
  5877. var cell = this._cells[key];
  5878. this._removeCell(cell, key);
  5879. }
  5880. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5881. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5882. var previousKey = x + ":" + (y - 1);
  5883. var key = x + ":" + y;
  5884. this._offsetCell(previousKey, key);
  5885. }
  5886. }
  5887. this._columnDefinitions.splice(index, 1);
  5888. this._markAsDirty();
  5889. return this;
  5890. };
  5891. /**
  5892. * Remove a row definition at specified index
  5893. * @param index defines the index of the row to remove
  5894. * @returns the current grid
  5895. */
  5896. Grid.prototype.removeRowDefinition = function (index) {
  5897. if (index < 0 || index >= this._rowDefinitions.length) {
  5898. return this;
  5899. }
  5900. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5901. var key = index + ":" + y;
  5902. var cell = this._cells[key];
  5903. this._removeCell(cell, key);
  5904. }
  5905. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5906. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5907. var previousKey = x - 1 + ":" + y;
  5908. var key = x + ":" + y;
  5909. this._offsetCell(previousKey, key);
  5910. }
  5911. }
  5912. this._rowDefinitions.splice(index, 1);
  5913. this._markAsDirty();
  5914. return this;
  5915. };
  5916. /**
  5917. * Adds a new control to the current grid
  5918. * @param control defines the control to add
  5919. * @param row defines the row where to add the control (0 by default)
  5920. * @param column defines the column where to add the control (0 by default)
  5921. * @returns the current grid
  5922. */
  5923. Grid.prototype.addControl = function (control, row, column) {
  5924. if (row === void 0) { row = 0; }
  5925. if (column === void 0) { column = 0; }
  5926. if (this._rowDefinitions.length === 0) {
  5927. // Add default row definition
  5928. this.addRowDefinition(1, false);
  5929. }
  5930. if (this._columnDefinitions.length === 0) {
  5931. // Add default column definition
  5932. this.addColumnDefinition(1, false);
  5933. }
  5934. if (this._childControls.indexOf(control) !== -1) {
  5935. 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");
  5936. return this;
  5937. }
  5938. var x = Math.min(row, this._rowDefinitions.length - 1);
  5939. var y = Math.min(column, this._columnDefinitions.length - 1);
  5940. var key = x + ":" + y;
  5941. var goodContainer = this._cells[key];
  5942. if (!goodContainer) {
  5943. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5944. this._cells[key] = goodContainer;
  5945. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5946. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5947. _super.prototype.addControl.call(this, goodContainer);
  5948. }
  5949. goodContainer.addControl(control);
  5950. this._childControls.push(control);
  5951. control._tag = key;
  5952. control.parent = this;
  5953. this._markAsDirty();
  5954. return this;
  5955. };
  5956. /**
  5957. * Removes a control from the current container
  5958. * @param control defines the control to remove
  5959. * @returns the current container
  5960. */
  5961. Grid.prototype.removeControl = function (control) {
  5962. var index = this._childControls.indexOf(control);
  5963. if (index !== -1) {
  5964. this._childControls.splice(index, 1);
  5965. }
  5966. var cell = this._cells[control._tag];
  5967. if (cell) {
  5968. cell.removeControl(control);
  5969. control._tag = null;
  5970. }
  5971. this._markAsDirty();
  5972. return this;
  5973. };
  5974. Grid.prototype._getTypeName = function () {
  5975. return "Grid";
  5976. };
  5977. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5978. var widths = [];
  5979. var heights = [];
  5980. var lefts = [];
  5981. var tops = [];
  5982. var availableWidth = this._currentMeasure.width;
  5983. var globalWidthPercentage = 0;
  5984. var availableHeight = this._currentMeasure.height;
  5985. var globalHeightPercentage = 0;
  5986. // Heights
  5987. var index = 0;
  5988. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5989. var value = _a[_i];
  5990. if (value.isPixel) {
  5991. var height = value.getValue(this._host);
  5992. availableHeight -= height;
  5993. heights[index] = height;
  5994. }
  5995. else {
  5996. globalHeightPercentage += value.internalValue;
  5997. }
  5998. index++;
  5999. }
  6000. var top = 0;
  6001. index = 0;
  6002. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6003. var value = _c[_b];
  6004. tops.push(top);
  6005. if (!value.isPixel) {
  6006. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6007. top += height;
  6008. heights[index] = height;
  6009. }
  6010. else {
  6011. top += value.getValue(this._host);
  6012. }
  6013. index++;
  6014. }
  6015. // Widths
  6016. index = 0;
  6017. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6018. var value = _e[_d];
  6019. if (value.isPixel) {
  6020. var width = value.getValue(this._host);
  6021. availableWidth -= width;
  6022. widths[index] = width;
  6023. }
  6024. else {
  6025. globalWidthPercentage += value.internalValue;
  6026. }
  6027. index++;
  6028. }
  6029. var left = 0;
  6030. index = 0;
  6031. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6032. var value = _g[_f];
  6033. lefts.push(left);
  6034. if (!value.isPixel) {
  6035. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6036. left += width;
  6037. widths[index] = width;
  6038. }
  6039. else {
  6040. left += value.getValue(this._host);
  6041. }
  6042. index++;
  6043. }
  6044. definitionCallback(lefts, tops, widths, heights);
  6045. };
  6046. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6047. var _this = this;
  6048. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6049. // Setting child sizes
  6050. for (var key in _this._cells) {
  6051. if (!_this._cells.hasOwnProperty(key)) {
  6052. continue;
  6053. }
  6054. var split = key.split(":");
  6055. var x = parseInt(split[0]);
  6056. var y = parseInt(split[1]);
  6057. var cell = _this._cells[key];
  6058. cell.left = lefts[y] + "px";
  6059. cell.top = tops[x] + "px";
  6060. cell.width = widths[y] + "px";
  6061. cell.height = heights[x] + "px";
  6062. cell._left.ignoreAdaptiveScaling = true;
  6063. cell._top.ignoreAdaptiveScaling = true;
  6064. cell._width.ignoreAdaptiveScaling = true;
  6065. cell._height.ignoreAdaptiveScaling = true;
  6066. }
  6067. });
  6068. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6069. };
  6070. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6071. for (var key in this._cells) {
  6072. if (!this._cells.hasOwnProperty(key)) {
  6073. continue;
  6074. }
  6075. var child = this._cells[key];
  6076. child._markMatrixAsDirty();
  6077. }
  6078. };
  6079. Grid.prototype._renderHighlightSpecific = function (context) {
  6080. var _this = this;
  6081. _super.prototype._renderHighlightSpecific.call(this, context);
  6082. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6083. // Columns
  6084. for (var index = 0; index < lefts.length; index++) {
  6085. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6086. context.beginPath();
  6087. context.moveTo(left, _this._currentMeasure.top);
  6088. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6089. context.stroke();
  6090. }
  6091. // Rows
  6092. for (var index = 0; index < tops.length; index++) {
  6093. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6094. context.beginPath();
  6095. context.moveTo(_this._currentMeasure.left, top_1);
  6096. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6097. context.stroke();
  6098. }
  6099. });
  6100. context.restore();
  6101. };
  6102. /** Releases associated resources */
  6103. Grid.prototype.dispose = function () {
  6104. _super.prototype.dispose.call(this);
  6105. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6106. var control = _a[_i];
  6107. control.dispose();
  6108. }
  6109. this._childControls = [];
  6110. };
  6111. return Grid;
  6112. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6113. /***/ }),
  6114. /***/ "./2D/controls/image.ts":
  6115. /*!******************************!*\
  6116. !*** ./2D/controls/image.ts ***!
  6117. \******************************/
  6118. /*! exports provided: Image */
  6119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6120. "use strict";
  6121. __webpack_require__.r(__webpack_exports__);
  6122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6123. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6124. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6125. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6126. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6127. /**
  6128. * Class used to create 2D images
  6129. */
  6130. var Image = /** @class */ (function (_super) {
  6131. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6132. /**
  6133. * Creates a new Image
  6134. * @param name defines the control name
  6135. * @param url defines the image url
  6136. */
  6137. function Image(name, url) {
  6138. if (url === void 0) { url = null; }
  6139. var _this = _super.call(this, name) || this;
  6140. _this.name = name;
  6141. _this._loaded = false;
  6142. _this._stretch = Image.STRETCH_FILL;
  6143. _this._autoScale = false;
  6144. _this._sourceLeft = 0;
  6145. _this._sourceTop = 0;
  6146. _this._sourceWidth = 0;
  6147. _this._sourceHeight = 0;
  6148. _this._cellWidth = 0;
  6149. _this._cellHeight = 0;
  6150. _this._cellId = -1;
  6151. _this._populateNinePatchSlicesFromImage = false;
  6152. /**
  6153. * Observable notified when the content is loaded
  6154. */
  6155. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6156. _this.source = url;
  6157. return _this;
  6158. }
  6159. Object.defineProperty(Image.prototype, "isLoaded", {
  6160. /**
  6161. * Gets a boolean indicating that the content is loaded
  6162. */
  6163. get: function () {
  6164. return this._loaded;
  6165. },
  6166. enumerable: true,
  6167. configurable: true
  6168. });
  6169. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6170. /**
  6171. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6172. */
  6173. get: function () {
  6174. return this._populateNinePatchSlicesFromImage;
  6175. },
  6176. set: function (value) {
  6177. if (this._populateNinePatchSlicesFromImage === value) {
  6178. return;
  6179. }
  6180. this._populateNinePatchSlicesFromImage = value;
  6181. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6182. this._extractNinePatchSliceDataFromImage();
  6183. }
  6184. },
  6185. enumerable: true,
  6186. configurable: true
  6187. });
  6188. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6189. /**
  6190. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6191. * Beware using this as this will comsume more memory as the image has to be stored twice
  6192. */
  6193. get: function () {
  6194. return this._detectPointerOnOpaqueOnly;
  6195. },
  6196. set: function (value) {
  6197. if (this._detectPointerOnOpaqueOnly === value) {
  6198. return;
  6199. }
  6200. this._detectPointerOnOpaqueOnly = value;
  6201. },
  6202. enumerable: true,
  6203. configurable: true
  6204. });
  6205. Object.defineProperty(Image.prototype, "sliceLeft", {
  6206. /**
  6207. * Gets or sets the left value for slicing (9-patch)
  6208. */
  6209. get: function () {
  6210. return this._sliceLeft;
  6211. },
  6212. set: function (value) {
  6213. if (this._sliceLeft === value) {
  6214. return;
  6215. }
  6216. this._sliceLeft = value;
  6217. this._markAsDirty();
  6218. },
  6219. enumerable: true,
  6220. configurable: true
  6221. });
  6222. Object.defineProperty(Image.prototype, "sliceRight", {
  6223. /**
  6224. * Gets or sets the right value for slicing (9-patch)
  6225. */
  6226. get: function () {
  6227. return this._sliceRight;
  6228. },
  6229. set: function (value) {
  6230. if (this._sliceRight === value) {
  6231. return;
  6232. }
  6233. this._sliceRight = value;
  6234. this._markAsDirty();
  6235. },
  6236. enumerable: true,
  6237. configurable: true
  6238. });
  6239. Object.defineProperty(Image.prototype, "sliceTop", {
  6240. /**
  6241. * Gets or sets the top value for slicing (9-patch)
  6242. */
  6243. get: function () {
  6244. return this._sliceTop;
  6245. },
  6246. set: function (value) {
  6247. if (this._sliceTop === value) {
  6248. return;
  6249. }
  6250. this._sliceTop = value;
  6251. this._markAsDirty();
  6252. },
  6253. enumerable: true,
  6254. configurable: true
  6255. });
  6256. Object.defineProperty(Image.prototype, "sliceBottom", {
  6257. /**
  6258. * Gets or sets the bottom value for slicing (9-patch)
  6259. */
  6260. get: function () {
  6261. return this._sliceBottom;
  6262. },
  6263. set: function (value) {
  6264. if (this._sliceBottom === value) {
  6265. return;
  6266. }
  6267. this._sliceBottom = value;
  6268. this._markAsDirty();
  6269. },
  6270. enumerable: true,
  6271. configurable: true
  6272. });
  6273. Object.defineProperty(Image.prototype, "sourceLeft", {
  6274. /**
  6275. * Gets or sets the left coordinate in the source image
  6276. */
  6277. get: function () {
  6278. return this._sourceLeft;
  6279. },
  6280. set: function (value) {
  6281. if (this._sourceLeft === value) {
  6282. return;
  6283. }
  6284. this._sourceLeft = value;
  6285. this._markAsDirty();
  6286. },
  6287. enumerable: true,
  6288. configurable: true
  6289. });
  6290. Object.defineProperty(Image.prototype, "sourceTop", {
  6291. /**
  6292. * Gets or sets the top coordinate in the source image
  6293. */
  6294. get: function () {
  6295. return this._sourceTop;
  6296. },
  6297. set: function (value) {
  6298. if (this._sourceTop === value) {
  6299. return;
  6300. }
  6301. this._sourceTop = value;
  6302. this._markAsDirty();
  6303. },
  6304. enumerable: true,
  6305. configurable: true
  6306. });
  6307. Object.defineProperty(Image.prototype, "sourceWidth", {
  6308. /**
  6309. * Gets or sets the width to capture in the source image
  6310. */
  6311. get: function () {
  6312. return this._sourceWidth;
  6313. },
  6314. set: function (value) {
  6315. if (this._sourceWidth === value) {
  6316. return;
  6317. }
  6318. this._sourceWidth = value;
  6319. this._markAsDirty();
  6320. },
  6321. enumerable: true,
  6322. configurable: true
  6323. });
  6324. Object.defineProperty(Image.prototype, "sourceHeight", {
  6325. /**
  6326. * Gets or sets the height to capture in the source image
  6327. */
  6328. get: function () {
  6329. return this._sourceHeight;
  6330. },
  6331. set: function (value) {
  6332. if (this._sourceHeight === value) {
  6333. return;
  6334. }
  6335. this._sourceHeight = value;
  6336. this._markAsDirty();
  6337. },
  6338. enumerable: true,
  6339. configurable: true
  6340. });
  6341. Object.defineProperty(Image.prototype, "autoScale", {
  6342. /**
  6343. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6344. * @see http://doc.babylonjs.com/how_to/gui#image
  6345. */
  6346. get: function () {
  6347. return this._autoScale;
  6348. },
  6349. set: function (value) {
  6350. if (this._autoScale === value) {
  6351. return;
  6352. }
  6353. this._autoScale = value;
  6354. if (value && this._loaded) {
  6355. this.synchronizeSizeWithContent();
  6356. }
  6357. },
  6358. enumerable: true,
  6359. configurable: true
  6360. });
  6361. Object.defineProperty(Image.prototype, "stretch", {
  6362. /** Gets or sets the streching mode used by the image */
  6363. get: function () {
  6364. return this._stretch;
  6365. },
  6366. set: function (value) {
  6367. if (this._stretch === value) {
  6368. return;
  6369. }
  6370. this._stretch = value;
  6371. this._markAsDirty();
  6372. },
  6373. enumerable: true,
  6374. configurable: true
  6375. });
  6376. Object.defineProperty(Image.prototype, "domImage", {
  6377. get: function () {
  6378. return this._domImage;
  6379. },
  6380. /**
  6381. * Gets or sets the internal DOM image used to render the control
  6382. */
  6383. set: function (value) {
  6384. var _this = this;
  6385. this._domImage = value;
  6386. this._loaded = false;
  6387. if (this._domImage.width) {
  6388. this._onImageLoaded();
  6389. }
  6390. else {
  6391. this._domImage.onload = function () {
  6392. _this._onImageLoaded();
  6393. };
  6394. }
  6395. },
  6396. enumerable: true,
  6397. configurable: true
  6398. });
  6399. Image.prototype._onImageLoaded = function () {
  6400. this._imageWidth = this._domImage.width;
  6401. this._imageHeight = this._domImage.height;
  6402. this._loaded = true;
  6403. if (this._populateNinePatchSlicesFromImage) {
  6404. this._extractNinePatchSliceDataFromImage();
  6405. }
  6406. if (this._autoScale) {
  6407. this.synchronizeSizeWithContent();
  6408. }
  6409. this.onImageLoadedObservable.notifyObservers(this);
  6410. this._markAsDirty();
  6411. };
  6412. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6413. if (!Image._WorkingCanvas) {
  6414. Image._WorkingCanvas = document.createElement('canvas');
  6415. }
  6416. var canvas = Image._WorkingCanvas;
  6417. var context = canvas.getContext('2d');
  6418. var width = this._domImage.width;
  6419. var height = this._domImage.height;
  6420. canvas.width = width;
  6421. canvas.height = height;
  6422. context.drawImage(this._domImage, 0, 0, width, height);
  6423. var imageData = context.getImageData(0, 0, width, height);
  6424. // Left and right
  6425. this._sliceLeft = -1;
  6426. this._sliceRight = -1;
  6427. for (var x = 0; x < width; x++) {
  6428. var alpha = imageData.data[x * 4 + 3];
  6429. if (alpha > 127 && this._sliceLeft === -1) {
  6430. this._sliceLeft = x;
  6431. continue;
  6432. }
  6433. if (alpha < 127 && this._sliceLeft > -1) {
  6434. this._sliceRight = x;
  6435. break;
  6436. }
  6437. }
  6438. // top and bottom
  6439. this._sliceTop = -1;
  6440. this._sliceBottom = -1;
  6441. for (var y = 0; y < height; y++) {
  6442. var alpha = imageData.data[y * width * 4 + 3];
  6443. if (alpha > 127 && this._sliceTop === -1) {
  6444. this._sliceTop = y;
  6445. continue;
  6446. }
  6447. if (alpha < 127 && this._sliceTop > -1) {
  6448. this._sliceBottom = y;
  6449. break;
  6450. }
  6451. }
  6452. };
  6453. Object.defineProperty(Image.prototype, "source", {
  6454. /**
  6455. * Gets or sets image source url
  6456. */
  6457. set: function (value) {
  6458. var _this = this;
  6459. if (this._source === value) {
  6460. return;
  6461. }
  6462. this._loaded = false;
  6463. this._source = value;
  6464. this._domImage = document.createElement("img");
  6465. this._domImage.onload = function () {
  6466. _this._onImageLoaded();
  6467. };
  6468. if (value) {
  6469. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6470. this._domImage.src = value;
  6471. }
  6472. },
  6473. enumerable: true,
  6474. configurable: true
  6475. });
  6476. Object.defineProperty(Image.prototype, "cellWidth", {
  6477. /**
  6478. * Gets or sets the cell width to use when animation sheet is enabled
  6479. * @see http://doc.babylonjs.com/how_to/gui#image
  6480. */
  6481. get: function () {
  6482. return this._cellWidth;
  6483. },
  6484. set: function (value) {
  6485. if (this._cellWidth === value) {
  6486. return;
  6487. }
  6488. this._cellWidth = value;
  6489. this._markAsDirty();
  6490. },
  6491. enumerable: true,
  6492. configurable: true
  6493. });
  6494. Object.defineProperty(Image.prototype, "cellHeight", {
  6495. /**
  6496. * Gets or sets the cell height to use when animation sheet is enabled
  6497. * @see http://doc.babylonjs.com/how_to/gui#image
  6498. */
  6499. get: function () {
  6500. return this._cellHeight;
  6501. },
  6502. set: function (value) {
  6503. if (this._cellHeight === value) {
  6504. return;
  6505. }
  6506. this._cellHeight = value;
  6507. this._markAsDirty();
  6508. },
  6509. enumerable: true,
  6510. configurable: true
  6511. });
  6512. Object.defineProperty(Image.prototype, "cellId", {
  6513. /**
  6514. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6515. * @see http://doc.babylonjs.com/how_to/gui#image
  6516. */
  6517. get: function () {
  6518. return this._cellId;
  6519. },
  6520. set: function (value) {
  6521. if (this._cellId === value) {
  6522. return;
  6523. }
  6524. this._cellId = value;
  6525. this._markAsDirty();
  6526. },
  6527. enumerable: true,
  6528. configurable: true
  6529. });
  6530. /**
  6531. * Tests if a given coordinates belong to the current control
  6532. * @param x defines x coordinate to test
  6533. * @param y defines y coordinate to test
  6534. * @returns true if the coordinates are inside the control
  6535. */
  6536. Image.prototype.contains = function (x, y) {
  6537. if (!_super.prototype.contains.call(this, x, y)) {
  6538. return false;
  6539. }
  6540. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6541. return true;
  6542. }
  6543. var canvas = Image._WorkingCanvas;
  6544. var context = canvas.getContext("2d");
  6545. var width = this._currentMeasure.width | 0;
  6546. var height = this._currentMeasure.height | 0;
  6547. var imageData = context.getImageData(0, 0, width, height).data;
  6548. x = (x - this._currentMeasure.left) | 0;
  6549. y = (y - this._currentMeasure.top) | 0;
  6550. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6551. return pickedPixel > 0;
  6552. };
  6553. Image.prototype._getTypeName = function () {
  6554. return "Image";
  6555. };
  6556. /** Force the control to synchronize with its content */
  6557. Image.prototype.synchronizeSizeWithContent = function () {
  6558. if (!this._loaded) {
  6559. return;
  6560. }
  6561. this.width = this._domImage.width + "px";
  6562. this.height = this._domImage.height + "px";
  6563. };
  6564. Image.prototype._processMeasures = function (parentMeasure, context) {
  6565. if (this._loaded) {
  6566. switch (this._stretch) {
  6567. case Image.STRETCH_NONE:
  6568. break;
  6569. case Image.STRETCH_FILL:
  6570. break;
  6571. case Image.STRETCH_UNIFORM:
  6572. break;
  6573. case Image.STRETCH_NINE_PATCH:
  6574. break;
  6575. case Image.STRETCH_EXTEND:
  6576. if (this._autoScale) {
  6577. this.synchronizeSizeWithContent();
  6578. }
  6579. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6580. this.parent.adaptWidthToChildren = true;
  6581. this.parent.adaptHeightToChildren = true;
  6582. }
  6583. break;
  6584. }
  6585. }
  6586. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6587. };
  6588. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6589. if (!this._detectPointerOnOpaqueOnly) {
  6590. return;
  6591. }
  6592. if (!Image._WorkingCanvas) {
  6593. Image._WorkingCanvas = document.createElement('canvas');
  6594. }
  6595. var canvas = Image._WorkingCanvas;
  6596. var width = this._currentMeasure.width;
  6597. var height = this._currentMeasure.height;
  6598. var context = canvas.getContext("2d");
  6599. canvas.width = width;
  6600. canvas.height = height;
  6601. context.clearRect(0, 0, width, height);
  6602. };
  6603. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6604. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6605. if (!this._detectPointerOnOpaqueOnly) {
  6606. return;
  6607. }
  6608. var canvas = Image._WorkingCanvas;
  6609. context = canvas.getContext("2d");
  6610. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6611. };
  6612. Image.prototype._draw = function (context) {
  6613. context.save();
  6614. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6615. context.shadowColor = this.shadowColor;
  6616. context.shadowBlur = this.shadowBlur;
  6617. context.shadowOffsetX = this.shadowOffsetX;
  6618. context.shadowOffsetY = this.shadowOffsetY;
  6619. }
  6620. var x, y, width, height;
  6621. if (this.cellId == -1) {
  6622. x = this._sourceLeft;
  6623. y = this._sourceTop;
  6624. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6625. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6626. }
  6627. else {
  6628. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6629. var column = (this.cellId / rowCount) >> 0;
  6630. var row = this.cellId % rowCount;
  6631. x = this.cellWidth * row;
  6632. y = this.cellHeight * column;
  6633. width = this.cellWidth;
  6634. height = this.cellHeight;
  6635. }
  6636. this._prepareWorkingCanvasForOpaqueDetection();
  6637. this._applyStates(context);
  6638. if (this._loaded) {
  6639. switch (this._stretch) {
  6640. case Image.STRETCH_NONE:
  6641. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6642. break;
  6643. case Image.STRETCH_FILL:
  6644. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6645. break;
  6646. case Image.STRETCH_UNIFORM:
  6647. var hRatio = this._currentMeasure.width / width;
  6648. var vRatio = this._currentMeasure.height / height;
  6649. var ratio = Math.min(hRatio, vRatio);
  6650. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6651. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6652. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6653. break;
  6654. case Image.STRETCH_EXTEND:
  6655. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6656. break;
  6657. case Image.STRETCH_NINE_PATCH:
  6658. this._renderNinePatch(context);
  6659. break;
  6660. }
  6661. }
  6662. context.restore();
  6663. };
  6664. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6665. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6666. };
  6667. Image.prototype._renderNinePatch = function (context) {
  6668. var height = this._imageHeight;
  6669. var leftWidth = this._sliceLeft;
  6670. var topHeight = this._sliceTop;
  6671. var bottomHeight = this._imageHeight - this._sliceBottom;
  6672. var rightWidth = this._imageWidth - this._sliceRight;
  6673. var left = 0;
  6674. var top = 0;
  6675. if (this._populateNinePatchSlicesFromImage) {
  6676. left = 1;
  6677. top = 1;
  6678. height -= 2;
  6679. leftWidth -= 1;
  6680. topHeight -= 1;
  6681. bottomHeight -= 1;
  6682. rightWidth -= 1;
  6683. }
  6684. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6685. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6686. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6687. // Corners
  6688. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6689. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6690. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6691. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6692. // Center
  6693. 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);
  6694. // Borders
  6695. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6696. 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);
  6697. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6698. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6699. };
  6700. Image.prototype.dispose = function () {
  6701. _super.prototype.dispose.call(this);
  6702. this.onImageLoadedObservable.clear();
  6703. };
  6704. Image._WorkingCanvas = null;
  6705. // Static
  6706. /** STRETCH_NONE */
  6707. Image.STRETCH_NONE = 0;
  6708. /** STRETCH_FILL */
  6709. Image.STRETCH_FILL = 1;
  6710. /** STRETCH_UNIFORM */
  6711. Image.STRETCH_UNIFORM = 2;
  6712. /** STRETCH_EXTEND */
  6713. Image.STRETCH_EXTEND = 3;
  6714. /** NINE_PATCH */
  6715. Image.STRETCH_NINE_PATCH = 4;
  6716. return Image;
  6717. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6718. /***/ }),
  6719. /***/ "./2D/controls/index.ts":
  6720. /*!******************************!*\
  6721. !*** ./2D/controls/index.ts ***!
  6722. \******************************/
  6723. /*! 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 */
  6724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6725. "use strict";
  6726. __webpack_require__.r(__webpack_exports__);
  6727. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6729. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6731. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6733. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6735. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6737. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6739. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6741. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6743. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6745. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6747. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6749. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6751. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6753. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6755. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6761. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6763. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6766. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6769. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6771. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6773. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6775. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6777. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6779. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6781. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6783. /***/ }),
  6784. /***/ "./2D/controls/inputPassword.ts":
  6785. /*!**************************************!*\
  6786. !*** ./2D/controls/inputPassword.ts ***!
  6787. \**************************************/
  6788. /*! exports provided: InputPassword */
  6789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6790. "use strict";
  6791. __webpack_require__.r(__webpack_exports__);
  6792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6793. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6794. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6795. /**
  6796. * Class used to create a password control
  6797. */
  6798. var InputPassword = /** @class */ (function (_super) {
  6799. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6800. function InputPassword() {
  6801. return _super !== null && _super.apply(this, arguments) || this;
  6802. }
  6803. InputPassword.prototype._beforeRenderText = function (text) {
  6804. var txt = "";
  6805. for (var i = 0; i < text.length; i++) {
  6806. txt += "\u2022";
  6807. }
  6808. return txt;
  6809. };
  6810. return InputPassword;
  6811. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6812. /***/ }),
  6813. /***/ "./2D/controls/inputText.ts":
  6814. /*!**********************************!*\
  6815. !*** ./2D/controls/inputText.ts ***!
  6816. \**********************************/
  6817. /*! exports provided: InputText */
  6818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6819. "use strict";
  6820. __webpack_require__.r(__webpack_exports__);
  6821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6822. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6823. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6824. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6825. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6826. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6827. /**
  6828. * Class used to create input text control
  6829. */
  6830. var InputText = /** @class */ (function (_super) {
  6831. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6832. /**
  6833. * Creates a new InputText
  6834. * @param name defines the control name
  6835. * @param text defines the text of the control
  6836. */
  6837. function InputText(name, text) {
  6838. if (text === void 0) { text = ""; }
  6839. var _this = _super.call(this, name) || this;
  6840. _this.name = name;
  6841. _this._text = "";
  6842. _this._placeholderText = "";
  6843. _this._background = "#222222";
  6844. _this._focusedBackground = "#000000";
  6845. _this._focusedColor = "white";
  6846. _this._placeholderColor = "gray";
  6847. _this._thickness = 1;
  6848. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6849. _this._autoStretchWidth = true;
  6850. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6851. _this._isFocused = false;
  6852. _this._blinkIsEven = false;
  6853. _this._cursorOffset = 0;
  6854. _this._deadKey = false;
  6855. _this._addKey = true;
  6856. _this._currentKey = "";
  6857. _this._isTextHighlightOn = false;
  6858. _this._textHighlightColor = "#d5e0ff";
  6859. _this._highligherOpacity = 0.4;
  6860. _this._highlightedText = "";
  6861. _this._startHighlightIndex = 0;
  6862. _this._endHighlightIndex = 0;
  6863. _this._cursorIndex = -1;
  6864. _this._onFocusSelectAll = false;
  6865. _this._isPointerDown = false;
  6866. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6867. _this.promptMessage = "Please enter text:";
  6868. /** Force disable prompt on mobile device */
  6869. _this.disableMobilePrompt = false;
  6870. /** Observable raised when the text changes */
  6871. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6872. /** Observable raised just before an entered character is to be added */
  6873. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6874. /** Observable raised when the control gets the focus */
  6875. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6876. /** Observable raised when the control loses the focus */
  6877. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6878. /**Observable raised when the text is highlighted */
  6879. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6880. /**Observable raised when copy event is triggered */
  6881. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6882. /** Observable raised when cut event is triggered */
  6883. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6884. /** Observable raised when paste event is triggered */
  6885. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6886. /** Observable raised when a key event was processed */
  6887. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6888. _this.text = text;
  6889. _this.isPointerBlocker = true;
  6890. return _this;
  6891. }
  6892. Object.defineProperty(InputText.prototype, "maxWidth", {
  6893. /** Gets or sets the maximum width allowed by the control */
  6894. get: function () {
  6895. return this._maxWidth.toString(this._host);
  6896. },
  6897. set: function (value) {
  6898. if (this._maxWidth.toString(this._host) === value) {
  6899. return;
  6900. }
  6901. if (this._maxWidth.fromString(value)) {
  6902. this._markAsDirty();
  6903. }
  6904. },
  6905. enumerable: true,
  6906. configurable: true
  6907. });
  6908. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6909. /** Gets the maximum width allowed by the control in pixels */
  6910. get: function () {
  6911. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6912. },
  6913. enumerable: true,
  6914. configurable: true
  6915. });
  6916. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6917. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6918. get: function () {
  6919. return this._highligherOpacity;
  6920. },
  6921. set: function (value) {
  6922. if (this._highligherOpacity === value) {
  6923. return;
  6924. }
  6925. this._highligherOpacity = value;
  6926. this._markAsDirty();
  6927. },
  6928. enumerable: true,
  6929. configurable: true
  6930. });
  6931. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6932. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6933. get: function () {
  6934. return this._onFocusSelectAll;
  6935. },
  6936. set: function (value) {
  6937. if (this._onFocusSelectAll === value) {
  6938. return;
  6939. }
  6940. this._onFocusSelectAll = value;
  6941. this._markAsDirty();
  6942. },
  6943. enumerable: true,
  6944. configurable: true
  6945. });
  6946. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6947. /** Gets or sets the text hightlight color */
  6948. get: function () {
  6949. return this._textHighlightColor;
  6950. },
  6951. set: function (value) {
  6952. if (this._textHighlightColor === value) {
  6953. return;
  6954. }
  6955. this._textHighlightColor = value;
  6956. this._markAsDirty();
  6957. },
  6958. enumerable: true,
  6959. configurable: true
  6960. });
  6961. Object.defineProperty(InputText.prototype, "margin", {
  6962. /** Gets or sets control margin */
  6963. get: function () {
  6964. return this._margin.toString(this._host);
  6965. },
  6966. set: function (value) {
  6967. if (this._margin.toString(this._host) === value) {
  6968. return;
  6969. }
  6970. if (this._margin.fromString(value)) {
  6971. this._markAsDirty();
  6972. }
  6973. },
  6974. enumerable: true,
  6975. configurable: true
  6976. });
  6977. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6978. /** Gets control margin in pixels */
  6979. get: function () {
  6980. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6981. },
  6982. enumerable: true,
  6983. configurable: true
  6984. });
  6985. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6986. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6987. get: function () {
  6988. return this._autoStretchWidth;
  6989. },
  6990. set: function (value) {
  6991. if (this._autoStretchWidth === value) {
  6992. return;
  6993. }
  6994. this._autoStretchWidth = value;
  6995. this._markAsDirty();
  6996. },
  6997. enumerable: true,
  6998. configurable: true
  6999. });
  7000. Object.defineProperty(InputText.prototype, "thickness", {
  7001. /** Gets or sets border thickness */
  7002. get: function () {
  7003. return this._thickness;
  7004. },
  7005. set: function (value) {
  7006. if (this._thickness === value) {
  7007. return;
  7008. }
  7009. this._thickness = value;
  7010. this._markAsDirty();
  7011. },
  7012. enumerable: true,
  7013. configurable: true
  7014. });
  7015. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7016. /** Gets or sets the background color when focused */
  7017. get: function () {
  7018. return this._focusedBackground;
  7019. },
  7020. set: function (value) {
  7021. if (this._focusedBackground === value) {
  7022. return;
  7023. }
  7024. this._focusedBackground = value;
  7025. this._markAsDirty();
  7026. },
  7027. enumerable: true,
  7028. configurable: true
  7029. });
  7030. Object.defineProperty(InputText.prototype, "focusedColor", {
  7031. /** Gets or sets the background color when focused */
  7032. get: function () {
  7033. return this._focusedColor;
  7034. },
  7035. set: function (value) {
  7036. if (this._focusedColor === value) {
  7037. return;
  7038. }
  7039. this._focusedColor = value;
  7040. this._markAsDirty();
  7041. },
  7042. enumerable: true,
  7043. configurable: true
  7044. });
  7045. Object.defineProperty(InputText.prototype, "background", {
  7046. /** Gets or sets the background color */
  7047. get: function () {
  7048. return this._background;
  7049. },
  7050. set: function (value) {
  7051. if (this._background === value) {
  7052. return;
  7053. }
  7054. this._background = value;
  7055. this._markAsDirty();
  7056. },
  7057. enumerable: true,
  7058. configurable: true
  7059. });
  7060. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7061. /** Gets or sets the placeholder color */
  7062. get: function () {
  7063. return this._placeholderColor;
  7064. },
  7065. set: function (value) {
  7066. if (this._placeholderColor === value) {
  7067. return;
  7068. }
  7069. this._placeholderColor = value;
  7070. this._markAsDirty();
  7071. },
  7072. enumerable: true,
  7073. configurable: true
  7074. });
  7075. Object.defineProperty(InputText.prototype, "placeholderText", {
  7076. /** Gets or sets the text displayed when the control is empty */
  7077. get: function () {
  7078. return this._placeholderText;
  7079. },
  7080. set: function (value) {
  7081. if (this._placeholderText === value) {
  7082. return;
  7083. }
  7084. this._placeholderText = value;
  7085. this._markAsDirty();
  7086. },
  7087. enumerable: true,
  7088. configurable: true
  7089. });
  7090. Object.defineProperty(InputText.prototype, "deadKey", {
  7091. /** Gets or sets the dead key flag */
  7092. get: function () {
  7093. return this._deadKey;
  7094. },
  7095. set: function (flag) {
  7096. this._deadKey = flag;
  7097. },
  7098. enumerable: true,
  7099. configurable: true
  7100. });
  7101. Object.defineProperty(InputText.prototype, "highlightedText", {
  7102. /** Gets or sets the highlight text */
  7103. get: function () {
  7104. return this._highlightedText;
  7105. },
  7106. set: function (text) {
  7107. if (this._highlightedText === text) {
  7108. return;
  7109. }
  7110. this._highlightedText = text;
  7111. this._markAsDirty();
  7112. },
  7113. enumerable: true,
  7114. configurable: true
  7115. });
  7116. Object.defineProperty(InputText.prototype, "addKey", {
  7117. /** Gets or sets if the current key should be added */
  7118. get: function () {
  7119. return this._addKey;
  7120. },
  7121. set: function (flag) {
  7122. this._addKey = flag;
  7123. },
  7124. enumerable: true,
  7125. configurable: true
  7126. });
  7127. Object.defineProperty(InputText.prototype, "currentKey", {
  7128. /** Gets or sets the value of the current key being entered */
  7129. get: function () {
  7130. return this._currentKey;
  7131. },
  7132. set: function (key) {
  7133. this._currentKey = key;
  7134. },
  7135. enumerable: true,
  7136. configurable: true
  7137. });
  7138. Object.defineProperty(InputText.prototype, "text", {
  7139. /** Gets or sets the text displayed in the control */
  7140. get: function () {
  7141. return this._text;
  7142. },
  7143. set: function (value) {
  7144. var valueAsString = value.toString(); // Forcing convertion
  7145. if (this._text === valueAsString) {
  7146. return;
  7147. }
  7148. this._text = valueAsString;
  7149. this._markAsDirty();
  7150. this.onTextChangedObservable.notifyObservers(this);
  7151. },
  7152. enumerable: true,
  7153. configurable: true
  7154. });
  7155. Object.defineProperty(InputText.prototype, "width", {
  7156. /** Gets or sets control width */
  7157. get: function () {
  7158. return this._width.toString(this._host);
  7159. },
  7160. set: function (value) {
  7161. if (this._width.toString(this._host) === value) {
  7162. return;
  7163. }
  7164. if (this._width.fromString(value)) {
  7165. this._markAsDirty();
  7166. }
  7167. this.autoStretchWidth = false;
  7168. },
  7169. enumerable: true,
  7170. configurable: true
  7171. });
  7172. /** @hidden */
  7173. InputText.prototype.onBlur = function () {
  7174. this._isFocused = false;
  7175. this._scrollLeft = null;
  7176. this._cursorOffset = 0;
  7177. clearTimeout(this._blinkTimeout);
  7178. this._markAsDirty();
  7179. this.onBlurObservable.notifyObservers(this);
  7180. this._host.unRegisterClipboardEvents();
  7181. if (this._onClipboardObserver) {
  7182. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7183. }
  7184. var scene = this._host.getScene();
  7185. if (this._onPointerDblTapObserver && scene) {
  7186. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7187. }
  7188. };
  7189. /** @hidden */
  7190. InputText.prototype.onFocus = function () {
  7191. var _this = this;
  7192. if (!this._isEnabled) {
  7193. return;
  7194. }
  7195. this._scrollLeft = null;
  7196. this._isFocused = true;
  7197. this._blinkIsEven = false;
  7198. this._cursorOffset = 0;
  7199. this._markAsDirty();
  7200. this.onFocusObservable.notifyObservers(this);
  7201. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7202. var value = prompt(this.promptMessage);
  7203. if (value !== null) {
  7204. this.text = value;
  7205. }
  7206. this._host.focusedControl = null;
  7207. return;
  7208. }
  7209. this._host.registerClipboardEvents();
  7210. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7211. // process clipboard event, can be configured.
  7212. switch (clipboardInfo.type) {
  7213. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7214. _this._onCopyText(clipboardInfo.event);
  7215. _this.onTextCopyObservable.notifyObservers(_this);
  7216. break;
  7217. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7218. _this._onCutText(clipboardInfo.event);
  7219. _this.onTextCutObservable.notifyObservers(_this);
  7220. break;
  7221. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7222. _this._onPasteText(clipboardInfo.event);
  7223. _this.onTextPasteObservable.notifyObservers(_this);
  7224. break;
  7225. default: return;
  7226. }
  7227. });
  7228. var scene = this._host.getScene();
  7229. if (scene) {
  7230. //register the pointer double tap event
  7231. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7232. if (!_this._isFocused) {
  7233. return;
  7234. }
  7235. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7236. _this._processDblClick(pointerInfo);
  7237. }
  7238. });
  7239. }
  7240. if (this._onFocusSelectAll) {
  7241. this._selectAllText();
  7242. }
  7243. };
  7244. InputText.prototype._getTypeName = function () {
  7245. return "InputText";
  7246. };
  7247. /**
  7248. * Function called to get the list of controls that should not steal the focus from this control
  7249. * @returns an array of controls
  7250. */
  7251. InputText.prototype.keepsFocusWith = function () {
  7252. if (!this._connectedVirtualKeyboard) {
  7253. return null;
  7254. }
  7255. return [this._connectedVirtualKeyboard];
  7256. };
  7257. /** @hidden */
  7258. InputText.prototype.processKey = function (keyCode, key, evt) {
  7259. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7260. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7261. return;
  7262. }
  7263. //select all
  7264. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7265. this._selectAllText();
  7266. evt.preventDefault();
  7267. return;
  7268. }
  7269. // Specific cases
  7270. switch (keyCode) {
  7271. case 32: //SPACE
  7272. key = " "; //ie11 key for space is "Spacebar"
  7273. break;
  7274. case 191: //SLASH
  7275. if (evt) {
  7276. evt.preventDefault();
  7277. }
  7278. break;
  7279. case 8: // BACKSPACE
  7280. if (this._text && this._text.length > 0) {
  7281. //delete the highlighted text
  7282. if (this._isTextHighlightOn) {
  7283. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7284. this._isTextHighlightOn = false;
  7285. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7286. this._blinkIsEven = false;
  7287. if (evt) {
  7288. evt.preventDefault();
  7289. }
  7290. return;
  7291. }
  7292. //delete single character
  7293. if (this._cursorOffset === 0) {
  7294. this.text = this._text.substr(0, this._text.length - 1);
  7295. }
  7296. else {
  7297. var deletePosition = this._text.length - this._cursorOffset;
  7298. if (deletePosition > 0) {
  7299. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7300. }
  7301. }
  7302. }
  7303. if (evt) {
  7304. evt.preventDefault();
  7305. }
  7306. return;
  7307. case 46: // DELETE
  7308. if (this._isTextHighlightOn) {
  7309. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7310. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7311. while (decrementor > 0 && this._cursorOffset > 0) {
  7312. this._cursorOffset--;
  7313. }
  7314. this._isTextHighlightOn = false;
  7315. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7316. if (evt) {
  7317. evt.preventDefault();
  7318. }
  7319. return;
  7320. }
  7321. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7322. var deletePosition = this._text.length - this._cursorOffset;
  7323. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7324. this._cursorOffset--;
  7325. }
  7326. if (evt) {
  7327. evt.preventDefault();
  7328. }
  7329. return;
  7330. case 13: // RETURN
  7331. this._host.focusedControl = null;
  7332. this._isTextHighlightOn = false;
  7333. return;
  7334. case 35: // END
  7335. this._cursorOffset = 0;
  7336. this._blinkIsEven = false;
  7337. this._isTextHighlightOn = false;
  7338. this._markAsDirty();
  7339. return;
  7340. case 36: // HOME
  7341. this._cursorOffset = this._text.length;
  7342. this._blinkIsEven = false;
  7343. this._isTextHighlightOn = false;
  7344. this._markAsDirty();
  7345. return;
  7346. case 37: // LEFT
  7347. this._cursorOffset++;
  7348. if (this._cursorOffset > this._text.length) {
  7349. this._cursorOffset = this._text.length;
  7350. }
  7351. if (evt && evt.shiftKey) {
  7352. // update the cursor
  7353. this._blinkIsEven = false;
  7354. // shift + ctrl/cmd + <-
  7355. if (evt.ctrlKey || evt.metaKey) {
  7356. if (!this._isTextHighlightOn) {
  7357. if (this._text.length === this._cursorOffset) {
  7358. return;
  7359. }
  7360. else {
  7361. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7362. }
  7363. }
  7364. this._startHighlightIndex = 0;
  7365. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7366. this._cursorOffset = this._text.length;
  7367. this._isTextHighlightOn = true;
  7368. this._markAsDirty();
  7369. return;
  7370. }
  7371. //store the starting point
  7372. if (!this._isTextHighlightOn) {
  7373. this._isTextHighlightOn = true;
  7374. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7375. }
  7376. //if text is already highlighted
  7377. else if (this._cursorIndex === -1) {
  7378. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7379. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7380. }
  7381. //set the highlight indexes
  7382. if (this._cursorIndex < this._cursorOffset) {
  7383. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7384. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7385. }
  7386. else if (this._cursorIndex > this._cursorOffset) {
  7387. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7388. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7389. }
  7390. else {
  7391. this._isTextHighlightOn = false;
  7392. }
  7393. this._markAsDirty();
  7394. return;
  7395. }
  7396. if (this._isTextHighlightOn) {
  7397. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7398. this._isTextHighlightOn = false;
  7399. }
  7400. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7401. this._cursorOffset = this.text.length;
  7402. evt.preventDefault();
  7403. }
  7404. this._blinkIsEven = false;
  7405. this._isTextHighlightOn = false;
  7406. this._cursorIndex = -1;
  7407. this._markAsDirty();
  7408. return;
  7409. case 39: // RIGHT
  7410. this._cursorOffset--;
  7411. if (this._cursorOffset < 0) {
  7412. this._cursorOffset = 0;
  7413. }
  7414. if (evt && evt.shiftKey) {
  7415. //update the cursor
  7416. this._blinkIsEven = false;
  7417. //shift + ctrl/cmd + ->
  7418. if (evt.ctrlKey || evt.metaKey) {
  7419. if (!this._isTextHighlightOn) {
  7420. if (this._cursorOffset === 0) {
  7421. return;
  7422. }
  7423. else {
  7424. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7425. }
  7426. }
  7427. this._endHighlightIndex = this._text.length;
  7428. this._isTextHighlightOn = true;
  7429. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7430. this._cursorOffset = 0;
  7431. this._markAsDirty();
  7432. return;
  7433. }
  7434. if (!this._isTextHighlightOn) {
  7435. this._isTextHighlightOn = true;
  7436. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7437. }
  7438. //if text is already highlighted
  7439. else if (this._cursorIndex === -1) {
  7440. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7441. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7442. }
  7443. //set the highlight indexes
  7444. if (this._cursorIndex < this._cursorOffset) {
  7445. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7446. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7447. }
  7448. else if (this._cursorIndex > this._cursorOffset) {
  7449. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7450. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7451. }
  7452. else {
  7453. this._isTextHighlightOn = false;
  7454. }
  7455. this._markAsDirty();
  7456. return;
  7457. }
  7458. if (this._isTextHighlightOn) {
  7459. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7460. this._isTextHighlightOn = false;
  7461. }
  7462. //ctr + ->
  7463. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7464. this._cursorOffset = 0;
  7465. evt.preventDefault();
  7466. }
  7467. this._blinkIsEven = false;
  7468. this._isTextHighlightOn = false;
  7469. this._cursorIndex = -1;
  7470. this._markAsDirty();
  7471. return;
  7472. case 222: // Dead
  7473. if (evt) {
  7474. evt.preventDefault();
  7475. }
  7476. this._cursorIndex = -1;
  7477. this.deadKey = true;
  7478. break;
  7479. }
  7480. // Printable characters
  7481. if (key &&
  7482. ((keyCode === -1) || // Direct access
  7483. (keyCode === 32) || // Space
  7484. (keyCode > 47 && keyCode < 64) || // Numbers
  7485. (keyCode > 64 && keyCode < 91) || // Letters
  7486. (keyCode > 159 && keyCode < 193) || // Special characters
  7487. (keyCode > 218 && keyCode < 223) || // Special characters
  7488. (keyCode > 95 && keyCode < 112))) { // Numpad
  7489. this._currentKey = key;
  7490. this.onBeforeKeyAddObservable.notifyObservers(this);
  7491. key = this._currentKey;
  7492. if (this._addKey) {
  7493. if (this._isTextHighlightOn) {
  7494. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7495. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7496. this._isTextHighlightOn = false;
  7497. this._blinkIsEven = false;
  7498. this._markAsDirty();
  7499. }
  7500. else if (this._cursorOffset === 0) {
  7501. this.text += key;
  7502. }
  7503. else {
  7504. var insertPosition = this._text.length - this._cursorOffset;
  7505. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7506. }
  7507. }
  7508. }
  7509. };
  7510. /** @hidden */
  7511. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7512. //update the cursor
  7513. this._blinkIsEven = false;
  7514. if (this._cursorIndex === -1) {
  7515. this._cursorIndex = offset;
  7516. }
  7517. else {
  7518. if (this._cursorIndex < this._cursorOffset) {
  7519. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7520. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7521. }
  7522. else if (this._cursorIndex > this._cursorOffset) {
  7523. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7524. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7525. }
  7526. else {
  7527. this._isTextHighlightOn = false;
  7528. this._markAsDirty();
  7529. return;
  7530. }
  7531. }
  7532. this._isTextHighlightOn = true;
  7533. this._markAsDirty();
  7534. };
  7535. /** @hidden */
  7536. InputText.prototype._processDblClick = function (evt) {
  7537. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7538. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7539. this._endHighlightIndex = this._startHighlightIndex;
  7540. var rWord = /\w+/g, moveLeft, moveRight;
  7541. do {
  7542. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7543. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7544. } while (moveLeft || moveRight);
  7545. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7546. this.onTextHighlightObservable.notifyObservers(this);
  7547. this._isTextHighlightOn = true;
  7548. this._clickedCoordinate = null;
  7549. this._blinkIsEven = true;
  7550. this._cursorIndex = -1;
  7551. this._markAsDirty();
  7552. };
  7553. /** @hidden */
  7554. InputText.prototype._selectAllText = function () {
  7555. this._blinkIsEven = true;
  7556. this._isTextHighlightOn = true;
  7557. this._startHighlightIndex = 0;
  7558. this._endHighlightIndex = this._text.length;
  7559. this._cursorOffset = this._text.length;
  7560. this._cursorIndex = -1;
  7561. this._markAsDirty();
  7562. };
  7563. /**
  7564. * Handles the keyboard event
  7565. * @param evt Defines the KeyboardEvent
  7566. */
  7567. InputText.prototype.processKeyboard = function (evt) {
  7568. // process pressed key
  7569. this.processKey(evt.keyCode, evt.key, evt);
  7570. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7571. };
  7572. /** @hidden */
  7573. InputText.prototype._onCopyText = function (ev) {
  7574. this._isTextHighlightOn = false;
  7575. //when write permission to clipbaord data is denied
  7576. try {
  7577. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7578. }
  7579. catch (_a) { } //pass
  7580. this._host.clipboardData = this._highlightedText;
  7581. };
  7582. /** @hidden */
  7583. InputText.prototype._onCutText = function (ev) {
  7584. if (!this._highlightedText) {
  7585. return;
  7586. }
  7587. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7588. this._isTextHighlightOn = false;
  7589. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7590. //when write permission to clipbaord data is denied
  7591. try {
  7592. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7593. }
  7594. catch (_a) { } //pass
  7595. this._host.clipboardData = this._highlightedText;
  7596. this._highlightedText = "";
  7597. };
  7598. /** @hidden */
  7599. InputText.prototype._onPasteText = function (ev) {
  7600. var data = "";
  7601. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7602. data = ev.clipboardData.getData("text/plain");
  7603. }
  7604. else {
  7605. //get the cached data; returns blank string by default
  7606. data = this._host.clipboardData;
  7607. }
  7608. var insertPosition = this._text.length - this._cursorOffset;
  7609. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7610. };
  7611. InputText.prototype._draw = function (context) {
  7612. var _this = this;
  7613. context.save();
  7614. this._applyStates(context);
  7615. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7616. context.shadowColor = this.shadowColor;
  7617. context.shadowBlur = this.shadowBlur;
  7618. context.shadowOffsetX = this.shadowOffsetX;
  7619. context.shadowOffsetY = this.shadowOffsetY;
  7620. }
  7621. // Background
  7622. if (this._isFocused) {
  7623. if (this._focusedBackground) {
  7624. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7625. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7626. }
  7627. }
  7628. else if (this._background) {
  7629. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7630. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7631. }
  7632. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7633. context.shadowBlur = 0;
  7634. context.shadowOffsetX = 0;
  7635. context.shadowOffsetY = 0;
  7636. }
  7637. if (!this._fontOffset) {
  7638. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7639. }
  7640. // Text
  7641. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7642. if (this.color) {
  7643. context.fillStyle = this.color;
  7644. }
  7645. var text = this._beforeRenderText(this._text);
  7646. if (!this._isFocused && !this._text && this._placeholderText) {
  7647. text = this._placeholderText;
  7648. if (this._placeholderColor) {
  7649. context.fillStyle = this._placeholderColor;
  7650. }
  7651. }
  7652. this._textWidth = context.measureText(text).width;
  7653. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7654. if (this._autoStretchWidth) {
  7655. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7656. }
  7657. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7658. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7659. context.save();
  7660. context.beginPath();
  7661. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7662. context.clip();
  7663. if (this._isFocused && this._textWidth > availableWidth) {
  7664. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7665. if (!this._scrollLeft) {
  7666. this._scrollLeft = textLeft;
  7667. }
  7668. }
  7669. else {
  7670. this._scrollLeft = clipTextLeft;
  7671. }
  7672. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7673. // Cursor
  7674. if (this._isFocused) {
  7675. // Need to move cursor
  7676. if (this._clickedCoordinate) {
  7677. var rightPosition = this._scrollLeft + this._textWidth;
  7678. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7679. var currentSize = 0;
  7680. this._cursorOffset = 0;
  7681. var previousDist = 0;
  7682. do {
  7683. if (this._cursorOffset) {
  7684. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7685. }
  7686. this._cursorOffset++;
  7687. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7688. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7689. // Find closest move
  7690. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7691. this._cursorOffset--;
  7692. }
  7693. this._blinkIsEven = false;
  7694. this._clickedCoordinate = null;
  7695. }
  7696. // Render cursor
  7697. if (!this._blinkIsEven) {
  7698. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7699. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7700. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7701. if (cursorLeft < clipTextLeft) {
  7702. this._scrollLeft += (clipTextLeft - cursorLeft);
  7703. cursorLeft = clipTextLeft;
  7704. this._markAsDirty();
  7705. }
  7706. else if (cursorLeft > clipTextLeft + availableWidth) {
  7707. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7708. cursorLeft = clipTextLeft + availableWidth;
  7709. this._markAsDirty();
  7710. }
  7711. if (!this._isTextHighlightOn) {
  7712. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7713. }
  7714. }
  7715. clearTimeout(this._blinkTimeout);
  7716. this._blinkTimeout = setTimeout(function () {
  7717. _this._blinkIsEven = !_this._blinkIsEven;
  7718. _this._markAsDirty();
  7719. }, 500);
  7720. //show the highlighted text
  7721. if (this._isTextHighlightOn) {
  7722. clearTimeout(this._blinkTimeout);
  7723. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7724. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7725. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7726. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7727. if (highlightCursorLeft < clipTextLeft) {
  7728. width = width - (clipTextLeft - highlightCursorLeft);
  7729. if (!width) {
  7730. // when using left arrow on text.length > availableWidth;
  7731. // assigns the width of the first letter after clipTextLeft
  7732. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7733. }
  7734. highlightCursorLeft = clipTextLeft;
  7735. }
  7736. //for transparancy
  7737. context.globalAlpha = this._highligherOpacity;
  7738. context.fillStyle = this._textHighlightColor;
  7739. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7740. context.globalAlpha = 1.0;
  7741. }
  7742. }
  7743. context.restore();
  7744. // Border
  7745. if (this._thickness) {
  7746. if (this._isFocused) {
  7747. if (this.focusedColor) {
  7748. context.strokeStyle = this.focusedColor;
  7749. }
  7750. }
  7751. else {
  7752. if (this.color) {
  7753. context.strokeStyle = this.color;
  7754. }
  7755. }
  7756. context.lineWidth = this._thickness;
  7757. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7758. }
  7759. context.restore();
  7760. };
  7761. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7762. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7763. return false;
  7764. }
  7765. this._clickedCoordinate = coordinates.x;
  7766. this._isTextHighlightOn = false;
  7767. this._highlightedText = "";
  7768. this._cursorIndex = -1;
  7769. this._isPointerDown = true;
  7770. this._host._capturingControl[pointerId] = this;
  7771. if (this._host.focusedControl === this) {
  7772. // Move cursor
  7773. clearTimeout(this._blinkTimeout);
  7774. this._markAsDirty();
  7775. return true;
  7776. }
  7777. if (!this._isEnabled) {
  7778. return false;
  7779. }
  7780. this._host.focusedControl = this;
  7781. return true;
  7782. };
  7783. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7784. if (this._host.focusedControl === this && this._isPointerDown) {
  7785. this._clickedCoordinate = coordinates.x;
  7786. this._markAsDirty();
  7787. this._updateValueFromCursorIndex(this._cursorOffset);
  7788. }
  7789. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7790. };
  7791. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7792. this._isPointerDown = false;
  7793. delete this._host._capturingControl[pointerId];
  7794. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7795. };
  7796. InputText.prototype._beforeRenderText = function (text) {
  7797. return text;
  7798. };
  7799. InputText.prototype.dispose = function () {
  7800. _super.prototype.dispose.call(this);
  7801. this.onBlurObservable.clear();
  7802. this.onFocusObservable.clear();
  7803. this.onTextChangedObservable.clear();
  7804. this.onTextCopyObservable.clear();
  7805. this.onTextCutObservable.clear();
  7806. this.onTextPasteObservable.clear();
  7807. this.onTextHighlightObservable.clear();
  7808. this.onKeyboardEventProcessedObservable.clear();
  7809. };
  7810. return InputText;
  7811. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7812. /***/ }),
  7813. /***/ "./2D/controls/line.ts":
  7814. /*!*****************************!*\
  7815. !*** ./2D/controls/line.ts ***!
  7816. \*****************************/
  7817. /*! exports provided: Line */
  7818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7819. "use strict";
  7820. __webpack_require__.r(__webpack_exports__);
  7821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7822. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7823. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  7824. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7825. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7826. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7827. /** Class used to render 2D lines */
  7828. var Line = /** @class */ (function (_super) {
  7829. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7830. /**
  7831. * Creates a new Line
  7832. * @param name defines the control name
  7833. */
  7834. function Line(name) {
  7835. var _this = _super.call(this, name) || this;
  7836. _this.name = name;
  7837. _this._lineWidth = 1;
  7838. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7839. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7840. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7841. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7842. _this._dash = new Array();
  7843. _this.isHitTestVisible = false;
  7844. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7845. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7846. return _this;
  7847. }
  7848. Object.defineProperty(Line.prototype, "dash", {
  7849. /** Gets or sets the dash pattern */
  7850. get: function () {
  7851. return this._dash;
  7852. },
  7853. set: function (value) {
  7854. if (this._dash === value) {
  7855. return;
  7856. }
  7857. this._dash = value;
  7858. this._markAsDirty();
  7859. },
  7860. enumerable: true,
  7861. configurable: true
  7862. });
  7863. Object.defineProperty(Line.prototype, "connectedControl", {
  7864. /** Gets or sets the control connected with the line end */
  7865. get: function () {
  7866. return this._connectedControl;
  7867. },
  7868. set: function (value) {
  7869. var _this = this;
  7870. if (this._connectedControl === value) {
  7871. return;
  7872. }
  7873. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7874. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7875. this._connectedControlDirtyObserver = null;
  7876. }
  7877. if (value) {
  7878. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7879. }
  7880. this._connectedControl = value;
  7881. this._markAsDirty();
  7882. },
  7883. enumerable: true,
  7884. configurable: true
  7885. });
  7886. Object.defineProperty(Line.prototype, "x1", {
  7887. /** Gets or sets start coordinates on X axis */
  7888. get: function () {
  7889. return this._x1.toString(this._host);
  7890. },
  7891. set: function (value) {
  7892. if (this._x1.toString(this._host) === value) {
  7893. return;
  7894. }
  7895. if (this._x1.fromString(value)) {
  7896. this._markAsDirty();
  7897. }
  7898. },
  7899. enumerable: true,
  7900. configurable: true
  7901. });
  7902. Object.defineProperty(Line.prototype, "y1", {
  7903. /** Gets or sets start coordinates on Y axis */
  7904. get: function () {
  7905. return this._y1.toString(this._host);
  7906. },
  7907. set: function (value) {
  7908. if (this._y1.toString(this._host) === value) {
  7909. return;
  7910. }
  7911. if (this._y1.fromString(value)) {
  7912. this._markAsDirty();
  7913. }
  7914. },
  7915. enumerable: true,
  7916. configurable: true
  7917. });
  7918. Object.defineProperty(Line.prototype, "x2", {
  7919. /** Gets or sets end coordinates on X axis */
  7920. get: function () {
  7921. return this._x2.toString(this._host);
  7922. },
  7923. set: function (value) {
  7924. if (this._x2.toString(this._host) === value) {
  7925. return;
  7926. }
  7927. if (this._x2.fromString(value)) {
  7928. this._markAsDirty();
  7929. }
  7930. },
  7931. enumerable: true,
  7932. configurable: true
  7933. });
  7934. Object.defineProperty(Line.prototype, "y2", {
  7935. /** Gets or sets end coordinates on Y axis */
  7936. get: function () {
  7937. return this._y2.toString(this._host);
  7938. },
  7939. set: function (value) {
  7940. if (this._y2.toString(this._host) === value) {
  7941. return;
  7942. }
  7943. if (this._y2.fromString(value)) {
  7944. this._markAsDirty();
  7945. }
  7946. },
  7947. enumerable: true,
  7948. configurable: true
  7949. });
  7950. Object.defineProperty(Line.prototype, "lineWidth", {
  7951. /** Gets or sets line width */
  7952. get: function () {
  7953. return this._lineWidth;
  7954. },
  7955. set: function (value) {
  7956. if (this._lineWidth === value) {
  7957. return;
  7958. }
  7959. this._lineWidth = value;
  7960. this._markAsDirty();
  7961. },
  7962. enumerable: true,
  7963. configurable: true
  7964. });
  7965. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7966. /** Gets or sets horizontal alignment */
  7967. set: function (value) {
  7968. return;
  7969. },
  7970. enumerable: true,
  7971. configurable: true
  7972. });
  7973. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7974. /** Gets or sets vertical alignment */
  7975. set: function (value) {
  7976. return;
  7977. },
  7978. enumerable: true,
  7979. configurable: true
  7980. });
  7981. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7982. get: function () {
  7983. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7984. },
  7985. enumerable: true,
  7986. configurable: true
  7987. });
  7988. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7989. get: function () {
  7990. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7991. },
  7992. enumerable: true,
  7993. configurable: true
  7994. });
  7995. Line.prototype._getTypeName = function () {
  7996. return "Line";
  7997. };
  7998. Line.prototype._draw = function (context) {
  7999. context.save();
  8000. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8001. context.shadowColor = this.shadowColor;
  8002. context.shadowBlur = this.shadowBlur;
  8003. context.shadowOffsetX = this.shadowOffsetX;
  8004. context.shadowOffsetY = this.shadowOffsetY;
  8005. }
  8006. this._applyStates(context);
  8007. context.strokeStyle = this.color;
  8008. context.lineWidth = this._lineWidth;
  8009. context.setLineDash(this._dash);
  8010. context.beginPath();
  8011. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8012. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8013. context.stroke();
  8014. context.restore();
  8015. };
  8016. Line.prototype._measure = function () {
  8017. // Width / Height
  8018. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8019. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8020. };
  8021. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8022. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8023. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8024. };
  8025. /**
  8026. * Move one end of the line given 3D cartesian coordinates.
  8027. * @param position Targeted world position
  8028. * @param scene Scene
  8029. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8030. */
  8031. Line.prototype.moveToVector3 = function (position, scene, end) {
  8032. if (end === void 0) { end = false; }
  8033. if (!this._host || this.parent !== this._host._rootContainer) {
  8034. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8035. return;
  8036. }
  8037. var globalViewport = this._host._getGlobalViewport(scene);
  8038. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8039. this._moveToProjectedPosition(projectedPosition, end);
  8040. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8041. this.notRenderable = true;
  8042. return;
  8043. }
  8044. this.notRenderable = false;
  8045. };
  8046. /**
  8047. * Move one end of the line to a position in screen absolute space.
  8048. * @param projectedPosition Position in screen absolute space (X, Y)
  8049. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8050. */
  8051. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8052. if (end === void 0) { end = false; }
  8053. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8054. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8055. if (end) {
  8056. this.x2 = x;
  8057. this.y2 = y;
  8058. this._x2.ignoreAdaptiveScaling = true;
  8059. this._y2.ignoreAdaptiveScaling = true;
  8060. }
  8061. else {
  8062. this.x1 = x;
  8063. this.y1 = y;
  8064. this._x1.ignoreAdaptiveScaling = true;
  8065. this._y1.ignoreAdaptiveScaling = true;
  8066. }
  8067. };
  8068. return Line;
  8069. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8070. /***/ }),
  8071. /***/ "./2D/controls/multiLine.ts":
  8072. /*!**********************************!*\
  8073. !*** ./2D/controls/multiLine.ts ***!
  8074. \**********************************/
  8075. /*! exports provided: MultiLine */
  8076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8077. "use strict";
  8078. __webpack_require__.r(__webpack_exports__);
  8079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8080. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8081. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math");
  8082. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8083. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8084. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8085. /**
  8086. * Class used to create multi line control
  8087. */
  8088. var MultiLine = /** @class */ (function (_super) {
  8089. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8090. /**
  8091. * Creates a new MultiLine
  8092. * @param name defines the control name
  8093. */
  8094. function MultiLine(name) {
  8095. var _this = _super.call(this, name) || this;
  8096. _this.name = name;
  8097. _this._lineWidth = 1;
  8098. /** Function called when a point is updated */
  8099. _this.onPointUpdate = function () {
  8100. _this._markAsDirty();
  8101. };
  8102. _this.isHitTestVisible = false;
  8103. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8104. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8105. _this._dash = [];
  8106. _this._points = [];
  8107. return _this;
  8108. }
  8109. Object.defineProperty(MultiLine.prototype, "dash", {
  8110. /** Gets or sets dash pattern */
  8111. get: function () {
  8112. return this._dash;
  8113. },
  8114. set: function (value) {
  8115. if (this._dash === value) {
  8116. return;
  8117. }
  8118. this._dash = value;
  8119. this._markAsDirty();
  8120. },
  8121. enumerable: true,
  8122. configurable: true
  8123. });
  8124. /**
  8125. * Gets point stored at specified index
  8126. * @param index defines the index to look for
  8127. * @returns the requested point if found
  8128. */
  8129. MultiLine.prototype.getAt = function (index) {
  8130. if (!this._points[index]) {
  8131. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8132. }
  8133. return this._points[index];
  8134. };
  8135. /**
  8136. * Adds new points to the point collection
  8137. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8138. * @returns the list of created MultiLinePoint
  8139. */
  8140. MultiLine.prototype.add = function () {
  8141. var _this = this;
  8142. var items = [];
  8143. for (var _i = 0; _i < arguments.length; _i++) {
  8144. items[_i] = arguments[_i];
  8145. }
  8146. return items.map(function (item) { return _this.push(item); });
  8147. };
  8148. /**
  8149. * Adds a new point to the point collection
  8150. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8151. * @returns the created MultiLinePoint
  8152. */
  8153. MultiLine.prototype.push = function (item) {
  8154. var point = this.getAt(this._points.length);
  8155. if (item == null) {
  8156. return point;
  8157. }
  8158. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8159. point.mesh = item;
  8160. }
  8161. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8162. point.control = item;
  8163. }
  8164. else if (item.x != null && item.y != null) {
  8165. point.x = item.x;
  8166. point.y = item.y;
  8167. }
  8168. return point;
  8169. };
  8170. /**
  8171. * Remove a specific value or point from the active point collection
  8172. * @param value defines the value or point to remove
  8173. */
  8174. MultiLine.prototype.remove = function (value) {
  8175. var index;
  8176. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8177. index = this._points.indexOf(value);
  8178. if (index === -1) {
  8179. return;
  8180. }
  8181. }
  8182. else {
  8183. index = value;
  8184. }
  8185. var point = this._points[index];
  8186. if (!point) {
  8187. return;
  8188. }
  8189. point.dispose();
  8190. this._points.splice(index, 1);
  8191. };
  8192. /**
  8193. * Resets this object to initial state (no point)
  8194. */
  8195. MultiLine.prototype.reset = function () {
  8196. while (this._points.length > 0) {
  8197. this.remove(this._points.length - 1);
  8198. }
  8199. };
  8200. /**
  8201. * Resets all links
  8202. */
  8203. MultiLine.prototype.resetLinks = function () {
  8204. this._points.forEach(function (point) {
  8205. if (point != null) {
  8206. point.resetLinks();
  8207. }
  8208. });
  8209. };
  8210. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8211. /** Gets or sets line width */
  8212. get: function () {
  8213. return this._lineWidth;
  8214. },
  8215. set: function (value) {
  8216. if (this._lineWidth === value) {
  8217. return;
  8218. }
  8219. this._lineWidth = value;
  8220. this._markAsDirty();
  8221. },
  8222. enumerable: true,
  8223. configurable: true
  8224. });
  8225. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8226. set: function (value) {
  8227. return;
  8228. },
  8229. enumerable: true,
  8230. configurable: true
  8231. });
  8232. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8233. set: function (value) {
  8234. return;
  8235. },
  8236. enumerable: true,
  8237. configurable: true
  8238. });
  8239. MultiLine.prototype._getTypeName = function () {
  8240. return "MultiLine";
  8241. };
  8242. MultiLine.prototype._draw = function (context) {
  8243. context.save();
  8244. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8245. context.shadowColor = this.shadowColor;
  8246. context.shadowBlur = this.shadowBlur;
  8247. context.shadowOffsetX = this.shadowOffsetX;
  8248. context.shadowOffsetY = this.shadowOffsetY;
  8249. }
  8250. this._applyStates(context);
  8251. context.strokeStyle = this.color;
  8252. context.lineWidth = this._lineWidth;
  8253. context.setLineDash(this._dash);
  8254. context.beginPath();
  8255. var first = true; //first index is not necessarily 0
  8256. this._points.forEach(function (point) {
  8257. if (!point) {
  8258. return;
  8259. }
  8260. if (first) {
  8261. context.moveTo(point._point.x, point._point.y);
  8262. first = false;
  8263. }
  8264. else {
  8265. context.lineTo(point._point.x, point._point.y);
  8266. }
  8267. });
  8268. context.stroke();
  8269. context.restore();
  8270. };
  8271. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8272. var _this = this;
  8273. this._minX = null;
  8274. this._minY = null;
  8275. this._maxX = null;
  8276. this._maxY = null;
  8277. this._points.forEach(function (point, index) {
  8278. if (!point) {
  8279. return;
  8280. }
  8281. point.translate();
  8282. if (_this._minX == null || point._point.x < _this._minX) {
  8283. _this._minX = point._point.x;
  8284. }
  8285. if (_this._minY == null || point._point.y < _this._minY) {
  8286. _this._minY = point._point.y;
  8287. }
  8288. if (_this._maxX == null || point._point.x > _this._maxX) {
  8289. _this._maxX = point._point.x;
  8290. }
  8291. if (_this._maxY == null || point._point.y > _this._maxY) {
  8292. _this._maxY = point._point.y;
  8293. }
  8294. });
  8295. if (this._minX == null) {
  8296. this._minX = 0;
  8297. }
  8298. if (this._minY == null) {
  8299. this._minY = 0;
  8300. }
  8301. if (this._maxX == null) {
  8302. this._maxX = 0;
  8303. }
  8304. if (this._maxY == null) {
  8305. this._maxY = 0;
  8306. }
  8307. };
  8308. MultiLine.prototype._measure = function () {
  8309. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8310. return;
  8311. }
  8312. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8313. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8314. };
  8315. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8316. if (this._minX == null || this._minY == null) {
  8317. return;
  8318. }
  8319. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8320. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8321. };
  8322. MultiLine.prototype.dispose = function () {
  8323. this.reset();
  8324. _super.prototype.dispose.call(this);
  8325. };
  8326. return MultiLine;
  8327. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8328. /***/ }),
  8329. /***/ "./2D/controls/radioButton.ts":
  8330. /*!************************************!*\
  8331. !*** ./2D/controls/radioButton.ts ***!
  8332. \************************************/
  8333. /*! exports provided: RadioButton */
  8334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8335. "use strict";
  8336. __webpack_require__.r(__webpack_exports__);
  8337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8338. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8339. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  8340. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8341. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8342. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8343. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8344. /**
  8345. * Class used to create radio button controls
  8346. */
  8347. var RadioButton = /** @class */ (function (_super) {
  8348. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8349. /**
  8350. * Creates a new RadioButton
  8351. * @param name defines the control name
  8352. */
  8353. function RadioButton(name) {
  8354. var _this = _super.call(this, name) || this;
  8355. _this.name = name;
  8356. _this._isChecked = false;
  8357. _this._background = "black";
  8358. _this._checkSizeRatio = 0.8;
  8359. _this._thickness = 1;
  8360. /** Gets or sets group name */
  8361. _this.group = "";
  8362. /** Observable raised when isChecked is changed */
  8363. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8364. _this.isPointerBlocker = true;
  8365. return _this;
  8366. }
  8367. Object.defineProperty(RadioButton.prototype, "thickness", {
  8368. /** Gets or sets border thickness */
  8369. get: function () {
  8370. return this._thickness;
  8371. },
  8372. set: function (value) {
  8373. if (this._thickness === value) {
  8374. return;
  8375. }
  8376. this._thickness = value;
  8377. this._markAsDirty();
  8378. },
  8379. enumerable: true,
  8380. configurable: true
  8381. });
  8382. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8383. /** Gets or sets a value indicating the ratio between overall size and check size */
  8384. get: function () {
  8385. return this._checkSizeRatio;
  8386. },
  8387. set: function (value) {
  8388. value = Math.max(Math.min(1, value), 0);
  8389. if (this._checkSizeRatio === value) {
  8390. return;
  8391. }
  8392. this._checkSizeRatio = value;
  8393. this._markAsDirty();
  8394. },
  8395. enumerable: true,
  8396. configurable: true
  8397. });
  8398. Object.defineProperty(RadioButton.prototype, "background", {
  8399. /** Gets or sets background color */
  8400. get: function () {
  8401. return this._background;
  8402. },
  8403. set: function (value) {
  8404. if (this._background === value) {
  8405. return;
  8406. }
  8407. this._background = value;
  8408. this._markAsDirty();
  8409. },
  8410. enumerable: true,
  8411. configurable: true
  8412. });
  8413. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8414. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8415. get: function () {
  8416. return this._isChecked;
  8417. },
  8418. set: function (value) {
  8419. var _this = this;
  8420. if (this._isChecked === value) {
  8421. return;
  8422. }
  8423. this._isChecked = value;
  8424. this._markAsDirty();
  8425. this.onIsCheckedChangedObservable.notifyObservers(value);
  8426. if (this._isChecked && this._host) {
  8427. // Update all controls from same group
  8428. this._host.executeOnAllControls(function (control) {
  8429. if (control === _this) {
  8430. return;
  8431. }
  8432. if (control.group === undefined) {
  8433. return;
  8434. }
  8435. var childRadio = control;
  8436. if (childRadio.group === _this.group) {
  8437. childRadio.isChecked = false;
  8438. }
  8439. });
  8440. }
  8441. },
  8442. enumerable: true,
  8443. configurable: true
  8444. });
  8445. RadioButton.prototype._getTypeName = function () {
  8446. return "RadioButton";
  8447. };
  8448. RadioButton.prototype._draw = function (context) {
  8449. context.save();
  8450. this._applyStates(context);
  8451. var actualWidth = this._currentMeasure.width - this._thickness;
  8452. var actualHeight = this._currentMeasure.height - this._thickness;
  8453. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8454. context.shadowColor = this.shadowColor;
  8455. context.shadowBlur = this.shadowBlur;
  8456. context.shadowOffsetX = this.shadowOffsetX;
  8457. context.shadowOffsetY = this.shadowOffsetY;
  8458. }
  8459. // Outer
  8460. _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);
  8461. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8462. context.fill();
  8463. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8464. context.shadowBlur = 0;
  8465. context.shadowOffsetX = 0;
  8466. context.shadowOffsetY = 0;
  8467. }
  8468. context.strokeStyle = this.color;
  8469. context.lineWidth = this._thickness;
  8470. context.stroke();
  8471. // Inner
  8472. if (this._isChecked) {
  8473. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8474. var offsetWidth = actualWidth * this._checkSizeRatio;
  8475. var offseHeight = actualHeight * this._checkSizeRatio;
  8476. _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);
  8477. context.fill();
  8478. }
  8479. context.restore();
  8480. };
  8481. // Events
  8482. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8483. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8484. return false;
  8485. }
  8486. if (!this.isChecked) {
  8487. this.isChecked = true;
  8488. }
  8489. return true;
  8490. };
  8491. /**
  8492. * Utility function to easily create a radio button with a header
  8493. * @param title defines the label to use for the header
  8494. * @param group defines the group to use for the radio button
  8495. * @param isChecked defines the initial state of the radio button
  8496. * @param onValueChanged defines the callback to call when value changes
  8497. * @returns a StackPanel containing the radio button and a textBlock
  8498. */
  8499. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8500. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8501. panel.isVertical = false;
  8502. panel.height = "30px";
  8503. var radio = new RadioButton();
  8504. radio.width = "20px";
  8505. radio.height = "20px";
  8506. radio.isChecked = isChecked;
  8507. radio.color = "green";
  8508. radio.group = group;
  8509. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8510. panel.addControl(radio);
  8511. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8512. header.text = title;
  8513. header.width = "180px";
  8514. header.paddingLeft = "5px";
  8515. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8516. header.color = "white";
  8517. panel.addControl(header);
  8518. return panel;
  8519. };
  8520. return RadioButton;
  8521. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8522. /***/ }),
  8523. /***/ "./2D/controls/rectangle.ts":
  8524. /*!**********************************!*\
  8525. !*** ./2D/controls/rectangle.ts ***!
  8526. \**********************************/
  8527. /*! exports provided: Rectangle */
  8528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8529. "use strict";
  8530. __webpack_require__.r(__webpack_exports__);
  8531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8532. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8533. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8534. /** Class used to create rectangle container */
  8535. var Rectangle = /** @class */ (function (_super) {
  8536. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8537. /**
  8538. * Creates a new Rectangle
  8539. * @param name defines the control name
  8540. */
  8541. function Rectangle(name) {
  8542. var _this = _super.call(this, name) || this;
  8543. _this.name = name;
  8544. _this._thickness = 1;
  8545. _this._cornerRadius = 0;
  8546. return _this;
  8547. }
  8548. Object.defineProperty(Rectangle.prototype, "thickness", {
  8549. /** Gets or sets border thickness */
  8550. get: function () {
  8551. return this._thickness;
  8552. },
  8553. set: function (value) {
  8554. if (this._thickness === value) {
  8555. return;
  8556. }
  8557. this._thickness = value;
  8558. this._markAsDirty();
  8559. },
  8560. enumerable: true,
  8561. configurable: true
  8562. });
  8563. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8564. /** Gets or sets the corner radius angle */
  8565. get: function () {
  8566. return this._cornerRadius;
  8567. },
  8568. set: function (value) {
  8569. if (value < 0) {
  8570. value = 0;
  8571. }
  8572. if (this._cornerRadius === value) {
  8573. return;
  8574. }
  8575. this._cornerRadius = value;
  8576. this._markAsDirty();
  8577. },
  8578. enumerable: true,
  8579. configurable: true
  8580. });
  8581. Rectangle.prototype._getTypeName = function () {
  8582. return "Rectangle";
  8583. };
  8584. Rectangle.prototype._localDraw = function (context) {
  8585. context.save();
  8586. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8587. context.shadowColor = this.shadowColor;
  8588. context.shadowBlur = this.shadowBlur;
  8589. context.shadowOffsetX = this.shadowOffsetX;
  8590. context.shadowOffsetY = this.shadowOffsetY;
  8591. }
  8592. if (this._background) {
  8593. context.fillStyle = this._background;
  8594. if (this._cornerRadius) {
  8595. this._drawRoundedRect(context, this._thickness / 2);
  8596. context.fill();
  8597. }
  8598. else {
  8599. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8600. }
  8601. }
  8602. if (this._thickness) {
  8603. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8604. context.shadowBlur = 0;
  8605. context.shadowOffsetX = 0;
  8606. context.shadowOffsetY = 0;
  8607. }
  8608. if (this.color) {
  8609. context.strokeStyle = this.color;
  8610. }
  8611. context.lineWidth = this._thickness;
  8612. if (this._cornerRadius) {
  8613. this._drawRoundedRect(context, this._thickness / 2);
  8614. context.stroke();
  8615. }
  8616. else {
  8617. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8618. }
  8619. }
  8620. context.restore();
  8621. };
  8622. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8623. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8624. this._measureForChildren.width -= 2 * this._thickness;
  8625. this._measureForChildren.height -= 2 * this._thickness;
  8626. this._measureForChildren.left += this._thickness;
  8627. this._measureForChildren.top += this._thickness;
  8628. };
  8629. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8630. if (offset === void 0) { offset = 0; }
  8631. var x = this._currentMeasure.left + offset;
  8632. var y = this._currentMeasure.top + offset;
  8633. var width = this._currentMeasure.width - offset * 2;
  8634. var height = this._currentMeasure.height - offset * 2;
  8635. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8636. context.beginPath();
  8637. context.moveTo(x + radius, y);
  8638. context.lineTo(x + width - radius, y);
  8639. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8640. context.lineTo(x + width, y + height - radius);
  8641. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8642. context.lineTo(x + radius, y + height);
  8643. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8644. context.lineTo(x, y + radius);
  8645. context.quadraticCurveTo(x, y, x + radius, y);
  8646. context.closePath();
  8647. };
  8648. Rectangle.prototype._clipForChildren = function (context) {
  8649. if (this._cornerRadius) {
  8650. this._drawRoundedRect(context, this._thickness);
  8651. context.clip();
  8652. }
  8653. };
  8654. return Rectangle;
  8655. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8656. /***/ }),
  8657. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8658. /*!***************************************************!*\
  8659. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8660. \***************************************************/
  8661. /*! exports provided: ScrollViewer */
  8662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8663. "use strict";
  8664. __webpack_require__.r(__webpack_exports__);
  8665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8666. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8667. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Maths/math");
  8668. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8669. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8670. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8671. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8672. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8673. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8674. /**
  8675. * Class used to hold a viewer window and sliders in a grid
  8676. */
  8677. var ScrollViewer = /** @class */ (function (_super) {
  8678. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8679. /**
  8680. * Creates a new ScrollViewer
  8681. * @param name of ScrollViewer
  8682. */
  8683. function ScrollViewer(name) {
  8684. var _this = _super.call(this, name) || this;
  8685. _this._barSize = 20;
  8686. _this._pointerIsOver = false;
  8687. _this._wheelPrecision = 0.05;
  8688. _this.onDirtyObservable.add(function () {
  8689. _this._horizontalBarSpace.color = _this.color;
  8690. _this._verticalBarSpace.color = _this.color;
  8691. _this._dragSpace.color = _this.color;
  8692. });
  8693. _this.onPointerEnterObservable.add(function () {
  8694. _this._pointerIsOver = true;
  8695. });
  8696. _this.onPointerOutObservable.add(function () {
  8697. _this._pointerIsOver = false;
  8698. });
  8699. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8700. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8701. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8702. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8703. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8704. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8705. _this._grid.addColumnDefinition(1);
  8706. _this._grid.addColumnDefinition(0, true);
  8707. _this._grid.addRowDefinition(1);
  8708. _this._grid.addRowDefinition(0, true);
  8709. _super.prototype.addControl.call(_this, _this._grid);
  8710. _this._grid.addControl(_this._window, 0, 0);
  8711. _this._verticalBar.paddingLeft = 0;
  8712. _this._verticalBar.width = "100%";
  8713. _this._verticalBar.height = "100%";
  8714. _this._verticalBar.barOffset = 0;
  8715. _this._verticalBar.value = 0;
  8716. _this._verticalBar.maximum = 1;
  8717. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8718. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8719. _this._verticalBar.isVertical = true;
  8720. _this._verticalBar.rotation = Math.PI;
  8721. _this._verticalBar.isVisible = false;
  8722. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8723. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8724. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8725. _this._verticalBarSpace.thickness = 1;
  8726. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8727. _this._verticalBarSpace.addControl(_this._verticalBar);
  8728. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8729. _this._window.top = value * _this._endTop + "px";
  8730. });
  8731. _this._horizontalBar.paddingLeft = 0;
  8732. _this._horizontalBar.width = "100%";
  8733. _this._horizontalBar.height = "100%";
  8734. _this._horizontalBar.barOffset = 0;
  8735. _this._horizontalBar.value = 0;
  8736. _this._horizontalBar.maximum = 1;
  8737. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8738. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8739. _this._horizontalBar.isVisible = false;
  8740. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8741. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8742. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8743. _this._horizontalBarSpace.thickness = 1;
  8744. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8745. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8746. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8747. _this._window.left = value * _this._endLeft + "px";
  8748. });
  8749. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8750. _this._dragSpace.thickness = 1;
  8751. _this._grid.addControl(_this._dragSpace, 1, 1);
  8752. // Colors
  8753. _this.barColor = "grey";
  8754. _this.barBackground = "transparent";
  8755. return _this;
  8756. }
  8757. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8758. /**
  8759. * Gets the horizontal scrollbar
  8760. */
  8761. get: function () {
  8762. return this._horizontalBar;
  8763. },
  8764. enumerable: true,
  8765. configurable: true
  8766. });
  8767. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8768. /**
  8769. * Gets the vertical scrollbar
  8770. */
  8771. get: function () {
  8772. return this._verticalBar;
  8773. },
  8774. enumerable: true,
  8775. configurable: true
  8776. });
  8777. /**
  8778. * Adds a new control to the current container
  8779. * @param control defines the control to add
  8780. * @returns the current container
  8781. */
  8782. ScrollViewer.prototype.addControl = function (control) {
  8783. if (!control) {
  8784. return this;
  8785. }
  8786. this._window.addControl(control);
  8787. return this;
  8788. };
  8789. /**
  8790. * Removes a control from the current container
  8791. * @param control defines the control to remove
  8792. * @returns the current container
  8793. */
  8794. ScrollViewer.prototype.removeControl = function (control) {
  8795. this._window.removeControl(control);
  8796. return this;
  8797. };
  8798. Object.defineProperty(ScrollViewer.prototype, "children", {
  8799. /** Gets the list of children */
  8800. get: function () {
  8801. return this._window.children;
  8802. },
  8803. enumerable: true,
  8804. configurable: true
  8805. });
  8806. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8807. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8808. var child = _a[_i];
  8809. child._markMatrixAsDirty();
  8810. }
  8811. };
  8812. /** Reset the scroll viewer window to initial size */
  8813. ScrollViewer.prototype.resetWindow = function () {
  8814. this._window.width = "100%";
  8815. this._window.height = "100%";
  8816. };
  8817. ScrollViewer.prototype._getTypeName = function () {
  8818. return "ScrollViewer";
  8819. };
  8820. ScrollViewer.prototype._buildClientSizes = function () {
  8821. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8822. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8823. this._clientWidth = this._window.parentClientWidth;
  8824. this._clientHeight = this._window.parentClientHeight;
  8825. };
  8826. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8827. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8828. this._buildClientSizes();
  8829. };
  8830. ScrollViewer.prototype._postMeasure = function () {
  8831. _super.prototype._postMeasure.call(this);
  8832. this._updateScroller();
  8833. };
  8834. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8835. /**
  8836. * Gets or sets the mouse wheel precision
  8837. * from 0 to 1 with a default value of 0.05
  8838. * */
  8839. get: function () {
  8840. return this._wheelPrecision;
  8841. },
  8842. set: function (value) {
  8843. if (this._wheelPrecision === value) {
  8844. return;
  8845. }
  8846. if (value < 0) {
  8847. value = 0;
  8848. }
  8849. if (value > 1) {
  8850. value = 1;
  8851. }
  8852. this._wheelPrecision = value;
  8853. },
  8854. enumerable: true,
  8855. configurable: true
  8856. });
  8857. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8858. /** Gets or sets the bar color */
  8859. get: function () {
  8860. return this._barColor;
  8861. },
  8862. set: function (color) {
  8863. if (this._barColor === color) {
  8864. return;
  8865. }
  8866. this._barColor = color;
  8867. this._horizontalBar.color = color;
  8868. this._verticalBar.color = color;
  8869. },
  8870. enumerable: true,
  8871. configurable: true
  8872. });
  8873. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8874. /** Gets or sets the size of the bar */
  8875. get: function () {
  8876. return this._barSize;
  8877. },
  8878. set: function (value) {
  8879. if (this._barSize === value) {
  8880. return;
  8881. }
  8882. this._barSize = value;
  8883. this._markAsDirty();
  8884. if (this._horizontalBar.isVisible) {
  8885. this._grid.setRowDefinition(1, this._barSize, true);
  8886. }
  8887. if (this._verticalBar.isVisible) {
  8888. this._grid.setColumnDefinition(1, this._barSize, true);
  8889. }
  8890. },
  8891. enumerable: true,
  8892. configurable: true
  8893. });
  8894. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8895. /** Gets or sets the bar background */
  8896. get: function () {
  8897. return this._barBackground;
  8898. },
  8899. set: function (color) {
  8900. if (this._barBackground === color) {
  8901. return;
  8902. }
  8903. this._barBackground = color;
  8904. this._horizontalBar.background = color;
  8905. this._verticalBar.background = color;
  8906. this._dragSpace.background = color;
  8907. },
  8908. enumerable: true,
  8909. configurable: true
  8910. });
  8911. /** @hidden */
  8912. ScrollViewer.prototype._updateScroller = function () {
  8913. var windowContentsWidth = this._window._currentMeasure.width;
  8914. var windowContentsHeight = this._window._currentMeasure.height;
  8915. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8916. this._grid.setRowDefinition(1, 0, true);
  8917. this._horizontalBar.isVisible = false;
  8918. this._horizontalBar.value = 0;
  8919. this._rebuildLayout = true;
  8920. }
  8921. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8922. this._grid.setRowDefinition(1, this._barSize, true);
  8923. this._horizontalBar.isVisible = true;
  8924. this._rebuildLayout = true;
  8925. }
  8926. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8927. this._grid.setColumnDefinition(1, 0, true);
  8928. this._verticalBar.isVisible = false;
  8929. this._verticalBar.value = 0;
  8930. this._rebuildLayout = true;
  8931. }
  8932. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8933. this._grid.setColumnDefinition(1, this._barSize, true);
  8934. this._verticalBar.isVisible = true;
  8935. this._rebuildLayout = true;
  8936. }
  8937. this._buildClientSizes();
  8938. this._endLeft = this._clientWidth - windowContentsWidth;
  8939. this._endTop = this._clientHeight - windowContentsHeight;
  8940. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8941. var newTop = this._verticalBar.value * this._endTop + "px";
  8942. if (newLeft !== this._window.left) {
  8943. this._window.left = newLeft;
  8944. this._rebuildLayout = true;
  8945. }
  8946. if (newTop !== this._window.top) {
  8947. this._window.top = newTop;
  8948. this._rebuildLayout = true;
  8949. }
  8950. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8951. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8952. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8953. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8954. };
  8955. ScrollViewer.prototype._link = function (host) {
  8956. _super.prototype._link.call(this, host);
  8957. this._attachWheel();
  8958. };
  8959. /** @hidden */
  8960. ScrollViewer.prototype._attachWheel = function () {
  8961. var _this = this;
  8962. if (!this._host || this._onPointerObserver) {
  8963. return;
  8964. }
  8965. var scene = this._host.getScene();
  8966. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8967. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8968. return;
  8969. }
  8970. if (_this._verticalBar.isVisible == true) {
  8971. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8972. _this._verticalBar.value -= _this._wheelPrecision;
  8973. }
  8974. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8975. _this._verticalBar.value += _this._wheelPrecision;
  8976. }
  8977. }
  8978. if (_this._horizontalBar.isVisible == true) {
  8979. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8980. _this._horizontalBar.value += _this._wheelPrecision;
  8981. }
  8982. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8983. _this._horizontalBar.value -= _this._wheelPrecision;
  8984. }
  8985. }
  8986. });
  8987. };
  8988. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8989. if (!this.isHighlighted) {
  8990. return;
  8991. }
  8992. _super.prototype._renderHighlightSpecific.call(this, context);
  8993. this._grid._renderHighlightSpecific(context);
  8994. context.restore();
  8995. };
  8996. /** Releases associated resources */
  8997. ScrollViewer.prototype.dispose = function () {
  8998. var scene = this._host.getScene();
  8999. if (scene && this._onPointerObserver) {
  9000. scene.onPointerObservable.remove(this._onPointerObserver);
  9001. this._onPointerObserver = null;
  9002. }
  9003. _super.prototype.dispose.call(this);
  9004. };
  9005. return ScrollViewer;
  9006. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9007. /***/ }),
  9008. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9009. /*!*********************************************************!*\
  9010. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9011. \*********************************************************/
  9012. /*! exports provided: _ScrollViewerWindow */
  9013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9014. "use strict";
  9015. __webpack_require__.r(__webpack_exports__);
  9016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9017. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9018. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9019. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9020. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9021. /**
  9022. * Class used to hold a the container for ScrollViewer
  9023. * @hidden
  9024. */
  9025. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9026. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  9027. /**
  9028. * Creates a new ScrollViewerWindow
  9029. * @param name of ScrollViewerWindow
  9030. */
  9031. function _ScrollViewerWindow(name) {
  9032. return _super.call(this, name) || this;
  9033. }
  9034. _ScrollViewerWindow.prototype._getTypeName = function () {
  9035. return "ScrollViewerWindow";
  9036. };
  9037. /** @hidden */
  9038. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9039. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9040. this._measureForChildren.left = this._currentMeasure.left;
  9041. this._measureForChildren.top = this._currentMeasure.top;
  9042. this._measureForChildren.width = parentMeasure.width;
  9043. this._measureForChildren.height = parentMeasure.height;
  9044. };
  9045. _ScrollViewerWindow.prototype._postMeasure = function () {
  9046. var maxWidth = this.parentClientWidth;
  9047. var maxHeight = this.parentClientHeight;
  9048. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9049. var child = _a[_i];
  9050. if (!child.isVisible || child.notRenderable) {
  9051. continue;
  9052. }
  9053. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9054. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9055. }
  9056. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9057. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9058. }
  9059. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9060. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9061. }
  9062. if (this._currentMeasure.width !== maxWidth) {
  9063. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9064. this._currentMeasure.width = maxWidth;
  9065. this._rebuildLayout = true;
  9066. this._isDirty = true;
  9067. }
  9068. if (this._currentMeasure.height !== maxHeight) {
  9069. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9070. this._currentMeasure.height = maxHeight;
  9071. this._rebuildLayout = true;
  9072. this._isDirty = true;
  9073. }
  9074. _super.prototype._postMeasure.call(this);
  9075. };
  9076. return _ScrollViewerWindow;
  9077. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9078. /***/ }),
  9079. /***/ "./2D/controls/selector.ts":
  9080. /*!*********************************!*\
  9081. !*** ./2D/controls/selector.ts ***!
  9082. \*********************************/
  9083. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9085. "use strict";
  9086. __webpack_require__.r(__webpack_exports__);
  9087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9092. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9093. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9094. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9095. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9096. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9097. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9098. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9099. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9100. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9101. /** Class used to create a RadioGroup
  9102. * which contains groups of radio buttons
  9103. */
  9104. var SelectorGroup = /** @class */ (function () {
  9105. /**
  9106. * Creates a new SelectorGroup
  9107. * @param name of group, used as a group heading
  9108. */
  9109. function SelectorGroup(
  9110. /** name of SelectorGroup */
  9111. name) {
  9112. this.name = name;
  9113. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9114. this._selectors = new Array();
  9115. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9116. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9117. this._groupHeader = this._addGroupHeader(name);
  9118. }
  9119. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9120. /** Gets the groupPanel of the SelectorGroup */
  9121. get: function () {
  9122. return this._groupPanel;
  9123. },
  9124. enumerable: true,
  9125. configurable: true
  9126. });
  9127. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9128. /** Gets the selectors array */
  9129. get: function () {
  9130. return this._selectors;
  9131. },
  9132. enumerable: true,
  9133. configurable: true
  9134. });
  9135. Object.defineProperty(SelectorGroup.prototype, "header", {
  9136. /** Gets and sets the group header */
  9137. get: function () {
  9138. return this._groupHeader.text;
  9139. },
  9140. set: function (label) {
  9141. if (this._groupHeader.text === "label") {
  9142. return;
  9143. }
  9144. this._groupHeader.text = label;
  9145. },
  9146. enumerable: true,
  9147. configurable: true
  9148. });
  9149. /** @hidden */
  9150. SelectorGroup.prototype._addGroupHeader = function (text) {
  9151. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9152. groupHeading.width = 0.9;
  9153. groupHeading.height = "30px";
  9154. groupHeading.textWrapping = true;
  9155. groupHeading.color = "black";
  9156. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9157. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9158. groupHeading.left = "2px";
  9159. this._groupPanel.addControl(groupHeading);
  9160. return groupHeading;
  9161. };
  9162. /** @hidden*/
  9163. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9164. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9165. return;
  9166. }
  9167. return this._selectors[selectorNb];
  9168. };
  9169. /** Removes the selector at the given position
  9170. * @param selectorNb the position of the selector within the group
  9171. */
  9172. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9173. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9174. return;
  9175. }
  9176. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9177. this._selectors.splice(selectorNb, 1);
  9178. };
  9179. return SelectorGroup;
  9180. }());
  9181. /** Class used to create a CheckboxGroup
  9182. * which contains groups of checkbox buttons
  9183. */
  9184. var CheckboxGroup = /** @class */ (function (_super) {
  9185. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9186. function CheckboxGroup() {
  9187. return _super !== null && _super.apply(this, arguments) || this;
  9188. }
  9189. /** Adds a checkbox as a control
  9190. * @param text is the label for the selector
  9191. * @param func is the function called when the Selector is checked
  9192. * @param checked is true when Selector is checked
  9193. */
  9194. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9195. if (func === void 0) { func = function (s) { }; }
  9196. if (checked === void 0) { checked = false; }
  9197. var checked = checked || false;
  9198. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9199. button.width = "20px";
  9200. button.height = "20px";
  9201. button.color = "#364249";
  9202. button.background = "#CCCCCC";
  9203. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9204. button.onIsCheckedChangedObservable.add(function (state) {
  9205. func(state);
  9206. });
  9207. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9208. _selector.height = "30px";
  9209. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9210. _selector.left = "4px";
  9211. this.groupPanel.addControl(_selector);
  9212. this.selectors.push(_selector);
  9213. button.isChecked = checked;
  9214. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9215. button.color = this.groupPanel.parent.parent.buttonColor;
  9216. button.background = this.groupPanel.parent.parent.buttonBackground;
  9217. }
  9218. };
  9219. /** @hidden */
  9220. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9221. this.selectors[selectorNb].children[1].text = label;
  9222. };
  9223. /** @hidden */
  9224. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9225. this.selectors[selectorNb].children[1].color = color;
  9226. };
  9227. /** @hidden */
  9228. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9229. this.selectors[selectorNb].children[0].color = color;
  9230. };
  9231. /** @hidden */
  9232. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9233. this.selectors[selectorNb].children[0].background = color;
  9234. };
  9235. return CheckboxGroup;
  9236. }(SelectorGroup));
  9237. /** Class used to create a RadioGroup
  9238. * which contains groups of radio buttons
  9239. */
  9240. var RadioGroup = /** @class */ (function (_super) {
  9241. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9242. function RadioGroup() {
  9243. var _this = _super !== null && _super.apply(this, arguments) || this;
  9244. _this._selectNb = 0;
  9245. return _this;
  9246. }
  9247. /** Adds a radio button as a control
  9248. * @param label is the label for the selector
  9249. * @param func is the function called when the Selector is checked
  9250. * @param checked is true when Selector is checked
  9251. */
  9252. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9253. if (func === void 0) { func = function (n) { }; }
  9254. if (checked === void 0) { checked = false; }
  9255. var nb = this._selectNb++;
  9256. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9257. button.name = label;
  9258. button.width = "20px";
  9259. button.height = "20px";
  9260. button.color = "#364249";
  9261. button.background = "#CCCCCC";
  9262. button.group = this.name;
  9263. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9264. button.onIsCheckedChangedObservable.add(function (state) {
  9265. if (state) {
  9266. func(nb);
  9267. }
  9268. });
  9269. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9270. _selector.height = "30px";
  9271. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9272. _selector.left = "4px";
  9273. this.groupPanel.addControl(_selector);
  9274. this.selectors.push(_selector);
  9275. button.isChecked = checked;
  9276. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9277. button.color = this.groupPanel.parent.parent.buttonColor;
  9278. button.background = this.groupPanel.parent.parent.buttonBackground;
  9279. }
  9280. };
  9281. /** @hidden */
  9282. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9283. this.selectors[selectorNb].children[1].text = label;
  9284. };
  9285. /** @hidden */
  9286. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9287. this.selectors[selectorNb].children[1].color = color;
  9288. };
  9289. /** @hidden */
  9290. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9291. this.selectors[selectorNb].children[0].color = color;
  9292. };
  9293. /** @hidden */
  9294. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9295. this.selectors[selectorNb].children[0].background = color;
  9296. };
  9297. return RadioGroup;
  9298. }(SelectorGroup));
  9299. /** Class used to create a SliderGroup
  9300. * which contains groups of slider buttons
  9301. */
  9302. var SliderGroup = /** @class */ (function (_super) {
  9303. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9304. function SliderGroup() {
  9305. return _super !== null && _super.apply(this, arguments) || this;
  9306. }
  9307. /**
  9308. * Adds a slider to the SelectorGroup
  9309. * @param label is the label for the SliderBar
  9310. * @param func is the function called when the Slider moves
  9311. * @param unit is a string describing the units used, eg degrees or metres
  9312. * @param min is the minimum value for the Slider
  9313. * @param max is the maximum value for the Slider
  9314. * @param value is the start value for the Slider between min and max
  9315. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9316. */
  9317. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9318. if (func === void 0) { func = function (v) { }; }
  9319. if (unit === void 0) { unit = "Units"; }
  9320. if (min === void 0) { min = 0; }
  9321. if (max === void 0) { max = 0; }
  9322. if (value === void 0) { value = 0; }
  9323. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9324. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9325. button.name = unit;
  9326. button.value = value;
  9327. button.minimum = min;
  9328. button.maximum = max;
  9329. button.width = 0.9;
  9330. button.height = "20px";
  9331. button.color = "#364249";
  9332. button.background = "#CCCCCC";
  9333. button.borderColor = "black";
  9334. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9335. button.left = "4px";
  9336. button.paddingBottom = "4px";
  9337. button.onValueChangedObservable.add(function (value) {
  9338. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9339. func(value);
  9340. });
  9341. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9342. _selector.height = "60px";
  9343. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9344. _selector.left = "4px";
  9345. _selector.children[0].name = label;
  9346. this.groupPanel.addControl(_selector);
  9347. this.selectors.push(_selector);
  9348. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9349. button.color = this.groupPanel.parent.parent.buttonColor;
  9350. button.background = this.groupPanel.parent.parent.buttonBackground;
  9351. }
  9352. };
  9353. /** @hidden */
  9354. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9355. this.selectors[selectorNb].children[0].name = label;
  9356. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9357. };
  9358. /** @hidden */
  9359. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9360. this.selectors[selectorNb].children[0].color = color;
  9361. };
  9362. /** @hidden */
  9363. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9364. this.selectors[selectorNb].children[1].color = color;
  9365. };
  9366. /** @hidden */
  9367. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9368. this.selectors[selectorNb].children[1].background = color;
  9369. };
  9370. return SliderGroup;
  9371. }(SelectorGroup));
  9372. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9373. * @see http://doc.babylonjs.com/how_to/selector
  9374. */
  9375. var SelectionPanel = /** @class */ (function (_super) {
  9376. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9377. /**
  9378. * Creates a new SelectionPanel
  9379. * @param name of SelectionPanel
  9380. * @param groups is an array of SelectionGroups
  9381. */
  9382. function SelectionPanel(
  9383. /** name of SelectionPanel */
  9384. name,
  9385. /** an array of SelectionGroups */
  9386. groups) {
  9387. if (groups === void 0) { groups = []; }
  9388. var _this = _super.call(this, name) || this;
  9389. _this.name = name;
  9390. _this.groups = groups;
  9391. _this._buttonColor = "#364249";
  9392. _this._buttonBackground = "#CCCCCC";
  9393. _this._headerColor = "black";
  9394. _this._barColor = "white";
  9395. _this._barHeight = "2px";
  9396. _this._spacerHeight = "20px";
  9397. _this._bars = new Array();
  9398. _this._groups = groups;
  9399. _this.thickness = 2;
  9400. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9401. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9402. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9403. _this._panel.top = 5;
  9404. _this._panel.left = 5;
  9405. _this._panel.width = 0.95;
  9406. if (groups.length > 0) {
  9407. for (var i = 0; i < groups.length - 1; i++) {
  9408. _this._panel.addControl(groups[i].groupPanel);
  9409. _this._addSpacer();
  9410. }
  9411. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9412. }
  9413. _this.addControl(_this._panel);
  9414. return _this;
  9415. }
  9416. SelectionPanel.prototype._getTypeName = function () {
  9417. return "SelectionPanel";
  9418. };
  9419. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9420. /** Gets or sets the headerColor */
  9421. get: function () {
  9422. return this._headerColor;
  9423. },
  9424. set: function (color) {
  9425. if (this._headerColor === color) {
  9426. return;
  9427. }
  9428. this._headerColor = color;
  9429. this._setHeaderColor();
  9430. },
  9431. enumerable: true,
  9432. configurable: true
  9433. });
  9434. SelectionPanel.prototype._setHeaderColor = function () {
  9435. for (var i = 0; i < this._groups.length; i++) {
  9436. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9437. }
  9438. };
  9439. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9440. /** Gets or sets the button color */
  9441. get: function () {
  9442. return this._buttonColor;
  9443. },
  9444. set: function (color) {
  9445. if (this._buttonColor === color) {
  9446. return;
  9447. }
  9448. this._buttonColor = color;
  9449. this._setbuttonColor();
  9450. },
  9451. enumerable: true,
  9452. configurable: true
  9453. });
  9454. SelectionPanel.prototype._setbuttonColor = function () {
  9455. for (var i = 0; i < this._groups.length; i++) {
  9456. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9457. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9458. }
  9459. }
  9460. };
  9461. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9462. /** Gets or sets the label color */
  9463. get: function () {
  9464. return this._labelColor;
  9465. },
  9466. set: function (color) {
  9467. if (this._labelColor === color) {
  9468. return;
  9469. }
  9470. this._labelColor = color;
  9471. this._setLabelColor();
  9472. },
  9473. enumerable: true,
  9474. configurable: true
  9475. });
  9476. SelectionPanel.prototype._setLabelColor = function () {
  9477. for (var i = 0; i < this._groups.length; i++) {
  9478. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9479. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9480. }
  9481. }
  9482. };
  9483. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9484. /** Gets or sets the button background */
  9485. get: function () {
  9486. return this._buttonBackground;
  9487. },
  9488. set: function (color) {
  9489. if (this._buttonBackground === color) {
  9490. return;
  9491. }
  9492. this._buttonBackground = color;
  9493. this._setButtonBackground();
  9494. },
  9495. enumerable: true,
  9496. configurable: true
  9497. });
  9498. SelectionPanel.prototype._setButtonBackground = function () {
  9499. for (var i = 0; i < this._groups.length; i++) {
  9500. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9501. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9502. }
  9503. }
  9504. };
  9505. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9506. /** Gets or sets the color of separator bar */
  9507. get: function () {
  9508. return this._barColor;
  9509. },
  9510. set: function (color) {
  9511. if (this._barColor === color) {
  9512. return;
  9513. }
  9514. this._barColor = color;
  9515. this._setBarColor();
  9516. },
  9517. enumerable: true,
  9518. configurable: true
  9519. });
  9520. SelectionPanel.prototype._setBarColor = function () {
  9521. for (var i = 0; i < this._bars.length; i++) {
  9522. this._bars[i].children[0].background = this._barColor;
  9523. }
  9524. };
  9525. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9526. /** Gets or sets the height of separator bar */
  9527. get: function () {
  9528. return this._barHeight;
  9529. },
  9530. set: function (value) {
  9531. if (this._barHeight === value) {
  9532. return;
  9533. }
  9534. this._barHeight = value;
  9535. this._setBarHeight();
  9536. },
  9537. enumerable: true,
  9538. configurable: true
  9539. });
  9540. SelectionPanel.prototype._setBarHeight = function () {
  9541. for (var i = 0; i < this._bars.length; i++) {
  9542. this._bars[i].children[0].height = this._barHeight;
  9543. }
  9544. };
  9545. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9546. /** Gets or sets the height of spacers*/
  9547. get: function () {
  9548. return this._spacerHeight;
  9549. },
  9550. set: function (value) {
  9551. if (this._spacerHeight === value) {
  9552. return;
  9553. }
  9554. this._spacerHeight = value;
  9555. this._setSpacerHeight();
  9556. },
  9557. enumerable: true,
  9558. configurable: true
  9559. });
  9560. SelectionPanel.prototype._setSpacerHeight = function () {
  9561. for (var i = 0; i < this._bars.length; i++) {
  9562. this._bars[i].height = this._spacerHeight;
  9563. }
  9564. };
  9565. /** Adds a bar between groups */
  9566. SelectionPanel.prototype._addSpacer = function () {
  9567. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9568. separator.width = 1;
  9569. separator.height = this._spacerHeight;
  9570. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9571. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9572. bar.width = 1;
  9573. bar.height = this._barHeight;
  9574. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9575. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9576. bar.background = this._barColor;
  9577. bar.color = "transparent";
  9578. separator.addControl(bar);
  9579. this._panel.addControl(separator);
  9580. this._bars.push(separator);
  9581. };
  9582. /** Add a group to the selection panel
  9583. * @param group is the selector group to add
  9584. */
  9585. SelectionPanel.prototype.addGroup = function (group) {
  9586. if (this._groups.length > 0) {
  9587. this._addSpacer();
  9588. }
  9589. this._panel.addControl(group.groupPanel);
  9590. this._groups.push(group);
  9591. group.groupPanel.children[0].color = this._headerColor;
  9592. for (var j = 0; j < group.selectors.length; j++) {
  9593. group._setSelectorButtonColor(j, this._buttonColor);
  9594. group._setSelectorButtonBackground(j, this._buttonBackground);
  9595. }
  9596. };
  9597. /** Remove the group from the given position
  9598. * @param groupNb is the position of the group in the list
  9599. */
  9600. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9601. if (groupNb < 0 || groupNb >= this._groups.length) {
  9602. return;
  9603. }
  9604. var group = this._groups[groupNb];
  9605. this._panel.removeControl(group.groupPanel);
  9606. this._groups.splice(groupNb, 1);
  9607. if (groupNb < this._bars.length) {
  9608. this._panel.removeControl(this._bars[groupNb]);
  9609. this._bars.splice(groupNb, 1);
  9610. }
  9611. };
  9612. /** Change a group header label
  9613. * @param label is the new group header label
  9614. * @param groupNb is the number of the group to relabel
  9615. * */
  9616. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9617. if (groupNb < 0 || groupNb >= this._groups.length) {
  9618. return;
  9619. }
  9620. var group = this._groups[groupNb];
  9621. group.groupPanel.children[0].text = label;
  9622. };
  9623. /** Change selector label to the one given
  9624. * @param label is the new selector label
  9625. * @param groupNb is the number of the groupcontaining the selector
  9626. * @param selectorNb is the number of the selector within a group to relabel
  9627. * */
  9628. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9629. if (groupNb < 0 || groupNb >= this._groups.length) {
  9630. return;
  9631. }
  9632. var group = this._groups[groupNb];
  9633. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9634. return;
  9635. }
  9636. group._setSelectorLabel(selectorNb, label);
  9637. };
  9638. /** For a given group position remove the selector at the given position
  9639. * @param groupNb is the number of the group to remove the selector from
  9640. * @param selectorNb is the number of the selector within the group
  9641. */
  9642. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9643. if (groupNb < 0 || groupNb >= this._groups.length) {
  9644. return;
  9645. }
  9646. var group = this._groups[groupNb];
  9647. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9648. return;
  9649. }
  9650. group.removeSelector(selectorNb);
  9651. };
  9652. /** For a given group position of correct type add a checkbox button
  9653. * @param groupNb is the number of the group to remove the selector from
  9654. * @param label is the label for the selector
  9655. * @param func is the function called when the Selector is checked
  9656. * @param checked is true when Selector is checked
  9657. */
  9658. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9659. if (func === void 0) { func = function () { }; }
  9660. if (checked === void 0) { checked = false; }
  9661. if (groupNb < 0 || groupNb >= this._groups.length) {
  9662. return;
  9663. }
  9664. var group = this._groups[groupNb];
  9665. group.addCheckbox(label, func, checked);
  9666. };
  9667. /** For a given group position of correct type add a radio button
  9668. * @param groupNb is the number of the group to remove the selector from
  9669. * @param label is the label for the selector
  9670. * @param func is the function called when the Selector is checked
  9671. * @param checked is true when Selector is checked
  9672. */
  9673. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9674. if (func === void 0) { func = function () { }; }
  9675. if (checked === void 0) { checked = false; }
  9676. if (groupNb < 0 || groupNb >= this._groups.length) {
  9677. return;
  9678. }
  9679. var group = this._groups[groupNb];
  9680. group.addRadio(label, func, checked);
  9681. };
  9682. /**
  9683. * For a given slider group add a slider
  9684. * @param groupNb is the number of the group to add the slider to
  9685. * @param label is the label for the Slider
  9686. * @param func is the function called when the Slider moves
  9687. * @param unit is a string describing the units used, eg degrees or metres
  9688. * @param min is the minimum value for the Slider
  9689. * @param max is the maximum value for the Slider
  9690. * @param value is the start value for the Slider between min and max
  9691. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9692. */
  9693. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9694. if (func === void 0) { func = function () { }; }
  9695. if (unit === void 0) { unit = "Units"; }
  9696. if (min === void 0) { min = 0; }
  9697. if (max === void 0) { max = 0; }
  9698. if (value === void 0) { value = 0; }
  9699. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9700. if (groupNb < 0 || groupNb >= this._groups.length) {
  9701. return;
  9702. }
  9703. var group = this._groups[groupNb];
  9704. group.addSlider(label, func, unit, min, max, value, onVal);
  9705. };
  9706. return SelectionPanel;
  9707. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9708. /***/ }),
  9709. /***/ "./2D/controls/sliders/baseSlider.ts":
  9710. /*!*******************************************!*\
  9711. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9712. \*******************************************/
  9713. /*! exports provided: BaseSlider */
  9714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9715. "use strict";
  9716. __webpack_require__.r(__webpack_exports__);
  9717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9718. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9719. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  9720. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9721. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9722. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9723. /**
  9724. * Class used to create slider controls
  9725. */
  9726. var BaseSlider = /** @class */ (function (_super) {
  9727. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9728. /**
  9729. * Creates a new BaseSlider
  9730. * @param name defines the control name
  9731. */
  9732. function BaseSlider(name) {
  9733. var _this = _super.call(this, name) || this;
  9734. _this.name = name;
  9735. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9736. _this._minimum = 0;
  9737. _this._maximum = 100;
  9738. _this._value = 50;
  9739. _this._isVertical = false;
  9740. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9741. _this._isThumbClamped = false;
  9742. _this._displayThumb = true;
  9743. _this._step = 0;
  9744. _this._lastPointerDownID = -1;
  9745. // Shared rendering info
  9746. _this._effectiveBarOffset = 0;
  9747. /** Observable raised when the sldier value changes */
  9748. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9749. // Events
  9750. _this._pointerIsDown = false;
  9751. _this.isPointerBlocker = true;
  9752. return _this;
  9753. }
  9754. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9755. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9756. get: function () {
  9757. return this._displayThumb;
  9758. },
  9759. set: function (value) {
  9760. if (this._displayThumb === value) {
  9761. return;
  9762. }
  9763. this._displayThumb = value;
  9764. this._markAsDirty();
  9765. },
  9766. enumerable: true,
  9767. configurable: true
  9768. });
  9769. Object.defineProperty(BaseSlider.prototype, "step", {
  9770. /** Gets or sets a step to apply to values (0 by default) */
  9771. get: function () {
  9772. return this._step;
  9773. },
  9774. set: function (value) {
  9775. if (this._step === value) {
  9776. return;
  9777. }
  9778. this._step = value;
  9779. this._markAsDirty();
  9780. },
  9781. enumerable: true,
  9782. configurable: true
  9783. });
  9784. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9785. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9786. get: function () {
  9787. return this._barOffset.toString(this._host);
  9788. },
  9789. set: function (value) {
  9790. if (this._barOffset.toString(this._host) === value) {
  9791. return;
  9792. }
  9793. if (this._barOffset.fromString(value)) {
  9794. this._markAsDirty();
  9795. }
  9796. },
  9797. enumerable: true,
  9798. configurable: true
  9799. });
  9800. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9801. /** Gets main bar offset in pixels*/
  9802. get: function () {
  9803. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9804. },
  9805. enumerable: true,
  9806. configurable: true
  9807. });
  9808. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9809. /** Gets or sets thumb width */
  9810. get: function () {
  9811. return this._thumbWidth.toString(this._host);
  9812. },
  9813. set: function (value) {
  9814. if (this._thumbWidth.toString(this._host) === value) {
  9815. return;
  9816. }
  9817. if (this._thumbWidth.fromString(value)) {
  9818. this._markAsDirty();
  9819. }
  9820. },
  9821. enumerable: true,
  9822. configurable: true
  9823. });
  9824. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9825. /** Gets thumb width in pixels */
  9826. get: function () {
  9827. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9828. },
  9829. enumerable: true,
  9830. configurable: true
  9831. });
  9832. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9833. /** Gets or sets minimum value */
  9834. get: function () {
  9835. return this._minimum;
  9836. },
  9837. set: function (value) {
  9838. if (this._minimum === value) {
  9839. return;
  9840. }
  9841. this._minimum = value;
  9842. this._markAsDirty();
  9843. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9844. },
  9845. enumerable: true,
  9846. configurable: true
  9847. });
  9848. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9849. /** Gets or sets maximum value */
  9850. get: function () {
  9851. return this._maximum;
  9852. },
  9853. set: function (value) {
  9854. if (this._maximum === value) {
  9855. return;
  9856. }
  9857. this._maximum = value;
  9858. this._markAsDirty();
  9859. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9860. },
  9861. enumerable: true,
  9862. configurable: true
  9863. });
  9864. Object.defineProperty(BaseSlider.prototype, "value", {
  9865. /** Gets or sets current value */
  9866. get: function () {
  9867. return this._value;
  9868. },
  9869. set: function (value) {
  9870. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9871. if (this._value === value) {
  9872. return;
  9873. }
  9874. this._value = value;
  9875. this._markAsDirty();
  9876. this.onValueChangedObservable.notifyObservers(this._value);
  9877. },
  9878. enumerable: true,
  9879. configurable: true
  9880. });
  9881. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9882. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9883. get: function () {
  9884. return this._isVertical;
  9885. },
  9886. set: function (value) {
  9887. if (this._isVertical === value) {
  9888. return;
  9889. }
  9890. this._isVertical = value;
  9891. this._markAsDirty();
  9892. },
  9893. enumerable: true,
  9894. configurable: true
  9895. });
  9896. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9897. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9898. get: function () {
  9899. return this._isThumbClamped;
  9900. },
  9901. set: function (value) {
  9902. if (this._isThumbClamped === value) {
  9903. return;
  9904. }
  9905. this._isThumbClamped = value;
  9906. this._markAsDirty();
  9907. },
  9908. enumerable: true,
  9909. configurable: true
  9910. });
  9911. BaseSlider.prototype._getTypeName = function () {
  9912. return "BaseSlider";
  9913. };
  9914. BaseSlider.prototype._getThumbPosition = function () {
  9915. if (this.isVertical) {
  9916. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9917. }
  9918. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9919. };
  9920. BaseSlider.prototype._getThumbThickness = function (type) {
  9921. var thumbThickness = 0;
  9922. switch (type) {
  9923. case "circle":
  9924. if (this._thumbWidth.isPixel) {
  9925. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9926. }
  9927. else {
  9928. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9929. }
  9930. break;
  9931. case "rectangle":
  9932. if (this._thumbWidth.isPixel) {
  9933. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9934. }
  9935. else {
  9936. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9937. }
  9938. }
  9939. return thumbThickness;
  9940. };
  9941. BaseSlider.prototype._prepareRenderingData = function (type) {
  9942. // Main bar
  9943. this._effectiveBarOffset = 0;
  9944. this._renderLeft = this._currentMeasure.left;
  9945. this._renderTop = this._currentMeasure.top;
  9946. this._renderWidth = this._currentMeasure.width;
  9947. this._renderHeight = this._currentMeasure.height;
  9948. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9949. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9950. this._effectiveThumbThickness = this._getThumbThickness(type);
  9951. if (this.displayThumb) {
  9952. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9953. }
  9954. //throw error when height is less than width for vertical slider
  9955. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9956. console.error("Height should be greater than width");
  9957. return;
  9958. }
  9959. if (this._barOffset.isPixel) {
  9960. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9961. }
  9962. else {
  9963. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9964. }
  9965. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9966. if (this.isVertical) {
  9967. this._renderLeft += this._effectiveBarOffset;
  9968. if (!this.isThumbClamped && this.displayThumb) {
  9969. this._renderTop += (this._effectiveThumbThickness / 2);
  9970. }
  9971. this._renderHeight = this._backgroundBoxLength;
  9972. this._renderWidth = this._backgroundBoxThickness;
  9973. }
  9974. else {
  9975. this._renderTop += this._effectiveBarOffset;
  9976. if (!this.isThumbClamped && this.displayThumb) {
  9977. this._renderLeft += (this._effectiveThumbThickness / 2);
  9978. }
  9979. this._renderHeight = this._backgroundBoxThickness;
  9980. this._renderWidth = this._backgroundBoxLength;
  9981. }
  9982. };
  9983. /** @hidden */
  9984. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9985. if (this.rotation != 0) {
  9986. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9987. x = this._transformedPosition.x;
  9988. y = this._transformedPosition.y;
  9989. }
  9990. var value;
  9991. if (this._isVertical) {
  9992. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9993. }
  9994. else {
  9995. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9996. }
  9997. var mult = (1 / this._step) | 0;
  9998. this.value = this._step ? ((value * mult) | 0) / mult : value;
  9999. };
  10000. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10001. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10002. return false;
  10003. }
  10004. this._pointerIsDown = true;
  10005. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10006. this._host._capturingControl[pointerId] = this;
  10007. this._lastPointerDownID = pointerId;
  10008. return true;
  10009. };
  10010. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10011. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10012. if (pointerId != this._lastPointerDownID) {
  10013. return;
  10014. }
  10015. if (this._pointerIsDown) {
  10016. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10017. }
  10018. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10019. };
  10020. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10021. this._pointerIsDown = false;
  10022. delete this._host._capturingControl[pointerId];
  10023. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10024. };
  10025. return BaseSlider;
  10026. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10027. /***/ }),
  10028. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10029. /*!*************************************************!*\
  10030. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10031. \*************************************************/
  10032. /*! exports provided: ImageBasedSlider */
  10033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10034. "use strict";
  10035. __webpack_require__.r(__webpack_exports__);
  10036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10037. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10038. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10039. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10040. /**
  10041. * Class used to create slider controls based on images
  10042. */
  10043. var ImageBasedSlider = /** @class */ (function (_super) {
  10044. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  10045. /**
  10046. * Creates a new ImageBasedSlider
  10047. * @param name defines the control name
  10048. */
  10049. function ImageBasedSlider(name) {
  10050. var _this = _super.call(this, name) || this;
  10051. _this.name = name;
  10052. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10053. return _this;
  10054. }
  10055. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10056. get: function () {
  10057. return this._displayThumb && this.thumbImage != null;
  10058. },
  10059. set: function (value) {
  10060. if (this._displayThumb === value) {
  10061. return;
  10062. }
  10063. this._displayThumb = value;
  10064. this._markAsDirty();
  10065. },
  10066. enumerable: true,
  10067. configurable: true
  10068. });
  10069. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10070. /**
  10071. * Gets or sets the image used to render the background
  10072. */
  10073. get: function () {
  10074. return this._backgroundImage;
  10075. },
  10076. set: function (value) {
  10077. var _this = this;
  10078. if (this._backgroundImage === value) {
  10079. return;
  10080. }
  10081. this._backgroundImage = value;
  10082. if (value && !value.isLoaded) {
  10083. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10084. }
  10085. this._markAsDirty();
  10086. },
  10087. enumerable: true,
  10088. configurable: true
  10089. });
  10090. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10091. /**
  10092. * Gets or sets the image used to render the value bar
  10093. */
  10094. get: function () {
  10095. return this._valueBarImage;
  10096. },
  10097. set: function (value) {
  10098. var _this = this;
  10099. if (this._valueBarImage === value) {
  10100. return;
  10101. }
  10102. this._valueBarImage = value;
  10103. if (value && !value.isLoaded) {
  10104. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10105. }
  10106. this._markAsDirty();
  10107. },
  10108. enumerable: true,
  10109. configurable: true
  10110. });
  10111. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10112. /**
  10113. * Gets or sets the image used to render the thumb
  10114. */
  10115. get: function () {
  10116. return this._thumbImage;
  10117. },
  10118. set: function (value) {
  10119. var _this = this;
  10120. if (this._thumbImage === value) {
  10121. return;
  10122. }
  10123. this._thumbImage = value;
  10124. if (value && !value.isLoaded) {
  10125. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10126. }
  10127. this._markAsDirty();
  10128. },
  10129. enumerable: true,
  10130. configurable: true
  10131. });
  10132. ImageBasedSlider.prototype._getTypeName = function () {
  10133. return "ImageBasedSlider";
  10134. };
  10135. ImageBasedSlider.prototype._draw = function (context) {
  10136. context.save();
  10137. this._applyStates(context);
  10138. this._prepareRenderingData("rectangle");
  10139. var thumbPosition = this._getThumbPosition();
  10140. var left = this._renderLeft;
  10141. var top = this._renderTop;
  10142. var width = this._renderWidth;
  10143. var height = this._renderHeight;
  10144. // Background
  10145. if (this._backgroundImage) {
  10146. this._tempMeasure.copyFromFloats(left, top, width, height);
  10147. if (this.isThumbClamped && this.displayThumb) {
  10148. if (this.isVertical) {
  10149. this._tempMeasure.height += this._effectiveThumbThickness;
  10150. }
  10151. else {
  10152. this._tempMeasure.width += this._effectiveThumbThickness;
  10153. }
  10154. }
  10155. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10156. this._backgroundImage._draw(context);
  10157. }
  10158. // Bar
  10159. if (this._valueBarImage) {
  10160. if (this.isVertical) {
  10161. if (this.isThumbClamped && this.displayThumb) {
  10162. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10163. }
  10164. else {
  10165. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10166. }
  10167. }
  10168. else {
  10169. if (this.isThumbClamped && this.displayThumb) {
  10170. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10171. }
  10172. else {
  10173. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10174. }
  10175. }
  10176. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10177. this._valueBarImage._draw(context);
  10178. }
  10179. // Thumb
  10180. if (this.displayThumb) {
  10181. if (this.isVertical) {
  10182. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10183. }
  10184. else {
  10185. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10186. }
  10187. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10188. this._thumbImage._draw(context);
  10189. }
  10190. context.restore();
  10191. };
  10192. return ImageBasedSlider;
  10193. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10194. /***/ }),
  10195. /***/ "./2D/controls/sliders/scrollBar.ts":
  10196. /*!******************************************!*\
  10197. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10198. \******************************************/
  10199. /*! exports provided: ScrollBar */
  10200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10201. "use strict";
  10202. __webpack_require__.r(__webpack_exports__);
  10203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10204. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10205. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10206. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10207. /**
  10208. * Class used to create slider controls
  10209. */
  10210. var ScrollBar = /** @class */ (function (_super) {
  10211. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10212. /**
  10213. * Creates a new Slider
  10214. * @param name defines the control name
  10215. */
  10216. function ScrollBar(name) {
  10217. var _this = _super.call(this, name) || this;
  10218. _this.name = name;
  10219. _this._background = "black";
  10220. _this._borderColor = "white";
  10221. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10222. return _this;
  10223. }
  10224. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10225. /** Gets or sets border color */
  10226. get: function () {
  10227. return this._borderColor;
  10228. },
  10229. set: function (value) {
  10230. if (this._borderColor === value) {
  10231. return;
  10232. }
  10233. this._borderColor = value;
  10234. this._markAsDirty();
  10235. },
  10236. enumerable: true,
  10237. configurable: true
  10238. });
  10239. Object.defineProperty(ScrollBar.prototype, "background", {
  10240. /** Gets or sets background color */
  10241. get: function () {
  10242. return this._background;
  10243. },
  10244. set: function (value) {
  10245. if (this._background === value) {
  10246. return;
  10247. }
  10248. this._background = value;
  10249. this._markAsDirty();
  10250. },
  10251. enumerable: true,
  10252. configurable: true
  10253. });
  10254. ScrollBar.prototype._getTypeName = function () {
  10255. return "Scrollbar";
  10256. };
  10257. ScrollBar.prototype._getThumbThickness = function () {
  10258. var thumbThickness = 0;
  10259. if (this._thumbWidth.isPixel) {
  10260. thumbThickness = this._thumbWidth.getValue(this._host);
  10261. }
  10262. else {
  10263. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10264. }
  10265. return thumbThickness;
  10266. };
  10267. ScrollBar.prototype._draw = function (context) {
  10268. context.save();
  10269. this._applyStates(context);
  10270. this._prepareRenderingData("rectangle");
  10271. var left = this._renderLeft;
  10272. var thumbPosition = this._getThumbPosition();
  10273. context.fillStyle = this._background;
  10274. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10275. // Value bar
  10276. context.fillStyle = this.color;
  10277. // Thumb
  10278. if (this.isVertical) {
  10279. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10280. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10281. this._thumbMeasure.width = this._currentMeasure.width;
  10282. this._thumbMeasure.height = this._effectiveThumbThickness;
  10283. }
  10284. else {
  10285. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10286. this._thumbMeasure.top = this._currentMeasure.top;
  10287. this._thumbMeasure.width = this._effectiveThumbThickness;
  10288. this._thumbMeasure.height = this._currentMeasure.height;
  10289. }
  10290. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10291. context.restore();
  10292. };
  10293. /** @hidden */
  10294. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10295. if (this.rotation != 0) {
  10296. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10297. x = this._transformedPosition.x;
  10298. y = this._transformedPosition.y;
  10299. }
  10300. if (this._first) {
  10301. this._first = false;
  10302. this._originX = x;
  10303. this._originY = y;
  10304. // Check if move is required
  10305. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10306. if (this.isVertical) {
  10307. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10308. }
  10309. else {
  10310. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10311. }
  10312. }
  10313. }
  10314. // Delta mode
  10315. var delta = 0;
  10316. if (this.isVertical) {
  10317. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10318. }
  10319. else {
  10320. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10321. }
  10322. this.value += delta * (this.maximum - this.minimum);
  10323. this._originX = x;
  10324. this._originY = y;
  10325. };
  10326. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10327. this._first = true;
  10328. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10329. };
  10330. return ScrollBar;
  10331. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10332. /***/ }),
  10333. /***/ "./2D/controls/sliders/slider.ts":
  10334. /*!***************************************!*\
  10335. !*** ./2D/controls/sliders/slider.ts ***!
  10336. \***************************************/
  10337. /*! exports provided: Slider */
  10338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10339. "use strict";
  10340. __webpack_require__.r(__webpack_exports__);
  10341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10342. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10343. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10344. /**
  10345. * Class used to create slider controls
  10346. */
  10347. var Slider = /** @class */ (function (_super) {
  10348. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10349. /**
  10350. * Creates a new Slider
  10351. * @param name defines the control name
  10352. */
  10353. function Slider(name) {
  10354. var _this = _super.call(this, name) || this;
  10355. _this.name = name;
  10356. _this._background = "black";
  10357. _this._borderColor = "white";
  10358. _this._isThumbCircle = false;
  10359. _this._displayValueBar = true;
  10360. return _this;
  10361. }
  10362. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10363. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10364. get: function () {
  10365. return this._displayValueBar;
  10366. },
  10367. set: function (value) {
  10368. if (this._displayValueBar === value) {
  10369. return;
  10370. }
  10371. this._displayValueBar = value;
  10372. this._markAsDirty();
  10373. },
  10374. enumerable: true,
  10375. configurable: true
  10376. });
  10377. Object.defineProperty(Slider.prototype, "borderColor", {
  10378. /** Gets or sets border color */
  10379. get: function () {
  10380. return this._borderColor;
  10381. },
  10382. set: function (value) {
  10383. if (this._borderColor === value) {
  10384. return;
  10385. }
  10386. this._borderColor = value;
  10387. this._markAsDirty();
  10388. },
  10389. enumerable: true,
  10390. configurable: true
  10391. });
  10392. Object.defineProperty(Slider.prototype, "background", {
  10393. /** Gets or sets background color */
  10394. get: function () {
  10395. return this._background;
  10396. },
  10397. set: function (value) {
  10398. if (this._background === value) {
  10399. return;
  10400. }
  10401. this._background = value;
  10402. this._markAsDirty();
  10403. },
  10404. enumerable: true,
  10405. configurable: true
  10406. });
  10407. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10408. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10409. get: function () {
  10410. return this._isThumbCircle;
  10411. },
  10412. set: function (value) {
  10413. if (this._isThumbCircle === value) {
  10414. return;
  10415. }
  10416. this._isThumbCircle = value;
  10417. this._markAsDirty();
  10418. },
  10419. enumerable: true,
  10420. configurable: true
  10421. });
  10422. Slider.prototype._getTypeName = function () {
  10423. return "Slider";
  10424. };
  10425. Slider.prototype._draw = function (context) {
  10426. context.save();
  10427. this._applyStates(context);
  10428. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10429. var left = this._renderLeft;
  10430. var top = this._renderTop;
  10431. var width = this._renderWidth;
  10432. var height = this._renderHeight;
  10433. var radius = 0;
  10434. if (this.isThumbClamped && this.isThumbCircle) {
  10435. if (this.isVertical) {
  10436. top += (this._effectiveThumbThickness / 2);
  10437. }
  10438. else {
  10439. left += (this._effectiveThumbThickness / 2);
  10440. }
  10441. radius = this._backgroundBoxThickness / 2;
  10442. }
  10443. else {
  10444. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10445. }
  10446. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10447. context.shadowColor = this.shadowColor;
  10448. context.shadowBlur = this.shadowBlur;
  10449. context.shadowOffsetX = this.shadowOffsetX;
  10450. context.shadowOffsetY = this.shadowOffsetY;
  10451. }
  10452. var thumbPosition = this._getThumbPosition();
  10453. context.fillStyle = this._background;
  10454. if (this.isVertical) {
  10455. if (this.isThumbClamped) {
  10456. if (this.isThumbCircle) {
  10457. context.beginPath();
  10458. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10459. context.fill();
  10460. context.fillRect(left, top, width, height);
  10461. }
  10462. else {
  10463. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10464. }
  10465. }
  10466. else {
  10467. context.fillRect(left, top, width, height);
  10468. }
  10469. }
  10470. else {
  10471. if (this.isThumbClamped) {
  10472. if (this.isThumbCircle) {
  10473. context.beginPath();
  10474. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10475. context.fill();
  10476. context.fillRect(left, top, width, height);
  10477. }
  10478. else {
  10479. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10480. }
  10481. }
  10482. else {
  10483. context.fillRect(left, top, width, height);
  10484. }
  10485. }
  10486. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10487. context.shadowBlur = 0;
  10488. context.shadowOffsetX = 0;
  10489. context.shadowOffsetY = 0;
  10490. }
  10491. // Value bar
  10492. context.fillStyle = this.color;
  10493. if (this._displayValueBar) {
  10494. if (this.isVertical) {
  10495. if (this.isThumbClamped) {
  10496. if (this.isThumbCircle) {
  10497. context.beginPath();
  10498. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10499. context.fill();
  10500. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10501. }
  10502. else {
  10503. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10504. }
  10505. }
  10506. else {
  10507. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10508. }
  10509. }
  10510. else {
  10511. if (this.isThumbClamped) {
  10512. if (this.isThumbCircle) {
  10513. context.beginPath();
  10514. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10515. context.fill();
  10516. context.fillRect(left, top, thumbPosition, height);
  10517. }
  10518. else {
  10519. context.fillRect(left, top, thumbPosition, height);
  10520. }
  10521. }
  10522. else {
  10523. context.fillRect(left, top, thumbPosition, height);
  10524. }
  10525. }
  10526. }
  10527. // Thumb
  10528. if (this.displayThumb) {
  10529. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10530. context.shadowColor = this.shadowColor;
  10531. context.shadowBlur = this.shadowBlur;
  10532. context.shadowOffsetX = this.shadowOffsetX;
  10533. context.shadowOffsetY = this.shadowOffsetY;
  10534. }
  10535. if (this._isThumbCircle) {
  10536. context.beginPath();
  10537. if (this.isVertical) {
  10538. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10539. }
  10540. else {
  10541. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10542. }
  10543. context.fill();
  10544. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10545. context.shadowBlur = 0;
  10546. context.shadowOffsetX = 0;
  10547. context.shadowOffsetY = 0;
  10548. }
  10549. context.strokeStyle = this._borderColor;
  10550. context.stroke();
  10551. }
  10552. else {
  10553. if (this.isVertical) {
  10554. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10555. }
  10556. else {
  10557. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10558. }
  10559. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10560. context.shadowBlur = 0;
  10561. context.shadowOffsetX = 0;
  10562. context.shadowOffsetY = 0;
  10563. }
  10564. context.strokeStyle = this._borderColor;
  10565. if (this.isVertical) {
  10566. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10567. }
  10568. else {
  10569. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10570. }
  10571. }
  10572. }
  10573. context.restore();
  10574. };
  10575. return Slider;
  10576. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10577. /***/ }),
  10578. /***/ "./2D/controls/stackPanel.ts":
  10579. /*!***********************************!*\
  10580. !*** ./2D/controls/stackPanel.ts ***!
  10581. \***********************************/
  10582. /*! exports provided: StackPanel */
  10583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10584. "use strict";
  10585. __webpack_require__.r(__webpack_exports__);
  10586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10587. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10588. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  10589. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10590. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10591. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10592. /**
  10593. * Class used to create a 2D stack panel container
  10594. */
  10595. var StackPanel = /** @class */ (function (_super) {
  10596. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10597. /**
  10598. * Creates a new StackPanel
  10599. * @param name defines control name
  10600. */
  10601. function StackPanel(name) {
  10602. var _this = _super.call(this, name) || this;
  10603. _this.name = name;
  10604. _this._isVertical = true;
  10605. _this._manualWidth = false;
  10606. _this._manualHeight = false;
  10607. _this._doNotTrackManualChanges = false;
  10608. /**
  10609. * Gets or sets a boolean indicating that layou warnings should be ignored
  10610. */
  10611. _this.ignoreLayoutWarnings = false;
  10612. return _this;
  10613. }
  10614. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10615. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10616. get: function () {
  10617. return this._isVertical;
  10618. },
  10619. set: function (value) {
  10620. if (this._isVertical === value) {
  10621. return;
  10622. }
  10623. this._isVertical = value;
  10624. this._markAsDirty();
  10625. },
  10626. enumerable: true,
  10627. configurable: true
  10628. });
  10629. Object.defineProperty(StackPanel.prototype, "width", {
  10630. get: function () {
  10631. return this._width.toString(this._host);
  10632. },
  10633. /**
  10634. * Gets or sets panel width.
  10635. * This value should not be set when in horizontal mode as it will be computed automatically
  10636. */
  10637. set: function (value) {
  10638. if (!this._doNotTrackManualChanges) {
  10639. this._manualWidth = true;
  10640. }
  10641. if (this._width.toString(this._host) === value) {
  10642. return;
  10643. }
  10644. if (this._width.fromString(value)) {
  10645. this._markAsDirty();
  10646. }
  10647. },
  10648. enumerable: true,
  10649. configurable: true
  10650. });
  10651. Object.defineProperty(StackPanel.prototype, "height", {
  10652. get: function () {
  10653. return this._height.toString(this._host);
  10654. },
  10655. /**
  10656. * Gets or sets panel height.
  10657. * This value should not be set when in vertical mode as it will be computed automatically
  10658. */
  10659. set: function (value) {
  10660. if (!this._doNotTrackManualChanges) {
  10661. this._manualHeight = true;
  10662. }
  10663. if (this._height.toString(this._host) === value) {
  10664. return;
  10665. }
  10666. if (this._height.fromString(value)) {
  10667. this._markAsDirty();
  10668. }
  10669. },
  10670. enumerable: true,
  10671. configurable: true
  10672. });
  10673. StackPanel.prototype._getTypeName = function () {
  10674. return "StackPanel";
  10675. };
  10676. /** @hidden */
  10677. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10678. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10679. var child = _a[_i];
  10680. if (this._isVertical) {
  10681. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10682. }
  10683. else {
  10684. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10685. }
  10686. }
  10687. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10688. };
  10689. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10690. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10691. this._measureForChildren.copyFrom(parentMeasure);
  10692. this._measureForChildren.left = this._currentMeasure.left;
  10693. this._measureForChildren.top = this._currentMeasure.top;
  10694. if (!this.isVertical || this._manualWidth) {
  10695. this._measureForChildren.width = this._currentMeasure.width;
  10696. }
  10697. if (this.isVertical || this._manualHeight) {
  10698. this._measureForChildren.height = this._currentMeasure.height;
  10699. }
  10700. };
  10701. StackPanel.prototype._postMeasure = function () {
  10702. var stackWidth = 0;
  10703. var stackHeight = 0;
  10704. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10705. var child = _a[_i];
  10706. if (!child.isVisible || child.notRenderable) {
  10707. continue;
  10708. }
  10709. if (this._isVertical) {
  10710. if (child.top !== stackHeight + "px") {
  10711. child.top = stackHeight + "px";
  10712. this._rebuildLayout = true;
  10713. child._top.ignoreAdaptiveScaling = true;
  10714. }
  10715. if (child._height.isPercentage) {
  10716. if (!this.ignoreLayoutWarnings) {
  10717. 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");
  10718. }
  10719. }
  10720. else {
  10721. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10722. }
  10723. }
  10724. else {
  10725. if (child.left !== stackWidth + "px") {
  10726. child.left = stackWidth + "px";
  10727. this._rebuildLayout = true;
  10728. child._left.ignoreAdaptiveScaling = true;
  10729. }
  10730. if (child._width.isPercentage) {
  10731. if (!this.ignoreLayoutWarnings) {
  10732. 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");
  10733. }
  10734. }
  10735. else {
  10736. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10737. }
  10738. }
  10739. }
  10740. this._doNotTrackManualChanges = true;
  10741. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10742. // User can now define their own height and width for stack panel.
  10743. var panelWidthChanged = false;
  10744. var panelHeightChanged = false;
  10745. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10746. var previousHeight = this.height;
  10747. this.height = stackHeight + "px";
  10748. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10749. }
  10750. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10751. var previousWidth = this.width;
  10752. this.width = stackWidth + "px";
  10753. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10754. }
  10755. if (panelHeightChanged) {
  10756. this._height.ignoreAdaptiveScaling = true;
  10757. }
  10758. if (panelWidthChanged) {
  10759. this._width.ignoreAdaptiveScaling = true;
  10760. }
  10761. this._doNotTrackManualChanges = false;
  10762. if (panelWidthChanged || panelHeightChanged) {
  10763. this._rebuildLayout = true;
  10764. }
  10765. _super.prototype._postMeasure.call(this);
  10766. };
  10767. return StackPanel;
  10768. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10769. /***/ }),
  10770. /***/ "./2D/controls/statics.ts":
  10771. /*!********************************!*\
  10772. !*** ./2D/controls/statics.ts ***!
  10773. \********************************/
  10774. /*! exports provided: name */
  10775. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10776. "use strict";
  10777. __webpack_require__.r(__webpack_exports__);
  10778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10779. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10780. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10781. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10782. /**
  10783. * Forcing an export so that this code will execute
  10784. * @hidden
  10785. */
  10786. var name = "Statics";
  10787. /**
  10788. * Creates a stack panel that can be used to render headers
  10789. * @param control defines the control to associate with the header
  10790. * @param text defines the text of the header
  10791. * @param size defines the size of the header
  10792. * @param options defines options used to configure the header
  10793. * @returns a new StackPanel
  10794. */
  10795. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10796. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10797. var isHorizontal = options ? options.isHorizontal : true;
  10798. var controlFirst = options ? options.controlFirst : true;
  10799. panel.isVertical = !isHorizontal;
  10800. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10801. header.text = text;
  10802. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10803. if (isHorizontal) {
  10804. header.width = size;
  10805. }
  10806. else {
  10807. header.height = size;
  10808. }
  10809. if (controlFirst) {
  10810. panel.addControl(control);
  10811. panel.addControl(header);
  10812. header.paddingLeft = "5px";
  10813. }
  10814. else {
  10815. panel.addControl(header);
  10816. panel.addControl(control);
  10817. header.paddingRight = "5px";
  10818. }
  10819. header.shadowBlur = control.shadowBlur;
  10820. header.shadowColor = control.shadowColor;
  10821. header.shadowOffsetX = control.shadowOffsetX;
  10822. header.shadowOffsetY = control.shadowOffsetY;
  10823. return panel;
  10824. };
  10825. /***/ }),
  10826. /***/ "./2D/controls/textBlock.ts":
  10827. /*!**********************************!*\
  10828. !*** ./2D/controls/textBlock.ts ***!
  10829. \**********************************/
  10830. /*! exports provided: TextWrapping, TextBlock */
  10831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10832. "use strict";
  10833. __webpack_require__.r(__webpack_exports__);
  10834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10836. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10837. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  10838. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10839. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10840. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10841. /**
  10842. * Enum that determines the text-wrapping mode to use.
  10843. */
  10844. var TextWrapping;
  10845. (function (TextWrapping) {
  10846. /**
  10847. * Clip the text when it's larger than Control.width; this is the default mode.
  10848. */
  10849. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10850. /**
  10851. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10852. */
  10853. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10854. /**
  10855. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10856. */
  10857. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10858. })(TextWrapping || (TextWrapping = {}));
  10859. /**
  10860. * Class used to create text block control
  10861. */
  10862. var TextBlock = /** @class */ (function (_super) {
  10863. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10864. /**
  10865. * Creates a new TextBlock object
  10866. * @param name defines the name of the control
  10867. * @param text defines the text to display (emptry string by default)
  10868. */
  10869. function TextBlock(
  10870. /**
  10871. * Defines the name of the control
  10872. */
  10873. name, text) {
  10874. if (text === void 0) { text = ""; }
  10875. var _this = _super.call(this, name) || this;
  10876. _this.name = name;
  10877. _this._text = "";
  10878. _this._textWrapping = TextWrapping.Clip;
  10879. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10880. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10881. _this._resizeToFit = false;
  10882. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10883. _this._outlineWidth = 0;
  10884. _this._outlineColor = "white";
  10885. /**
  10886. * An event triggered after the text is changed
  10887. */
  10888. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10889. /**
  10890. * An event triggered after the text was broken up into lines
  10891. */
  10892. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10893. _this.text = text;
  10894. return _this;
  10895. }
  10896. Object.defineProperty(TextBlock.prototype, "lines", {
  10897. /**
  10898. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10899. */
  10900. get: function () {
  10901. return this._lines;
  10902. },
  10903. enumerable: true,
  10904. configurable: true
  10905. });
  10906. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10907. /**
  10908. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10909. */
  10910. get: function () {
  10911. return this._resizeToFit;
  10912. },
  10913. /**
  10914. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10915. */
  10916. set: function (value) {
  10917. if (this._resizeToFit === value) {
  10918. return;
  10919. }
  10920. this._resizeToFit = value;
  10921. if (this._resizeToFit) {
  10922. this._width.ignoreAdaptiveScaling = true;
  10923. this._height.ignoreAdaptiveScaling = true;
  10924. }
  10925. this._markAsDirty();
  10926. },
  10927. enumerable: true,
  10928. configurable: true
  10929. });
  10930. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10931. /**
  10932. * Gets or sets a boolean indicating if text must be wrapped
  10933. */
  10934. get: function () {
  10935. return this._textWrapping;
  10936. },
  10937. /**
  10938. * Gets or sets a boolean indicating if text must be wrapped
  10939. */
  10940. set: function (value) {
  10941. if (this._textWrapping === value) {
  10942. return;
  10943. }
  10944. this._textWrapping = +value;
  10945. this._markAsDirty();
  10946. },
  10947. enumerable: true,
  10948. configurable: true
  10949. });
  10950. Object.defineProperty(TextBlock.prototype, "text", {
  10951. /**
  10952. * Gets or sets text to display
  10953. */
  10954. get: function () {
  10955. return this._text;
  10956. },
  10957. /**
  10958. * Gets or sets text to display
  10959. */
  10960. set: function (value) {
  10961. if (this._text === value) {
  10962. return;
  10963. }
  10964. this._text = value;
  10965. this._markAsDirty();
  10966. this.onTextChangedObservable.notifyObservers(this);
  10967. },
  10968. enumerable: true,
  10969. configurable: true
  10970. });
  10971. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10972. /**
  10973. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10974. */
  10975. get: function () {
  10976. return this._textHorizontalAlignment;
  10977. },
  10978. /**
  10979. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10980. */
  10981. set: function (value) {
  10982. if (this._textHorizontalAlignment === value) {
  10983. return;
  10984. }
  10985. this._textHorizontalAlignment = value;
  10986. this._markAsDirty();
  10987. },
  10988. enumerable: true,
  10989. configurable: true
  10990. });
  10991. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10992. /**
  10993. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10994. */
  10995. get: function () {
  10996. return this._textVerticalAlignment;
  10997. },
  10998. /**
  10999. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11000. */
  11001. set: function (value) {
  11002. if (this._textVerticalAlignment === value) {
  11003. return;
  11004. }
  11005. this._textVerticalAlignment = value;
  11006. this._markAsDirty();
  11007. },
  11008. enumerable: true,
  11009. configurable: true
  11010. });
  11011. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11012. /**
  11013. * Gets or sets line spacing value
  11014. */
  11015. get: function () {
  11016. return this._lineSpacing.toString(this._host);
  11017. },
  11018. /**
  11019. * Gets or sets line spacing value
  11020. */
  11021. set: function (value) {
  11022. if (this._lineSpacing.fromString(value)) {
  11023. this._markAsDirty();
  11024. }
  11025. },
  11026. enumerable: true,
  11027. configurable: true
  11028. });
  11029. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11030. /**
  11031. * Gets or sets outlineWidth of the text to display
  11032. */
  11033. get: function () {
  11034. return this._outlineWidth;
  11035. },
  11036. /**
  11037. * Gets or sets outlineWidth of the text to display
  11038. */
  11039. set: function (value) {
  11040. if (this._outlineWidth === value) {
  11041. return;
  11042. }
  11043. this._outlineWidth = value;
  11044. this._markAsDirty();
  11045. },
  11046. enumerable: true,
  11047. configurable: true
  11048. });
  11049. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11050. /**
  11051. * Gets or sets outlineColor of the text to display
  11052. */
  11053. get: function () {
  11054. return this._outlineColor;
  11055. },
  11056. /**
  11057. * Gets or sets outlineColor of the text to display
  11058. */
  11059. set: function (value) {
  11060. if (this._outlineColor === value) {
  11061. return;
  11062. }
  11063. this._outlineColor = value;
  11064. this._markAsDirty();
  11065. },
  11066. enumerable: true,
  11067. configurable: true
  11068. });
  11069. TextBlock.prototype._getTypeName = function () {
  11070. return "TextBlock";
  11071. };
  11072. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11073. if (!this._fontOffset) {
  11074. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11075. }
  11076. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11077. // Prepare lines
  11078. this._lines = this._breakLines(this._currentMeasure.width, context);
  11079. this.onLinesReadyObservable.notifyObservers(this);
  11080. var maxLineWidth = 0;
  11081. for (var i = 0; i < this._lines.length; i++) {
  11082. var line = this._lines[i];
  11083. if (line.width > maxLineWidth) {
  11084. maxLineWidth = line.width;
  11085. }
  11086. }
  11087. if (this._resizeToFit) {
  11088. if (this._textWrapping === TextWrapping.Clip) {
  11089. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11090. if (newWidth !== this._width.internalValue) {
  11091. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11092. this._rebuildLayout = true;
  11093. }
  11094. }
  11095. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11096. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11097. var lineSpacing = 0;
  11098. if (this._lineSpacing.isPixel) {
  11099. lineSpacing = this._lineSpacing.getValue(this._host);
  11100. }
  11101. else {
  11102. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11103. }
  11104. newHeight += (this._lines.length - 1) * lineSpacing;
  11105. }
  11106. if (newHeight !== this._height.internalValue) {
  11107. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11108. this._rebuildLayout = true;
  11109. }
  11110. }
  11111. };
  11112. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11113. var width = this._currentMeasure.width;
  11114. var x = 0;
  11115. switch (this._textHorizontalAlignment) {
  11116. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11117. x = 0;
  11118. break;
  11119. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11120. x = width - textWidth;
  11121. break;
  11122. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11123. x = (width - textWidth) / 2;
  11124. break;
  11125. }
  11126. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11127. context.shadowColor = this.shadowColor;
  11128. context.shadowBlur = this.shadowBlur;
  11129. context.shadowOffsetX = this.shadowOffsetX;
  11130. context.shadowOffsetY = this.shadowOffsetY;
  11131. }
  11132. if (this.outlineWidth) {
  11133. context.strokeText(text, this._currentMeasure.left + x, y);
  11134. }
  11135. context.fillText(text, this._currentMeasure.left + x, y);
  11136. };
  11137. /** @hidden */
  11138. TextBlock.prototype._draw = function (context) {
  11139. context.save();
  11140. this._applyStates(context);
  11141. // Render lines
  11142. this._renderLines(context);
  11143. context.restore();
  11144. };
  11145. TextBlock.prototype._applyStates = function (context) {
  11146. _super.prototype._applyStates.call(this, context);
  11147. if (this.outlineWidth) {
  11148. context.lineWidth = this.outlineWidth;
  11149. context.strokeStyle = this.outlineColor;
  11150. }
  11151. };
  11152. TextBlock.prototype._breakLines = function (refWidth, context) {
  11153. var lines = [];
  11154. var _lines = this.text.split("\n");
  11155. if (this._textWrapping === TextWrapping.Ellipsis) {
  11156. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11157. var _line = _lines_1[_i];
  11158. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11159. }
  11160. }
  11161. else if (this._textWrapping === TextWrapping.WordWrap) {
  11162. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11163. var _line = _lines_2[_a];
  11164. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11165. }
  11166. }
  11167. else {
  11168. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11169. var _line = _lines_3[_b];
  11170. lines.push(this._parseLine(_line, context));
  11171. }
  11172. }
  11173. return lines;
  11174. };
  11175. TextBlock.prototype._parseLine = function (line, context) {
  11176. if (line === void 0) { line = ''; }
  11177. return { text: line, width: context.measureText(line).width };
  11178. };
  11179. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11180. if (line === void 0) { line = ''; }
  11181. var lineWidth = context.measureText(line).width;
  11182. if (lineWidth > width) {
  11183. line += '…';
  11184. }
  11185. while (line.length > 2 && lineWidth > width) {
  11186. line = line.slice(0, -2) + '…';
  11187. lineWidth = context.measureText(line).width;
  11188. }
  11189. return { text: line, width: lineWidth };
  11190. };
  11191. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11192. if (line === void 0) { line = ''; }
  11193. var lines = [];
  11194. var words = line.split(' ');
  11195. var lineWidth = 0;
  11196. for (var n = 0; n < words.length; n++) {
  11197. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11198. var metrics = context.measureText(testLine);
  11199. var testWidth = metrics.width;
  11200. if (testWidth > width && n > 0) {
  11201. lines.push({ text: line, width: lineWidth });
  11202. line = words[n];
  11203. lineWidth = context.measureText(line).width;
  11204. }
  11205. else {
  11206. lineWidth = testWidth;
  11207. line = testLine;
  11208. }
  11209. }
  11210. lines.push({ text: line, width: lineWidth });
  11211. return lines;
  11212. };
  11213. TextBlock.prototype._renderLines = function (context) {
  11214. var height = this._currentMeasure.height;
  11215. var rootY = 0;
  11216. switch (this._textVerticalAlignment) {
  11217. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11218. rootY = this._fontOffset.ascent;
  11219. break;
  11220. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11221. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11222. break;
  11223. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11224. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11225. break;
  11226. }
  11227. rootY += this._currentMeasure.top;
  11228. for (var i = 0; i < this._lines.length; i++) {
  11229. var line = this._lines[i];
  11230. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11231. if (this._lineSpacing.isPixel) {
  11232. rootY += this._lineSpacing.getValue(this._host);
  11233. }
  11234. else {
  11235. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11236. }
  11237. }
  11238. this._drawText(line.text, line.width, rootY, context);
  11239. rootY += this._fontOffset.height;
  11240. }
  11241. };
  11242. /**
  11243. * Given a width constraint applied on the text block, find the expected height
  11244. * @returns expected height
  11245. */
  11246. TextBlock.prototype.computeExpectedHeight = function () {
  11247. if (this.text && this.widthInPixels) {
  11248. var context_1 = document.createElement('canvas').getContext('2d');
  11249. if (context_1) {
  11250. this._applyStates(context_1);
  11251. if (!this._fontOffset) {
  11252. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11253. }
  11254. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11255. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11256. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11257. var lineSpacing = 0;
  11258. if (this._lineSpacing.isPixel) {
  11259. lineSpacing = this._lineSpacing.getValue(this._host);
  11260. }
  11261. else {
  11262. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11263. }
  11264. newHeight += (lines.length - 1) * lineSpacing;
  11265. }
  11266. return newHeight;
  11267. }
  11268. }
  11269. return 0;
  11270. };
  11271. TextBlock.prototype.dispose = function () {
  11272. _super.prototype.dispose.call(this);
  11273. this.onTextChangedObservable.clear();
  11274. };
  11275. return TextBlock;
  11276. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11277. /***/ }),
  11278. /***/ "./2D/controls/virtualKeyboard.ts":
  11279. /*!****************************************!*\
  11280. !*** ./2D/controls/virtualKeyboard.ts ***!
  11281. \****************************************/
  11282. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11284. "use strict";
  11285. __webpack_require__.r(__webpack_exports__);
  11286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11288. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11289. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11290. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11291. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11292. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11293. /**
  11294. * Class used to store key control properties
  11295. */
  11296. var KeyPropertySet = /** @class */ (function () {
  11297. function KeyPropertySet() {
  11298. }
  11299. return KeyPropertySet;
  11300. }());
  11301. /**
  11302. * Class used to create virtual keyboard
  11303. */
  11304. var VirtualKeyboard = /** @class */ (function (_super) {
  11305. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11306. function VirtualKeyboard() {
  11307. var _this = _super !== null && _super.apply(this, arguments) || this;
  11308. /** Observable raised when a key is pressed */
  11309. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11310. /** Gets or sets default key button width */
  11311. _this.defaultButtonWidth = "40px";
  11312. /** Gets or sets default key button height */
  11313. _this.defaultButtonHeight = "40px";
  11314. /** Gets or sets default key button left padding */
  11315. _this.defaultButtonPaddingLeft = "2px";
  11316. /** Gets or sets default key button right padding */
  11317. _this.defaultButtonPaddingRight = "2px";
  11318. /** Gets or sets default key button top padding */
  11319. _this.defaultButtonPaddingTop = "2px";
  11320. /** Gets or sets default key button bottom padding */
  11321. _this.defaultButtonPaddingBottom = "2px";
  11322. /** Gets or sets default key button foreground color */
  11323. _this.defaultButtonColor = "#DDD";
  11324. /** Gets or sets default key button background color */
  11325. _this.defaultButtonBackground = "#070707";
  11326. /** Gets or sets shift button foreground color */
  11327. _this.shiftButtonColor = "#7799FF";
  11328. /** Gets or sets shift button thickness*/
  11329. _this.selectedShiftThickness = 1;
  11330. /** Gets shift key state */
  11331. _this.shiftState = 0;
  11332. _this._currentlyConnectedInputText = null;
  11333. _this._connectedInputTexts = [];
  11334. _this._onKeyPressObserver = null;
  11335. return _this;
  11336. }
  11337. VirtualKeyboard.prototype._getTypeName = function () {
  11338. return "VirtualKeyboard";
  11339. };
  11340. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11341. var _this = this;
  11342. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11343. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11344. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11345. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11346. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11347. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11348. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11349. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11350. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11351. button.thickness = 0;
  11352. button.isFocusInvisible = true;
  11353. button.shadowColor = this.shadowColor;
  11354. button.shadowBlur = this.shadowBlur;
  11355. button.shadowOffsetX = this.shadowOffsetX;
  11356. button.shadowOffsetY = this.shadowOffsetY;
  11357. button.onPointerUpObservable.add(function () {
  11358. _this.onKeyPressObservable.notifyObservers(key);
  11359. });
  11360. return button;
  11361. };
  11362. /**
  11363. * Adds a new row of keys
  11364. * @param keys defines the list of keys to add
  11365. * @param propertySets defines the associated property sets
  11366. */
  11367. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11368. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11369. panel.isVertical = false;
  11370. panel.isFocusInvisible = true;
  11371. var maxKey = null;
  11372. for (var i = 0; i < keys.length; i++) {
  11373. var properties = null;
  11374. if (propertySets && propertySets.length === keys.length) {
  11375. properties = propertySets[i];
  11376. }
  11377. var key = this._createKey(keys[i], properties);
  11378. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11379. maxKey = key;
  11380. }
  11381. panel.addControl(key);
  11382. }
  11383. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11384. this.addControl(panel);
  11385. };
  11386. /**
  11387. * Set the shift key to a specific state
  11388. * @param shiftState defines the new shift state
  11389. */
  11390. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11391. if (!this.children) {
  11392. return;
  11393. }
  11394. for (var i = 0; i < this.children.length; i++) {
  11395. var row = this.children[i];
  11396. if (!row || !row.children) {
  11397. continue;
  11398. }
  11399. var rowContainer = row;
  11400. for (var j = 0; j < rowContainer.children.length; j++) {
  11401. var button = rowContainer.children[j];
  11402. if (!button || !button.children[0]) {
  11403. continue;
  11404. }
  11405. var button_tblock = button.children[0];
  11406. if (button_tblock.text === "\u21E7") {
  11407. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11408. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11409. }
  11410. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11411. }
  11412. }
  11413. };
  11414. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11415. /** Gets the input text control currently attached to the keyboard */
  11416. get: function () {
  11417. return this._currentlyConnectedInputText;
  11418. },
  11419. enumerable: true,
  11420. configurable: true
  11421. });
  11422. /**
  11423. * Connects the keyboard with an input text control
  11424. *
  11425. * @param input defines the target control
  11426. */
  11427. VirtualKeyboard.prototype.connect = function (input) {
  11428. var _this = this;
  11429. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11430. if (inputTextAlreadyConnected) {
  11431. return;
  11432. }
  11433. if (this._onKeyPressObserver === null) {
  11434. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11435. if (!_this._currentlyConnectedInputText) {
  11436. return;
  11437. }
  11438. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11439. switch (key) {
  11440. case "\u21E7":
  11441. _this.shiftState++;
  11442. if (_this.shiftState > 2) {
  11443. _this.shiftState = 0;
  11444. }
  11445. _this.applyShiftState(_this.shiftState);
  11446. return;
  11447. case "\u2190":
  11448. _this._currentlyConnectedInputText.processKey(8);
  11449. return;
  11450. case "\u21B5":
  11451. _this._currentlyConnectedInputText.processKey(13);
  11452. return;
  11453. }
  11454. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11455. if (_this.shiftState === 1) {
  11456. _this.shiftState = 0;
  11457. _this.applyShiftState(_this.shiftState);
  11458. }
  11459. });
  11460. }
  11461. this.isVisible = false;
  11462. this._currentlyConnectedInputText = input;
  11463. input._connectedVirtualKeyboard = this;
  11464. // Events hooking
  11465. var onFocusObserver = input.onFocusObservable.add(function () {
  11466. _this._currentlyConnectedInputText = input;
  11467. input._connectedVirtualKeyboard = _this;
  11468. _this.isVisible = true;
  11469. });
  11470. var onBlurObserver = input.onBlurObservable.add(function () {
  11471. input._connectedVirtualKeyboard = null;
  11472. _this._currentlyConnectedInputText = null;
  11473. _this.isVisible = false;
  11474. });
  11475. this._connectedInputTexts.push({
  11476. input: input,
  11477. onBlurObserver: onBlurObserver,
  11478. onFocusObserver: onFocusObserver
  11479. });
  11480. };
  11481. /**
  11482. * Disconnects the keyboard from connected InputText controls
  11483. *
  11484. * @param input optionally defines a target control, otherwise all are disconnected
  11485. */
  11486. VirtualKeyboard.prototype.disconnect = function (input) {
  11487. var _this = this;
  11488. if (input) {
  11489. // .find not available on IE
  11490. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11491. if (filtered.length === 1) {
  11492. this._removeConnectedInputObservables(filtered[0]);
  11493. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11494. if (this._currentlyConnectedInputText === input) {
  11495. this._currentlyConnectedInputText = null;
  11496. }
  11497. }
  11498. }
  11499. else {
  11500. this._connectedInputTexts.forEach(function (connectedInputText) {
  11501. _this._removeConnectedInputObservables(connectedInputText);
  11502. });
  11503. this._connectedInputTexts = [];
  11504. }
  11505. if (this._connectedInputTexts.length === 0) {
  11506. this._currentlyConnectedInputText = null;
  11507. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11508. this._onKeyPressObserver = null;
  11509. }
  11510. };
  11511. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11512. connectedInputText.input._connectedVirtualKeyboard = null;
  11513. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11514. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11515. };
  11516. /**
  11517. * Release all resources
  11518. */
  11519. VirtualKeyboard.prototype.dispose = function () {
  11520. _super.prototype.dispose.call(this);
  11521. this.disconnect();
  11522. };
  11523. // Statics
  11524. /**
  11525. * Creates a new keyboard using a default layout
  11526. *
  11527. * @param name defines control name
  11528. * @returns a new VirtualKeyboard
  11529. */
  11530. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11531. var returnValue = new VirtualKeyboard(name);
  11532. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11533. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11534. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11535. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11536. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11537. return returnValue;
  11538. };
  11539. return VirtualKeyboard;
  11540. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11541. /***/ }),
  11542. /***/ "./2D/index.ts":
  11543. /*!*********************!*\
  11544. !*** ./2D/index.ts ***!
  11545. \*********************/
  11546. /*! 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 */
  11547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11548. "use strict";
  11549. __webpack_require__.r(__webpack_exports__);
  11550. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11582. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11584. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11586. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11589. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11591. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11593. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11595. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11597. /***/ }),
  11598. /***/ "./2D/math2D.ts":
  11599. /*!**********************!*\
  11600. !*** ./2D/math2D.ts ***!
  11601. \**********************/
  11602. /*! exports provided: Vector2WithInfo, Matrix2D */
  11603. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11604. "use strict";
  11605. __webpack_require__.r(__webpack_exports__);
  11606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11607. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11608. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11609. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11610. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11611. /**
  11612. * Class used to transport Vector2 information for pointer events
  11613. */
  11614. var Vector2WithInfo = /** @class */ (function (_super) {
  11615. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11616. /**
  11617. * Creates a new Vector2WithInfo
  11618. * @param source defines the vector2 data to transport
  11619. * @param buttonIndex defines the current mouse button index
  11620. */
  11621. function Vector2WithInfo(source,
  11622. /** defines the current mouse button index */
  11623. buttonIndex) {
  11624. if (buttonIndex === void 0) { buttonIndex = 0; }
  11625. var _this = _super.call(this, source.x, source.y) || this;
  11626. _this.buttonIndex = buttonIndex;
  11627. return _this;
  11628. }
  11629. return Vector2WithInfo;
  11630. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11631. /** Class used to provide 2D matrix features */
  11632. var Matrix2D = /** @class */ (function () {
  11633. /**
  11634. * Creates a new matrix
  11635. * @param m00 defines value for (0, 0)
  11636. * @param m01 defines value for (0, 1)
  11637. * @param m10 defines value for (1, 0)
  11638. * @param m11 defines value for (1, 1)
  11639. * @param m20 defines value for (2, 0)
  11640. * @param m21 defines value for (2, 1)
  11641. */
  11642. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11643. /** Gets the internal array of 6 floats used to store matrix data */
  11644. this.m = new Float32Array(6);
  11645. this.fromValues(m00, m01, m10, m11, m20, m21);
  11646. }
  11647. /**
  11648. * Fills the matrix from direct values
  11649. * @param m00 defines value for (0, 0)
  11650. * @param m01 defines value for (0, 1)
  11651. * @param m10 defines value for (1, 0)
  11652. * @param m11 defines value for (1, 1)
  11653. * @param m20 defines value for (2, 0)
  11654. * @param m21 defines value for (2, 1)
  11655. * @returns the current modified matrix
  11656. */
  11657. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11658. this.m[0] = m00;
  11659. this.m[1] = m01;
  11660. this.m[2] = m10;
  11661. this.m[3] = m11;
  11662. this.m[4] = m20;
  11663. this.m[5] = m21;
  11664. return this;
  11665. };
  11666. /**
  11667. * Gets matrix determinant
  11668. * @returns the determinant
  11669. */
  11670. Matrix2D.prototype.determinant = function () {
  11671. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11672. };
  11673. /**
  11674. * Inverses the matrix and stores it in a target matrix
  11675. * @param result defines the target matrix
  11676. * @returns the current matrix
  11677. */
  11678. Matrix2D.prototype.invertToRef = function (result) {
  11679. var l0 = this.m[0];
  11680. var l1 = this.m[1];
  11681. var l2 = this.m[2];
  11682. var l3 = this.m[3];
  11683. var l4 = this.m[4];
  11684. var l5 = this.m[5];
  11685. var det = this.determinant();
  11686. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11687. result.m[0] = 0;
  11688. result.m[1] = 0;
  11689. result.m[2] = 0;
  11690. result.m[3] = 0;
  11691. result.m[4] = 0;
  11692. result.m[5] = 0;
  11693. return this;
  11694. }
  11695. var detDiv = 1 / det;
  11696. var det4 = l2 * l5 - l3 * l4;
  11697. var det5 = l1 * l4 - l0 * l5;
  11698. result.m[0] = l3 * detDiv;
  11699. result.m[1] = -l1 * detDiv;
  11700. result.m[2] = -l2 * detDiv;
  11701. result.m[3] = l0 * detDiv;
  11702. result.m[4] = det4 * detDiv;
  11703. result.m[5] = det5 * detDiv;
  11704. return this;
  11705. };
  11706. /**
  11707. * Multiplies the current matrix with another one
  11708. * @param other defines the second operand
  11709. * @param result defines the target matrix
  11710. * @returns the current matrix
  11711. */
  11712. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11713. var l0 = this.m[0];
  11714. var l1 = this.m[1];
  11715. var l2 = this.m[2];
  11716. var l3 = this.m[3];
  11717. var l4 = this.m[4];
  11718. var l5 = this.m[5];
  11719. var r0 = other.m[0];
  11720. var r1 = other.m[1];
  11721. var r2 = other.m[2];
  11722. var r3 = other.m[3];
  11723. var r4 = other.m[4];
  11724. var r5 = other.m[5];
  11725. result.m[0] = l0 * r0 + l1 * r2;
  11726. result.m[1] = l0 * r1 + l1 * r3;
  11727. result.m[2] = l2 * r0 + l3 * r2;
  11728. result.m[3] = l2 * r1 + l3 * r3;
  11729. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11730. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11731. return this;
  11732. };
  11733. /**
  11734. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11735. * @param x defines the x coordinate to transform
  11736. * @param y defines the x coordinate to transform
  11737. * @param result defines the target vector2
  11738. * @returns the current matrix
  11739. */
  11740. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11741. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11742. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11743. return this;
  11744. };
  11745. // Statics
  11746. /**
  11747. * Creates an identity matrix
  11748. * @returns a new matrix
  11749. */
  11750. Matrix2D.Identity = function () {
  11751. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11752. };
  11753. /**
  11754. * Creates a translation matrix and stores it in a target matrix
  11755. * @param x defines the x coordinate of the translation
  11756. * @param y defines the y coordinate of the translation
  11757. * @param result defines the target matrix
  11758. */
  11759. Matrix2D.TranslationToRef = function (x, y, result) {
  11760. result.fromValues(1, 0, 0, 1, x, y);
  11761. };
  11762. /**
  11763. * Creates a scaling matrix and stores it in a target matrix
  11764. * @param x defines the x coordinate of the scaling
  11765. * @param y defines the y coordinate of the scaling
  11766. * @param result defines the target matrix
  11767. */
  11768. Matrix2D.ScalingToRef = function (x, y, result) {
  11769. result.fromValues(x, 0, 0, y, 0, 0);
  11770. };
  11771. /**
  11772. * Creates a rotation matrix and stores it in a target matrix
  11773. * @param angle defines the rotation angle
  11774. * @param result defines the target matrix
  11775. */
  11776. Matrix2D.RotationToRef = function (angle, result) {
  11777. var s = Math.sin(angle);
  11778. var c = Math.cos(angle);
  11779. result.fromValues(c, s, -s, c, 0, 0);
  11780. };
  11781. /**
  11782. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11783. * @param tx defines the x coordinate of the translation
  11784. * @param ty defines the y coordinate of the translation
  11785. * @param angle defines the rotation angle
  11786. * @param scaleX defines the x coordinate of the scaling
  11787. * @param scaleY defines the y coordinate of the scaling
  11788. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11789. * @param result defines the target matrix
  11790. */
  11791. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11792. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11793. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11794. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11795. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11796. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11797. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11798. if (parentMatrix) {
  11799. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11800. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11801. }
  11802. else {
  11803. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11804. }
  11805. };
  11806. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11807. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11808. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11809. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11810. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11811. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11812. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11813. return Matrix2D;
  11814. }());
  11815. /***/ }),
  11816. /***/ "./2D/measure.ts":
  11817. /*!***********************!*\
  11818. !*** ./2D/measure.ts ***!
  11819. \***********************/
  11820. /*! exports provided: Measure */
  11821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11822. "use strict";
  11823. __webpack_require__.r(__webpack_exports__);
  11824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11825. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11826. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11827. /**
  11828. * Class used to store 2D control sizes
  11829. */
  11830. var Measure = /** @class */ (function () {
  11831. /**
  11832. * Creates a new measure
  11833. * @param left defines left coordinate
  11834. * @param top defines top coordinate
  11835. * @param width defines width dimension
  11836. * @param height defines height dimension
  11837. */
  11838. function Measure(
  11839. /** defines left coordinate */
  11840. left,
  11841. /** defines top coordinate */
  11842. top,
  11843. /** defines width dimension */
  11844. width,
  11845. /** defines height dimension */
  11846. height) {
  11847. this.left = left;
  11848. this.top = top;
  11849. this.width = width;
  11850. this.height = height;
  11851. }
  11852. /**
  11853. * Copy from another measure
  11854. * @param other defines the other measure to copy from
  11855. */
  11856. Measure.prototype.copyFrom = function (other) {
  11857. this.left = other.left;
  11858. this.top = other.top;
  11859. this.width = other.width;
  11860. this.height = other.height;
  11861. };
  11862. /**
  11863. * Copy from a group of 4 floats
  11864. * @param left defines left coordinate
  11865. * @param top defines top coordinate
  11866. * @param width defines width dimension
  11867. * @param height defines height dimension
  11868. */
  11869. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11870. this.left = left;
  11871. this.top = top;
  11872. this.width = width;
  11873. this.height = height;
  11874. };
  11875. /**
  11876. * Computes the axis aligned bounding box measure for two given measures
  11877. * @param a Input measure
  11878. * @param b Input measure
  11879. * @param result the resulting bounding measure
  11880. */
  11881. Measure.CombineToRef = function (a, b, result) {
  11882. var left = Math.min(a.left, b.left);
  11883. var top = Math.min(a.top, b.top);
  11884. var right = Math.max(a.left + a.width, b.left + b.width);
  11885. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11886. result.left = left;
  11887. result.top = top;
  11888. result.width = right - left;
  11889. result.height = bottom - top;
  11890. };
  11891. /**
  11892. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11893. * @param transform the matrix to transform the measure before computing the AABB
  11894. * @param result the resulting AABB
  11895. */
  11896. Measure.prototype.transformToRef = function (transform, result) {
  11897. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11898. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11899. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11900. for (var i = 0; i < 4; i++) {
  11901. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11902. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11903. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11904. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11905. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11906. }
  11907. result.left = min.x;
  11908. result.top = min.y;
  11909. result.width = max.x - min.x;
  11910. result.height = max.y - min.y;
  11911. };
  11912. /**
  11913. * Check equality between this measure and another one
  11914. * @param other defines the other measures
  11915. * @returns true if both measures are equals
  11916. */
  11917. Measure.prototype.isEqualsTo = function (other) {
  11918. if (this.left !== other.left) {
  11919. return false;
  11920. }
  11921. if (this.top !== other.top) {
  11922. return false;
  11923. }
  11924. if (this.width !== other.width) {
  11925. return false;
  11926. }
  11927. if (this.height !== other.height) {
  11928. return false;
  11929. }
  11930. return true;
  11931. };
  11932. /**
  11933. * Creates an empty measure
  11934. * @returns a new measure
  11935. */
  11936. Measure.Empty = function () {
  11937. return new Measure(0, 0, 0, 0);
  11938. };
  11939. return Measure;
  11940. }());
  11941. /***/ }),
  11942. /***/ "./2D/multiLinePoint.ts":
  11943. /*!******************************!*\
  11944. !*** ./2D/multiLinePoint.ts ***!
  11945. \******************************/
  11946. /*! exports provided: MultiLinePoint */
  11947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11948. "use strict";
  11949. __webpack_require__.r(__webpack_exports__);
  11950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11951. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11952. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11953. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11954. /**
  11955. * Class used to store a point for a MultiLine object.
  11956. * The point can be pure 2D coordinates, a mesh or a control
  11957. */
  11958. var MultiLinePoint = /** @class */ (function () {
  11959. /**
  11960. * Creates a new MultiLinePoint
  11961. * @param multiLine defines the source MultiLine object
  11962. */
  11963. function MultiLinePoint(multiLine) {
  11964. this._multiLine = multiLine;
  11965. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11966. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11967. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11968. }
  11969. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11970. /** Gets or sets x coordinate */
  11971. get: function () {
  11972. return this._x.toString(this._multiLine._host);
  11973. },
  11974. set: function (value) {
  11975. if (this._x.toString(this._multiLine._host) === value) {
  11976. return;
  11977. }
  11978. if (this._x.fromString(value)) {
  11979. this._multiLine._markAsDirty();
  11980. }
  11981. },
  11982. enumerable: true,
  11983. configurable: true
  11984. });
  11985. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11986. /** Gets or sets y coordinate */
  11987. get: function () {
  11988. return this._y.toString(this._multiLine._host);
  11989. },
  11990. set: function (value) {
  11991. if (this._y.toString(this._multiLine._host) === value) {
  11992. return;
  11993. }
  11994. if (this._y.fromString(value)) {
  11995. this._multiLine._markAsDirty();
  11996. }
  11997. },
  11998. enumerable: true,
  11999. configurable: true
  12000. });
  12001. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12002. /** Gets or sets the control associated with this point */
  12003. get: function () {
  12004. return this._control;
  12005. },
  12006. set: function (value) {
  12007. if (this._control === value) {
  12008. return;
  12009. }
  12010. if (this._control && this._controlObserver) {
  12011. this._control.onDirtyObservable.remove(this._controlObserver);
  12012. this._controlObserver = null;
  12013. }
  12014. this._control = value;
  12015. if (this._control) {
  12016. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12017. }
  12018. this._multiLine._markAsDirty();
  12019. },
  12020. enumerable: true,
  12021. configurable: true
  12022. });
  12023. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12024. /** Gets or sets the mesh associated with this point */
  12025. get: function () {
  12026. return this._mesh;
  12027. },
  12028. set: function (value) {
  12029. if (this._mesh === value) {
  12030. return;
  12031. }
  12032. if (this._mesh && this._meshObserver) {
  12033. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12034. }
  12035. this._mesh = value;
  12036. if (this._mesh) {
  12037. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12038. }
  12039. this._multiLine._markAsDirty();
  12040. },
  12041. enumerable: true,
  12042. configurable: true
  12043. });
  12044. /** Resets links */
  12045. MultiLinePoint.prototype.resetLinks = function () {
  12046. this.control = null;
  12047. this.mesh = null;
  12048. };
  12049. /**
  12050. * Gets a translation vector
  12051. * @returns the translation vector
  12052. */
  12053. MultiLinePoint.prototype.translate = function () {
  12054. this._point = this._translatePoint();
  12055. return this._point;
  12056. };
  12057. MultiLinePoint.prototype._translatePoint = function () {
  12058. if (this._mesh != null) {
  12059. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12060. }
  12061. else if (this._control != null) {
  12062. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12063. }
  12064. else {
  12065. var host = this._multiLine._host;
  12066. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12067. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12068. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12069. }
  12070. };
  12071. /** Release associated resources */
  12072. MultiLinePoint.prototype.dispose = function () {
  12073. this.resetLinks();
  12074. };
  12075. return MultiLinePoint;
  12076. }());
  12077. /***/ }),
  12078. /***/ "./2D/style.ts":
  12079. /*!*********************!*\
  12080. !*** ./2D/style.ts ***!
  12081. \*********************/
  12082. /*! exports provided: Style */
  12083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12084. "use strict";
  12085. __webpack_require__.r(__webpack_exports__);
  12086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12087. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12088. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12089. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12090. /**
  12091. * Define a style used by control to automatically setup properties based on a template.
  12092. * Only support font related properties so far
  12093. */
  12094. var Style = /** @class */ (function () {
  12095. /**
  12096. * Creates a new style object
  12097. * @param host defines the AdvancedDynamicTexture which hosts this style
  12098. */
  12099. function Style(host) {
  12100. this._fontFamily = "Arial";
  12101. this._fontStyle = "";
  12102. this._fontWeight = "";
  12103. /** @hidden */
  12104. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12105. /**
  12106. * Observable raised when the style values are changed
  12107. */
  12108. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12109. this._host = host;
  12110. }
  12111. Object.defineProperty(Style.prototype, "fontSize", {
  12112. /**
  12113. * Gets or sets the font size
  12114. */
  12115. get: function () {
  12116. return this._fontSize.toString(this._host);
  12117. },
  12118. set: function (value) {
  12119. if (this._fontSize.toString(this._host) === value) {
  12120. return;
  12121. }
  12122. if (this._fontSize.fromString(value)) {
  12123. this.onChangedObservable.notifyObservers(this);
  12124. }
  12125. },
  12126. enumerable: true,
  12127. configurable: true
  12128. });
  12129. Object.defineProperty(Style.prototype, "fontFamily", {
  12130. /**
  12131. * Gets or sets the font family
  12132. */
  12133. get: function () {
  12134. return this._fontFamily;
  12135. },
  12136. set: function (value) {
  12137. if (this._fontFamily === value) {
  12138. return;
  12139. }
  12140. this._fontFamily = value;
  12141. this.onChangedObservable.notifyObservers(this);
  12142. },
  12143. enumerable: true,
  12144. configurable: true
  12145. });
  12146. Object.defineProperty(Style.prototype, "fontStyle", {
  12147. /**
  12148. * Gets or sets the font style
  12149. */
  12150. get: function () {
  12151. return this._fontStyle;
  12152. },
  12153. set: function (value) {
  12154. if (this._fontStyle === value) {
  12155. return;
  12156. }
  12157. this._fontStyle = value;
  12158. this.onChangedObservable.notifyObservers(this);
  12159. },
  12160. enumerable: true,
  12161. configurable: true
  12162. });
  12163. Object.defineProperty(Style.prototype, "fontWeight", {
  12164. /** Gets or sets font weight */
  12165. get: function () {
  12166. return this._fontWeight;
  12167. },
  12168. set: function (value) {
  12169. if (this._fontWeight === value) {
  12170. return;
  12171. }
  12172. this._fontWeight = value;
  12173. this.onChangedObservable.notifyObservers(this);
  12174. },
  12175. enumerable: true,
  12176. configurable: true
  12177. });
  12178. /** Dispose all associated resources */
  12179. Style.prototype.dispose = function () {
  12180. this.onChangedObservable.clear();
  12181. };
  12182. return Style;
  12183. }());
  12184. /***/ }),
  12185. /***/ "./2D/valueAndUnit.ts":
  12186. /*!****************************!*\
  12187. !*** ./2D/valueAndUnit.ts ***!
  12188. \****************************/
  12189. /*! exports provided: ValueAndUnit */
  12190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12191. "use strict";
  12192. __webpack_require__.r(__webpack_exports__);
  12193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12194. /**
  12195. * Class used to specific a value and its associated unit
  12196. */
  12197. var ValueAndUnit = /** @class */ (function () {
  12198. /**
  12199. * Creates a new ValueAndUnit
  12200. * @param value defines the value to store
  12201. * @param unit defines the unit to store
  12202. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12203. */
  12204. function ValueAndUnit(value,
  12205. /** defines the unit to store */
  12206. unit,
  12207. /** defines a boolean indicating if the value can be negative */
  12208. negativeValueAllowed) {
  12209. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12210. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12211. this.unit = unit;
  12212. this.negativeValueAllowed = negativeValueAllowed;
  12213. this._value = 1;
  12214. /**
  12215. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12216. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12217. */
  12218. this.ignoreAdaptiveScaling = false;
  12219. this._value = value;
  12220. this._originalUnit = unit;
  12221. }
  12222. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12223. /** Gets a boolean indicating if the value is a percentage */
  12224. get: function () {
  12225. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12226. },
  12227. enumerable: true,
  12228. configurable: true
  12229. });
  12230. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12231. /** Gets a boolean indicating if the value is store as pixel */
  12232. get: function () {
  12233. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12234. },
  12235. enumerable: true,
  12236. configurable: true
  12237. });
  12238. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12239. /** Gets direct internal value */
  12240. get: function () {
  12241. return this._value;
  12242. },
  12243. enumerable: true,
  12244. configurable: true
  12245. });
  12246. /**
  12247. * Gets value as pixel
  12248. * @param host defines the root host
  12249. * @param refValue defines the reference value for percentages
  12250. * @returns the value as pixel
  12251. */
  12252. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12253. if (this.isPixel) {
  12254. return this.getValue(host);
  12255. }
  12256. return this.getValue(host) * refValue;
  12257. };
  12258. /**
  12259. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12260. * @param value defines the value to store
  12261. * @param unit defines the unit to store
  12262. * @returns the current ValueAndUnit
  12263. */
  12264. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12265. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12266. this._value = value;
  12267. this.unit = unit;
  12268. return this;
  12269. };
  12270. /**
  12271. * Gets the value accordingly to its unit
  12272. * @param host defines the root host
  12273. * @returns the value
  12274. */
  12275. ValueAndUnit.prototype.getValue = function (host) {
  12276. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12277. var width = 0;
  12278. var height = 0;
  12279. if (host.idealWidth) {
  12280. width = (this._value * host.getSize().width) / host.idealWidth;
  12281. }
  12282. if (host.idealHeight) {
  12283. height = (this._value * host.getSize().height) / host.idealHeight;
  12284. }
  12285. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12286. return window.innerWidth < window.innerHeight ? width : height;
  12287. }
  12288. if (host.idealWidth) { // horizontal
  12289. return width;
  12290. }
  12291. if (host.idealHeight) { // vertical
  12292. return height;
  12293. }
  12294. }
  12295. return this._value;
  12296. };
  12297. /**
  12298. * Gets a string representation of the value
  12299. * @param host defines the root host
  12300. * @param decimals defines an optional number of decimals to display
  12301. * @returns a string
  12302. */
  12303. ValueAndUnit.prototype.toString = function (host, decimals) {
  12304. switch (this.unit) {
  12305. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12306. var percentage = this.getValue(host) * 100;
  12307. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12308. case ValueAndUnit.UNITMODE_PIXEL:
  12309. var pixels = this.getValue(host);
  12310. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12311. }
  12312. return this.unit.toString();
  12313. };
  12314. /**
  12315. * Store a value parsed from a string
  12316. * @param source defines the source string
  12317. * @returns true if the value was successfully parsed
  12318. */
  12319. ValueAndUnit.prototype.fromString = function (source) {
  12320. var match = ValueAndUnit._Regex.exec(source.toString());
  12321. if (!match || match.length === 0) {
  12322. return false;
  12323. }
  12324. var sourceValue = parseFloat(match[1]);
  12325. var sourceUnit = this._originalUnit;
  12326. if (!this.negativeValueAllowed) {
  12327. if (sourceValue < 0) {
  12328. sourceValue = 0;
  12329. }
  12330. }
  12331. if (match.length === 4) {
  12332. switch (match[3]) {
  12333. case "px":
  12334. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12335. break;
  12336. case "%":
  12337. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12338. sourceValue /= 100.0;
  12339. break;
  12340. }
  12341. }
  12342. if (sourceValue === this._value && sourceUnit === this.unit) {
  12343. return false;
  12344. }
  12345. this._value = sourceValue;
  12346. this.unit = sourceUnit;
  12347. return true;
  12348. };
  12349. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12350. /** UNITMODE_PERCENTAGE */
  12351. get: function () {
  12352. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12353. },
  12354. enumerable: true,
  12355. configurable: true
  12356. });
  12357. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12358. /** UNITMODE_PIXEL */
  12359. get: function () {
  12360. return ValueAndUnit._UNITMODE_PIXEL;
  12361. },
  12362. enumerable: true,
  12363. configurable: true
  12364. });
  12365. // Static
  12366. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12367. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12368. ValueAndUnit._UNITMODE_PIXEL = 1;
  12369. return ValueAndUnit;
  12370. }());
  12371. /***/ }),
  12372. /***/ "./3D/controls/abstractButton3D.ts":
  12373. /*!*****************************************!*\
  12374. !*** ./3D/controls/abstractButton3D.ts ***!
  12375. \*****************************************/
  12376. /*! exports provided: AbstractButton3D */
  12377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12378. "use strict";
  12379. __webpack_require__.r(__webpack_exports__);
  12380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12381. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12382. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  12383. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12384. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12385. /**
  12386. * Class used as a root to all buttons
  12387. */
  12388. var AbstractButton3D = /** @class */ (function (_super) {
  12389. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12390. /**
  12391. * Creates a new button
  12392. * @param name defines the control name
  12393. */
  12394. function AbstractButton3D(name) {
  12395. return _super.call(this, name) || this;
  12396. }
  12397. AbstractButton3D.prototype._getTypeName = function () {
  12398. return "AbstractButton3D";
  12399. };
  12400. // Mesh association
  12401. AbstractButton3D.prototype._createNode = function (scene) {
  12402. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12403. };
  12404. return AbstractButton3D;
  12405. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12406. /***/ }),
  12407. /***/ "./3D/controls/button3D.ts":
  12408. /*!*********************************!*\
  12409. !*** ./3D/controls/button3D.ts ***!
  12410. \*********************************/
  12411. /*! exports provided: Button3D */
  12412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12413. "use strict";
  12414. __webpack_require__.r(__webpack_exports__);
  12415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12416. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12417. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12418. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12419. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12420. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12421. /**
  12422. * Class used to create a button in 3D
  12423. */
  12424. var Button3D = /** @class */ (function (_super) {
  12425. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12426. /**
  12427. * Creates a new button
  12428. * @param name defines the control name
  12429. */
  12430. function Button3D(name) {
  12431. var _this = _super.call(this, name) || this;
  12432. _this._contentResolution = 512;
  12433. _this._contentScaleRatio = 2;
  12434. // Default animations
  12435. _this.pointerEnterAnimation = function () {
  12436. if (!_this.mesh) {
  12437. return;
  12438. }
  12439. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12440. };
  12441. _this.pointerOutAnimation = function () {
  12442. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12443. };
  12444. _this.pointerDownAnimation = function () {
  12445. if (!_this.mesh) {
  12446. return;
  12447. }
  12448. _this.mesh.scaling.scaleInPlace(0.95);
  12449. };
  12450. _this.pointerUpAnimation = function () {
  12451. if (!_this.mesh) {
  12452. return;
  12453. }
  12454. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12455. };
  12456. return _this;
  12457. }
  12458. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12459. /**
  12460. * Gets or sets the texture resolution used to render content (512 by default)
  12461. */
  12462. get: function () {
  12463. return this._contentResolution;
  12464. },
  12465. set: function (value) {
  12466. if (this._contentResolution === value) {
  12467. return;
  12468. }
  12469. this._contentResolution = value;
  12470. this._resetContent();
  12471. },
  12472. enumerable: true,
  12473. configurable: true
  12474. });
  12475. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12476. /**
  12477. * Gets or sets the texture scale ratio used to render content (2 by default)
  12478. */
  12479. get: function () {
  12480. return this._contentScaleRatio;
  12481. },
  12482. set: function (value) {
  12483. if (this._contentScaleRatio === value) {
  12484. return;
  12485. }
  12486. this._contentScaleRatio = value;
  12487. this._resetContent();
  12488. },
  12489. enumerable: true,
  12490. configurable: true
  12491. });
  12492. Button3D.prototype._disposeFacadeTexture = function () {
  12493. if (this._facadeTexture) {
  12494. this._facadeTexture.dispose();
  12495. this._facadeTexture = null;
  12496. }
  12497. };
  12498. Button3D.prototype._resetContent = function () {
  12499. this._disposeFacadeTexture();
  12500. this.content = this._content;
  12501. };
  12502. Object.defineProperty(Button3D.prototype, "content", {
  12503. /**
  12504. * Gets or sets the GUI 2D content used to display the button's facade
  12505. */
  12506. get: function () {
  12507. return this._content;
  12508. },
  12509. set: function (value) {
  12510. this._content = value;
  12511. if (!this._host || !this._host.utilityLayer) {
  12512. return;
  12513. }
  12514. if (!this._facadeTexture) {
  12515. 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);
  12516. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12517. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12518. this._facadeTexture.premulAlpha = true;
  12519. }
  12520. this._facadeTexture.addControl(value);
  12521. this._applyFacade(this._facadeTexture);
  12522. },
  12523. enumerable: true,
  12524. configurable: true
  12525. });
  12526. /**
  12527. * Apply the facade texture (created from the content property).
  12528. * This function can be overloaded by child classes
  12529. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12530. */
  12531. Button3D.prototype._applyFacade = function (facadeTexture) {
  12532. this._currentMaterial.emissiveTexture = facadeTexture;
  12533. };
  12534. Button3D.prototype._getTypeName = function () {
  12535. return "Button3D";
  12536. };
  12537. // Mesh association
  12538. Button3D.prototype._createNode = function (scene) {
  12539. var faceUV = new Array(6);
  12540. for (var i = 0; i < 6; i++) {
  12541. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12542. }
  12543. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12544. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12545. width: 1.0,
  12546. height: 1.0,
  12547. depth: 0.08,
  12548. faceUV: faceUV
  12549. }, scene);
  12550. return mesh;
  12551. };
  12552. Button3D.prototype._affectMaterial = function (mesh) {
  12553. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12554. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12555. mesh.material = material;
  12556. this._currentMaterial = material;
  12557. this._resetContent();
  12558. };
  12559. /**
  12560. * Releases all associated resources
  12561. */
  12562. Button3D.prototype.dispose = function () {
  12563. _super.prototype.dispose.call(this);
  12564. this._disposeFacadeTexture();
  12565. if (this._currentMaterial) {
  12566. this._currentMaterial.dispose();
  12567. }
  12568. };
  12569. return Button3D;
  12570. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12571. /***/ }),
  12572. /***/ "./3D/controls/container3D.ts":
  12573. /*!************************************!*\
  12574. !*** ./3D/controls/container3D.ts ***!
  12575. \************************************/
  12576. /*! exports provided: Container3D */
  12577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12578. "use strict";
  12579. __webpack_require__.r(__webpack_exports__);
  12580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12581. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12582. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  12583. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12584. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12585. /**
  12586. * Class used to create containers for controls
  12587. */
  12588. var Container3D = /** @class */ (function (_super) {
  12589. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12590. /**
  12591. * Creates a new container
  12592. * @param name defines the container name
  12593. */
  12594. function Container3D(name) {
  12595. var _this = _super.call(this, name) || this;
  12596. _this._blockLayout = false;
  12597. /**
  12598. * Gets the list of child controls
  12599. */
  12600. _this._children = new Array();
  12601. return _this;
  12602. }
  12603. Object.defineProperty(Container3D.prototype, "children", {
  12604. /**
  12605. * Gets the list of child controls
  12606. */
  12607. get: function () {
  12608. return this._children;
  12609. },
  12610. enumerable: true,
  12611. configurable: true
  12612. });
  12613. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12614. /**
  12615. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12616. * This is helpful to optimize layout operation when adding multiple children in a row
  12617. */
  12618. get: function () {
  12619. return this._blockLayout;
  12620. },
  12621. set: function (value) {
  12622. if (this._blockLayout === value) {
  12623. return;
  12624. }
  12625. this._blockLayout = value;
  12626. if (!this._blockLayout) {
  12627. this._arrangeChildren();
  12628. }
  12629. },
  12630. enumerable: true,
  12631. configurable: true
  12632. });
  12633. /**
  12634. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12635. * @returns the current container
  12636. */
  12637. Container3D.prototype.updateLayout = function () {
  12638. this._arrangeChildren();
  12639. return this;
  12640. };
  12641. /**
  12642. * Gets a boolean indicating if the given control is in the children of this control
  12643. * @param control defines the control to check
  12644. * @returns true if the control is in the child list
  12645. */
  12646. Container3D.prototype.containsControl = function (control) {
  12647. return this._children.indexOf(control) !== -1;
  12648. };
  12649. /**
  12650. * Adds a control to the children of this control
  12651. * @param control defines the control to add
  12652. * @returns the current container
  12653. */
  12654. Container3D.prototype.addControl = function (control) {
  12655. var index = this._children.indexOf(control);
  12656. if (index !== -1) {
  12657. return this;
  12658. }
  12659. control.parent = this;
  12660. control._host = this._host;
  12661. this._children.push(control);
  12662. if (this._host.utilityLayer) {
  12663. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12664. if (control.node) {
  12665. control.node.parent = this.node;
  12666. }
  12667. if (!this.blockLayout) {
  12668. this._arrangeChildren();
  12669. }
  12670. }
  12671. return this;
  12672. };
  12673. /**
  12674. * This function will be called everytime a new control is added
  12675. */
  12676. Container3D.prototype._arrangeChildren = function () {
  12677. };
  12678. Container3D.prototype._createNode = function (scene) {
  12679. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12680. };
  12681. /**
  12682. * Removes a control from the children of this control
  12683. * @param control defines the control to remove
  12684. * @returns the current container
  12685. */
  12686. Container3D.prototype.removeControl = function (control) {
  12687. var index = this._children.indexOf(control);
  12688. if (index !== -1) {
  12689. this._children.splice(index, 1);
  12690. control.parent = null;
  12691. control._disposeNode();
  12692. }
  12693. return this;
  12694. };
  12695. Container3D.prototype._getTypeName = function () {
  12696. return "Container3D";
  12697. };
  12698. /**
  12699. * Releases all associated resources
  12700. */
  12701. Container3D.prototype.dispose = function () {
  12702. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12703. var control = _a[_i];
  12704. control.dispose();
  12705. }
  12706. this._children = [];
  12707. _super.prototype.dispose.call(this);
  12708. };
  12709. /** Control rotation will remain unchanged */
  12710. Container3D.UNSET_ORIENTATION = 0;
  12711. /** Control will rotate to make it look at sphere central axis */
  12712. Container3D.FACEORIGIN_ORIENTATION = 1;
  12713. /** Control will rotate to make it look back at sphere central axis */
  12714. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12715. /** Control will rotate to look at z axis (0, 0, 1) */
  12716. Container3D.FACEFORWARD_ORIENTATION = 3;
  12717. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12718. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12719. return Container3D;
  12720. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12721. /***/ }),
  12722. /***/ "./3D/controls/control3D.ts":
  12723. /*!**********************************!*\
  12724. !*** ./3D/controls/control3D.ts ***!
  12725. \**********************************/
  12726. /*! exports provided: Control3D */
  12727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12728. "use strict";
  12729. __webpack_require__.r(__webpack_exports__);
  12730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12731. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12732. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12733. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12734. /**
  12735. * Class used as base class for controls
  12736. */
  12737. var Control3D = /** @class */ (function () {
  12738. /**
  12739. * Creates a new control
  12740. * @param name defines the control name
  12741. */
  12742. function Control3D(
  12743. /** Defines the control name */
  12744. name) {
  12745. this.name = name;
  12746. this._downCount = 0;
  12747. this._enterCount = -1;
  12748. this._downPointerIds = {};
  12749. this._isVisible = true;
  12750. /**
  12751. * An event triggered when the pointer move over the control
  12752. */
  12753. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12754. /**
  12755. * An event triggered when the pointer move out of the control
  12756. */
  12757. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12758. /**
  12759. * An event triggered when the pointer taps the control
  12760. */
  12761. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12762. /**
  12763. * An event triggered when pointer is up
  12764. */
  12765. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12766. /**
  12767. * An event triggered when a control is clicked on (with a mouse)
  12768. */
  12769. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12770. /**
  12771. * An event triggered when pointer enters the control
  12772. */
  12773. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12774. // Behaviors
  12775. this._behaviors = new Array();
  12776. }
  12777. Object.defineProperty(Control3D.prototype, "position", {
  12778. /** Gets or sets the control position in world space */
  12779. get: function () {
  12780. if (!this._node) {
  12781. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12782. }
  12783. return this._node.position;
  12784. },
  12785. set: function (value) {
  12786. if (!this._node) {
  12787. return;
  12788. }
  12789. this._node.position = value;
  12790. },
  12791. enumerable: true,
  12792. configurable: true
  12793. });
  12794. Object.defineProperty(Control3D.prototype, "scaling", {
  12795. /** Gets or sets the control scaling in world space */
  12796. get: function () {
  12797. if (!this._node) {
  12798. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12799. }
  12800. return this._node.scaling;
  12801. },
  12802. set: function (value) {
  12803. if (!this._node) {
  12804. return;
  12805. }
  12806. this._node.scaling = value;
  12807. },
  12808. enumerable: true,
  12809. configurable: true
  12810. });
  12811. Object.defineProperty(Control3D.prototype, "behaviors", {
  12812. /**
  12813. * Gets the list of attached behaviors
  12814. * @see http://doc.babylonjs.com/features/behaviour
  12815. */
  12816. get: function () {
  12817. return this._behaviors;
  12818. },
  12819. enumerable: true,
  12820. configurable: true
  12821. });
  12822. /**
  12823. * Attach a behavior to the control
  12824. * @see http://doc.babylonjs.com/features/behaviour
  12825. * @param behavior defines the behavior to attach
  12826. * @returns the current control
  12827. */
  12828. Control3D.prototype.addBehavior = function (behavior) {
  12829. var _this = this;
  12830. var index = this._behaviors.indexOf(behavior);
  12831. if (index !== -1) {
  12832. return this;
  12833. }
  12834. behavior.init();
  12835. var scene = this._host.scene;
  12836. if (scene.isLoading) {
  12837. // We defer the attach when the scene will be loaded
  12838. scene.onDataLoadedObservable.addOnce(function () {
  12839. behavior.attach(_this);
  12840. });
  12841. }
  12842. else {
  12843. behavior.attach(this);
  12844. }
  12845. this._behaviors.push(behavior);
  12846. return this;
  12847. };
  12848. /**
  12849. * Remove an attached behavior
  12850. * @see http://doc.babylonjs.com/features/behaviour
  12851. * @param behavior defines the behavior to attach
  12852. * @returns the current control
  12853. */
  12854. Control3D.prototype.removeBehavior = function (behavior) {
  12855. var index = this._behaviors.indexOf(behavior);
  12856. if (index === -1) {
  12857. return this;
  12858. }
  12859. this._behaviors[index].detach();
  12860. this._behaviors.splice(index, 1);
  12861. return this;
  12862. };
  12863. /**
  12864. * Gets an attached behavior by name
  12865. * @param name defines the name of the behavior to look for
  12866. * @see http://doc.babylonjs.com/features/behaviour
  12867. * @returns null if behavior was not found else the requested behavior
  12868. */
  12869. Control3D.prototype.getBehaviorByName = function (name) {
  12870. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12871. var behavior = _a[_i];
  12872. if (behavior.name === name) {
  12873. return behavior;
  12874. }
  12875. }
  12876. return null;
  12877. };
  12878. Object.defineProperty(Control3D.prototype, "isVisible", {
  12879. /** Gets or sets a boolean indicating if the control is visible */
  12880. get: function () {
  12881. return this._isVisible;
  12882. },
  12883. set: function (value) {
  12884. if (this._isVisible === value) {
  12885. return;
  12886. }
  12887. this._isVisible = value;
  12888. var mesh = this.mesh;
  12889. if (mesh) {
  12890. mesh.setEnabled(value);
  12891. }
  12892. },
  12893. enumerable: true,
  12894. configurable: true
  12895. });
  12896. Object.defineProperty(Control3D.prototype, "typeName", {
  12897. /**
  12898. * Gets a string representing the class name
  12899. */
  12900. get: function () {
  12901. return this._getTypeName();
  12902. },
  12903. enumerable: true,
  12904. configurable: true
  12905. });
  12906. /**
  12907. * Get the current class name of the control.
  12908. * @returns current class name
  12909. */
  12910. Control3D.prototype.getClassName = function () {
  12911. return this._getTypeName();
  12912. };
  12913. Control3D.prototype._getTypeName = function () {
  12914. return "Control3D";
  12915. };
  12916. Object.defineProperty(Control3D.prototype, "node", {
  12917. /**
  12918. * Gets the transform node used by this control
  12919. */
  12920. get: function () {
  12921. return this._node;
  12922. },
  12923. enumerable: true,
  12924. configurable: true
  12925. });
  12926. Object.defineProperty(Control3D.prototype, "mesh", {
  12927. /**
  12928. * Gets the mesh used to render this control
  12929. */
  12930. get: function () {
  12931. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12932. return this._node;
  12933. }
  12934. return null;
  12935. },
  12936. enumerable: true,
  12937. configurable: true
  12938. });
  12939. /**
  12940. * Link the control as child of the given node
  12941. * @param node defines the node to link to. Use null to unlink the control
  12942. * @returns the current control
  12943. */
  12944. Control3D.prototype.linkToTransformNode = function (node) {
  12945. if (this._node) {
  12946. this._node.parent = node;
  12947. }
  12948. return this;
  12949. };
  12950. /** @hidden **/
  12951. Control3D.prototype._prepareNode = function (scene) {
  12952. if (!this._node) {
  12953. this._node = this._createNode(scene);
  12954. if (!this.node) {
  12955. return;
  12956. }
  12957. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12958. this._node.position = this.position;
  12959. this._node.scaling = this.scaling;
  12960. var mesh = this.mesh;
  12961. if (mesh) {
  12962. mesh.isPickable = true;
  12963. this._affectMaterial(mesh);
  12964. }
  12965. }
  12966. };
  12967. /**
  12968. * Node creation.
  12969. * Can be overriden by children
  12970. * @param scene defines the scene where the node must be attached
  12971. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12972. */
  12973. Control3D.prototype._createNode = function (scene) {
  12974. // Do nothing by default
  12975. return null;
  12976. };
  12977. /**
  12978. * Affect a material to the given mesh
  12979. * @param mesh defines the mesh which will represent the control
  12980. */
  12981. Control3D.prototype._affectMaterial = function (mesh) {
  12982. mesh.material = null;
  12983. };
  12984. // Pointers
  12985. /** @hidden */
  12986. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12987. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12988. };
  12989. /** @hidden */
  12990. Control3D.prototype._onPointerEnter = function (target) {
  12991. if (this._enterCount > 0) {
  12992. return false;
  12993. }
  12994. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12995. this._enterCount = 0;
  12996. }
  12997. this._enterCount++;
  12998. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12999. if (this.pointerEnterAnimation) {
  13000. this.pointerEnterAnimation();
  13001. }
  13002. return true;
  13003. };
  13004. /** @hidden */
  13005. Control3D.prototype._onPointerOut = function (target) {
  13006. this._enterCount = 0;
  13007. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13008. if (this.pointerOutAnimation) {
  13009. this.pointerOutAnimation();
  13010. }
  13011. };
  13012. /** @hidden */
  13013. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13014. if (this._downCount !== 0) {
  13015. this._downCount++;
  13016. return false;
  13017. }
  13018. this._downCount++;
  13019. this._downPointerIds[pointerId] = true;
  13020. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13021. if (this.pointerDownAnimation) {
  13022. this.pointerDownAnimation();
  13023. }
  13024. return true;
  13025. };
  13026. /** @hidden */
  13027. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13028. this._downCount--;
  13029. delete this._downPointerIds[pointerId];
  13030. if (this._downCount < 0) {
  13031. // Handle if forcePointerUp was called prior to this
  13032. this._downCount = 0;
  13033. return;
  13034. }
  13035. if (this._downCount == 0) {
  13036. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13037. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13038. }
  13039. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13040. if (this.pointerUpAnimation) {
  13041. this.pointerUpAnimation();
  13042. }
  13043. }
  13044. };
  13045. /** @hidden */
  13046. Control3D.prototype.forcePointerUp = function (pointerId) {
  13047. if (pointerId === void 0) { pointerId = null; }
  13048. if (pointerId !== null) {
  13049. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13050. }
  13051. else {
  13052. for (var key in this._downPointerIds) {
  13053. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13054. }
  13055. if (this._downCount > 0) {
  13056. this._downCount = 1;
  13057. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13058. }
  13059. }
  13060. };
  13061. /** @hidden */
  13062. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13063. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13064. this._onPointerMove(this, pickedPoint);
  13065. var previousControlOver = this._host._lastControlOver[pointerId];
  13066. if (previousControlOver && previousControlOver !== this) {
  13067. previousControlOver._onPointerOut(this);
  13068. }
  13069. if (previousControlOver !== this) {
  13070. this._onPointerEnter(this);
  13071. }
  13072. this._host._lastControlOver[pointerId] = this;
  13073. return true;
  13074. }
  13075. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13076. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13077. this._host._lastControlDown[pointerId] = this;
  13078. this._host._lastPickedControl = this;
  13079. return true;
  13080. }
  13081. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13082. if (this._host._lastControlDown[pointerId]) {
  13083. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13084. }
  13085. delete this._host._lastControlDown[pointerId];
  13086. return true;
  13087. }
  13088. return false;
  13089. };
  13090. /** @hidden */
  13091. Control3D.prototype._disposeNode = function () {
  13092. if (this._node) {
  13093. this._node.dispose();
  13094. this._node = null;
  13095. }
  13096. };
  13097. /**
  13098. * Releases all associated resources
  13099. */
  13100. Control3D.prototype.dispose = function () {
  13101. this.onPointerDownObservable.clear();
  13102. this.onPointerEnterObservable.clear();
  13103. this.onPointerMoveObservable.clear();
  13104. this.onPointerOutObservable.clear();
  13105. this.onPointerUpObservable.clear();
  13106. this.onPointerClickObservable.clear();
  13107. this._disposeNode();
  13108. // Behaviors
  13109. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13110. var behavior = _a[_i];
  13111. behavior.detach();
  13112. }
  13113. };
  13114. return Control3D;
  13115. }());
  13116. /***/ }),
  13117. /***/ "./3D/controls/cylinderPanel.ts":
  13118. /*!**************************************!*\
  13119. !*** ./3D/controls/cylinderPanel.ts ***!
  13120. \**************************************/
  13121. /*! exports provided: CylinderPanel */
  13122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13123. "use strict";
  13124. __webpack_require__.r(__webpack_exports__);
  13125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13126. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13127. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13128. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13129. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13130. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13131. /**
  13132. * Class used to create a container panel deployed on the surface of a cylinder
  13133. */
  13134. var CylinderPanel = /** @class */ (function (_super) {
  13135. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13136. function CylinderPanel() {
  13137. var _this = _super !== null && _super.apply(this, arguments) || this;
  13138. _this._radius = 5.0;
  13139. return _this;
  13140. }
  13141. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13142. /**
  13143. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13144. */
  13145. get: function () {
  13146. return this._radius;
  13147. },
  13148. set: function (value) {
  13149. var _this = this;
  13150. if (this._radius === value) {
  13151. return;
  13152. }
  13153. this._radius = value;
  13154. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13155. _this._arrangeChildren();
  13156. });
  13157. },
  13158. enumerable: true,
  13159. configurable: true
  13160. });
  13161. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13162. var mesh = control.mesh;
  13163. if (!mesh) {
  13164. return;
  13165. }
  13166. var newPos = this._cylindricalMapping(nodePosition);
  13167. control.position = newPos;
  13168. switch (this.orientation) {
  13169. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13170. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13171. break;
  13172. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13173. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13174. break;
  13175. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13176. break;
  13177. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13178. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13179. break;
  13180. }
  13181. };
  13182. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13183. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13184. var yAngle = (source.x / this._radius);
  13185. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13186. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13187. };
  13188. return CylinderPanel;
  13189. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13190. /***/ }),
  13191. /***/ "./3D/controls/holographicButton.ts":
  13192. /*!******************************************!*\
  13193. !*** ./3D/controls/holographicButton.ts ***!
  13194. \******************************************/
  13195. /*! exports provided: HolographicButton */
  13196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13197. "use strict";
  13198. __webpack_require__.r(__webpack_exports__);
  13199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13200. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13201. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13202. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13203. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13204. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13205. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13206. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13207. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13208. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13209. /**
  13210. * Class used to create a holographic button in 3D
  13211. */
  13212. var HolographicButton = /** @class */ (function (_super) {
  13213. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13214. /**
  13215. * Creates a new button
  13216. * @param name defines the control name
  13217. */
  13218. function HolographicButton(name, shareMaterials) {
  13219. if (shareMaterials === void 0) { shareMaterials = true; }
  13220. var _this = _super.call(this, name) || this;
  13221. _this._shareMaterials = true;
  13222. _this._shareMaterials = shareMaterials;
  13223. // Default animations
  13224. _this.pointerEnterAnimation = function () {
  13225. if (!_this.mesh) {
  13226. return;
  13227. }
  13228. _this._frontPlate.setEnabled(true);
  13229. };
  13230. _this.pointerOutAnimation = function () {
  13231. if (!_this.mesh) {
  13232. return;
  13233. }
  13234. _this._frontPlate.setEnabled(false);
  13235. };
  13236. return _this;
  13237. }
  13238. HolographicButton.prototype._disposeTooltip = function () {
  13239. this._tooltipFade = null;
  13240. if (this._tooltipTextBlock) {
  13241. this._tooltipTextBlock.dispose();
  13242. }
  13243. if (this._tooltipTexture) {
  13244. this._tooltipTexture.dispose();
  13245. }
  13246. if (this._tooltipMesh) {
  13247. this._tooltipMesh.dispose();
  13248. }
  13249. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13250. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13251. };
  13252. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13253. get: function () {
  13254. if (this._tooltipTextBlock) {
  13255. return this._tooltipTextBlock.text;
  13256. }
  13257. return null;
  13258. },
  13259. /**
  13260. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13261. */
  13262. set: function (text) {
  13263. var _this = this;
  13264. if (!text) {
  13265. this._disposeTooltip();
  13266. return;
  13267. }
  13268. if (!this._tooltipFade) {
  13269. // Create tooltip with mesh and text
  13270. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13271. 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);
  13272. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13273. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13274. tooltipBackground.material = mat;
  13275. tooltipBackground.isPickable = false;
  13276. this._tooltipMesh.addChild(tooltipBackground);
  13277. tooltipBackground.position.z = 0.05;
  13278. this._tooltipMesh.scaling.y = 1 / 3;
  13279. this._tooltipMesh.position.y = 0.7;
  13280. this._tooltipMesh.position.z = -0.15;
  13281. this._tooltipMesh.isPickable = false;
  13282. this._tooltipMesh.parent = this._backPlate;
  13283. // Create text texture for the tooltip
  13284. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13285. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13286. this._tooltipTextBlock.scaleY = 3;
  13287. this._tooltipTextBlock.color = "white";
  13288. this._tooltipTextBlock.fontSize = 130;
  13289. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13290. // Add hover action to tooltip
  13291. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13292. this._tooltipFade.delay = 500;
  13293. this._tooltipMesh.addBehavior(this._tooltipFade);
  13294. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13295. if (_this._tooltipFade) {
  13296. _this._tooltipFade.fadeIn(true);
  13297. }
  13298. });
  13299. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13300. if (_this._tooltipFade) {
  13301. _this._tooltipFade.fadeIn(false);
  13302. }
  13303. });
  13304. }
  13305. if (this._tooltipTextBlock) {
  13306. this._tooltipTextBlock.text = text;
  13307. }
  13308. },
  13309. enumerable: true,
  13310. configurable: true
  13311. });
  13312. Object.defineProperty(HolographicButton.prototype, "text", {
  13313. /**
  13314. * Gets or sets text for the button
  13315. */
  13316. get: function () {
  13317. return this._text;
  13318. },
  13319. set: function (value) {
  13320. if (this._text === value) {
  13321. return;
  13322. }
  13323. this._text = value;
  13324. this._rebuildContent();
  13325. },
  13326. enumerable: true,
  13327. configurable: true
  13328. });
  13329. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13330. /**
  13331. * Gets or sets the image url for the button
  13332. */
  13333. get: function () {
  13334. return this._imageUrl;
  13335. },
  13336. set: function (value) {
  13337. if (this._imageUrl === value) {
  13338. return;
  13339. }
  13340. this._imageUrl = value;
  13341. this._rebuildContent();
  13342. },
  13343. enumerable: true,
  13344. configurable: true
  13345. });
  13346. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13347. /**
  13348. * Gets the back material used by this button
  13349. */
  13350. get: function () {
  13351. return this._backMaterial;
  13352. },
  13353. enumerable: true,
  13354. configurable: true
  13355. });
  13356. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13357. /**
  13358. * Gets the front material used by this button
  13359. */
  13360. get: function () {
  13361. return this._frontMaterial;
  13362. },
  13363. enumerable: true,
  13364. configurable: true
  13365. });
  13366. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13367. /**
  13368. * Gets the plate material used by this button
  13369. */
  13370. get: function () {
  13371. return this._plateMaterial;
  13372. },
  13373. enumerable: true,
  13374. configurable: true
  13375. });
  13376. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13377. /**
  13378. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13379. */
  13380. get: function () {
  13381. return this._shareMaterials;
  13382. },
  13383. enumerable: true,
  13384. configurable: true
  13385. });
  13386. HolographicButton.prototype._getTypeName = function () {
  13387. return "HolographicButton";
  13388. };
  13389. HolographicButton.prototype._rebuildContent = function () {
  13390. this._disposeFacadeTexture();
  13391. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13392. panel.isVertical = true;
  13393. if (this._imageUrl) {
  13394. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13395. image.source = this._imageUrl;
  13396. image.paddingTop = "40px";
  13397. image.height = "180px";
  13398. image.width = "100px";
  13399. image.paddingBottom = "40px";
  13400. panel.addControl(image);
  13401. }
  13402. if (this._text) {
  13403. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13404. text.text = this._text;
  13405. text.color = "white";
  13406. text.height = "30px";
  13407. text.fontSize = 24;
  13408. panel.addControl(text);
  13409. }
  13410. if (this._frontPlate) {
  13411. this.content = panel;
  13412. }
  13413. };
  13414. // Mesh association
  13415. HolographicButton.prototype._createNode = function (scene) {
  13416. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13417. width: 1.0,
  13418. height: 1.0,
  13419. depth: 0.08
  13420. }, scene);
  13421. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13422. width: 1.0,
  13423. height: 1.0,
  13424. depth: 0.08
  13425. }, scene);
  13426. this._frontPlate.parent = this._backPlate;
  13427. this._frontPlate.position.z = -0.08;
  13428. this._frontPlate.isPickable = false;
  13429. this._frontPlate.setEnabled(false);
  13430. this._textPlate = _super.prototype._createNode.call(this, scene);
  13431. this._textPlate.parent = this._backPlate;
  13432. this._textPlate.position.z = -0.08;
  13433. this._textPlate.isPickable = false;
  13434. return this._backPlate;
  13435. };
  13436. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13437. this._plateMaterial.emissiveTexture = facadeTexture;
  13438. this._plateMaterial.opacityTexture = facadeTexture;
  13439. };
  13440. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13441. var _this = this;
  13442. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13443. this._backMaterial.renderHoverLight = true;
  13444. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13445. if (pickedPoint) {
  13446. _this._backMaterial.hoverPosition = pickedPoint;
  13447. _this._backMaterial.hoverColor.a = 1.0;
  13448. }
  13449. else {
  13450. _this._backMaterial.hoverColor.a = 0;
  13451. }
  13452. });
  13453. };
  13454. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13455. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13456. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13457. this._frontMaterial.alpha = 0.5; // Additive
  13458. this._frontMaterial.renderBorders = true;
  13459. };
  13460. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13461. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13462. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13463. };
  13464. HolographicButton.prototype._affectMaterial = function (mesh) {
  13465. // Back
  13466. if (this._shareMaterials) {
  13467. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13468. this._createBackMaterial(mesh);
  13469. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13470. }
  13471. else {
  13472. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13473. }
  13474. // Front
  13475. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13476. this._createFrontMaterial(mesh);
  13477. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13478. }
  13479. else {
  13480. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13481. }
  13482. }
  13483. else {
  13484. this._createBackMaterial(mesh);
  13485. this._createFrontMaterial(mesh);
  13486. }
  13487. this._createPlateMaterial(mesh);
  13488. this._backPlate.material = this._backMaterial;
  13489. this._frontPlate.material = this._frontMaterial;
  13490. this._textPlate.material = this._plateMaterial;
  13491. this._rebuildContent();
  13492. };
  13493. /**
  13494. * Releases all associated resources
  13495. */
  13496. HolographicButton.prototype.dispose = function () {
  13497. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13498. this._disposeTooltip();
  13499. if (!this.shareMaterials) {
  13500. this._backMaterial.dispose();
  13501. this._frontMaterial.dispose();
  13502. this._plateMaterial.dispose();
  13503. if (this._pickedPointObserver) {
  13504. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13505. this._pickedPointObserver = null;
  13506. }
  13507. }
  13508. };
  13509. return HolographicButton;
  13510. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13511. /***/ }),
  13512. /***/ "./3D/controls/index.ts":
  13513. /*!******************************!*\
  13514. !*** ./3D/controls/index.ts ***!
  13515. \******************************/
  13516. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13517. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13518. "use strict";
  13519. __webpack_require__.r(__webpack_exports__);
  13520. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13522. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13524. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13526. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13528. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13530. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13532. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13534. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13536. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13538. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13540. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13542. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13544. /***/ }),
  13545. /***/ "./3D/controls/meshButton3D.ts":
  13546. /*!*************************************!*\
  13547. !*** ./3D/controls/meshButton3D.ts ***!
  13548. \*************************************/
  13549. /*! exports provided: MeshButton3D */
  13550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13551. "use strict";
  13552. __webpack_require__.r(__webpack_exports__);
  13553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13554. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13555. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13556. /**
  13557. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13558. */
  13559. var MeshButton3D = /** @class */ (function (_super) {
  13560. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13561. /**
  13562. * Creates a new 3D button based on a mesh
  13563. * @param mesh mesh to become a 3D button
  13564. * @param name defines the control name
  13565. */
  13566. function MeshButton3D(mesh, name) {
  13567. var _this = _super.call(this, name) || this;
  13568. _this._currentMesh = mesh;
  13569. /**
  13570. * Provides a default behavior on hover/out & up/down
  13571. * Override those function to create your own desired behavior specific to your mesh
  13572. */
  13573. _this.pointerEnterAnimation = function () {
  13574. if (!_this.mesh) {
  13575. return;
  13576. }
  13577. _this.mesh.scaling.scaleInPlace(1.1);
  13578. };
  13579. _this.pointerOutAnimation = function () {
  13580. if (!_this.mesh) {
  13581. return;
  13582. }
  13583. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13584. };
  13585. _this.pointerDownAnimation = function () {
  13586. if (!_this.mesh) {
  13587. return;
  13588. }
  13589. _this.mesh.scaling.scaleInPlace(0.95);
  13590. };
  13591. _this.pointerUpAnimation = function () {
  13592. if (!_this.mesh) {
  13593. return;
  13594. }
  13595. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13596. };
  13597. return _this;
  13598. }
  13599. MeshButton3D.prototype._getTypeName = function () {
  13600. return "MeshButton3D";
  13601. };
  13602. // Mesh association
  13603. MeshButton3D.prototype._createNode = function (scene) {
  13604. var _this = this;
  13605. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13606. mesh.metadata = _this;
  13607. });
  13608. return this._currentMesh;
  13609. };
  13610. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13611. };
  13612. return MeshButton3D;
  13613. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13614. /***/ }),
  13615. /***/ "./3D/controls/planePanel.ts":
  13616. /*!***********************************!*\
  13617. !*** ./3D/controls/planePanel.ts ***!
  13618. \***********************************/
  13619. /*! exports provided: PlanePanel */
  13620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13621. "use strict";
  13622. __webpack_require__.r(__webpack_exports__);
  13623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13624. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13625. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13626. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13627. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13628. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13629. /**
  13630. * Class used to create a container panel deployed on the surface of a plane
  13631. */
  13632. var PlanePanel = /** @class */ (function (_super) {
  13633. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13634. function PlanePanel() {
  13635. return _super !== null && _super.apply(this, arguments) || this;
  13636. }
  13637. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13638. var mesh = control.mesh;
  13639. if (!mesh) {
  13640. return;
  13641. }
  13642. control.position = nodePosition.clone();
  13643. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13644. target.copyFrom(nodePosition);
  13645. switch (this.orientation) {
  13646. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13647. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13648. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13649. mesh.lookAt(target);
  13650. break;
  13651. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13652. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13653. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13654. mesh.lookAt(target);
  13655. break;
  13656. }
  13657. };
  13658. return PlanePanel;
  13659. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13660. /***/ }),
  13661. /***/ "./3D/controls/scatterPanel.ts":
  13662. /*!*************************************!*\
  13663. !*** ./3D/controls/scatterPanel.ts ***!
  13664. \*************************************/
  13665. /*! exports provided: ScatterPanel */
  13666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13667. "use strict";
  13668. __webpack_require__.r(__webpack_exports__);
  13669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13670. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13671. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13672. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13673. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13674. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13675. /**
  13676. * Class used to create a container panel where items get randomized planar mapping
  13677. */
  13678. var ScatterPanel = /** @class */ (function (_super) {
  13679. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13680. function ScatterPanel() {
  13681. var _this = _super !== null && _super.apply(this, arguments) || this;
  13682. _this._iteration = 100.0;
  13683. return _this;
  13684. }
  13685. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13686. /**
  13687. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13688. */
  13689. get: function () {
  13690. return this._iteration;
  13691. },
  13692. set: function (value) {
  13693. var _this = this;
  13694. if (this._iteration === value) {
  13695. return;
  13696. }
  13697. this._iteration = value;
  13698. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13699. _this._arrangeChildren();
  13700. });
  13701. },
  13702. enumerable: true,
  13703. configurable: true
  13704. });
  13705. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13706. var mesh = control.mesh;
  13707. var newPos = this._scatterMapping(nodePosition);
  13708. if (!mesh) {
  13709. return;
  13710. }
  13711. switch (this.orientation) {
  13712. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13713. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13714. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13715. break;
  13716. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13717. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13718. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13719. break;
  13720. }
  13721. control.position = newPos;
  13722. };
  13723. ScatterPanel.prototype._scatterMapping = function (source) {
  13724. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13725. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13726. return source;
  13727. };
  13728. ScatterPanel.prototype._finalProcessing = function () {
  13729. var meshes = [];
  13730. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13731. var child = _a[_i];
  13732. if (!child.mesh) {
  13733. continue;
  13734. }
  13735. meshes.push(child.mesh);
  13736. }
  13737. for (var count = 0; count < this._iteration; count++) {
  13738. meshes.sort(function (a, b) {
  13739. var distance1 = a.position.lengthSquared();
  13740. var distance2 = b.position.lengthSquared();
  13741. if (distance1 < distance2) {
  13742. return 1;
  13743. }
  13744. else if (distance1 > distance2) {
  13745. return -1;
  13746. }
  13747. return 0;
  13748. });
  13749. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13750. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13751. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  13752. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13753. for (var i = 0; i < meshes.length - 1; i++) {
  13754. for (var j = i + 1; j < meshes.length; j++) {
  13755. if (i != j) {
  13756. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13757. // Ignore Z axis
  13758. difference2D.x = difference.x;
  13759. difference2D.y = difference.y;
  13760. var combinedRadius = cellSize;
  13761. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13762. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13763. distance -= minSeparation;
  13764. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13765. difference2D.normalize();
  13766. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13767. meshes[j].position.addInPlace(difference);
  13768. meshes[i].position.subtractInPlace(difference);
  13769. }
  13770. }
  13771. }
  13772. }
  13773. }
  13774. };
  13775. return ScatterPanel;
  13776. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13777. /***/ }),
  13778. /***/ "./3D/controls/spherePanel.ts":
  13779. /*!************************************!*\
  13780. !*** ./3D/controls/spherePanel.ts ***!
  13781. \************************************/
  13782. /*! exports provided: SpherePanel */
  13783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13784. "use strict";
  13785. __webpack_require__.r(__webpack_exports__);
  13786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13787. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13788. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13789. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13790. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13791. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13792. /**
  13793. * Class used to create a container panel deployed on the surface of a sphere
  13794. */
  13795. var SpherePanel = /** @class */ (function (_super) {
  13796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13797. function SpherePanel() {
  13798. var _this = _super !== null && _super.apply(this, arguments) || this;
  13799. _this._radius = 5.0;
  13800. return _this;
  13801. }
  13802. Object.defineProperty(SpherePanel.prototype, "radius", {
  13803. /**
  13804. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13805. */
  13806. get: function () {
  13807. return this._radius;
  13808. },
  13809. set: function (value) {
  13810. var _this = this;
  13811. if (this._radius === value) {
  13812. return;
  13813. }
  13814. this._radius = value;
  13815. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13816. _this._arrangeChildren();
  13817. });
  13818. },
  13819. enumerable: true,
  13820. configurable: true
  13821. });
  13822. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13823. var mesh = control.mesh;
  13824. if (!mesh) {
  13825. return;
  13826. }
  13827. var newPos = this._sphericalMapping(nodePosition);
  13828. control.position = newPos;
  13829. switch (this.orientation) {
  13830. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13831. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13832. break;
  13833. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13834. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13835. break;
  13836. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13837. break;
  13838. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13839. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13840. break;
  13841. }
  13842. };
  13843. SpherePanel.prototype._sphericalMapping = function (source) {
  13844. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13845. var xAngle = (source.y / this._radius);
  13846. var yAngle = -(source.x / this._radius);
  13847. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13848. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13849. };
  13850. return SpherePanel;
  13851. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13852. /***/ }),
  13853. /***/ "./3D/controls/stackPanel3D.ts":
  13854. /*!*************************************!*\
  13855. !*** ./3D/controls/stackPanel3D.ts ***!
  13856. \*************************************/
  13857. /*! exports provided: StackPanel3D */
  13858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13859. "use strict";
  13860. __webpack_require__.r(__webpack_exports__);
  13861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13862. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13863. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13864. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13865. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13866. /**
  13867. * Class used to create a stack panel in 3D on XY plane
  13868. */
  13869. var StackPanel3D = /** @class */ (function (_super) {
  13870. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13871. /**
  13872. * Creates new StackPanel
  13873. * @param isVertical
  13874. */
  13875. function StackPanel3D(isVertical) {
  13876. if (isVertical === void 0) { isVertical = false; }
  13877. var _this = _super.call(this) || this;
  13878. _this._isVertical = false;
  13879. /**
  13880. * Gets or sets the distance between elements
  13881. */
  13882. _this.margin = 0.1;
  13883. _this._isVertical = isVertical;
  13884. return _this;
  13885. }
  13886. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13887. /**
  13888. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13889. */
  13890. get: function () {
  13891. return this._isVertical;
  13892. },
  13893. set: function (value) {
  13894. var _this = this;
  13895. if (this._isVertical === value) {
  13896. return;
  13897. }
  13898. this._isVertical = value;
  13899. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13900. _this._arrangeChildren();
  13901. });
  13902. },
  13903. enumerable: true,
  13904. configurable: true
  13905. });
  13906. StackPanel3D.prototype._arrangeChildren = function () {
  13907. var width = 0;
  13908. var height = 0;
  13909. var controlCount = 0;
  13910. var extendSizes = [];
  13911. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13912. // Measure
  13913. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13914. var child = _a[_i];
  13915. if (!child.mesh) {
  13916. continue;
  13917. }
  13918. controlCount++;
  13919. child.mesh.computeWorldMatrix(true);
  13920. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13921. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13922. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13923. extendSizes.push(extendSize);
  13924. if (this._isVertical) {
  13925. height += extendSize.y;
  13926. }
  13927. else {
  13928. width += extendSize.x;
  13929. }
  13930. }
  13931. if (this._isVertical) {
  13932. height += (controlCount - 1) * this.margin / 2;
  13933. }
  13934. else {
  13935. width += (controlCount - 1) * this.margin / 2;
  13936. }
  13937. // Arrange
  13938. var offset;
  13939. if (this._isVertical) {
  13940. offset = -height;
  13941. }
  13942. else {
  13943. offset = -width;
  13944. }
  13945. var index = 0;
  13946. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13947. var child = _c[_b];
  13948. if (!child.mesh) {
  13949. continue;
  13950. }
  13951. controlCount--;
  13952. var extendSize = extendSizes[index++];
  13953. if (this._isVertical) {
  13954. child.position.y = offset + extendSize.y;
  13955. child.position.x = 0;
  13956. offset += extendSize.y * 2;
  13957. }
  13958. else {
  13959. child.position.x = offset + extendSize.x;
  13960. child.position.y = 0;
  13961. offset += extendSize.x * 2;
  13962. }
  13963. offset += (controlCount > 0 ? this.margin : 0);
  13964. }
  13965. };
  13966. return StackPanel3D;
  13967. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13968. /***/ }),
  13969. /***/ "./3D/controls/volumeBasedPanel.ts":
  13970. /*!*****************************************!*\
  13971. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13972. \*****************************************/
  13973. /*! exports provided: VolumeBasedPanel */
  13974. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13975. "use strict";
  13976. __webpack_require__.r(__webpack_exports__);
  13977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13978. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13979. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13980. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13981. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13982. /**
  13983. * Abstract class used to create a container panel deployed on the surface of a volume
  13984. */
  13985. var VolumeBasedPanel = /** @class */ (function (_super) {
  13986. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13987. /**
  13988. * Creates new VolumeBasedPanel
  13989. */
  13990. function VolumeBasedPanel() {
  13991. var _this = _super.call(this) || this;
  13992. _this._columns = 10;
  13993. _this._rows = 0;
  13994. _this._rowThenColum = true;
  13995. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13996. /**
  13997. * Gets or sets the distance between elements
  13998. */
  13999. _this.margin = 0;
  14000. return _this;
  14001. }
  14002. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14003. /**
  14004. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14005. * | Value | Type | Description |
  14006. * | ----- | ----------------------------------- | ----------- |
  14007. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14008. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14009. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14010. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14011. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14012. */
  14013. get: function () {
  14014. return this._orientation;
  14015. },
  14016. set: function (value) {
  14017. var _this = this;
  14018. if (this._orientation === value) {
  14019. return;
  14020. }
  14021. this._orientation = value;
  14022. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14023. _this._arrangeChildren();
  14024. });
  14025. },
  14026. enumerable: true,
  14027. configurable: true
  14028. });
  14029. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14030. /**
  14031. * Gets or sets the number of columns requested (10 by default).
  14032. * The panel will automatically compute the number of rows based on number of child controls.
  14033. */
  14034. get: function () {
  14035. return this._columns;
  14036. },
  14037. set: function (value) {
  14038. var _this = this;
  14039. if (this._columns === value) {
  14040. return;
  14041. }
  14042. this._columns = value;
  14043. this._rowThenColum = true;
  14044. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14045. _this._arrangeChildren();
  14046. });
  14047. },
  14048. enumerable: true,
  14049. configurable: true
  14050. });
  14051. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14052. /**
  14053. * Gets or sets a the number of rows requested.
  14054. * The panel will automatically compute the number of columns based on number of child controls.
  14055. */
  14056. get: function () {
  14057. return this._rows;
  14058. },
  14059. set: function (value) {
  14060. var _this = this;
  14061. if (this._rows === value) {
  14062. return;
  14063. }
  14064. this._rows = value;
  14065. this._rowThenColum = false;
  14066. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14067. _this._arrangeChildren();
  14068. });
  14069. },
  14070. enumerable: true,
  14071. configurable: true
  14072. });
  14073. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14074. this._cellWidth = 0;
  14075. this._cellHeight = 0;
  14076. var rows = 0;
  14077. var columns = 0;
  14078. var controlCount = 0;
  14079. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14080. // Measure
  14081. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14082. var child = _a[_i];
  14083. if (!child.mesh) {
  14084. continue;
  14085. }
  14086. controlCount++;
  14087. child.mesh.computeWorldMatrix(true);
  14088. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14089. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14090. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14091. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14092. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14093. diff.scaleInPlace(0.5);
  14094. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14095. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14096. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14097. }
  14098. this._cellWidth += this.margin * 2;
  14099. this._cellHeight += this.margin * 2;
  14100. // Arrange
  14101. if (this._rowThenColum) {
  14102. columns = this._columns;
  14103. rows = Math.ceil(controlCount / this._columns);
  14104. }
  14105. else {
  14106. rows = this._rows;
  14107. columns = Math.ceil(controlCount / this._rows);
  14108. }
  14109. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14110. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14111. var nodeGrid = [];
  14112. var cellCounter = 0;
  14113. if (this._rowThenColum) {
  14114. for (var r = 0; r < rows; r++) {
  14115. for (var c = 0; c < columns; c++) {
  14116. 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));
  14117. cellCounter++;
  14118. if (cellCounter > controlCount) {
  14119. break;
  14120. }
  14121. }
  14122. }
  14123. }
  14124. else {
  14125. for (var c = 0; c < columns; c++) {
  14126. for (var r = 0; r < rows; r++) {
  14127. 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));
  14128. cellCounter++;
  14129. if (cellCounter > controlCount) {
  14130. break;
  14131. }
  14132. }
  14133. }
  14134. }
  14135. cellCounter = 0;
  14136. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14137. var child = _c[_b];
  14138. if (!child.mesh) {
  14139. continue;
  14140. }
  14141. this._mapGridNode(child, nodeGrid[cellCounter]);
  14142. cellCounter++;
  14143. }
  14144. this._finalProcessing();
  14145. };
  14146. /** Child classes can implement this function to provide additional processing */
  14147. VolumeBasedPanel.prototype._finalProcessing = function () {
  14148. };
  14149. return VolumeBasedPanel;
  14150. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14151. /***/ }),
  14152. /***/ "./3D/gui3DManager.ts":
  14153. /*!****************************!*\
  14154. !*** ./3D/gui3DManager.ts ***!
  14155. \****************************/
  14156. /*! exports provided: GUI3DManager */
  14157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14158. "use strict";
  14159. __webpack_require__.r(__webpack_exports__);
  14160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14161. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  14162. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14163. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14164. /**
  14165. * Class used to manage 3D user interface
  14166. * @see http://doc.babylonjs.com/how_to/gui3d
  14167. */
  14168. var GUI3DManager = /** @class */ (function () {
  14169. /**
  14170. * Creates a new GUI3DManager
  14171. * @param scene
  14172. */
  14173. function GUI3DManager(scene) {
  14174. var _this = this;
  14175. /** @hidden */
  14176. this._lastControlOver = {};
  14177. /** @hidden */
  14178. this._lastControlDown = {};
  14179. /**
  14180. * Observable raised when the point picked by the pointer events changed
  14181. */
  14182. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14183. // Shared resources
  14184. /** @hidden */
  14185. this._sharedMaterials = {};
  14186. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14187. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14188. _this._sceneDisposeObserver = null;
  14189. _this._utilityLayer = null;
  14190. _this.dispose();
  14191. });
  14192. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14193. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14194. this._utilityLayer.pickUtilitySceneFirst = false;
  14195. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14196. return mesh && mesh.metadata && mesh.metadata._node;
  14197. };
  14198. // Root
  14199. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14200. this._rootContainer._host = this;
  14201. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14202. // Events
  14203. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14204. _this._handlePointerOut(pointerId, true);
  14205. });
  14206. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14207. _this._doPicking(pi);
  14208. });
  14209. // Scene
  14210. this._utilityLayer.utilityLayerScene.autoClear = false;
  14211. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14212. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14213. }
  14214. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14215. /** Gets the hosting scene */
  14216. get: function () {
  14217. return this._scene;
  14218. },
  14219. enumerable: true,
  14220. configurable: true
  14221. });
  14222. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14223. /** Gets associated utility layer */
  14224. get: function () {
  14225. return this._utilityLayer;
  14226. },
  14227. enumerable: true,
  14228. configurable: true
  14229. });
  14230. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14231. var previousControlOver = this._lastControlOver[pointerId];
  14232. if (previousControlOver) {
  14233. previousControlOver._onPointerOut(previousControlOver);
  14234. delete this._lastControlOver[pointerId];
  14235. }
  14236. if (isPointerUp) {
  14237. if (this._lastControlDown[pointerId]) {
  14238. this._lastControlDown[pointerId].forcePointerUp();
  14239. delete this._lastControlDown[pointerId];
  14240. }
  14241. }
  14242. this.onPickedPointChangedObservable.notifyObservers(null);
  14243. };
  14244. GUI3DManager.prototype._doPicking = function (pi) {
  14245. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14246. return false;
  14247. }
  14248. var pointerEvent = (pi.event);
  14249. var pointerId = pointerEvent.pointerId || 0;
  14250. var buttonIndex = pointerEvent.button;
  14251. var pickingInfo = pi.pickInfo;
  14252. if (!pickingInfo || !pickingInfo.hit) {
  14253. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14254. return false;
  14255. }
  14256. var control = (pickingInfo.pickedMesh.metadata);
  14257. if (pickingInfo.pickedPoint) {
  14258. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14259. }
  14260. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14261. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14262. if (this._lastControlOver[pointerId]) {
  14263. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14264. }
  14265. delete this._lastControlOver[pointerId];
  14266. }
  14267. }
  14268. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14269. if (this._lastControlDown[pointerEvent.pointerId]) {
  14270. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14271. delete this._lastControlDown[pointerEvent.pointerId];
  14272. }
  14273. if (pointerEvent.pointerType === "touch") {
  14274. this._handlePointerOut(pointerId, false);
  14275. }
  14276. }
  14277. return true;
  14278. };
  14279. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14280. /**
  14281. * Gets the root container
  14282. */
  14283. get: function () {
  14284. return this._rootContainer;
  14285. },
  14286. enumerable: true,
  14287. configurable: true
  14288. });
  14289. /**
  14290. * Gets a boolean indicating if the given control is in the root child list
  14291. * @param control defines the control to check
  14292. * @returns true if the control is in the root child list
  14293. */
  14294. GUI3DManager.prototype.containsControl = function (control) {
  14295. return this._rootContainer.containsControl(control);
  14296. };
  14297. /**
  14298. * Adds a control to the root child list
  14299. * @param control defines the control to add
  14300. * @returns the current manager
  14301. */
  14302. GUI3DManager.prototype.addControl = function (control) {
  14303. this._rootContainer.addControl(control);
  14304. return this;
  14305. };
  14306. /**
  14307. * Removes a control from the root child list
  14308. * @param control defines the control to remove
  14309. * @returns the current container
  14310. */
  14311. GUI3DManager.prototype.removeControl = function (control) {
  14312. this._rootContainer.removeControl(control);
  14313. return this;
  14314. };
  14315. /**
  14316. * Releases all associated resources
  14317. */
  14318. GUI3DManager.prototype.dispose = function () {
  14319. this._rootContainer.dispose();
  14320. for (var materialName in this._sharedMaterials) {
  14321. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14322. continue;
  14323. }
  14324. this._sharedMaterials[materialName].dispose();
  14325. }
  14326. this._sharedMaterials = {};
  14327. if (this._pointerOutObserver && this._utilityLayer) {
  14328. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14329. this._pointerOutObserver = null;
  14330. }
  14331. this.onPickedPointChangedObservable.clear();
  14332. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14333. if (utilityLayerScene) {
  14334. if (this._pointerObserver) {
  14335. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14336. this._pointerObserver = null;
  14337. }
  14338. }
  14339. if (this._scene) {
  14340. if (this._sceneDisposeObserver) {
  14341. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14342. this._sceneDisposeObserver = null;
  14343. }
  14344. }
  14345. if (this._utilityLayer) {
  14346. this._utilityLayer.dispose();
  14347. }
  14348. };
  14349. return GUI3DManager;
  14350. }());
  14351. /***/ }),
  14352. /***/ "./3D/index.ts":
  14353. /*!*********************!*\
  14354. !*** ./3D/index.ts ***!
  14355. \*********************/
  14356. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14358. "use strict";
  14359. __webpack_require__.r(__webpack_exports__);
  14360. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14373. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14376. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14378. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14380. /***/ }),
  14381. /***/ "./3D/materials/fluentMaterial.ts":
  14382. /*!****************************************!*\
  14383. !*** ./3D/materials/fluentMaterial.ts ***!
  14384. \****************************************/
  14385. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14387. "use strict";
  14388. __webpack_require__.r(__webpack_exports__);
  14389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14391. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14392. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math");
  14393. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14394. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14395. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14396. /** @hidden */
  14397. var FluentMaterialDefines = /** @class */ (function (_super) {
  14398. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14399. function FluentMaterialDefines() {
  14400. var _this = _super.call(this) || this;
  14401. _this.INNERGLOW = false;
  14402. _this.BORDER = false;
  14403. _this.HOVERLIGHT = false;
  14404. _this.TEXTURE = false;
  14405. _this.rebuild();
  14406. return _this;
  14407. }
  14408. return FluentMaterialDefines;
  14409. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14410. /**
  14411. * Class used to render controls with fluent desgin
  14412. */
  14413. var FluentMaterial = /** @class */ (function (_super) {
  14414. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14415. /**
  14416. * Creates a new Fluent material
  14417. * @param name defines the name of the material
  14418. * @param scene defines the hosting scene
  14419. */
  14420. function FluentMaterial(name, scene) {
  14421. var _this = _super.call(this, name, scene) || this;
  14422. /**
  14423. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14424. */
  14425. _this.innerGlowColorIntensity = 0.5;
  14426. /**
  14427. * Gets or sets the inner glow color (white by default)
  14428. */
  14429. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14430. /**
  14431. * Gets or sets alpha value (default is 1.0)
  14432. */
  14433. _this.alpha = 1.0;
  14434. /**
  14435. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14436. */
  14437. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14438. /**
  14439. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14440. */
  14441. _this.renderBorders = false;
  14442. /**
  14443. * Gets or sets border width (default is 0.5)
  14444. */
  14445. _this.borderWidth = 0.5;
  14446. /**
  14447. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14448. */
  14449. _this.edgeSmoothingValue = 0.02;
  14450. /**
  14451. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14452. */
  14453. _this.borderMinValue = 0.1;
  14454. /**
  14455. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14456. */
  14457. _this.renderHoverLight = false;
  14458. /**
  14459. * Gets or sets the radius used to render the hover light (default is 1.0)
  14460. */
  14461. _this.hoverRadius = 1.0;
  14462. /**
  14463. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14464. */
  14465. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14466. /**
  14467. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14468. */
  14469. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14470. return _this;
  14471. }
  14472. FluentMaterial.prototype.needAlphaBlending = function () {
  14473. return this.alpha !== 1.0;
  14474. };
  14475. FluentMaterial.prototype.needAlphaTesting = function () {
  14476. return false;
  14477. };
  14478. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14479. return null;
  14480. };
  14481. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14482. if (this.isFrozen) {
  14483. if (this._wasPreviouslyReady && subMesh.effect) {
  14484. return true;
  14485. }
  14486. }
  14487. if (!subMesh._materialDefines) {
  14488. subMesh._materialDefines = new FluentMaterialDefines();
  14489. }
  14490. var scene = this.getScene();
  14491. var defines = subMesh._materialDefines;
  14492. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14493. if (defines._renderId === scene.getRenderId()) {
  14494. return true;
  14495. }
  14496. }
  14497. if (defines._areTexturesDirty) {
  14498. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14499. defines.BORDER = this.renderBorders;
  14500. defines.HOVERLIGHT = this.renderHoverLight;
  14501. if (this._albedoTexture) {
  14502. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14503. return false;
  14504. }
  14505. else {
  14506. defines.TEXTURE = true;
  14507. }
  14508. }
  14509. else {
  14510. defines.TEXTURE = false;
  14511. }
  14512. }
  14513. var engine = scene.getEngine();
  14514. // Get correct effect
  14515. if (defines.isDirty) {
  14516. defines.markAsProcessed();
  14517. scene.resetCachedMaterial();
  14518. //Attributes
  14519. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14520. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14521. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14522. var shaderName = "fluent";
  14523. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14524. "hoverColor", "hoverPosition", "hoverRadius"
  14525. ];
  14526. var samplers = ["albedoSampler"];
  14527. var uniformBuffers = new Array();
  14528. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14529. uniformsNames: uniforms,
  14530. uniformBuffersNames: uniformBuffers,
  14531. samplers: samplers,
  14532. defines: defines,
  14533. maxSimultaneousLights: 4
  14534. });
  14535. var join = defines.toString();
  14536. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14537. attributes: attribs,
  14538. uniformsNames: uniforms,
  14539. uniformBuffersNames: uniformBuffers,
  14540. samplers: samplers,
  14541. defines: join,
  14542. fallbacks: null,
  14543. onCompiled: this.onCompiled,
  14544. onError: this.onError,
  14545. indexParameters: { maxSimultaneousLights: 4 }
  14546. }, engine));
  14547. }
  14548. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14549. return false;
  14550. }
  14551. defines._renderId = scene.getRenderId();
  14552. this._wasPreviouslyReady = true;
  14553. return true;
  14554. };
  14555. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14556. var scene = this.getScene();
  14557. var defines = subMesh._materialDefines;
  14558. if (!defines) {
  14559. return;
  14560. }
  14561. var effect = subMesh.effect;
  14562. if (!effect) {
  14563. return;
  14564. }
  14565. this._activeEffect = effect;
  14566. // Matrices
  14567. this.bindOnlyWorldMatrix(world);
  14568. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14569. if (this._mustRebind(scene, effect)) {
  14570. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14571. if (defines.INNERGLOW) {
  14572. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14573. }
  14574. if (defines.BORDER) {
  14575. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14576. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14577. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14578. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14579. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14580. }
  14581. if (defines.HOVERLIGHT) {
  14582. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14583. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14584. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14585. }
  14586. if (defines.TEXTURE) {
  14587. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14588. }
  14589. }
  14590. this._afterBind(mesh, this._activeEffect);
  14591. };
  14592. FluentMaterial.prototype.getActiveTextures = function () {
  14593. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14594. return activeTextures;
  14595. };
  14596. FluentMaterial.prototype.hasTexture = function (texture) {
  14597. if (_super.prototype.hasTexture.call(this, texture)) {
  14598. return true;
  14599. }
  14600. return false;
  14601. };
  14602. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14603. _super.prototype.dispose.call(this, forceDisposeEffect);
  14604. };
  14605. FluentMaterial.prototype.clone = function (name) {
  14606. var _this = this;
  14607. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14608. };
  14609. FluentMaterial.prototype.serialize = function () {
  14610. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14611. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14612. return serializationObject;
  14613. };
  14614. FluentMaterial.prototype.getClassName = function () {
  14615. return "FluentMaterial";
  14616. };
  14617. // Statics
  14618. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14619. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14620. };
  14621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14622. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14623. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14624. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14626. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14627. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14629. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14630. ], FluentMaterial.prototype, "alpha", void 0);
  14631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14632. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14633. ], FluentMaterial.prototype, "albedoColor", void 0);
  14634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14635. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14636. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14637. ], FluentMaterial.prototype, "renderBorders", void 0);
  14638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14639. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14640. ], FluentMaterial.prototype, "borderWidth", void 0);
  14641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14642. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14643. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14645. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14646. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14648. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14649. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14650. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14652. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14653. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14655. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14656. ], FluentMaterial.prototype, "hoverColor", void 0);
  14657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14658. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14659. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14661. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14662. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14664. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14665. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14666. return FluentMaterial;
  14667. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14668. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14669. /***/ }),
  14670. /***/ "./3D/materials/index.ts":
  14671. /*!*******************************!*\
  14672. !*** ./3D/materials/index.ts ***!
  14673. \*******************************/
  14674. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14676. "use strict";
  14677. __webpack_require__.r(__webpack_exports__);
  14678. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14681. /***/ }),
  14682. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14683. /*!*************************************************!*\
  14684. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14685. \*************************************************/
  14686. /*! exports provided: fluentPixelShader */
  14687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14688. "use strict";
  14689. __webpack_require__.r(__webpack_exports__);
  14690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14691. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  14692. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14693. var name = 'fluentPixelShader';
  14694. 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}";
  14695. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14696. /** @hidden */
  14697. var fluentPixelShader = { name: name, shader: shader };
  14698. /***/ }),
  14699. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14700. /*!***********************************************!*\
  14701. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14702. \***********************************************/
  14703. /*! exports provided: fluentVertexShader */
  14704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14705. "use strict";
  14706. __webpack_require__.r(__webpack_exports__);
  14707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14708. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  14709. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14710. var name = 'fluentVertexShader';
  14711. 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";
  14712. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14713. /** @hidden */
  14714. var fluentVertexShader = { name: name, shader: shader };
  14715. /***/ }),
  14716. /***/ "./3D/vector3WithInfo.ts":
  14717. /*!*******************************!*\
  14718. !*** ./3D/vector3WithInfo.ts ***!
  14719. \*******************************/
  14720. /*! exports provided: Vector3WithInfo */
  14721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14722. "use strict";
  14723. __webpack_require__.r(__webpack_exports__);
  14724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14725. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14726. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14727. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14728. /**
  14729. * Class used to transport Vector3 information for pointer events
  14730. */
  14731. var Vector3WithInfo = /** @class */ (function (_super) {
  14732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14733. /**
  14734. * Creates a new Vector3WithInfo
  14735. * @param source defines the vector3 data to transport
  14736. * @param buttonIndex defines the current mouse button index
  14737. */
  14738. function Vector3WithInfo(source,
  14739. /** defines the current mouse button index */
  14740. buttonIndex) {
  14741. if (buttonIndex === void 0) { buttonIndex = 0; }
  14742. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14743. _this.buttonIndex = buttonIndex;
  14744. return _this;
  14745. }
  14746. return Vector3WithInfo;
  14747. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14748. /***/ }),
  14749. /***/ "./index.ts":
  14750. /*!******************!*\
  14751. !*** ./index.ts ***!
  14752. \******************/
  14753. /*! 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 */
  14754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14755. "use strict";
  14756. __webpack_require__.r(__webpack_exports__);
  14757. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14797. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14814. /***/ }),
  14815. /***/ "./legacy/legacy.ts":
  14816. /*!**************************!*\
  14817. !*** ./legacy/legacy.ts ***!
  14818. \**************************/
  14819. /*! 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 */
  14820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14821. "use strict";
  14822. __webpack_require__.r(__webpack_exports__);
  14823. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14879. /**
  14880. * Legacy support, defining window.BABYLON.GUI (global variable).
  14881. *
  14882. * This is the entry point for the UMD module.
  14883. * The entry point for a future ESM package should be index.ts
  14884. */
  14885. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14886. if (typeof globalObject !== "undefined") {
  14887. globalObject.BABYLON = globalObject.BABYLON || {};
  14888. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14889. }
  14890. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14891. /***/ }),
  14892. /***/ "babylonjs/Maths/math":
  14893. /*!****************************************************************************************************!*\
  14894. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14895. \****************************************************************************************************/
  14896. /*! no static exports found */
  14897. /***/ (function(module, exports) {
  14898. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math__;
  14899. /***/ })
  14900. /******/ });
  14901. });
  14902. //# sourceMappingURL=babylon.gui.js.map