babylon.gui.js 681 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704
  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. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Maths/math");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /**
  516. * Define type to string to ensure compatibility across browsers
  517. * Safari doesn't support DataTransfer constructor
  518. */
  519. _this._clipboardData = "";
  520. /**
  521. * Observable event triggered each time an clipboard event is received from the rendering canvas
  522. */
  523. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  524. /**
  525. * Observable event triggered each time a pointer down is intercepted by a control
  526. */
  527. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered before layout is evaluated
  530. */
  531. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered after the layout was evaluated
  534. */
  535. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered before the texture is rendered
  538. */
  539. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered after the texture was rendered
  542. */
  543. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Gets or sets a boolean defining if alpha is stored as premultiplied
  546. */
  547. _this.premulAlpha = false;
  548. _this._useInvalidateRectOptimization = true;
  549. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  550. _this._invalidatedRectangle = null;
  551. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  552. /** @hidden */
  553. _this.onClipboardCopy = function (rawEvt) {
  554. var evt = rawEvt;
  555. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  556. _this.onClipboardObservable.notifyObservers(ev);
  557. evt.preventDefault();
  558. };
  559. /** @hidden */
  560. _this.onClipboardCut = function (rawEvt) {
  561. var evt = rawEvt;
  562. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  563. _this.onClipboardObservable.notifyObservers(ev);
  564. evt.preventDefault();
  565. };
  566. /** @hidden */
  567. _this.onClipboardPaste = function (rawEvt) {
  568. var evt = rawEvt;
  569. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  570. _this.onClipboardObservable.notifyObservers(ev);
  571. evt.preventDefault();
  572. };
  573. scene = _this.getScene();
  574. if (!scene || !_this._texture) {
  575. return _this;
  576. }
  577. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  578. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  579. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  580. if (!_this._focusedControl) {
  581. return;
  582. }
  583. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  584. _this._focusedControl.processKeyboard(info.event);
  585. }
  586. info.skipOnPointerObservable = true;
  587. });
  588. _this._rootContainer._link(_this);
  589. _this.hasAlpha = true;
  590. if (!width || !height) {
  591. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  592. _this._onResize();
  593. }
  594. _this._texture.isReady = true;
  595. return _this;
  596. }
  597. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  598. /**
  599. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  600. * Useful when you want more antialiasing
  601. */
  602. get: function () {
  603. return this._renderScale;
  604. },
  605. set: function (value) {
  606. if (value === this._renderScale) {
  607. return;
  608. }
  609. this._renderScale = value;
  610. this._onResize();
  611. },
  612. enumerable: true,
  613. configurable: true
  614. });
  615. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  616. /** Gets or sets the background color */
  617. get: function () {
  618. return this._background;
  619. },
  620. set: function (value) {
  621. if (this._background === value) {
  622. return;
  623. }
  624. this._background = value;
  625. this.markAsDirty();
  626. },
  627. enumerable: true,
  628. configurable: true
  629. });
  630. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  631. /**
  632. * Gets or sets the ideal width used to design controls.
  633. * The GUI will then rescale everything accordingly
  634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  635. */
  636. get: function () {
  637. return this._idealWidth;
  638. },
  639. set: function (value) {
  640. if (this._idealWidth === value) {
  641. return;
  642. }
  643. this._idealWidth = value;
  644. this.markAsDirty();
  645. this._rootContainer._markAllAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  651. /**
  652. * Gets or sets the ideal height used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealHeight;
  658. },
  659. set: function (value) {
  660. if (this._idealHeight === value) {
  661. return;
  662. }
  663. this._idealHeight = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  671. /**
  672. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  673. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  674. */
  675. get: function () {
  676. return this._useSmallestIdeal;
  677. },
  678. set: function (value) {
  679. if (this._useSmallestIdeal === value) {
  680. return;
  681. }
  682. this._useSmallestIdeal = value;
  683. this.markAsDirty();
  684. this._rootContainer._markAllAsDirty();
  685. },
  686. enumerable: true,
  687. configurable: true
  688. });
  689. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  690. /**
  691. * Gets or sets a boolean indicating if adaptive scaling must be used
  692. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  693. */
  694. get: function () {
  695. return this._renderAtIdealSize;
  696. },
  697. set: function (value) {
  698. if (this._renderAtIdealSize === value) {
  699. return;
  700. }
  701. this._renderAtIdealSize = value;
  702. this._onResize();
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  708. /**
  709. * Gets the underlying layer used to render the texture when in fullscreen mode
  710. */
  711. get: function () {
  712. return this._layerToDispose;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  718. /**
  719. * Gets the root container control
  720. */
  721. get: function () {
  722. return this._rootContainer;
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. /**
  728. * Returns an array containing the root container.
  729. * This is mostly used to let the Inspector introspects the ADT
  730. * @returns an array containing the rootContainer
  731. */
  732. AdvancedDynamicTexture.prototype.getChildren = function () {
  733. return [this._rootContainer];
  734. };
  735. /**
  736. * Will return all controls that are inside this texture
  737. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  738. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  739. * @return all child controls
  740. */
  741. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  742. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  743. };
  744. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  745. /**
  746. * Gets or sets the current focused control
  747. */
  748. get: function () {
  749. return this._focusedControl;
  750. },
  751. set: function (control) {
  752. if (this._focusedControl == control) {
  753. return;
  754. }
  755. if (this._focusedControl) {
  756. this._focusedControl.onBlur();
  757. }
  758. if (control) {
  759. control.onFocus();
  760. }
  761. this._focusedControl = control;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  767. /**
  768. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  769. */
  770. get: function () {
  771. if (!this.layer) {
  772. return true;
  773. }
  774. return (!this.layer.isBackground);
  775. },
  776. set: function (value) {
  777. if (!this.layer) {
  778. return;
  779. }
  780. if (this.layer.isBackground === !value) {
  781. return;
  782. }
  783. this.layer.isBackground = !value;
  784. },
  785. enumerable: true,
  786. configurable: true
  787. });
  788. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  789. /**
  790. * Gets or set information about clipboardData
  791. */
  792. get: function () {
  793. return this._clipboardData;
  794. },
  795. set: function (value) {
  796. this._clipboardData = value;
  797. },
  798. enumerable: true,
  799. configurable: true
  800. });
  801. /**
  802. * Get the current class name of the texture useful for serialization or dynamic coding.
  803. * @returns "AdvancedDynamicTexture"
  804. */
  805. AdvancedDynamicTexture.prototype.getClassName = function () {
  806. return "AdvancedDynamicTexture";
  807. };
  808. /**
  809. * Function used to execute a function on all controls
  810. * @param func defines the function to execute
  811. * @param container defines the container where controls belong. If null the root container will be used
  812. */
  813. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  814. if (!container) {
  815. container = this._rootContainer;
  816. }
  817. func(container);
  818. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  819. var child = _a[_i];
  820. if (child.children) {
  821. this.executeOnAllControls(func, child);
  822. continue;
  823. }
  824. func(child);
  825. }
  826. };
  827. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  828. /**
  829. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  830. */
  831. get: function () {
  832. return this._useInvalidateRectOptimization;
  833. },
  834. set: function (value) {
  835. this._useInvalidateRectOptimization = value;
  836. },
  837. enumerable: true,
  838. configurable: true
  839. });
  840. /**
  841. * Invalidates a rectangle area on the gui texture
  842. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  843. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  844. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  845. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  846. */
  847. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  848. if (!this._useInvalidateRectOptimization) {
  849. return;
  850. }
  851. if (!this._invalidatedRectangle) {
  852. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  853. }
  854. else {
  855. // Compute intersection
  856. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  857. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  858. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  859. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  860. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  861. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  862. }
  863. };
  864. /**
  865. * Marks the texture as dirty forcing a complete update
  866. */
  867. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  868. this._isDirty = true;
  869. };
  870. /**
  871. * Helper function used to create a new style
  872. * @returns a new style
  873. * @see http://doc.babylonjs.com/how_to/gui#styles
  874. */
  875. AdvancedDynamicTexture.prototype.createStyle = function () {
  876. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  877. };
  878. /**
  879. * Adds a new control to the root container
  880. * @param control defines the control to add
  881. * @returns the current texture
  882. */
  883. AdvancedDynamicTexture.prototype.addControl = function (control) {
  884. this._rootContainer.addControl(control);
  885. return this;
  886. };
  887. /**
  888. * Removes a control from the root container
  889. * @param control defines the control to remove
  890. * @returns the current texture
  891. */
  892. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  893. this._rootContainer.removeControl(control);
  894. return this;
  895. };
  896. /**
  897. * Release all resources
  898. */
  899. AdvancedDynamicTexture.prototype.dispose = function () {
  900. var scene = this.getScene();
  901. if (!scene) {
  902. return;
  903. }
  904. this._rootCanvas = null;
  905. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  906. if (this._resizeObserver) {
  907. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  908. }
  909. if (this._pointerMoveObserver) {
  910. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  911. }
  912. if (this._pointerObserver) {
  913. scene.onPointerObservable.remove(this._pointerObserver);
  914. }
  915. if (this._preKeyboardObserver) {
  916. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  917. }
  918. if (this._canvasPointerOutObserver) {
  919. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  920. }
  921. if (this._layerToDispose) {
  922. this._layerToDispose.texture = null;
  923. this._layerToDispose.dispose();
  924. this._layerToDispose = null;
  925. }
  926. this._rootContainer.dispose();
  927. this.onClipboardObservable.clear();
  928. this.onControlPickedObservable.clear();
  929. this.onBeginRenderObservable.clear();
  930. this.onEndRenderObservable.clear();
  931. this.onBeginLayoutObservable.clear();
  932. this.onEndLayoutObservable.clear();
  933. _super.prototype.dispose.call(this);
  934. };
  935. AdvancedDynamicTexture.prototype._onResize = function () {
  936. var scene = this.getScene();
  937. if (!scene) {
  938. return;
  939. }
  940. // Check size
  941. var engine = scene.getEngine();
  942. var textureSize = this.getSize();
  943. var renderWidth = engine.getRenderWidth() * this._renderScale;
  944. var renderHeight = engine.getRenderHeight() * this._renderScale;
  945. if (this._renderAtIdealSize) {
  946. if (this._idealWidth) {
  947. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  948. renderWidth = this._idealWidth;
  949. }
  950. else if (this._idealHeight) {
  951. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  952. renderHeight = this._idealHeight;
  953. }
  954. }
  955. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  956. this.scaleTo(renderWidth, renderHeight);
  957. this.markAsDirty();
  958. if (this._idealWidth || this._idealHeight) {
  959. this._rootContainer._markAllAsDirty();
  960. }
  961. }
  962. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  963. };
  964. /** @hidden */
  965. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  966. var engine = scene.getEngine();
  967. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  968. };
  969. /**
  970. * Get screen coordinates for a vector3
  971. * @param position defines the position to project
  972. * @param worldMatrix defines the world matrix to use
  973. * @returns the projected position
  974. */
  975. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  976. var scene = this.getScene();
  977. if (!scene) {
  978. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  979. }
  980. var globalViewport = this._getGlobalViewport(scene);
  981. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  982. projectedPosition.scaleInPlace(this.renderScale);
  983. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  984. };
  985. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  986. if (this._layerToDispose) {
  987. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  988. return;
  989. }
  990. }
  991. if (this._isFullscreen && this._linkedControls.length) {
  992. var scene = this.getScene();
  993. if (!scene) {
  994. return;
  995. }
  996. var globalViewport = this._getGlobalViewport(scene);
  997. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  998. var control = _a[_i];
  999. if (!control.isVisible) {
  1000. continue;
  1001. }
  1002. var mesh = control._linkedMesh;
  1003. if (!mesh || mesh.isDisposed()) {
  1004. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1005. control.linkWithMesh(null);
  1006. });
  1007. continue;
  1008. }
  1009. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1010. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1011. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1012. control.notRenderable = true;
  1013. continue;
  1014. }
  1015. control.notRenderable = false;
  1016. // Account for RenderScale.
  1017. projectedPosition.scaleInPlace(this.renderScale);
  1018. control._moveToProjectedPosition(projectedPosition);
  1019. }
  1020. }
  1021. if (!this._isDirty && !this._rootContainer.isDirty) {
  1022. return;
  1023. }
  1024. this._isDirty = false;
  1025. this._render();
  1026. this.update(true, this.premulAlpha);
  1027. };
  1028. AdvancedDynamicTexture.prototype._render = function () {
  1029. var textureSize = this.getSize();
  1030. var renderWidth = textureSize.width;
  1031. var renderHeight = textureSize.height;
  1032. var context = this.getContext();
  1033. context.font = "18px Arial";
  1034. context.strokeStyle = "white";
  1035. // Layout
  1036. this.onBeginLayoutObservable.notifyObservers(this);
  1037. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1038. this._rootContainer._layout(measure, context);
  1039. this.onEndLayoutObservable.notifyObservers(this);
  1040. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1041. // Clear
  1042. if (this._invalidatedRectangle) {
  1043. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1044. }
  1045. else {
  1046. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1047. }
  1048. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1049. if (this._background) {
  1050. context.save();
  1051. context.fillStyle = this._background;
  1052. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1053. context.restore();
  1054. }
  1055. // Render
  1056. this.onBeginRenderObservable.notifyObservers(this);
  1057. this._rootContainer._render(context, this._invalidatedRectangle);
  1058. this.onEndRenderObservable.notifyObservers(this);
  1059. this._invalidatedRectangle = null;
  1060. };
  1061. /** @hidden */
  1062. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1063. if (this._rootCanvas) {
  1064. this._rootCanvas.style.cursor = cursor;
  1065. this._cursorChanged = true;
  1066. }
  1067. };
  1068. /** @hidden */
  1069. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1070. this._lastControlDown[pointerId] = control;
  1071. this.onControlPickedObservable.notifyObservers(control);
  1072. };
  1073. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1074. var scene = this.getScene();
  1075. if (!scene) {
  1076. return;
  1077. }
  1078. var engine = scene.getEngine();
  1079. var textureSize = this.getSize();
  1080. if (this._isFullscreen) {
  1081. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1082. var viewport = camera.viewport;
  1083. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1084. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1085. }
  1086. if (this._capturingControl[pointerId]) {
  1087. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1088. return;
  1089. }
  1090. this._cursorChanged = false;
  1091. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1092. this._changeCursor("");
  1093. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1094. if (this._lastControlOver[pointerId]) {
  1095. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1096. delete this._lastControlOver[pointerId];
  1097. }
  1098. }
  1099. }
  1100. if (!this._cursorChanged) {
  1101. this._changeCursor("");
  1102. }
  1103. this._manageFocus();
  1104. };
  1105. /** @hidden */
  1106. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1107. for (var pointerId in list) {
  1108. if (!list.hasOwnProperty(pointerId)) {
  1109. continue;
  1110. }
  1111. var lastControlOver = list[pointerId];
  1112. if (lastControlOver === control) {
  1113. delete list[pointerId];
  1114. }
  1115. }
  1116. };
  1117. /** @hidden */
  1118. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1119. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1120. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1121. };
  1122. /** Attach to all scene events required to support pointer events */
  1123. AdvancedDynamicTexture.prototype.attach = function () {
  1124. var _this = this;
  1125. var scene = this.getScene();
  1126. if (!scene) {
  1127. return;
  1128. }
  1129. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1130. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1131. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1132. return;
  1133. }
  1134. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1135. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1136. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1137. return;
  1138. }
  1139. if (!scene) {
  1140. return;
  1141. }
  1142. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1143. var engine = scene.getEngine();
  1144. if (!camera) {
  1145. tempViewport.x = 0;
  1146. tempViewport.y = 0;
  1147. tempViewport.width = engine.getRenderWidth();
  1148. tempViewport.height = engine.getRenderHeight();
  1149. }
  1150. else {
  1151. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1152. }
  1153. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1154. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1155. _this._shouldBlockPointer = false;
  1156. // Do picking modifies _shouldBlockPointer
  1157. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1158. // Avoid overwriting a true skipOnPointerObservable to false
  1159. if (_this._shouldBlockPointer) {
  1160. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1161. }
  1162. });
  1163. this._attachToOnPointerOut(scene);
  1164. };
  1165. /**
  1166. * Register the clipboard Events onto the canvas
  1167. */
  1168. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1169. self.addEventListener("copy", this.onClipboardCopy, false);
  1170. self.addEventListener("cut", this.onClipboardCut, false);
  1171. self.addEventListener("paste", this.onClipboardPaste, false);
  1172. };
  1173. /**
  1174. * Unregister the clipboard Events from the canvas
  1175. */
  1176. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1177. self.removeEventListener("copy", this.onClipboardCopy);
  1178. self.removeEventListener("cut", this.onClipboardCut);
  1179. self.removeEventListener("paste", this.onClipboardPaste);
  1180. };
  1181. /**
  1182. * Connect the texture to a hosting mesh to enable interactions
  1183. * @param mesh defines the mesh to attach to
  1184. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1185. */
  1186. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1187. var _this = this;
  1188. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1189. var scene = this.getScene();
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1194. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1195. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1196. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1197. return;
  1198. }
  1199. var pointerId = pi.event.pointerId || 0;
  1200. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1201. var uv = pi.pickInfo.getTextureCoordinates();
  1202. if (uv) {
  1203. var size = _this.getSize();
  1204. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1205. }
  1206. }
  1207. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1208. if (_this._lastControlDown[pointerId]) {
  1209. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1210. }
  1211. delete _this._lastControlDown[pointerId];
  1212. if (_this.focusedControl) {
  1213. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1214. var canMoveFocus = true;
  1215. if (friendlyControls) {
  1216. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1217. var control = friendlyControls_1[_i];
  1218. // Same host, no need to keep the focus
  1219. if (_this === control._host) {
  1220. continue;
  1221. }
  1222. // Different hosts
  1223. var otherHost = control._host;
  1224. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1225. canMoveFocus = false;
  1226. break;
  1227. }
  1228. }
  1229. }
  1230. if (canMoveFocus) {
  1231. _this.focusedControl = null;
  1232. }
  1233. }
  1234. }
  1235. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1236. if (_this._lastControlOver[pointerId]) {
  1237. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1238. }
  1239. delete _this._lastControlOver[pointerId];
  1240. }
  1241. });
  1242. mesh.enablePointerMoveEvents = supportPointerMove;
  1243. this._attachToOnPointerOut(scene);
  1244. };
  1245. /**
  1246. * Move the focus to a specific control
  1247. * @param control defines the control which will receive the focus
  1248. */
  1249. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1250. this.focusedControl = control;
  1251. this._lastPickedControl = control;
  1252. this._blockNextFocusCheck = true;
  1253. };
  1254. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1255. if (this._blockNextFocusCheck) {
  1256. this._blockNextFocusCheck = false;
  1257. this._lastPickedControl = this._focusedControl;
  1258. return;
  1259. }
  1260. // Focus management
  1261. if (this._focusedControl) {
  1262. if (this._focusedControl !== this._lastPickedControl) {
  1263. if (this._lastPickedControl.isFocusInvisible) {
  1264. return;
  1265. }
  1266. this.focusedControl = null;
  1267. }
  1268. }
  1269. };
  1270. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1271. var _this = this;
  1272. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1273. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1274. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1275. }
  1276. delete _this._lastControlOver[pointerEvent.pointerId];
  1277. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1278. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1279. delete _this._lastControlDown[pointerEvent.pointerId];
  1280. }
  1281. });
  1282. };
  1283. // Statics
  1284. /**
  1285. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1286. * @param mesh defines the mesh which will receive the texture
  1287. * @param width defines the texture width (1024 by default)
  1288. * @param height defines the texture height (1024 by default)
  1289. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1290. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1291. * @returns a new AdvancedDynamicTexture
  1292. */
  1293. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1294. if (width === void 0) { width = 1024; }
  1295. if (height === void 0) { height = 1024; }
  1296. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1297. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1298. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1299. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1300. material.backFaceCulling = false;
  1301. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1302. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1303. if (onlyAlphaTesting) {
  1304. material.diffuseTexture = result;
  1305. material.emissiveTexture = result;
  1306. result.hasAlpha = true;
  1307. }
  1308. else {
  1309. material.emissiveTexture = result;
  1310. material.opacityTexture = result;
  1311. }
  1312. mesh.material = material;
  1313. result.attachToMesh(mesh, supportPointerMove);
  1314. return result;
  1315. };
  1316. /**
  1317. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1318. * In this mode the texture will rely on a layer for its rendering.
  1319. * This allows it to be treated like any other layer.
  1320. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1321. * LayerMask is set through advancedTexture.layer.layerMask
  1322. * @param name defines name for the texture
  1323. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1324. * @param scene defines the hsoting scene
  1325. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1326. * @returns a new AdvancedDynamicTexture
  1327. */
  1328. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1329. if (foreground === void 0) { foreground = true; }
  1330. if (scene === void 0) { scene = null; }
  1331. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1332. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1333. // Display
  1334. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1335. layer.texture = result;
  1336. result._layerToDispose = layer;
  1337. result._isFullscreen = true;
  1338. // Attach
  1339. result.attach();
  1340. return result;
  1341. };
  1342. return AdvancedDynamicTexture;
  1343. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1344. /***/ }),
  1345. /***/ "./2D/controls/button.ts":
  1346. /*!*******************************!*\
  1347. !*** ./2D/controls/button.ts ***!
  1348. \*******************************/
  1349. /*! exports provided: Button */
  1350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1351. "use strict";
  1352. __webpack_require__.r(__webpack_exports__);
  1353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1355. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1356. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1357. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1358. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1359. /**
  1360. * Class used to create 2D buttons
  1361. */
  1362. var Button = /** @class */ (function (_super) {
  1363. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1364. /**
  1365. * Creates a new Button
  1366. * @param name defines the name of the button
  1367. */
  1368. function Button(name) {
  1369. var _this = _super.call(this, name) || this;
  1370. _this.name = name;
  1371. /**
  1372. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1373. */
  1374. _this.delegatePickingToChildren = false;
  1375. _this.thickness = 1;
  1376. _this.isPointerBlocker = true;
  1377. var alphaStore = null;
  1378. _this.pointerEnterAnimation = function () {
  1379. alphaStore = _this.alpha;
  1380. _this.alpha -= 0.1;
  1381. };
  1382. _this.pointerOutAnimation = function () {
  1383. if (alphaStore !== null) {
  1384. _this.alpha = alphaStore;
  1385. }
  1386. };
  1387. _this.pointerDownAnimation = function () {
  1388. _this.scaleX -= 0.05;
  1389. _this.scaleY -= 0.05;
  1390. };
  1391. _this.pointerUpAnimation = function () {
  1392. _this.scaleX += 0.05;
  1393. _this.scaleY += 0.05;
  1394. };
  1395. return _this;
  1396. }
  1397. Object.defineProperty(Button.prototype, "image", {
  1398. /**
  1399. * Returns the image part of the button (if any)
  1400. */
  1401. get: function () {
  1402. return this._image;
  1403. },
  1404. enumerable: true,
  1405. configurable: true
  1406. });
  1407. Object.defineProperty(Button.prototype, "textBlock", {
  1408. /**
  1409. * Returns the image part of the button (if any)
  1410. */
  1411. get: function () {
  1412. return this._textBlock;
  1413. },
  1414. enumerable: true,
  1415. configurable: true
  1416. });
  1417. Button.prototype._getTypeName = function () {
  1418. return "Button";
  1419. };
  1420. // While being a container, the button behaves like a control.
  1421. /** @hidden */
  1422. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1423. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1424. return false;
  1425. }
  1426. if (!_super.prototype.contains.call(this, x, y)) {
  1427. return false;
  1428. }
  1429. if (this.delegatePickingToChildren) {
  1430. var contains = false;
  1431. for (var index = this._children.length - 1; index >= 0; index--) {
  1432. var child = this._children[index];
  1433. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1434. contains = true;
  1435. break;
  1436. }
  1437. }
  1438. if (!contains) {
  1439. return false;
  1440. }
  1441. }
  1442. this._processObservables(type, x, y, pointerId, buttonIndex);
  1443. return true;
  1444. };
  1445. /** @hidden */
  1446. Button.prototype._onPointerEnter = function (target) {
  1447. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1448. return false;
  1449. }
  1450. if (this.pointerEnterAnimation) {
  1451. this.pointerEnterAnimation();
  1452. }
  1453. return true;
  1454. };
  1455. /** @hidden */
  1456. Button.prototype._onPointerOut = function (target, force) {
  1457. if (force === void 0) { force = false; }
  1458. if (this.pointerOutAnimation) {
  1459. this.pointerOutAnimation();
  1460. }
  1461. _super.prototype._onPointerOut.call(this, target, force);
  1462. };
  1463. /** @hidden */
  1464. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1465. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1466. return false;
  1467. }
  1468. if (this.pointerDownAnimation) {
  1469. this.pointerDownAnimation();
  1470. }
  1471. return true;
  1472. };
  1473. /** @hidden */
  1474. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1475. if (this.pointerUpAnimation) {
  1476. this.pointerUpAnimation();
  1477. }
  1478. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1479. };
  1480. // Statics
  1481. /**
  1482. * Creates a new button made with an image and a text
  1483. * @param name defines the name of the button
  1484. * @param text defines the text of the button
  1485. * @param imageUrl defines the url of the image
  1486. * @returns a new Button
  1487. */
  1488. Button.CreateImageButton = function (name, text, imageUrl) {
  1489. var result = new Button(name);
  1490. // Adding text
  1491. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1492. textBlock.textWrapping = true;
  1493. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1494. textBlock.paddingLeft = "20%";
  1495. result.addControl(textBlock);
  1496. // Adding image
  1497. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1498. iconImage.width = "20%";
  1499. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1500. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1501. result.addControl(iconImage);
  1502. // Store
  1503. result._image = iconImage;
  1504. result._textBlock = textBlock;
  1505. return result;
  1506. };
  1507. /**
  1508. * Creates a new button made with an image
  1509. * @param name defines the name of the button
  1510. * @param imageUrl defines the url of the image
  1511. * @returns a new Button
  1512. */
  1513. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1514. var result = new Button(name);
  1515. // Adding image
  1516. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1517. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1518. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1519. result.addControl(iconImage);
  1520. // Store
  1521. result._image = iconImage;
  1522. return result;
  1523. };
  1524. /**
  1525. * Creates a new button made with a text
  1526. * @param name defines the name of the button
  1527. * @param text defines the text of the button
  1528. * @returns a new Button
  1529. */
  1530. Button.CreateSimpleButton = function (name, text) {
  1531. var result = new Button(name);
  1532. // Adding text
  1533. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1534. textBlock.textWrapping = true;
  1535. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1536. result.addControl(textBlock);
  1537. // Store
  1538. result._textBlock = textBlock;
  1539. return result;
  1540. };
  1541. /**
  1542. * Creates a new button made with an image and a centered text
  1543. * @param name defines the name of the button
  1544. * @param text defines the text of the button
  1545. * @param imageUrl defines the url of the image
  1546. * @returns a new Button
  1547. */
  1548. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1549. var result = new Button(name);
  1550. // Adding image
  1551. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1552. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1553. result.addControl(iconImage);
  1554. // Adding text
  1555. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1556. textBlock.textWrapping = true;
  1557. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1558. result.addControl(textBlock);
  1559. // Store
  1560. result._image = iconImage;
  1561. result._textBlock = textBlock;
  1562. return result;
  1563. };
  1564. return Button;
  1565. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1566. /***/ }),
  1567. /***/ "./2D/controls/checkbox.ts":
  1568. /*!*********************************!*\
  1569. !*** ./2D/controls/checkbox.ts ***!
  1570. \*********************************/
  1571. /*! exports provided: Checkbox */
  1572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1573. "use strict";
  1574. __webpack_require__.r(__webpack_exports__);
  1575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1576. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1577. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1578. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1579. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1580. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1581. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1582. /**
  1583. * Class used to represent a 2D checkbox
  1584. */
  1585. var Checkbox = /** @class */ (function (_super) {
  1586. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1587. /**
  1588. * Creates a new CheckBox
  1589. * @param name defines the control name
  1590. */
  1591. function Checkbox(name) {
  1592. var _this = _super.call(this, name) || this;
  1593. _this.name = name;
  1594. _this._isChecked = false;
  1595. _this._background = "black";
  1596. _this._checkSizeRatio = 0.8;
  1597. _this._thickness = 1;
  1598. /**
  1599. * Observable raised when isChecked property changes
  1600. */
  1601. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1602. _this.isPointerBlocker = true;
  1603. return _this;
  1604. }
  1605. Object.defineProperty(Checkbox.prototype, "thickness", {
  1606. /** Gets or sets border thickness */
  1607. get: function () {
  1608. return this._thickness;
  1609. },
  1610. set: function (value) {
  1611. if (this._thickness === value) {
  1612. return;
  1613. }
  1614. this._thickness = value;
  1615. this._markAsDirty();
  1616. },
  1617. enumerable: true,
  1618. configurable: true
  1619. });
  1620. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1621. /** Gets or sets a value indicating the ratio between overall size and check size */
  1622. get: function () {
  1623. return this._checkSizeRatio;
  1624. },
  1625. set: function (value) {
  1626. value = Math.max(Math.min(1, value), 0);
  1627. if (this._checkSizeRatio === value) {
  1628. return;
  1629. }
  1630. this._checkSizeRatio = value;
  1631. this._markAsDirty();
  1632. },
  1633. enumerable: true,
  1634. configurable: true
  1635. });
  1636. Object.defineProperty(Checkbox.prototype, "background", {
  1637. /** Gets or sets background color */
  1638. get: function () {
  1639. return this._background;
  1640. },
  1641. set: function (value) {
  1642. if (this._background === value) {
  1643. return;
  1644. }
  1645. this._background = value;
  1646. this._markAsDirty();
  1647. },
  1648. enumerable: true,
  1649. configurable: true
  1650. });
  1651. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1652. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1653. get: function () {
  1654. return this._isChecked;
  1655. },
  1656. set: function (value) {
  1657. if (this._isChecked === value) {
  1658. return;
  1659. }
  1660. this._isChecked = value;
  1661. this._markAsDirty();
  1662. this.onIsCheckedChangedObservable.notifyObservers(value);
  1663. },
  1664. enumerable: true,
  1665. configurable: true
  1666. });
  1667. Checkbox.prototype._getTypeName = function () {
  1668. return "Checkbox";
  1669. };
  1670. /** @hidden */
  1671. Checkbox.prototype._draw = function (context) {
  1672. context.save();
  1673. this._applyStates(context);
  1674. var actualWidth = this._currentMeasure.width - this._thickness;
  1675. var actualHeight = this._currentMeasure.height - this._thickness;
  1676. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1677. context.shadowColor = this.shadowColor;
  1678. context.shadowBlur = this.shadowBlur;
  1679. context.shadowOffsetX = this.shadowOffsetX;
  1680. context.shadowOffsetY = this.shadowOffsetY;
  1681. }
  1682. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1683. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1684. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1685. context.shadowBlur = 0;
  1686. context.shadowOffsetX = 0;
  1687. context.shadowOffsetY = 0;
  1688. }
  1689. if (this._isChecked) {
  1690. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1691. var offsetWidth = actualWidth * this._checkSizeRatio;
  1692. var offseHeight = actualHeight * this._checkSizeRatio;
  1693. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1694. }
  1695. context.strokeStyle = this.color;
  1696. context.lineWidth = this._thickness;
  1697. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1698. context.restore();
  1699. };
  1700. // Events
  1701. /** @hidden */
  1702. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1703. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1704. return false;
  1705. }
  1706. this.isChecked = !this.isChecked;
  1707. return true;
  1708. };
  1709. /**
  1710. * Utility function to easily create a checkbox with a header
  1711. * @param title defines the label to use for the header
  1712. * @param onValueChanged defines the callback to call when value changes
  1713. * @returns a StackPanel containing the checkbox and a textBlock
  1714. */
  1715. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1716. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1717. panel.isVertical = false;
  1718. panel.height = "30px";
  1719. var checkbox = new Checkbox();
  1720. checkbox.width = "20px";
  1721. checkbox.height = "20px";
  1722. checkbox.isChecked = true;
  1723. checkbox.color = "green";
  1724. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1725. panel.addControl(checkbox);
  1726. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1727. header.text = title;
  1728. header.width = "180px";
  1729. header.paddingLeft = "5px";
  1730. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1731. header.color = "white";
  1732. panel.addControl(header);
  1733. return panel;
  1734. };
  1735. return Checkbox;
  1736. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1737. /***/ }),
  1738. /***/ "./2D/controls/colorpicker.ts":
  1739. /*!************************************!*\
  1740. !*** ./2D/controls/colorpicker.ts ***!
  1741. \************************************/
  1742. /*! exports provided: ColorPicker */
  1743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1744. "use strict";
  1745. __webpack_require__.r(__webpack_exports__);
  1746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1747. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1748. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1749. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1750. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1751. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1752. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1753. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1754. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1755. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1756. /** Class used to create color pickers */
  1757. var ColorPicker = /** @class */ (function (_super) {
  1758. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1759. /**
  1760. * Creates a new ColorPicker
  1761. * @param name defines the control name
  1762. */
  1763. function ColorPicker(name) {
  1764. var _this = _super.call(this, name) || this;
  1765. _this.name = name;
  1766. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1767. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1768. _this._pointerStartedOnSquare = false;
  1769. _this._pointerStartedOnWheel = false;
  1770. _this._squareLeft = 0;
  1771. _this._squareTop = 0;
  1772. _this._squareSize = 0;
  1773. _this._h = 360;
  1774. _this._s = 1;
  1775. _this._v = 1;
  1776. _this._lastPointerDownID = -1;
  1777. /**
  1778. * Observable raised when the value changes
  1779. */
  1780. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1781. // Events
  1782. _this._pointerIsDown = false;
  1783. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1784. _this.size = "200px";
  1785. _this.isPointerBlocker = true;
  1786. return _this;
  1787. }
  1788. Object.defineProperty(ColorPicker.prototype, "value", {
  1789. /** Gets or sets the color of the color picker */
  1790. get: function () {
  1791. return this._value;
  1792. },
  1793. set: function (value) {
  1794. if (this._value.equals(value)) {
  1795. return;
  1796. }
  1797. this._value.copyFrom(value);
  1798. this._value.toHSVToRef(this._tmpColor);
  1799. this._h = this._tmpColor.r;
  1800. this._s = Math.max(this._tmpColor.g, 0.00001);
  1801. this._v = Math.max(this._tmpColor.b, 0.00001);
  1802. this._markAsDirty();
  1803. if (this._value.r <= ColorPicker._Epsilon) {
  1804. this._value.r = 0;
  1805. }
  1806. if (this._value.g <= ColorPicker._Epsilon) {
  1807. this._value.g = 0;
  1808. }
  1809. if (this._value.b <= ColorPicker._Epsilon) {
  1810. this._value.b = 0;
  1811. }
  1812. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1813. this._value.r = 1.0;
  1814. }
  1815. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1816. this._value.g = 1.0;
  1817. }
  1818. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1819. this._value.b = 1.0;
  1820. }
  1821. this.onValueChangedObservable.notifyObservers(this._value);
  1822. },
  1823. enumerable: true,
  1824. configurable: true
  1825. });
  1826. Object.defineProperty(ColorPicker.prototype, "width", {
  1827. /**
  1828. * Gets or sets control width
  1829. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1830. */
  1831. get: function () {
  1832. return this._width.toString(this._host);
  1833. },
  1834. set: function (value) {
  1835. if (this._width.toString(this._host) === value) {
  1836. return;
  1837. }
  1838. if (this._width.fromString(value)) {
  1839. this._height.fromString(value);
  1840. this._markAsDirty();
  1841. }
  1842. },
  1843. enumerable: true,
  1844. configurable: true
  1845. });
  1846. Object.defineProperty(ColorPicker.prototype, "height", {
  1847. /**
  1848. * Gets or sets control height
  1849. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1850. */
  1851. get: function () {
  1852. return this._height.toString(this._host);
  1853. },
  1854. /** Gets or sets control height */
  1855. set: function (value) {
  1856. if (this._height.toString(this._host) === value) {
  1857. return;
  1858. }
  1859. if (this._height.fromString(value)) {
  1860. this._width.fromString(value);
  1861. this._markAsDirty();
  1862. }
  1863. },
  1864. enumerable: true,
  1865. configurable: true
  1866. });
  1867. Object.defineProperty(ColorPicker.prototype, "size", {
  1868. /** Gets or sets control size */
  1869. get: function () {
  1870. return this.width;
  1871. },
  1872. set: function (value) {
  1873. this.width = value;
  1874. },
  1875. enumerable: true,
  1876. configurable: true
  1877. });
  1878. ColorPicker.prototype._getTypeName = function () {
  1879. return "ColorPicker";
  1880. };
  1881. /** @hidden */
  1882. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1883. if (parentMeasure.width < parentMeasure.height) {
  1884. this._currentMeasure.height = parentMeasure.width;
  1885. }
  1886. else {
  1887. this._currentMeasure.width = parentMeasure.height;
  1888. }
  1889. };
  1890. ColorPicker.prototype._updateSquareProps = function () {
  1891. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1892. var wheelThickness = radius * .2;
  1893. var innerDiameter = (radius - wheelThickness) * 2;
  1894. var squareSize = innerDiameter / (Math.sqrt(2));
  1895. var offset = radius - squareSize * .5;
  1896. this._squareLeft = this._currentMeasure.left + offset;
  1897. this._squareTop = this._currentMeasure.top + offset;
  1898. this._squareSize = squareSize;
  1899. };
  1900. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1901. var lgh = context.createLinearGradient(left, top, width + left, top);
  1902. lgh.addColorStop(0, '#fff');
  1903. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1904. context.fillStyle = lgh;
  1905. context.fillRect(left, top, width, height);
  1906. var lgv = context.createLinearGradient(left, top, left, height + top);
  1907. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1908. lgv.addColorStop(1, '#000');
  1909. context.fillStyle = lgv;
  1910. context.fillRect(left, top, width, height);
  1911. };
  1912. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1913. context.beginPath();
  1914. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1915. context.lineWidth = 3;
  1916. context.strokeStyle = '#333333';
  1917. context.stroke();
  1918. context.beginPath();
  1919. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1920. context.lineWidth = 3;
  1921. context.strokeStyle = '#ffffff';
  1922. context.stroke();
  1923. };
  1924. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1925. var canvas = document.createElement("canvas");
  1926. canvas.width = radius * 2;
  1927. canvas.height = radius * 2;
  1928. var context = canvas.getContext("2d");
  1929. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1930. var data = image.data;
  1931. var color = this._tmpColor;
  1932. var maxDistSq = radius * radius;
  1933. var innerRadius = radius - thickness;
  1934. var minDistSq = innerRadius * innerRadius;
  1935. for (var x = -radius; x < radius; x++) {
  1936. for (var y = -radius; y < radius; y++) {
  1937. var distSq = x * x + y * y;
  1938. if (distSq > maxDistSq || distSq < minDistSq) {
  1939. continue;
  1940. }
  1941. var dist = Math.sqrt(distSq);
  1942. var ang = Math.atan2(y, x);
  1943. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1944. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1945. data[index] = color.r * 255;
  1946. data[index + 1] = color.g * 255;
  1947. data[index + 2] = color.b * 255;
  1948. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1949. //apply less alpha to bigger color pickers
  1950. var alphaAmount = .2;
  1951. var maxAlpha = .2;
  1952. var minAlpha = .04;
  1953. var lowerRadius = 50;
  1954. var upperRadius = 150;
  1955. if (radius < lowerRadius) {
  1956. alphaAmount = maxAlpha;
  1957. }
  1958. else if (radius > upperRadius) {
  1959. alphaAmount = minAlpha;
  1960. }
  1961. else {
  1962. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1963. }
  1964. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1965. if (alphaRatio < alphaAmount) {
  1966. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1967. }
  1968. else if (alphaRatio > 1 - alphaAmount) {
  1969. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1970. }
  1971. else {
  1972. data[index + 3] = 255;
  1973. }
  1974. }
  1975. }
  1976. context.putImageData(image, 0, 0);
  1977. return canvas;
  1978. };
  1979. /** @hidden */
  1980. ColorPicker.prototype._draw = function (context) {
  1981. context.save();
  1982. this._applyStates(context);
  1983. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1984. var wheelThickness = radius * .2;
  1985. var left = this._currentMeasure.left;
  1986. var top = this._currentMeasure.top;
  1987. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1988. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1989. }
  1990. this._updateSquareProps();
  1991. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1992. context.shadowColor = this.shadowColor;
  1993. context.shadowBlur = this.shadowBlur;
  1994. context.shadowOffsetX = this.shadowOffsetX;
  1995. context.shadowOffsetY = this.shadowOffsetY;
  1996. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  1997. }
  1998. context.drawImage(this._colorWheelCanvas, left, top);
  1999. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2000. context.shadowBlur = 0;
  2001. context.shadowOffsetX = 0;
  2002. context.shadowOffsetY = 0;
  2003. }
  2004. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2005. var cx = this._squareLeft + this._squareSize * this._s;
  2006. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2007. this._drawCircle(cx, cy, radius * .04, context);
  2008. var dist = radius - wheelThickness * .5;
  2009. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2010. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2011. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2012. context.restore();
  2013. };
  2014. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2015. if (this._pointerStartedOnWheel) {
  2016. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2017. var centerX = radius + this._currentMeasure.left;
  2018. var centerY = radius + this._currentMeasure.top;
  2019. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2020. }
  2021. else if (this._pointerStartedOnSquare) {
  2022. this._updateSquareProps();
  2023. this._s = (x - this._squareLeft) / this._squareSize;
  2024. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2025. this._s = Math.min(this._s, 1);
  2026. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2027. this._v = Math.min(this._v, 1);
  2028. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2029. }
  2030. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2031. this.value = this._tmpColor;
  2032. };
  2033. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2034. this._updateSquareProps();
  2035. var left = this._squareLeft;
  2036. var top = this._squareTop;
  2037. var size = this._squareSize;
  2038. if (x >= left && x <= left + size &&
  2039. y >= top && y <= top + size) {
  2040. return true;
  2041. }
  2042. return false;
  2043. };
  2044. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2045. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2046. var centerX = radius + this._currentMeasure.left;
  2047. var centerY = radius + this._currentMeasure.top;
  2048. var wheelThickness = radius * .2;
  2049. var innerRadius = radius - wheelThickness;
  2050. var radiusSq = radius * radius;
  2051. var innerRadiusSq = innerRadius * innerRadius;
  2052. var dx = x - centerX;
  2053. var dy = y - centerY;
  2054. var distSq = dx * dx + dy * dy;
  2055. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2056. return true;
  2057. }
  2058. return false;
  2059. };
  2060. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2061. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2062. return false;
  2063. }
  2064. this._pointerIsDown = true;
  2065. this._pointerStartedOnSquare = false;
  2066. this._pointerStartedOnWheel = false;
  2067. // Invert transform
  2068. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2069. var x = this._transformedPosition.x;
  2070. var y = this._transformedPosition.y;
  2071. if (this._isPointOnSquare(x, y)) {
  2072. this._pointerStartedOnSquare = true;
  2073. }
  2074. else if (this._isPointOnWheel(x, y)) {
  2075. this._pointerStartedOnWheel = true;
  2076. }
  2077. this._updateValueFromPointer(x, y);
  2078. this._host._capturingControl[pointerId] = this;
  2079. this._lastPointerDownID = pointerId;
  2080. return true;
  2081. };
  2082. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2083. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2084. if (pointerId != this._lastPointerDownID) {
  2085. return;
  2086. }
  2087. // Invert transform
  2088. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2089. var x = this._transformedPosition.x;
  2090. var y = this._transformedPosition.y;
  2091. if (this._pointerIsDown) {
  2092. this._updateValueFromPointer(x, y);
  2093. }
  2094. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2095. };
  2096. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2097. this._pointerIsDown = false;
  2098. delete this._host._capturingControl[pointerId];
  2099. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2100. };
  2101. /**
  2102. * This function expands the color picker by creating a color picker dialog with manual
  2103. * color value input and the ability to save colors into an array to be used later in
  2104. * subsequent launches of the dialogue.
  2105. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2106. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  2107. * @returns picked color as a hex string and the saved colors array as hex strings.
  2108. */
  2109. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2110. return new Promise(function (resolve, reject) {
  2111. // Default options
  2112. options.pickerWidth = options.pickerWidth || "640px";
  2113. options.pickerHeight = options.pickerHeight || "400px";
  2114. options.headerHeight = options.headerHeight || "35px";
  2115. options.lastColor = options.lastColor || "#000000";
  2116. options.swatchLimit = options.swatchLimit || 20;
  2117. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2118. // Window size settings
  2119. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2120. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2121. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2122. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2123. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2124. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2125. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2126. // Button Colors
  2127. var buttonColor = "#c0c0c0";
  2128. var buttonBackgroundColor = "#535353";
  2129. var buttonBackgroundHoverColor = "#414141";
  2130. var buttonBackgroundClickColor = "515151";
  2131. var buttonDisabledColor = "#555555";
  2132. var buttonDisabledBackgroundColor = "#454545";
  2133. var currentSwatchesOutlineColor = "#404040";
  2134. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2135. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2136. var iconColorDark = "#aaaaaa";
  2137. var iconColorLight = "#ffffff";
  2138. var closeIconColor;
  2139. // Button settings
  2140. var buttonFontSize;
  2141. var butEdit;
  2142. var buttonWidth;
  2143. var buttonHeight;
  2144. // Input Text Colors
  2145. var inputFieldLabels = ["R", "G", "B"];
  2146. var inputTextBackgroundColor = "#454545";
  2147. var inputTextColor = "#f0f0f0";
  2148. // This is the current color as set by either the picker or by entering a value
  2149. var currentColor;
  2150. // This int is used for naming swatches and serves as the index for calling them from the list
  2151. var swatchNumber;
  2152. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2153. var swatchDrawer;
  2154. var editSwatchMode = false;
  2155. // Color InputText fields that will be updated upon value change
  2156. var picker;
  2157. var rValInt;
  2158. var gValInt;
  2159. var bValInt;
  2160. var rValDec;
  2161. var gValDec;
  2162. var bValDec;
  2163. var hexVal;
  2164. var newSwatch;
  2165. var lastVal;
  2166. var activeField;
  2167. /**
  2168. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2169. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2170. * are will receive no update. This is to prevent the input from the user being overwritten.
  2171. */
  2172. function updateValues(value, inputField) {
  2173. activeField = inputField;
  2174. var pickedColor = value.toHexString();
  2175. newSwatch.background = pickedColor;
  2176. if (rValInt.name != activeField) {
  2177. rValInt.text = Math.floor(value.r * 255).toString();
  2178. }
  2179. if (gValInt.name != activeField) {
  2180. gValInt.text = Math.floor(value.g * 255).toString();
  2181. }
  2182. if (bValInt.name != activeField) {
  2183. bValInt.text = Math.floor(value.b * 255).toString();
  2184. }
  2185. if (rValDec.name != activeField) {
  2186. rValDec.text = value.r.toString();
  2187. }
  2188. if (gValDec.name != activeField) {
  2189. gValDec.text = value.g.toString();
  2190. }
  2191. if (bValDec.name != activeField) {
  2192. bValDec.text = value.b.toString();
  2193. }
  2194. if (hexVal.name != activeField) {
  2195. var minusPound = pickedColor.split("#");
  2196. hexVal.text = minusPound[1];
  2197. }
  2198. if (picker.name != activeField) {
  2199. picker.value = value;
  2200. }
  2201. }
  2202. // When the user enters an integer for R, G, or B we check to make sure it is a valid number and replace if not.
  2203. function updateInt(field, channel) {
  2204. var newValue = field.text;
  2205. var checkVal = /[^0-9]/g.test(newValue);
  2206. if (checkVal) {
  2207. field.text = lastVal;
  2208. return;
  2209. }
  2210. else {
  2211. if (newValue != "") {
  2212. if (Math.floor(parseInt(newValue)) < 0) {
  2213. newValue = "0";
  2214. }
  2215. else if (Math.floor(parseInt(newValue)) > 255) {
  2216. newValue = "255";
  2217. }
  2218. else if (isNaN(parseInt(newValue))) {
  2219. newValue = "0";
  2220. }
  2221. }
  2222. if (activeField == field.name) {
  2223. lastVal = newValue;
  2224. }
  2225. }
  2226. if (newValue != "") {
  2227. newValue = parseInt(newValue).toString();
  2228. field.text = newValue;
  2229. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2230. if (activeField == field.name) {
  2231. if (channel == "r") {
  2232. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2233. }
  2234. else if (channel == "g") {
  2235. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2236. }
  2237. else {
  2238. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2239. }
  2240. }
  2241. }
  2242. }
  2243. // When the user enters a float for R, G, or B we check to make sure it is a valid number and replace if not.
  2244. function updateFloat(field, channel) {
  2245. var newValue = field.text;
  2246. var checkVal = /[^0-9\.]/g.test(newValue);
  2247. if (checkVal) {
  2248. field.text = lastVal;
  2249. return;
  2250. }
  2251. else {
  2252. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2253. if (parseFloat(newValue) < 0.0) {
  2254. newValue = "0.0";
  2255. }
  2256. else if (parseFloat(newValue) > 1.0) {
  2257. newValue = "1.0";
  2258. }
  2259. else if (isNaN(parseFloat(newValue))) {
  2260. newValue = "0.0";
  2261. }
  2262. }
  2263. if (activeField == field.name) {
  2264. lastVal = newValue;
  2265. }
  2266. }
  2267. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2268. newValue = parseFloat(newValue).toString();
  2269. field.text = newValue;
  2270. }
  2271. else {
  2272. newValue = "0.0";
  2273. }
  2274. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2275. if (activeField == field.name) {
  2276. if (channel == "r") {
  2277. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2278. }
  2279. else if (channel == "g") {
  2280. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2281. }
  2282. else {
  2283. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2284. }
  2285. }
  2286. }
  2287. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2288. function deleteSwatch(index) {
  2289. if (options.savedColors) {
  2290. options.savedColors.splice(index, 1);
  2291. }
  2292. if (options.savedColors && options.savedColors.length == 0) {
  2293. setEditButtonVisibility(false);
  2294. editSwatchMode = false;
  2295. }
  2296. }
  2297. // Creates and styles an individual swatch when updateSwatches is called.
  2298. function createSwatch() {
  2299. if (options.savedColors && options.savedColors[swatchNumber]) {
  2300. if (editSwatchMode) {
  2301. var icon = "b";
  2302. }
  2303. else {
  2304. var icon = "";
  2305. }
  2306. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2307. swatch.fontFamily = "BabylonJSglyphs";
  2308. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2309. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2310. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2311. if (swatchLuminence > luminanceLimit) {
  2312. swatch.color = iconColorDark;
  2313. }
  2314. else {
  2315. swatch.color = iconColorLight;
  2316. }
  2317. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2318. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2319. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2320. swatch.background = options.savedColors[swatchNumber];
  2321. swatch.thickness = 2;
  2322. var metadata_1 = swatchNumber;
  2323. swatch.pointerDownAnimation = function () {
  2324. swatch.thickness = 4;
  2325. };
  2326. swatch.pointerUpAnimation = function () {
  2327. swatch.thickness = 3;
  2328. };
  2329. swatch.pointerEnterAnimation = function () {
  2330. swatch.thickness = 3;
  2331. };
  2332. swatch.pointerOutAnimation = function () {
  2333. swatch.thickness = 2;
  2334. };
  2335. swatch.onPointerClickObservable.add(function () {
  2336. if (!editSwatchMode) {
  2337. if (options.savedColors) {
  2338. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2339. }
  2340. }
  2341. else {
  2342. deleteSwatch(metadata_1);
  2343. updateSwatches("", butSave);
  2344. }
  2345. });
  2346. return swatch;
  2347. }
  2348. else {
  2349. return null;
  2350. }
  2351. }
  2352. // Mode switch to render button text and close symbols on swatch controls
  2353. function editSwatches(mode) {
  2354. if (mode !== undefined) {
  2355. editSwatchMode = mode;
  2356. }
  2357. if (editSwatchMode) {
  2358. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2359. var thisButton = swatchDrawer.children[i];
  2360. thisButton.textBlock.text = "b";
  2361. }
  2362. if (butEdit !== undefined) {
  2363. butEdit.textBlock.text = "Done";
  2364. }
  2365. }
  2366. else {
  2367. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2368. var thisButton = swatchDrawer.children[i];
  2369. thisButton.textBlock.text = "";
  2370. }
  2371. if (butEdit !== undefined) {
  2372. butEdit.textBlock.text = "Edit";
  2373. }
  2374. }
  2375. }
  2376. /**
  2377. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2378. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2379. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2380. * saved colors there are and how many can be stored per row.
  2381. */
  2382. function updateSwatches(color, button) {
  2383. if (options.savedColors) {
  2384. if (color != "") {
  2385. options.savedColors.push(color);
  2386. }
  2387. swatchNumber = 0;
  2388. swatchDrawer.clearControls();
  2389. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2390. if (rowCount == 0) {
  2391. var gutterCount = 0;
  2392. }
  2393. else {
  2394. var gutterCount = rowCount + 1;
  2395. }
  2396. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2397. var currentRows = swatchDrawer.rowCount;
  2398. for (var i = 0; i < currentRows; i++) {
  2399. swatchDrawer.removeRowDefinition(0);
  2400. }
  2401. for (var i = 0; i < rowCount + gutterCount; i++) {
  2402. if (i % 2) {
  2403. swatchDrawer.addRowDefinition(swatchSize, true);
  2404. }
  2405. else {
  2406. swatchDrawer.addRowDefinition(gutterSize, true);
  2407. }
  2408. }
  2409. }
  2410. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2411. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2412. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2413. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2414. var totalButtonsThisRow = options.numSwatchesPerLine;
  2415. }
  2416. else {
  2417. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2418. }
  2419. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2420. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2421. if (x > options.numSwatchesPerLine) {
  2422. continue;
  2423. }
  2424. var swatch = createSwatch();
  2425. if (swatch != null) {
  2426. swatchDrawer.addControl(swatch, y, w);
  2427. w += 2;
  2428. swatchNumber++;
  2429. }
  2430. else {
  2431. continue;
  2432. }
  2433. }
  2434. }
  2435. if (options.savedColors.length >= options.swatchLimit) {
  2436. disableButton(button, true);
  2437. }
  2438. else {
  2439. disableButton(button, false);
  2440. }
  2441. }
  2442. }
  2443. // Shows or hides edit swatches button depending on if there are saved swatches
  2444. function setEditButtonVisibility(enableButton) {
  2445. if (enableButton) {
  2446. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2447. butEdit.width = buttonWidth;
  2448. butEdit.height = buttonHeight;
  2449. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2450. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2451. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2452. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2453. butEdit.thickness = 2;
  2454. butEdit.color = buttonColor;
  2455. butEdit.fontSize = buttonFontSize;
  2456. butEdit.background = buttonBackgroundColor;
  2457. butEdit.onPointerEnterObservable.add(function () {
  2458. butEdit.background = buttonBackgroundHoverColor;
  2459. });
  2460. butEdit.onPointerOutObservable.add(function () {
  2461. butEdit.background = buttonBackgroundColor;
  2462. });
  2463. butEdit.pointerDownAnimation = function () {
  2464. butEdit.background = buttonBackgroundClickColor;
  2465. };
  2466. butEdit.pointerUpAnimation = function () {
  2467. butEdit.background = buttonBackgroundHoverColor;
  2468. };
  2469. butEdit.onPointerClickObservable.add(function () {
  2470. if (editSwatchMode) {
  2471. editSwatchMode = false;
  2472. }
  2473. else {
  2474. editSwatchMode = true;
  2475. }
  2476. editSwatches();
  2477. });
  2478. pickerGrid.addControl(butEdit, 1, 0);
  2479. }
  2480. else {
  2481. pickerGrid.removeControl(butEdit);
  2482. }
  2483. }
  2484. // Called when the user hits the limit of saved colors in the drawer.
  2485. function disableButton(button, disabled) {
  2486. if (disabled) {
  2487. button.color = buttonDisabledColor;
  2488. button.background = buttonDisabledBackgroundColor;
  2489. }
  2490. else {
  2491. button.color = buttonColor;
  2492. button.background = buttonBackgroundColor;
  2493. }
  2494. }
  2495. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2496. function closePicker(color) {
  2497. if (options.savedColors && options.savedColors.length > 0) {
  2498. resolve({
  2499. savedColors: options.savedColors,
  2500. pickedColor: color
  2501. });
  2502. }
  2503. else {
  2504. resolve({
  2505. pickedColor: color
  2506. });
  2507. }
  2508. advancedTexture.removeControl(dialogContainer);
  2509. }
  2510. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2511. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2512. dialogContainer.name = "Dialog Container";
  2513. dialogContainer.width = options.pickerWidth;
  2514. if (options.savedColors) {
  2515. dialogContainer.height = containerSize;
  2516. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2517. dialogContainer.addRowDefinition(topRow, false);
  2518. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2519. }
  2520. else {
  2521. dialogContainer.height = options.pickerHeight;
  2522. dialogContainer.addRowDefinition(1.0, false);
  2523. }
  2524. advancedTexture.addControl(dialogContainer);
  2525. // Swatch drawer which contains all saved color buttons
  2526. if (options.savedColors) {
  2527. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2528. swatchDrawer.name = "Swatch Drawer";
  2529. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2530. swatchDrawer.background = buttonBackgroundColor;
  2531. swatchDrawer.width = options.pickerWidth;
  2532. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2533. if (initialRows == 0) {
  2534. var gutterCount = 0;
  2535. }
  2536. else {
  2537. var gutterCount = initialRows + 1;
  2538. }
  2539. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2540. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2541. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2542. if (i % 2 != 0) {
  2543. swatchDrawer.addRowDefinition(swatchSize, true);
  2544. }
  2545. else {
  2546. swatchDrawer.addRowDefinition(gutterSize, true);
  2547. }
  2548. }
  2549. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2550. if (i % 2 != 0) {
  2551. swatchDrawer.addColumnDefinition(swatchSize, true);
  2552. }
  2553. else {
  2554. swatchDrawer.addColumnDefinition(gutterSize, true);
  2555. }
  2556. }
  2557. dialogContainer.addControl(swatchDrawer, 1, 0);
  2558. }
  2559. // Picker container
  2560. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2561. pickerPanel.name = "Picker Panel";
  2562. pickerPanel.height = options.pickerHeight;
  2563. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2564. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2565. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2566. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2567. dialogContainer.addControl(pickerPanel, 0, 0);
  2568. // Picker container header
  2569. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2570. header.name = "Dialogue Header Bar";
  2571. header.background = "#cccccc";
  2572. header.thickness = 0;
  2573. pickerPanel.addControl(header, 0, 0);
  2574. // Header close button
  2575. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2576. closeButton.fontFamily = "BabylonJSglyphs";
  2577. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2578. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2579. closeButton.color = closeIconColor.toHexString();
  2580. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2581. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2582. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2583. closeButton.height = closeButton.width = options.headerHeight;
  2584. closeButton.background = header.background;
  2585. closeButton.thickness = 0;
  2586. closeButton.pointerDownAnimation = function () {
  2587. };
  2588. closeButton.pointerUpAnimation = function () {
  2589. closeButton.background = header.background;
  2590. };
  2591. closeButton.pointerEnterAnimation = function () {
  2592. closeButton.color = header.background;
  2593. closeButton.background = "red";
  2594. };
  2595. closeButton.pointerOutAnimation = function () {
  2596. closeButton.color = closeIconColor.toHexString();
  2597. closeButton.background = header.background;
  2598. };
  2599. closeButton.onPointerClickObservable.add(function () {
  2600. closePicker(currentSwatch.background);
  2601. });
  2602. pickerPanel.addControl(closeButton, 0, 0);
  2603. // Dialog container body
  2604. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2605. dialogBody.name = "Dialogue Body";
  2606. dialogBody.background = buttonBackgroundColor;
  2607. var dialogBodyCols = [0.4375, 0.5625];
  2608. dialogBody.addRowDefinition(1.0, false);
  2609. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2610. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2611. pickerPanel.addControl(dialogBody, 1, 0);
  2612. // Picker grid
  2613. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2614. pickerGrid.name = "Picker Grid";
  2615. pickerGrid.addRowDefinition(0.85, false);
  2616. pickerGrid.addRowDefinition(0.15, false);
  2617. dialogBody.addControl(pickerGrid, 0, 0);
  2618. // Picker control
  2619. picker = new ColorPicker();
  2620. picker.name = "GUI Color Picker";
  2621. if (options.pickerHeight < options.pickerWidth) {
  2622. picker.width = 0.89;
  2623. }
  2624. else {
  2625. picker.height = 0.89;
  2626. }
  2627. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2628. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2629. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2630. picker.onPointerDownObservable.add(function () {
  2631. activeField = picker.name;
  2632. lastVal = "";
  2633. editSwatches(false);
  2634. });
  2635. picker.onValueChangedObservable.add(function (value) {
  2636. if (activeField == picker.name) {
  2637. updateValues(value, picker.name);
  2638. }
  2639. });
  2640. pickerGrid.addControl(picker, 0, 0);
  2641. // Picker body right quarant
  2642. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2643. pickerBodyRight.name = "Dialogue Right Half";
  2644. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2645. var pickerBodyRightRows = [0.514, 0.486];
  2646. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2647. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2648. dialogBody.addControl(pickerBodyRight, 1, 1);
  2649. // Picker container swatches and buttons
  2650. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2651. pickerSwatchesButtons.name = "Swatches and Buttons";
  2652. var pickerButtonsCol = [0.417, 0.583];
  2653. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2654. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2655. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2656. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2657. // Picker Swatches quadrant
  2658. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2659. pickerSwatches.name = "New and Current Swatches";
  2660. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2661. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2662. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2663. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2664. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2665. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2666. // Active swatches
  2667. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2668. activeSwatches.name = "Active Swatches";
  2669. activeSwatches.width = 0.67;
  2670. activeSwatches.addRowDefinition(0.5, false);
  2671. activeSwatches.addRowDefinition(0.5, false);
  2672. pickerSwatches.addControl(activeSwatches, 2, 0);
  2673. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2674. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2675. if (options.pickerWidth > options.pickerHeight) {
  2676. var labelTextSize = labelHeight;
  2677. }
  2678. else {
  2679. var labelTextSize = labelWidth;
  2680. }
  2681. // New color swatch and previous color button
  2682. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2683. newText.text = "new";
  2684. newText.name = "New Color Label";
  2685. newText.color = buttonColor;
  2686. newText.fontSize = labelTextSize;
  2687. pickerSwatches.addControl(newText, 1, 0);
  2688. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2689. newSwatch.name = "New Color Swatch";
  2690. newSwatch.background = options.lastColor;
  2691. newSwatch.thickness = 0;
  2692. activeSwatches.addControl(newSwatch, 0, 0);
  2693. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2694. currentSwatch.background = options.lastColor;
  2695. currentSwatch.thickness = 0;
  2696. currentSwatch.onPointerClickObservable.add(function () {
  2697. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2698. updateValues(revertColor, currentSwatch.name);
  2699. editSwatches(false);
  2700. });
  2701. currentSwatch.pointerDownAnimation = function () { };
  2702. currentSwatch.pointerUpAnimation = function () { };
  2703. currentSwatch.pointerEnterAnimation = function () { };
  2704. currentSwatch.pointerOutAnimation = function () { };
  2705. activeSwatches.addControl(currentSwatch, 1, 0);
  2706. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2707. swatchOutline.name = "Swatch Outline";
  2708. swatchOutline.width = 0.67;
  2709. swatchOutline.thickness = 2;
  2710. swatchOutline.color = currentSwatchesOutlineColor;
  2711. swatchOutline.isHitTestVisible = false;
  2712. pickerSwatches.addControl(swatchOutline, 2, 0);
  2713. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2714. currentText.name = "Current Color Label";
  2715. currentText.text = "current";
  2716. currentText.color = buttonColor;
  2717. currentText.fontSize = labelTextSize;
  2718. pickerSwatches.addControl(currentText, 3, 0);
  2719. // Buttons grid
  2720. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2721. buttonGrid.name = "Button Grid";
  2722. buttonGrid.height = 0.8;
  2723. var buttonGridRows = 1 / 3;
  2724. buttonGrid.addRowDefinition(buttonGridRows, false);
  2725. buttonGrid.addRowDefinition(buttonGridRows, false);
  2726. buttonGrid.addRowDefinition(buttonGridRows, false);
  2727. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2728. // Determine pixel width and height for all buttons from overall panel dimensions
  2729. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2730. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2731. // Determine button type size
  2732. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2733. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2734. }
  2735. else {
  2736. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2737. }
  2738. // Panel Buttons
  2739. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2740. butOK.width = buttonWidth;
  2741. butOK.height = buttonHeight;
  2742. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2743. butOK.thickness = 2;
  2744. butOK.color = buttonColor;
  2745. butOK.fontSize = buttonFontSize;
  2746. butOK.background = buttonBackgroundColor;
  2747. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2748. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2749. butOK.pointerDownAnimation = function () {
  2750. butOK.background = buttonBackgroundClickColor;
  2751. };
  2752. butOK.pointerUpAnimation = function () {
  2753. butOK.background = buttonBackgroundHoverColor;
  2754. };
  2755. butOK.onPointerClickObservable.add(function () {
  2756. editSwatches(false);
  2757. closePicker(newSwatch.background);
  2758. });
  2759. buttonGrid.addControl(butOK, 0, 0);
  2760. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2761. butCancel.width = buttonWidth;
  2762. butCancel.height = buttonHeight;
  2763. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2764. butCancel.thickness = 2;
  2765. butCancel.color = buttonColor;
  2766. butCancel.fontSize = buttonFontSize;
  2767. butCancel.background = buttonBackgroundColor;
  2768. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2769. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2770. butCancel.pointerDownAnimation = function () {
  2771. butCancel.background = buttonBackgroundClickColor;
  2772. };
  2773. butCancel.pointerUpAnimation = function () {
  2774. butCancel.background = buttonBackgroundHoverColor;
  2775. };
  2776. butCancel.onPointerClickObservable.add(function () {
  2777. editSwatches(false);
  2778. closePicker(currentSwatch.background);
  2779. });
  2780. buttonGrid.addControl(butCancel, 1, 0);
  2781. if (options.savedColors) {
  2782. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2783. butSave.width = buttonWidth;
  2784. butSave.height = buttonHeight;
  2785. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2786. butSave.thickness = 2;
  2787. butSave.fontSize = buttonFontSize;
  2788. if (options.savedColors.length < options.swatchLimit) {
  2789. butSave.color = buttonColor;
  2790. butSave.background = buttonBackgroundColor;
  2791. }
  2792. else {
  2793. disableButton(butSave, true);
  2794. }
  2795. butSave.onPointerEnterObservable.add(function () {
  2796. if (options.savedColors) {
  2797. if (options.savedColors.length < options.swatchLimit) {
  2798. butSave.background = buttonBackgroundHoverColor;
  2799. }
  2800. }
  2801. });
  2802. butSave.onPointerOutObservable.add(function () {
  2803. if (options.savedColors) {
  2804. if (options.savedColors.length < options.swatchLimit) {
  2805. butSave.background = buttonBackgroundColor;
  2806. }
  2807. }
  2808. });
  2809. butSave.pointerDownAnimation = function () {
  2810. if (options.savedColors) {
  2811. if (options.savedColors.length < options.swatchLimit) {
  2812. butSave.background = buttonBackgroundClickColor;
  2813. }
  2814. }
  2815. };
  2816. butSave.pointerUpAnimation = function () {
  2817. if (options.savedColors) {
  2818. if (options.savedColors.length < options.swatchLimit) {
  2819. butSave.background = buttonBackgroundHoverColor;
  2820. }
  2821. }
  2822. };
  2823. butSave.onPointerClickObservable.add(function () {
  2824. if (options.savedColors) {
  2825. if (options.savedColors.length == 0) {
  2826. setEditButtonVisibility(true);
  2827. }
  2828. if (options.savedColors.length < options.swatchLimit) {
  2829. updateSwatches(newSwatch.background, butSave);
  2830. }
  2831. editSwatches(false);
  2832. }
  2833. });
  2834. if (options.savedColors.length > 0) {
  2835. setEditButtonVisibility(true);
  2836. }
  2837. buttonGrid.addControl(butSave, 2, 0);
  2838. }
  2839. // Picker color values input
  2840. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2841. pickerColorValues.name = "Dialog Lower Right";
  2842. pickerColorValues.addRowDefinition(0.02, false);
  2843. pickerColorValues.addRowDefinition(0.63, false);
  2844. pickerColorValues.addRowDefinition(0.21, false);
  2845. pickerColorValues.addRowDefinition(0.14, false);
  2846. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2847. // RGB values text boxes
  2848. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2849. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2850. rgbValuesQuadrant.name = "RGB Values";
  2851. rgbValuesQuadrant.width = 0.82;
  2852. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2853. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2854. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2855. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2856. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2857. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2858. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2859. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2860. for (var i = 0; i < inputFieldLabels.length; i++) {
  2861. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2862. labelText.text = inputFieldLabels[i];
  2863. labelText.color = buttonColor;
  2864. labelText.fontSize = buttonFontSize;
  2865. rgbValuesQuadrant.addControl(labelText, i, 0);
  2866. }
  2867. // Input fields for RGB values
  2868. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2869. rValInt.width = 0.83;
  2870. rValInt.height = 0.72;
  2871. rValInt.name = "rIntField";
  2872. rValInt.fontSize = buttonFontSize;
  2873. rValInt.text = (currentColor.r * 255).toString();
  2874. rValInt.color = inputTextColor;
  2875. rValInt.background = inputTextBackgroundColor;
  2876. rValInt.onFocusObservable.add(function () {
  2877. activeField = rValInt.name;
  2878. lastVal = rValInt.text;
  2879. editSwatches(false);
  2880. });
  2881. rValInt.onBlurObservable.add(function () {
  2882. if (rValInt.text == "") {
  2883. rValInt.text = "0";
  2884. }
  2885. updateInt(rValInt, "r");
  2886. if (activeField == rValInt.name) {
  2887. activeField = "";
  2888. }
  2889. });
  2890. rValInt.onTextChangedObservable.add(function () {
  2891. if (activeField == rValInt.name) {
  2892. updateInt(rValInt, "r");
  2893. }
  2894. });
  2895. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2896. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2897. gValInt.width = 0.83;
  2898. gValInt.height = 0.72;
  2899. gValInt.name = "gIntField";
  2900. gValInt.fontSize = buttonFontSize;
  2901. gValInt.text = (currentColor.g * 255).toString();
  2902. gValInt.color = inputTextColor;
  2903. gValInt.background = inputTextBackgroundColor;
  2904. gValInt.onFocusObservable.add(function () {
  2905. activeField = gValInt.name;
  2906. lastVal = gValInt.text;
  2907. editSwatches(false);
  2908. });
  2909. gValInt.onBlurObservable.add(function () {
  2910. if (gValInt.text == "") {
  2911. gValInt.text = "0";
  2912. }
  2913. updateInt(gValInt, "g");
  2914. if (activeField == gValInt.name) {
  2915. activeField = "";
  2916. }
  2917. });
  2918. gValInt.onTextChangedObservable.add(function () {
  2919. if (activeField == gValInt.name) {
  2920. updateInt(gValInt, "g");
  2921. }
  2922. });
  2923. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2924. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2925. bValInt.width = 0.83;
  2926. bValInt.height = 0.72;
  2927. bValInt.name = "bIntField";
  2928. bValInt.fontSize = buttonFontSize;
  2929. bValInt.text = (currentColor.b * 255).toString();
  2930. bValInt.color = inputTextColor;
  2931. bValInt.background = inputTextBackgroundColor;
  2932. bValInt.onFocusObservable.add(function () {
  2933. activeField = bValInt.name;
  2934. lastVal = bValInt.text;
  2935. editSwatches(false);
  2936. });
  2937. bValInt.onBlurObservable.add(function () {
  2938. if (bValInt.text == "") {
  2939. bValInt.text = "0";
  2940. }
  2941. updateInt(bValInt, "b");
  2942. if (activeField == bValInt.name) {
  2943. activeField = "";
  2944. }
  2945. });
  2946. bValInt.onTextChangedObservable.add(function () {
  2947. if (activeField == bValInt.name) {
  2948. updateInt(bValInt, "b");
  2949. }
  2950. });
  2951. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2952. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2953. rValDec.width = 0.95;
  2954. rValDec.height = 0.72;
  2955. rValDec.name = "rDecField";
  2956. rValDec.fontSize = buttonFontSize;
  2957. rValDec.text = currentColor.r.toString();
  2958. rValDec.color = inputTextColor;
  2959. rValDec.background = inputTextBackgroundColor;
  2960. rValDec.onFocusObservable.add(function () {
  2961. activeField = rValDec.name;
  2962. lastVal = rValDec.text;
  2963. editSwatches(false);
  2964. });
  2965. rValDec.onBlurObservable.add(function () {
  2966. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2967. rValDec.text = "0";
  2968. updateFloat(rValDec, "r");
  2969. }
  2970. if (activeField == rValDec.name) {
  2971. activeField = "";
  2972. }
  2973. });
  2974. rValDec.onTextChangedObservable.add(function () {
  2975. if (activeField == rValDec.name) {
  2976. updateFloat(rValDec, "r");
  2977. }
  2978. });
  2979. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2980. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2981. gValDec.width = 0.95;
  2982. gValDec.height = 0.72;
  2983. gValDec.name = "gDecField";
  2984. gValDec.fontSize = buttonFontSize;
  2985. gValDec.text = currentColor.g.toString();
  2986. gValDec.color = inputTextColor;
  2987. gValDec.background = inputTextBackgroundColor;
  2988. gValDec.onFocusObservable.add(function () {
  2989. activeField = gValDec.name;
  2990. lastVal = gValDec.text;
  2991. editSwatches(false);
  2992. });
  2993. gValDec.onBlurObservable.add(function () {
  2994. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2995. gValDec.text = "0";
  2996. updateFloat(gValDec, "g");
  2997. }
  2998. if (activeField == gValDec.name) {
  2999. activeField = "";
  3000. }
  3001. });
  3002. gValDec.onTextChangedObservable.add(function () {
  3003. if (activeField == gValDec.name) {
  3004. updateFloat(gValDec, "g");
  3005. }
  3006. });
  3007. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3008. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3009. bValDec.width = 0.95;
  3010. bValDec.height = 0.72;
  3011. bValDec.name = "bDecField";
  3012. bValDec.fontSize = buttonFontSize;
  3013. bValDec.text = currentColor.b.toString();
  3014. bValDec.color = inputTextColor;
  3015. bValDec.background = inputTextBackgroundColor;
  3016. bValDec.onFocusObservable.add(function () {
  3017. activeField = bValDec.name;
  3018. lastVal = bValDec.text;
  3019. editSwatches(false);
  3020. });
  3021. bValDec.onBlurObservable.add(function () {
  3022. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3023. bValDec.text = "0";
  3024. updateFloat(bValDec, "b");
  3025. }
  3026. if (activeField == bValDec.name) {
  3027. activeField = "";
  3028. }
  3029. });
  3030. bValDec.onTextChangedObservable.add(function () {
  3031. if (activeField == bValDec.name) {
  3032. updateFloat(bValDec, "b");
  3033. }
  3034. });
  3035. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3036. // Hex value input
  3037. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3038. hexValueQuadrant.name = "Hex Value";
  3039. hexValueQuadrant.width = 0.82;
  3040. hexValueQuadrant.addRowDefinition(1.0, false);
  3041. hexValueQuadrant.addColumnDefinition(0.1, false);
  3042. hexValueQuadrant.addColumnDefinition(0.9, false);
  3043. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3044. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3045. labelText.text = "#";
  3046. labelText.color = buttonColor;
  3047. labelText.fontSize = buttonFontSize;
  3048. hexValueQuadrant.addControl(labelText, 0, 0);
  3049. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3050. hexVal.width = 0.96;
  3051. hexVal.height = 0.72;
  3052. hexVal.name = "hexField";
  3053. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3054. hexVal.fontSize = buttonFontSize;
  3055. var minusPound = options.lastColor.split("#");
  3056. hexVal.text = minusPound[1];
  3057. hexVal.color = inputTextColor;
  3058. hexVal.background = inputTextBackgroundColor;
  3059. hexVal.onFocusObservable.add(function () {
  3060. activeField = hexVal.name;
  3061. lastVal = hexVal.text;
  3062. editSwatches(false);
  3063. });
  3064. hexVal.onBlurObservable.add(function () {
  3065. if (hexVal.text.length == 3) {
  3066. var val = hexVal.text.split("");
  3067. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3068. }
  3069. if (hexVal.text == "") {
  3070. hexVal.text = "000000";
  3071. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3072. }
  3073. if (activeField == hexVal.name) {
  3074. activeField = "";
  3075. }
  3076. });
  3077. hexVal.onTextChangedObservable.add(function () {
  3078. var newHexValue = hexVal.text;
  3079. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3080. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3081. hexVal.text = lastVal;
  3082. }
  3083. else {
  3084. if (hexVal.text.length < 6) {
  3085. var leadingZero = 6 - hexVal.text.length;
  3086. for (var i = 0; i < leadingZero; i++) {
  3087. newHexValue = "0" + newHexValue;
  3088. }
  3089. }
  3090. if (hexVal.text.length == 3) {
  3091. var val = hexVal.text.split("");
  3092. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3093. }
  3094. newHexValue = "#" + newHexValue;
  3095. if (activeField == hexVal.name) {
  3096. lastVal = hexVal.text;
  3097. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3098. }
  3099. }
  3100. });
  3101. hexValueQuadrant.addControl(hexVal, 0, 1);
  3102. if (options.savedColors && options.savedColors.length > 0) {
  3103. updateSwatches("", butSave);
  3104. }
  3105. });
  3106. };
  3107. ColorPicker._Epsilon = 0.000001;
  3108. return ColorPicker;
  3109. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3110. /***/ }),
  3111. /***/ "./2D/controls/container.ts":
  3112. /*!**********************************!*\
  3113. !*** ./2D/controls/container.ts ***!
  3114. \**********************************/
  3115. /*! exports provided: Container */
  3116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3117. "use strict";
  3118. __webpack_require__.r(__webpack_exports__);
  3119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3120. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3121. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math");
  3122. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3123. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3124. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3125. /**
  3126. * Root class for 2D containers
  3127. * @see http://doc.babylonjs.com/how_to/gui#containers
  3128. */
  3129. var Container = /** @class */ (function (_super) {
  3130. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3131. /**
  3132. * Creates a new Container
  3133. * @param name defines the name of the container
  3134. */
  3135. function Container(name) {
  3136. var _this = _super.call(this, name) || this;
  3137. _this.name = name;
  3138. /** @hidden */
  3139. _this._children = new Array();
  3140. /** @hidden */
  3141. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3142. /** @hidden */
  3143. _this._background = "";
  3144. /** @hidden */
  3145. _this._adaptWidthToChildren = false;
  3146. /** @hidden */
  3147. _this._adaptHeightToChildren = false;
  3148. return _this;
  3149. }
  3150. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3151. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3152. get: function () {
  3153. return this._adaptHeightToChildren;
  3154. },
  3155. set: function (value) {
  3156. if (this._adaptHeightToChildren === value) {
  3157. return;
  3158. }
  3159. this._adaptHeightToChildren = value;
  3160. if (value) {
  3161. this.height = "100%";
  3162. }
  3163. this._markAsDirty();
  3164. },
  3165. enumerable: true,
  3166. configurable: true
  3167. });
  3168. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3169. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3170. get: function () {
  3171. return this._adaptWidthToChildren;
  3172. },
  3173. set: function (value) {
  3174. if (this._adaptWidthToChildren === value) {
  3175. return;
  3176. }
  3177. this._adaptWidthToChildren = value;
  3178. if (value) {
  3179. this.width = "100%";
  3180. }
  3181. this._markAsDirty();
  3182. },
  3183. enumerable: true,
  3184. configurable: true
  3185. });
  3186. Object.defineProperty(Container.prototype, "background", {
  3187. /** Gets or sets background color */
  3188. get: function () {
  3189. return this._background;
  3190. },
  3191. set: function (value) {
  3192. if (this._background === value) {
  3193. return;
  3194. }
  3195. this._background = value;
  3196. this._markAsDirty();
  3197. },
  3198. enumerable: true,
  3199. configurable: true
  3200. });
  3201. Object.defineProperty(Container.prototype, "children", {
  3202. /** Gets the list of children */
  3203. get: function () {
  3204. return this._children;
  3205. },
  3206. enumerable: true,
  3207. configurable: true
  3208. });
  3209. Container.prototype._getTypeName = function () {
  3210. return "Container";
  3211. };
  3212. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3213. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3214. var child = _a[_i];
  3215. child._markMatrixAsDirty();
  3216. }
  3217. };
  3218. /**
  3219. * Gets a child using its name
  3220. * @param name defines the child name to look for
  3221. * @returns the child control if found
  3222. */
  3223. Container.prototype.getChildByName = function (name) {
  3224. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3225. var child = _a[_i];
  3226. if (child.name === name) {
  3227. return child;
  3228. }
  3229. }
  3230. return null;
  3231. };
  3232. /**
  3233. * Gets a child using its type and its name
  3234. * @param name defines the child name to look for
  3235. * @param type defines the child type to look for
  3236. * @returns the child control if found
  3237. */
  3238. Container.prototype.getChildByType = function (name, type) {
  3239. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3240. var child = _a[_i];
  3241. if (child.typeName === type) {
  3242. return child;
  3243. }
  3244. }
  3245. return null;
  3246. };
  3247. /**
  3248. * Search for a specific control in children
  3249. * @param control defines the control to look for
  3250. * @returns true if the control is in child list
  3251. */
  3252. Container.prototype.containsControl = function (control) {
  3253. return this.children.indexOf(control) !== -1;
  3254. };
  3255. /**
  3256. * Adds a new control to the current container
  3257. * @param control defines the control to add
  3258. * @returns the current container
  3259. */
  3260. Container.prototype.addControl = function (control) {
  3261. if (!control) {
  3262. return this;
  3263. }
  3264. var index = this._children.indexOf(control);
  3265. if (index !== -1) {
  3266. return this;
  3267. }
  3268. control._link(this._host);
  3269. control._markAllAsDirty();
  3270. this._reOrderControl(control);
  3271. this._markAsDirty();
  3272. return this;
  3273. };
  3274. /**
  3275. * Removes all controls from the current container
  3276. * @returns the current container
  3277. */
  3278. Container.prototype.clearControls = function () {
  3279. var children = this.children.slice();
  3280. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3281. var child = children_1[_i];
  3282. this.removeControl(child);
  3283. }
  3284. return this;
  3285. };
  3286. /**
  3287. * Removes a control from the current container
  3288. * @param control defines the control to remove
  3289. * @returns the current container
  3290. */
  3291. Container.prototype.removeControl = function (control) {
  3292. var index = this._children.indexOf(control);
  3293. if (index !== -1) {
  3294. this._children.splice(index, 1);
  3295. control.parent = null;
  3296. }
  3297. control.linkWithMesh(null);
  3298. if (this._host) {
  3299. this._host._cleanControlAfterRemoval(control);
  3300. }
  3301. this._markAsDirty();
  3302. return this;
  3303. };
  3304. /** @hidden */
  3305. Container.prototype._reOrderControl = function (control) {
  3306. this.removeControl(control);
  3307. var wasAdded = false;
  3308. for (var index = 0; index < this._children.length; index++) {
  3309. if (this._children[index].zIndex > control.zIndex) {
  3310. this._children.splice(index, 0, control);
  3311. wasAdded = true;
  3312. break;
  3313. }
  3314. }
  3315. if (!wasAdded) {
  3316. this._children.push(control);
  3317. }
  3318. control.parent = this;
  3319. this._markAsDirty();
  3320. };
  3321. /** @hidden */
  3322. Container.prototype._offsetLeft = function (offset) {
  3323. _super.prototype._offsetLeft.call(this, offset);
  3324. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3325. var child = _a[_i];
  3326. child._offsetLeft(offset);
  3327. }
  3328. };
  3329. /** @hidden */
  3330. Container.prototype._offsetTop = function (offset) {
  3331. _super.prototype._offsetTop.call(this, offset);
  3332. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3333. var child = _a[_i];
  3334. child._offsetTop(offset);
  3335. }
  3336. };
  3337. /** @hidden */
  3338. Container.prototype._markAllAsDirty = function () {
  3339. _super.prototype._markAllAsDirty.call(this);
  3340. for (var index = 0; index < this._children.length; index++) {
  3341. this._children[index]._markAllAsDirty();
  3342. }
  3343. };
  3344. /** @hidden */
  3345. Container.prototype._localDraw = function (context) {
  3346. if (this._background) {
  3347. context.save();
  3348. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3349. context.shadowColor = this.shadowColor;
  3350. context.shadowBlur = this.shadowBlur;
  3351. context.shadowOffsetX = this.shadowOffsetX;
  3352. context.shadowOffsetY = this.shadowOffsetY;
  3353. }
  3354. context.fillStyle = this._background;
  3355. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3356. context.restore();
  3357. }
  3358. };
  3359. /** @hidden */
  3360. Container.prototype._link = function (host) {
  3361. _super.prototype._link.call(this, host);
  3362. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3363. var child = _a[_i];
  3364. child._link(host);
  3365. }
  3366. };
  3367. /** @hidden */
  3368. Container.prototype._beforeLayout = function () {
  3369. // Do nothing
  3370. };
  3371. /** @hidden */
  3372. Container.prototype._processMeasures = function (parentMeasure, context) {
  3373. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3374. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3375. this._evaluateClippingState(parentMeasure);
  3376. }
  3377. };
  3378. /** @hidden */
  3379. Container.prototype._layout = function (parentMeasure, context) {
  3380. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3381. return false;
  3382. }
  3383. if (this._isDirty) {
  3384. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3385. }
  3386. var rebuildCount = 0;
  3387. context.save();
  3388. this._applyStates(context);
  3389. this._beforeLayout();
  3390. do {
  3391. var computedWidth = -1;
  3392. var computedHeight = -1;
  3393. this._rebuildLayout = false;
  3394. this._processMeasures(parentMeasure, context);
  3395. if (!this._isClipped) {
  3396. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3397. var child = _a[_i];
  3398. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3399. if (child._layout(this._measureForChildren, context)) {
  3400. if (this.adaptWidthToChildren && child._width.isPixel) {
  3401. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3402. }
  3403. if (this.adaptHeightToChildren && child._height.isPixel) {
  3404. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3405. }
  3406. }
  3407. }
  3408. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3409. if (this.width !== computedWidth + "px") {
  3410. this.width = computedWidth + "px";
  3411. this._rebuildLayout = true;
  3412. }
  3413. }
  3414. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3415. if (this.height !== computedHeight + "px") {
  3416. this.height = computedHeight + "px";
  3417. this._rebuildLayout = true;
  3418. }
  3419. }
  3420. this._postMeasure();
  3421. }
  3422. rebuildCount++;
  3423. } while (this._rebuildLayout && rebuildCount < 3);
  3424. if (rebuildCount >= 3) {
  3425. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3426. }
  3427. context.restore();
  3428. if (this._isDirty) {
  3429. this.invalidateRect();
  3430. this._isDirty = false;
  3431. }
  3432. return true;
  3433. };
  3434. Container.prototype._postMeasure = function () {
  3435. // Do nothing by default
  3436. };
  3437. /** @hidden */
  3438. Container.prototype._draw = function (context, invalidatedRectangle) {
  3439. this._localDraw(context);
  3440. if (this.clipChildren) {
  3441. this._clipForChildren(context);
  3442. }
  3443. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3444. var child = _a[_i];
  3445. // Only redraw parts of the screen that are invalidated
  3446. if (invalidatedRectangle) {
  3447. if (!child._intersectsRect(invalidatedRectangle)) {
  3448. continue;
  3449. }
  3450. }
  3451. child._render(context, invalidatedRectangle);
  3452. }
  3453. };
  3454. /** @hidden */
  3455. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3456. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3457. if (!this.children) {
  3458. return;
  3459. }
  3460. for (var index = 0; index < this.children.length; index++) {
  3461. var item = this.children[index];
  3462. if (!predicate || predicate(item)) {
  3463. results.push(item);
  3464. }
  3465. if (!directDescendantsOnly) {
  3466. item._getDescendants(results, false, predicate);
  3467. }
  3468. }
  3469. };
  3470. /** @hidden */
  3471. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3472. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3473. return false;
  3474. }
  3475. if (!_super.prototype.contains.call(this, x, y)) {
  3476. return false;
  3477. }
  3478. // Checking backwards to pick closest first
  3479. for (var index = this._children.length - 1; index >= 0; index--) {
  3480. var child = this._children[index];
  3481. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3482. if (child.hoverCursor) {
  3483. this._host._changeCursor(child.hoverCursor);
  3484. }
  3485. return true;
  3486. }
  3487. }
  3488. if (!this.isHitTestVisible) {
  3489. return false;
  3490. }
  3491. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3492. };
  3493. /** @hidden */
  3494. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3495. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3496. this._measureForChildren.copyFrom(this._currentMeasure);
  3497. };
  3498. /** Releases associated resources */
  3499. Container.prototype.dispose = function () {
  3500. _super.prototype.dispose.call(this);
  3501. for (var index = this.children.length - 1; index >= 0; index--) {
  3502. this.children[index].dispose();
  3503. }
  3504. };
  3505. return Container;
  3506. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3507. /***/ }),
  3508. /***/ "./2D/controls/control.ts":
  3509. /*!********************************!*\
  3510. !*** ./2D/controls/control.ts ***!
  3511. \********************************/
  3512. /*! exports provided: Control */
  3513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3514. "use strict";
  3515. __webpack_require__.r(__webpack_exports__);
  3516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3517. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  3518. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3519. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3520. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3521. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3522. /**
  3523. * Root class used for all 2D controls
  3524. * @see http://doc.babylonjs.com/how_to/gui#controls
  3525. */
  3526. var Control = /** @class */ (function () {
  3527. // Functions
  3528. /**
  3529. * Creates a new control
  3530. * @param name defines the name of the control
  3531. */
  3532. function Control(
  3533. /** defines the name of the control */
  3534. name) {
  3535. this.name = name;
  3536. this._alpha = 1;
  3537. this._alphaSet = false;
  3538. this._zIndex = 0;
  3539. /** @hidden */
  3540. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3541. this._fontFamily = "Arial";
  3542. this._fontStyle = "";
  3543. this._fontWeight = "";
  3544. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3545. /** @hidden */
  3546. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3547. /** @hidden */
  3548. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3549. this._color = "";
  3550. this._style = null;
  3551. /** @hidden */
  3552. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3553. /** @hidden */
  3554. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3555. /** @hidden */
  3556. this._isDirty = true;
  3557. /** @hidden */
  3558. this._wasDirty = false;
  3559. /** @hidden */
  3560. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3561. /** @hidden */
  3562. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3563. /** @hidden */
  3564. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3565. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3566. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3567. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3568. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3569. /** @hidden */
  3570. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3571. /** @hidden */
  3572. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3573. this._scaleX = 1.0;
  3574. this._scaleY = 1.0;
  3575. this._rotation = 0;
  3576. this._transformCenterX = 0.5;
  3577. this._transformCenterY = 0.5;
  3578. /** @hidden */
  3579. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3580. /** @hidden */
  3581. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3582. /** @hidden */
  3583. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3584. this._isMatrixDirty = true;
  3585. this._isVisible = true;
  3586. this._isHighlighted = false;
  3587. this._fontSet = false;
  3588. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3589. this._downCount = 0;
  3590. this._enterCount = -1;
  3591. this._doNotRender = false;
  3592. this._downPointerIds = {};
  3593. this._isEnabled = true;
  3594. this._disabledColor = "#9a9a9a";
  3595. /** @hidden */
  3596. this._rebuildLayout = false;
  3597. /** @hidden */
  3598. this._isClipped = false;
  3599. /**
  3600. * Gets or sets an object used to store user defined information for the node
  3601. */
  3602. this.metadata = null;
  3603. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3604. this.isHitTestVisible = true;
  3605. /** Gets or sets a boolean indicating if the control can block pointer events */
  3606. this.isPointerBlocker = false;
  3607. /** Gets or sets a boolean indicating if the control can be focusable */
  3608. this.isFocusInvisible = false;
  3609. /**
  3610. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3611. * 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
  3612. */
  3613. this.clipChildren = true;
  3614. /**
  3615. * Gets or sets a boolean indicating that control content must be clipped
  3616. * 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
  3617. */
  3618. this.clipContent = true;
  3619. /**
  3620. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3621. */
  3622. this.useBitmapCache = false;
  3623. this._shadowOffsetX = 0;
  3624. this._shadowOffsetY = 0;
  3625. this._shadowBlur = 0;
  3626. this._shadowColor = 'black';
  3627. /** Gets or sets the cursor to use when the control is hovered */
  3628. this.hoverCursor = "";
  3629. /** @hidden */
  3630. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3631. /** @hidden */
  3632. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3633. /**
  3634. * An event triggered when the pointer move over the control.
  3635. */
  3636. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3637. /**
  3638. * An event triggered when the pointer move out of the control.
  3639. */
  3640. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3641. /**
  3642. * An event triggered when the pointer taps the control
  3643. */
  3644. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3645. /**
  3646. * An event triggered when pointer up
  3647. */
  3648. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3649. /**
  3650. * An event triggered when a control is clicked on
  3651. */
  3652. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3653. /**
  3654. * An event triggered when pointer enters the control
  3655. */
  3656. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3657. /**
  3658. * An event triggered when the control is marked as dirty
  3659. */
  3660. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3661. /**
  3662. * An event triggered before drawing the control
  3663. */
  3664. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3665. /**
  3666. * An event triggered after the control was drawn
  3667. */
  3668. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3669. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3670. }
  3671. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3672. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3673. get: function () {
  3674. return this._shadowOffsetX;
  3675. },
  3676. set: function (value) {
  3677. if (this._shadowOffsetX === value) {
  3678. return;
  3679. }
  3680. this._shadowOffsetX = value;
  3681. this._markAsDirty();
  3682. },
  3683. enumerable: true,
  3684. configurable: true
  3685. });
  3686. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3687. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3688. get: function () {
  3689. return this._shadowOffsetY;
  3690. },
  3691. set: function (value) {
  3692. if (this._shadowOffsetY === value) {
  3693. return;
  3694. }
  3695. this._shadowOffsetY = value;
  3696. this._markAsDirty();
  3697. },
  3698. enumerable: true,
  3699. configurable: true
  3700. });
  3701. Object.defineProperty(Control.prototype, "shadowBlur", {
  3702. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3703. get: function () {
  3704. return this._shadowBlur;
  3705. },
  3706. set: function (value) {
  3707. if (this._shadowBlur === value) {
  3708. return;
  3709. }
  3710. this._shadowBlur = value;
  3711. this._markAsDirty();
  3712. },
  3713. enumerable: true,
  3714. configurable: true
  3715. });
  3716. Object.defineProperty(Control.prototype, "shadowColor", {
  3717. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3718. get: function () {
  3719. return this._shadowColor;
  3720. },
  3721. set: function (value) {
  3722. if (this._shadowColor === value) {
  3723. return;
  3724. }
  3725. this._shadowColor = value;
  3726. this._markAsDirty();
  3727. },
  3728. enumerable: true,
  3729. configurable: true
  3730. });
  3731. Object.defineProperty(Control.prototype, "typeName", {
  3732. // Properties
  3733. /** Gets the control type name */
  3734. get: function () {
  3735. return this._getTypeName();
  3736. },
  3737. enumerable: true,
  3738. configurable: true
  3739. });
  3740. /**
  3741. * Get the current class name of the control.
  3742. * @returns current class name
  3743. */
  3744. Control.prototype.getClassName = function () {
  3745. return this._getTypeName();
  3746. };
  3747. Object.defineProperty(Control.prototype, "host", {
  3748. /**
  3749. * Get the hosting AdvancedDynamicTexture
  3750. */
  3751. get: function () {
  3752. return this._host;
  3753. },
  3754. enumerable: true,
  3755. configurable: true
  3756. });
  3757. Object.defineProperty(Control.prototype, "fontOffset", {
  3758. /** Gets or set information about font offsets (used to render and align text) */
  3759. get: function () {
  3760. return this._fontOffset;
  3761. },
  3762. set: function (offset) {
  3763. this._fontOffset = offset;
  3764. },
  3765. enumerable: true,
  3766. configurable: true
  3767. });
  3768. Object.defineProperty(Control.prototype, "alpha", {
  3769. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3770. get: function () {
  3771. return this._alpha;
  3772. },
  3773. set: function (value) {
  3774. if (this._alpha === value) {
  3775. return;
  3776. }
  3777. this._alphaSet = true;
  3778. this._alpha = value;
  3779. this._markAsDirty();
  3780. },
  3781. enumerable: true,
  3782. configurable: true
  3783. });
  3784. Object.defineProperty(Control.prototype, "isHighlighted", {
  3785. /**
  3786. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3787. */
  3788. get: function () {
  3789. return this._isHighlighted;
  3790. },
  3791. set: function (value) {
  3792. if (this._isHighlighted === value) {
  3793. return;
  3794. }
  3795. this._isHighlighted = value;
  3796. this._markAsDirty();
  3797. },
  3798. enumerable: true,
  3799. configurable: true
  3800. });
  3801. Object.defineProperty(Control.prototype, "scaleX", {
  3802. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3803. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3804. */
  3805. get: function () {
  3806. return this._scaleX;
  3807. },
  3808. set: function (value) {
  3809. if (this._scaleX === value) {
  3810. return;
  3811. }
  3812. this._scaleX = value;
  3813. this._markAsDirty();
  3814. this._markMatrixAsDirty();
  3815. },
  3816. enumerable: true,
  3817. configurable: true
  3818. });
  3819. Object.defineProperty(Control.prototype, "scaleY", {
  3820. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3821. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3822. */
  3823. get: function () {
  3824. return this._scaleY;
  3825. },
  3826. set: function (value) {
  3827. if (this._scaleY === value) {
  3828. return;
  3829. }
  3830. this._scaleY = value;
  3831. this._markAsDirty();
  3832. this._markMatrixAsDirty();
  3833. },
  3834. enumerable: true,
  3835. configurable: true
  3836. });
  3837. Object.defineProperty(Control.prototype, "rotation", {
  3838. /** Gets or sets the rotation angle (0 by default)
  3839. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3840. */
  3841. get: function () {
  3842. return this._rotation;
  3843. },
  3844. set: function (value) {
  3845. if (this._rotation === value) {
  3846. return;
  3847. }
  3848. this._rotation = value;
  3849. this._markAsDirty();
  3850. this._markMatrixAsDirty();
  3851. },
  3852. enumerable: true,
  3853. configurable: true
  3854. });
  3855. Object.defineProperty(Control.prototype, "transformCenterY", {
  3856. /** Gets or sets the transformation center on Y axis (0 by default)
  3857. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3858. */
  3859. get: function () {
  3860. return this._transformCenterY;
  3861. },
  3862. set: function (value) {
  3863. if (this._transformCenterY === value) {
  3864. return;
  3865. }
  3866. this._transformCenterY = value;
  3867. this._markAsDirty();
  3868. this._markMatrixAsDirty();
  3869. },
  3870. enumerable: true,
  3871. configurable: true
  3872. });
  3873. Object.defineProperty(Control.prototype, "transformCenterX", {
  3874. /** Gets or sets the transformation center on X axis (0 by default)
  3875. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3876. */
  3877. get: function () {
  3878. return this._transformCenterX;
  3879. },
  3880. set: function (value) {
  3881. if (this._transformCenterX === value) {
  3882. return;
  3883. }
  3884. this._transformCenterX = value;
  3885. this._markAsDirty();
  3886. this._markMatrixAsDirty();
  3887. },
  3888. enumerable: true,
  3889. configurable: true
  3890. });
  3891. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3892. /**
  3893. * Gets or sets the horizontal alignment
  3894. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3895. */
  3896. get: function () {
  3897. return this._horizontalAlignment;
  3898. },
  3899. set: function (value) {
  3900. if (this._horizontalAlignment === value) {
  3901. return;
  3902. }
  3903. this._horizontalAlignment = value;
  3904. this._markAsDirty();
  3905. },
  3906. enumerable: true,
  3907. configurable: true
  3908. });
  3909. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3910. /**
  3911. * Gets or sets the vertical alignment
  3912. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3913. */
  3914. get: function () {
  3915. return this._verticalAlignment;
  3916. },
  3917. set: function (value) {
  3918. if (this._verticalAlignment === value) {
  3919. return;
  3920. }
  3921. this._verticalAlignment = value;
  3922. this._markAsDirty();
  3923. },
  3924. enumerable: true,
  3925. configurable: true
  3926. });
  3927. Object.defineProperty(Control.prototype, "width", {
  3928. /**
  3929. * Gets or sets control width
  3930. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3931. */
  3932. get: function () {
  3933. return this._width.toString(this._host);
  3934. },
  3935. set: function (value) {
  3936. if (this._width.toString(this._host) === value) {
  3937. return;
  3938. }
  3939. if (this._width.fromString(value)) {
  3940. this._markAsDirty();
  3941. }
  3942. },
  3943. enumerable: true,
  3944. configurable: true
  3945. });
  3946. Object.defineProperty(Control.prototype, "widthInPixels", {
  3947. /**
  3948. * Gets or sets the control width in pixel
  3949. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3950. */
  3951. get: function () {
  3952. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3953. },
  3954. set: function (value) {
  3955. if (isNaN(value)) {
  3956. return;
  3957. }
  3958. this.width = value + "px";
  3959. },
  3960. enumerable: true,
  3961. configurable: true
  3962. });
  3963. Object.defineProperty(Control.prototype, "height", {
  3964. /**
  3965. * Gets or sets control height
  3966. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3967. */
  3968. get: function () {
  3969. return this._height.toString(this._host);
  3970. },
  3971. set: function (value) {
  3972. if (this._height.toString(this._host) === value) {
  3973. return;
  3974. }
  3975. if (this._height.fromString(value)) {
  3976. this._markAsDirty();
  3977. }
  3978. },
  3979. enumerable: true,
  3980. configurable: true
  3981. });
  3982. Object.defineProperty(Control.prototype, "heightInPixels", {
  3983. /**
  3984. * Gets or sets control height in pixel
  3985. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3986. */
  3987. get: function () {
  3988. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  3989. },
  3990. set: function (value) {
  3991. if (isNaN(value)) {
  3992. return;
  3993. }
  3994. this.height = value + "px";
  3995. },
  3996. enumerable: true,
  3997. configurable: true
  3998. });
  3999. Object.defineProperty(Control.prototype, "fontFamily", {
  4000. /** Gets or set font family */
  4001. get: function () {
  4002. if (!this._fontSet) {
  4003. return "";
  4004. }
  4005. return this._fontFamily;
  4006. },
  4007. set: function (value) {
  4008. if (this._fontFamily === value) {
  4009. return;
  4010. }
  4011. this._fontFamily = value;
  4012. this._resetFontCache();
  4013. },
  4014. enumerable: true,
  4015. configurable: true
  4016. });
  4017. Object.defineProperty(Control.prototype, "fontStyle", {
  4018. /** Gets or sets font style */
  4019. get: function () {
  4020. return this._fontStyle;
  4021. },
  4022. set: function (value) {
  4023. if (this._fontStyle === value) {
  4024. return;
  4025. }
  4026. this._fontStyle = value;
  4027. this._resetFontCache();
  4028. },
  4029. enumerable: true,
  4030. configurable: true
  4031. });
  4032. Object.defineProperty(Control.prototype, "fontWeight", {
  4033. /** Gets or sets font weight */
  4034. get: function () {
  4035. return this._fontWeight;
  4036. },
  4037. set: function (value) {
  4038. if (this._fontWeight === value) {
  4039. return;
  4040. }
  4041. this._fontWeight = value;
  4042. this._resetFontCache();
  4043. },
  4044. enumerable: true,
  4045. configurable: true
  4046. });
  4047. Object.defineProperty(Control.prototype, "style", {
  4048. /**
  4049. * Gets or sets style
  4050. * @see http://doc.babylonjs.com/how_to/gui#styles
  4051. */
  4052. get: function () {
  4053. return this._style;
  4054. },
  4055. set: function (value) {
  4056. var _this = this;
  4057. if (this._style) {
  4058. this._style.onChangedObservable.remove(this._styleObserver);
  4059. this._styleObserver = null;
  4060. }
  4061. this._style = value;
  4062. if (this._style) {
  4063. this._styleObserver = this._style.onChangedObservable.add(function () {
  4064. _this._markAsDirty();
  4065. _this._resetFontCache();
  4066. });
  4067. }
  4068. this._markAsDirty();
  4069. this._resetFontCache();
  4070. },
  4071. enumerable: true,
  4072. configurable: true
  4073. });
  4074. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4075. /** @hidden */
  4076. get: function () {
  4077. return this._fontSize.isPercentage;
  4078. },
  4079. enumerable: true,
  4080. configurable: true
  4081. });
  4082. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4083. /** Gets or sets font size in pixels */
  4084. get: function () {
  4085. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4086. if (fontSizeToUse.isPixel) {
  4087. return fontSizeToUse.getValue(this._host);
  4088. }
  4089. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4090. },
  4091. set: function (value) {
  4092. if (isNaN(value)) {
  4093. return;
  4094. }
  4095. this.fontSize = value + "px";
  4096. },
  4097. enumerable: true,
  4098. configurable: true
  4099. });
  4100. Object.defineProperty(Control.prototype, "fontSize", {
  4101. /** Gets or sets font size */
  4102. get: function () {
  4103. return this._fontSize.toString(this._host);
  4104. },
  4105. set: function (value) {
  4106. if (this._fontSize.toString(this._host) === value) {
  4107. return;
  4108. }
  4109. if (this._fontSize.fromString(value)) {
  4110. this._markAsDirty();
  4111. this._resetFontCache();
  4112. }
  4113. },
  4114. enumerable: true,
  4115. configurable: true
  4116. });
  4117. Object.defineProperty(Control.prototype, "color", {
  4118. /** Gets or sets foreground color */
  4119. get: function () {
  4120. return this._color;
  4121. },
  4122. set: function (value) {
  4123. if (this._color === value) {
  4124. return;
  4125. }
  4126. this._color = value;
  4127. this._markAsDirty();
  4128. },
  4129. enumerable: true,
  4130. configurable: true
  4131. });
  4132. Object.defineProperty(Control.prototype, "zIndex", {
  4133. /** Gets or sets z index which is used to reorder controls on the z axis */
  4134. get: function () {
  4135. return this._zIndex;
  4136. },
  4137. set: function (value) {
  4138. if (this.zIndex === value) {
  4139. return;
  4140. }
  4141. this._zIndex = value;
  4142. if (this.parent) {
  4143. this.parent._reOrderControl(this);
  4144. }
  4145. },
  4146. enumerable: true,
  4147. configurable: true
  4148. });
  4149. Object.defineProperty(Control.prototype, "notRenderable", {
  4150. /** Gets or sets a boolean indicating if the control can be rendered */
  4151. get: function () {
  4152. return this._doNotRender;
  4153. },
  4154. set: function (value) {
  4155. if (this._doNotRender === value) {
  4156. return;
  4157. }
  4158. this._doNotRender = value;
  4159. this._markAsDirty();
  4160. },
  4161. enumerable: true,
  4162. configurable: true
  4163. });
  4164. Object.defineProperty(Control.prototype, "isVisible", {
  4165. /** Gets or sets a boolean indicating if the control is visible */
  4166. get: function () {
  4167. return this._isVisible;
  4168. },
  4169. set: function (value) {
  4170. if (this._isVisible === value) {
  4171. return;
  4172. }
  4173. this._isVisible = value;
  4174. this._markAsDirty(true);
  4175. },
  4176. enumerable: true,
  4177. configurable: true
  4178. });
  4179. Object.defineProperty(Control.prototype, "isDirty", {
  4180. /** Gets a boolean indicating that the control needs to update its rendering */
  4181. get: function () {
  4182. return this._isDirty;
  4183. },
  4184. enumerable: true,
  4185. configurable: true
  4186. });
  4187. Object.defineProperty(Control.prototype, "linkedMesh", {
  4188. /**
  4189. * Gets the current linked mesh (or null if none)
  4190. */
  4191. get: function () {
  4192. return this._linkedMesh;
  4193. },
  4194. enumerable: true,
  4195. configurable: true
  4196. });
  4197. Object.defineProperty(Control.prototype, "paddingLeft", {
  4198. /**
  4199. * Gets or sets a value indicating the padding to use on the left of the control
  4200. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4201. */
  4202. get: function () {
  4203. return this._paddingLeft.toString(this._host);
  4204. },
  4205. set: function (value) {
  4206. if (this._paddingLeft.fromString(value)) {
  4207. this._markAsDirty();
  4208. }
  4209. },
  4210. enumerable: true,
  4211. configurable: true
  4212. });
  4213. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4214. /**
  4215. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4216. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4217. */
  4218. get: function () {
  4219. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4220. },
  4221. set: function (value) {
  4222. if (isNaN(value)) {
  4223. return;
  4224. }
  4225. this.paddingLeft = value + "px";
  4226. },
  4227. enumerable: true,
  4228. configurable: true
  4229. });
  4230. Object.defineProperty(Control.prototype, "paddingRight", {
  4231. /**
  4232. * Gets or sets a value indicating the padding to use on the right of the control
  4233. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4234. */
  4235. get: function () {
  4236. return this._paddingRight.toString(this._host);
  4237. },
  4238. set: function (value) {
  4239. if (this._paddingRight.fromString(value)) {
  4240. this._markAsDirty();
  4241. }
  4242. },
  4243. enumerable: true,
  4244. configurable: true
  4245. });
  4246. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4247. /**
  4248. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4249. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4250. */
  4251. get: function () {
  4252. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4253. },
  4254. set: function (value) {
  4255. if (isNaN(value)) {
  4256. return;
  4257. }
  4258. this.paddingRight = value + "px";
  4259. },
  4260. enumerable: true,
  4261. configurable: true
  4262. });
  4263. Object.defineProperty(Control.prototype, "paddingTop", {
  4264. /**
  4265. * Gets or sets a value indicating the padding to use on the top of the control
  4266. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4267. */
  4268. get: function () {
  4269. return this._paddingTop.toString(this._host);
  4270. },
  4271. set: function (value) {
  4272. if (this._paddingTop.fromString(value)) {
  4273. this._markAsDirty();
  4274. }
  4275. },
  4276. enumerable: true,
  4277. configurable: true
  4278. });
  4279. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4280. /**
  4281. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4282. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4283. */
  4284. get: function () {
  4285. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4286. },
  4287. set: function (value) {
  4288. if (isNaN(value)) {
  4289. return;
  4290. }
  4291. this.paddingTop = value + "px";
  4292. },
  4293. enumerable: true,
  4294. configurable: true
  4295. });
  4296. Object.defineProperty(Control.prototype, "paddingBottom", {
  4297. /**
  4298. * Gets or sets a value indicating the padding to use on the bottom of the control
  4299. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4300. */
  4301. get: function () {
  4302. return this._paddingBottom.toString(this._host);
  4303. },
  4304. set: function (value) {
  4305. if (this._paddingBottom.fromString(value)) {
  4306. this._markAsDirty();
  4307. }
  4308. },
  4309. enumerable: true,
  4310. configurable: true
  4311. });
  4312. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4313. /**
  4314. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4315. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4316. */
  4317. get: function () {
  4318. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4319. },
  4320. set: function (value) {
  4321. if (isNaN(value)) {
  4322. return;
  4323. }
  4324. this.paddingBottom = value + "px";
  4325. },
  4326. enumerable: true,
  4327. configurable: true
  4328. });
  4329. Object.defineProperty(Control.prototype, "left", {
  4330. /**
  4331. * Gets or sets a value indicating the left coordinate of the control
  4332. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4333. */
  4334. get: function () {
  4335. return this._left.toString(this._host);
  4336. },
  4337. set: function (value) {
  4338. if (this._left.fromString(value)) {
  4339. this._markAsDirty();
  4340. }
  4341. },
  4342. enumerable: true,
  4343. configurable: true
  4344. });
  4345. Object.defineProperty(Control.prototype, "leftInPixels", {
  4346. /**
  4347. * Gets or sets a value indicating the left coordinate in pixels of the control
  4348. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4349. */
  4350. get: function () {
  4351. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4352. },
  4353. set: function (value) {
  4354. if (isNaN(value)) {
  4355. return;
  4356. }
  4357. this.left = value + "px";
  4358. },
  4359. enumerable: true,
  4360. configurable: true
  4361. });
  4362. Object.defineProperty(Control.prototype, "top", {
  4363. /**
  4364. * Gets or sets a value indicating the top coordinate of the control
  4365. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4366. */
  4367. get: function () {
  4368. return this._top.toString(this._host);
  4369. },
  4370. set: function (value) {
  4371. if (this._top.fromString(value)) {
  4372. this._markAsDirty();
  4373. }
  4374. },
  4375. enumerable: true,
  4376. configurable: true
  4377. });
  4378. Object.defineProperty(Control.prototype, "topInPixels", {
  4379. /**
  4380. * Gets or sets a value indicating the top coordinate in pixels of the control
  4381. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4382. */
  4383. get: function () {
  4384. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4385. },
  4386. set: function (value) {
  4387. if (isNaN(value)) {
  4388. return;
  4389. }
  4390. this.top = value + "px";
  4391. },
  4392. enumerable: true,
  4393. configurable: true
  4394. });
  4395. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4396. /**
  4397. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4398. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4399. */
  4400. get: function () {
  4401. return this._linkOffsetX.toString(this._host);
  4402. },
  4403. set: function (value) {
  4404. if (this._linkOffsetX.fromString(value)) {
  4405. this._markAsDirty();
  4406. }
  4407. },
  4408. enumerable: true,
  4409. configurable: true
  4410. });
  4411. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4412. /**
  4413. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4414. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4415. */
  4416. get: function () {
  4417. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4418. },
  4419. set: function (value) {
  4420. if (isNaN(value)) {
  4421. return;
  4422. }
  4423. this.linkOffsetX = value + "px";
  4424. },
  4425. enumerable: true,
  4426. configurable: true
  4427. });
  4428. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4429. /**
  4430. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4431. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4432. */
  4433. get: function () {
  4434. return this._linkOffsetY.toString(this._host);
  4435. },
  4436. set: function (value) {
  4437. if (this._linkOffsetY.fromString(value)) {
  4438. this._markAsDirty();
  4439. }
  4440. },
  4441. enumerable: true,
  4442. configurable: true
  4443. });
  4444. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4445. /**
  4446. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4447. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4448. */
  4449. get: function () {
  4450. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4451. },
  4452. set: function (value) {
  4453. if (isNaN(value)) {
  4454. return;
  4455. }
  4456. this.linkOffsetY = value + "px";
  4457. },
  4458. enumerable: true,
  4459. configurable: true
  4460. });
  4461. Object.defineProperty(Control.prototype, "centerX", {
  4462. /** Gets the center coordinate on X axis */
  4463. get: function () {
  4464. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4465. },
  4466. enumerable: true,
  4467. configurable: true
  4468. });
  4469. Object.defineProperty(Control.prototype, "centerY", {
  4470. /** Gets the center coordinate on Y axis */
  4471. get: function () {
  4472. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4473. },
  4474. enumerable: true,
  4475. configurable: true
  4476. });
  4477. Object.defineProperty(Control.prototype, "isEnabled", {
  4478. /** Gets or sets if control is Enabled*/
  4479. get: function () {
  4480. return this._isEnabled;
  4481. },
  4482. set: function (value) {
  4483. if (this._isEnabled === value) {
  4484. return;
  4485. }
  4486. this._isEnabled = value;
  4487. this._markAsDirty();
  4488. },
  4489. enumerable: true,
  4490. configurable: true
  4491. });
  4492. Object.defineProperty(Control.prototype, "disabledColor", {
  4493. /** Gets or sets background color of control if it's disabled*/
  4494. get: function () {
  4495. return this._disabledColor;
  4496. },
  4497. set: function (value) {
  4498. if (this._disabledColor === value) {
  4499. return;
  4500. }
  4501. this._disabledColor = value;
  4502. this._markAsDirty();
  4503. },
  4504. enumerable: true,
  4505. configurable: true
  4506. });
  4507. /** @hidden */
  4508. Control.prototype._getTypeName = function () {
  4509. return "Control";
  4510. };
  4511. /**
  4512. * Gets the first ascendant in the hierarchy of the given type
  4513. * @param className defines the required type
  4514. * @returns the ascendant or null if not found
  4515. */
  4516. Control.prototype.getAscendantOfClass = function (className) {
  4517. if (!this.parent) {
  4518. return null;
  4519. }
  4520. if (this.parent.getClassName() === className) {
  4521. return this.parent;
  4522. }
  4523. return this.parent.getAscendantOfClass(className);
  4524. };
  4525. /** @hidden */
  4526. Control.prototype._resetFontCache = function () {
  4527. this._fontSet = true;
  4528. this._markAsDirty();
  4529. };
  4530. /**
  4531. * Determines if a container is an ascendant of the current control
  4532. * @param container defines the container to look for
  4533. * @returns true if the container is one of the ascendant of the control
  4534. */
  4535. Control.prototype.isAscendant = function (container) {
  4536. if (!this.parent) {
  4537. return false;
  4538. }
  4539. if (this.parent === container) {
  4540. return true;
  4541. }
  4542. return this.parent.isAscendant(container);
  4543. };
  4544. /**
  4545. * Gets coordinates in local control space
  4546. * @param globalCoordinates defines the coordinates to transform
  4547. * @returns the new coordinates in local space
  4548. */
  4549. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4550. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4551. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4552. return result;
  4553. };
  4554. /**
  4555. * Gets coordinates in local control space
  4556. * @param globalCoordinates defines the coordinates to transform
  4557. * @param result defines the target vector2 where to store the result
  4558. * @returns the current control
  4559. */
  4560. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4561. result.x = globalCoordinates.x - this._currentMeasure.left;
  4562. result.y = globalCoordinates.y - this._currentMeasure.top;
  4563. return this;
  4564. };
  4565. /**
  4566. * Gets coordinates in parent local control space
  4567. * @param globalCoordinates defines the coordinates to transform
  4568. * @returns the new coordinates in parent local space
  4569. */
  4570. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4571. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4572. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4573. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4574. return result;
  4575. };
  4576. /**
  4577. * Move the current control to a vector3 position projected onto the screen.
  4578. * @param position defines the target position
  4579. * @param scene defines the hosting scene
  4580. */
  4581. Control.prototype.moveToVector3 = function (position, scene) {
  4582. if (!this._host || this.parent !== this._host._rootContainer) {
  4583. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4584. return;
  4585. }
  4586. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4587. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4588. var globalViewport = this._host._getGlobalViewport(scene);
  4589. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4590. this._moveToProjectedPosition(projectedPosition);
  4591. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4592. this.notRenderable = true;
  4593. return;
  4594. }
  4595. this.notRenderable = false;
  4596. };
  4597. /** @hidden */
  4598. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4599. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4600. // Do nothing by default
  4601. };
  4602. /**
  4603. * Will return all controls that have this control as ascendant
  4604. * @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
  4605. * @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
  4606. * @return all child controls
  4607. */
  4608. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4609. var results = new Array();
  4610. this._getDescendants(results, directDescendantsOnly, predicate);
  4611. return results;
  4612. };
  4613. /**
  4614. * Link current control with a target mesh
  4615. * @param mesh defines the mesh to link with
  4616. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4617. */
  4618. Control.prototype.linkWithMesh = function (mesh) {
  4619. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4620. if (mesh) {
  4621. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4622. }
  4623. return;
  4624. }
  4625. var index = this._host._linkedControls.indexOf(this);
  4626. if (index !== -1) {
  4627. this._linkedMesh = mesh;
  4628. if (!mesh) {
  4629. this._host._linkedControls.splice(index, 1);
  4630. }
  4631. return;
  4632. }
  4633. else if (!mesh) {
  4634. return;
  4635. }
  4636. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4637. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4638. this._linkedMesh = mesh;
  4639. this._host._linkedControls.push(this);
  4640. };
  4641. /** @hidden */
  4642. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4643. var oldLeft = this._left.getValue(this._host);
  4644. var oldTop = this._top.getValue(this._host);
  4645. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4646. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4647. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4648. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4649. newLeft = oldLeft;
  4650. }
  4651. if (Math.abs(newTop - oldTop) < 0.5) {
  4652. newTop = oldTop;
  4653. }
  4654. }
  4655. this.left = newLeft + "px";
  4656. this.top = newTop + "px";
  4657. this._left.ignoreAdaptiveScaling = true;
  4658. this._top.ignoreAdaptiveScaling = true;
  4659. this._markAsDirty();
  4660. };
  4661. /** @hidden */
  4662. Control.prototype._offsetLeft = function (offset) {
  4663. this._isDirty = true;
  4664. this._currentMeasure.left += offset;
  4665. };
  4666. /** @hidden */
  4667. Control.prototype._offsetTop = function (offset) {
  4668. this._isDirty = true;
  4669. this._currentMeasure.top += offset;
  4670. };
  4671. /** @hidden */
  4672. Control.prototype._markMatrixAsDirty = function () {
  4673. this._isMatrixDirty = true;
  4674. this._flagDescendantsAsMatrixDirty();
  4675. };
  4676. /** @hidden */
  4677. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4678. // No child
  4679. };
  4680. /** @hidden */
  4681. Control.prototype._intersectsRect = function (rect) {
  4682. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4683. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4684. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4685. return false;
  4686. }
  4687. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4688. return false;
  4689. }
  4690. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4691. return false;
  4692. }
  4693. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4694. return false;
  4695. }
  4696. return true;
  4697. };
  4698. /** @hidden */
  4699. Control.prototype.invalidateRect = function () {
  4700. this._transform();
  4701. if (this.host && this.host.useInvalidateRectOptimization) {
  4702. // Rotate by transform to get the measure transformed to global space
  4703. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4704. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4705. // the previous measure is used to properly clear a control that is scaled down
  4706. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4707. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4708. // Expand rect based on shadows
  4709. var shadowOffsetX = this.shadowOffsetX;
  4710. var shadowOffsetY = this.shadowOffsetY;
  4711. var shadowBlur = this.shadowBlur;
  4712. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4713. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4714. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4715. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4716. 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));
  4717. }
  4718. else {
  4719. 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));
  4720. }
  4721. }
  4722. };
  4723. /** @hidden */
  4724. Control.prototype._markAsDirty = function (force) {
  4725. if (force === void 0) { force = false; }
  4726. if (!this._isVisible && !force) {
  4727. return;
  4728. }
  4729. this._isDirty = true;
  4730. // Redraw only this rectangle
  4731. if (this._host) {
  4732. this._host.markAsDirty();
  4733. }
  4734. };
  4735. /** @hidden */
  4736. Control.prototype._markAllAsDirty = function () {
  4737. this._markAsDirty();
  4738. if (this._font) {
  4739. this._prepareFont();
  4740. }
  4741. };
  4742. /** @hidden */
  4743. Control.prototype._link = function (host) {
  4744. this._host = host;
  4745. if (this._host) {
  4746. this.uniqueId = this._host.getScene().getUniqueId();
  4747. }
  4748. };
  4749. /** @hidden */
  4750. Control.prototype._transform = function (context) {
  4751. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4752. return;
  4753. }
  4754. // postTranslate
  4755. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4756. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4757. if (context) {
  4758. context.translate(offsetX, offsetY);
  4759. // rotate
  4760. context.rotate(this._rotation);
  4761. // scale
  4762. context.scale(this._scaleX, this._scaleY);
  4763. // preTranslate
  4764. context.translate(-offsetX, -offsetY);
  4765. }
  4766. // Need to update matrices?
  4767. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4768. this._cachedOffsetX = offsetX;
  4769. this._cachedOffsetY = offsetY;
  4770. this._isMatrixDirty = false;
  4771. this._flagDescendantsAsMatrixDirty();
  4772. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4773. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4774. }
  4775. };
  4776. /** @hidden */
  4777. Control.prototype._renderHighlight = function (context) {
  4778. if (!this.isHighlighted) {
  4779. return;
  4780. }
  4781. context.save();
  4782. context.strokeStyle = "#4affff";
  4783. context.lineWidth = 2;
  4784. this._renderHighlightSpecific(context);
  4785. context.restore();
  4786. };
  4787. /** @hidden */
  4788. Control.prototype._renderHighlightSpecific = function (context) {
  4789. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4790. };
  4791. /** @hidden */
  4792. Control.prototype._applyStates = function (context) {
  4793. if (this._isFontSizeInPercentage) {
  4794. this._fontSet = true;
  4795. }
  4796. if (this._fontSet) {
  4797. this._prepareFont();
  4798. this._fontSet = false;
  4799. }
  4800. if (this._font) {
  4801. context.font = this._font;
  4802. }
  4803. if (this._color) {
  4804. context.fillStyle = this._color;
  4805. }
  4806. if (Control.AllowAlphaInheritance) {
  4807. context.globalAlpha *= this._alpha;
  4808. }
  4809. else if (this._alphaSet) {
  4810. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4811. }
  4812. };
  4813. /** @hidden */
  4814. Control.prototype._layout = function (parentMeasure, context) {
  4815. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4816. return false;
  4817. }
  4818. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4819. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4820. context.save();
  4821. this._applyStates(context);
  4822. var rebuildCount = 0;
  4823. do {
  4824. this._rebuildLayout = false;
  4825. this._processMeasures(parentMeasure, context);
  4826. rebuildCount++;
  4827. } while (this._rebuildLayout && rebuildCount < 3);
  4828. if (rebuildCount >= 3) {
  4829. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4830. }
  4831. context.restore();
  4832. this.invalidateRect();
  4833. this._evaluateClippingState(parentMeasure);
  4834. }
  4835. this._wasDirty = this._isDirty;
  4836. this._isDirty = false;
  4837. return true;
  4838. };
  4839. /** @hidden */
  4840. Control.prototype._processMeasures = function (parentMeasure, context) {
  4841. this._currentMeasure.copyFrom(parentMeasure);
  4842. // Let children take some pre-measurement actions
  4843. this._preMeasure(parentMeasure, context);
  4844. this._measure();
  4845. this._computeAlignment(parentMeasure, context);
  4846. // Convert to int values
  4847. this._currentMeasure.left = this._currentMeasure.left | 0;
  4848. this._currentMeasure.top = this._currentMeasure.top | 0;
  4849. this._currentMeasure.width = this._currentMeasure.width | 0;
  4850. this._currentMeasure.height = this._currentMeasure.height | 0;
  4851. // Let children add more features
  4852. this._additionalProcessing(parentMeasure, context);
  4853. this._cachedParentMeasure.copyFrom(parentMeasure);
  4854. if (this.onDirtyObservable.hasObservers()) {
  4855. this.onDirtyObservable.notifyObservers(this);
  4856. }
  4857. };
  4858. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4859. if (this.parent && this.parent.clipChildren) {
  4860. // Early clip
  4861. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4862. this._isClipped = true;
  4863. return;
  4864. }
  4865. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4866. this._isClipped = true;
  4867. return;
  4868. }
  4869. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4870. this._isClipped = true;
  4871. return;
  4872. }
  4873. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4874. this._isClipped = true;
  4875. return;
  4876. }
  4877. }
  4878. this._isClipped = false;
  4879. };
  4880. /** @hidden */
  4881. Control.prototype._measure = function () {
  4882. // Width / Height
  4883. if (this._width.isPixel) {
  4884. this._currentMeasure.width = this._width.getValue(this._host);
  4885. }
  4886. else {
  4887. this._currentMeasure.width *= this._width.getValue(this._host);
  4888. }
  4889. if (this._height.isPixel) {
  4890. this._currentMeasure.height = this._height.getValue(this._host);
  4891. }
  4892. else {
  4893. this._currentMeasure.height *= this._height.getValue(this._host);
  4894. }
  4895. };
  4896. /** @hidden */
  4897. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4898. var width = this._currentMeasure.width;
  4899. var height = this._currentMeasure.height;
  4900. var parentWidth = parentMeasure.width;
  4901. var parentHeight = parentMeasure.height;
  4902. // Left / top
  4903. var x = 0;
  4904. var y = 0;
  4905. switch (this.horizontalAlignment) {
  4906. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4907. x = 0;
  4908. break;
  4909. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4910. x = parentWidth - width;
  4911. break;
  4912. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4913. x = (parentWidth - width) / 2;
  4914. break;
  4915. }
  4916. switch (this.verticalAlignment) {
  4917. case Control.VERTICAL_ALIGNMENT_TOP:
  4918. y = 0;
  4919. break;
  4920. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4921. y = parentHeight - height;
  4922. break;
  4923. case Control.VERTICAL_ALIGNMENT_CENTER:
  4924. y = (parentHeight - height) / 2;
  4925. break;
  4926. }
  4927. if (this._paddingLeft.isPixel) {
  4928. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4929. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4930. }
  4931. else {
  4932. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4933. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4934. }
  4935. if (this._paddingRight.isPixel) {
  4936. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4937. }
  4938. else {
  4939. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4940. }
  4941. if (this._paddingTop.isPixel) {
  4942. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4943. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4944. }
  4945. else {
  4946. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4947. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4948. }
  4949. if (this._paddingBottom.isPixel) {
  4950. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4951. }
  4952. else {
  4953. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4954. }
  4955. if (this._left.isPixel) {
  4956. this._currentMeasure.left += this._left.getValue(this._host);
  4957. }
  4958. else {
  4959. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4960. }
  4961. if (this._top.isPixel) {
  4962. this._currentMeasure.top += this._top.getValue(this._host);
  4963. }
  4964. else {
  4965. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4966. }
  4967. this._currentMeasure.left += x;
  4968. this._currentMeasure.top += y;
  4969. };
  4970. /** @hidden */
  4971. Control.prototype._preMeasure = function (parentMeasure, context) {
  4972. // Do nothing
  4973. };
  4974. /** @hidden */
  4975. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4976. // Do nothing
  4977. };
  4978. /** @hidden */
  4979. Control.prototype._clipForChildren = function (context) {
  4980. // DO nothing
  4981. };
  4982. Control.prototype._clip = function (context, invalidatedRectangle) {
  4983. context.beginPath();
  4984. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4985. if (invalidatedRectangle) {
  4986. // Rotate the invalidated rect into the control's space
  4987. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4988. // Get the intersection of the rect in context space and the current context
  4989. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4990. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4991. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4992. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4993. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4994. Control._ClipMeasure.copyFrom(intersection);
  4995. }
  4996. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4997. var shadowOffsetX = this.shadowOffsetX;
  4998. var shadowOffsetY = this.shadowOffsetY;
  4999. var shadowBlur = this.shadowBlur;
  5000. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5001. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5002. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5003. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5004. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5005. }
  5006. else {
  5007. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5008. }
  5009. context.clip();
  5010. };
  5011. /** @hidden */
  5012. Control.prototype._render = function (context, invalidatedRectangle) {
  5013. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5014. this._isDirty = false;
  5015. return false;
  5016. }
  5017. context.save();
  5018. this._applyStates(context);
  5019. // Transform
  5020. this._transform(context);
  5021. // Clip
  5022. if (this.clipContent) {
  5023. this._clip(context, invalidatedRectangle);
  5024. }
  5025. if (this.onBeforeDrawObservable.hasObservers()) {
  5026. this.onBeforeDrawObservable.notifyObservers(this);
  5027. }
  5028. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5029. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5030. }
  5031. else {
  5032. this._draw(context, invalidatedRectangle);
  5033. }
  5034. if (this.useBitmapCache && this._wasDirty) {
  5035. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5036. }
  5037. this._renderHighlight(context);
  5038. if (this.onAfterDrawObservable.hasObservers()) {
  5039. this.onAfterDrawObservable.notifyObservers(this);
  5040. }
  5041. context.restore();
  5042. return true;
  5043. };
  5044. /** @hidden */
  5045. Control.prototype._draw = function (context, invalidatedRectangle) {
  5046. // Do nothing
  5047. };
  5048. /**
  5049. * Tests if a given coordinates belong to the current control
  5050. * @param x defines x coordinate to test
  5051. * @param y defines y coordinate to test
  5052. * @returns true if the coordinates are inside the control
  5053. */
  5054. Control.prototype.contains = function (x, y) {
  5055. // Invert transform
  5056. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5057. x = this._transformedPosition.x;
  5058. y = this._transformedPosition.y;
  5059. // Check
  5060. if (x < this._currentMeasure.left) {
  5061. return false;
  5062. }
  5063. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5064. return false;
  5065. }
  5066. if (y < this._currentMeasure.top) {
  5067. return false;
  5068. }
  5069. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5070. return false;
  5071. }
  5072. if (this.isPointerBlocker) {
  5073. this._host._shouldBlockPointer = true;
  5074. }
  5075. return true;
  5076. };
  5077. /** @hidden */
  5078. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5079. if (!this._isEnabled) {
  5080. return false;
  5081. }
  5082. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5083. return false;
  5084. }
  5085. if (!this.contains(x, y)) {
  5086. return false;
  5087. }
  5088. this._processObservables(type, x, y, pointerId, buttonIndex);
  5089. return true;
  5090. };
  5091. /** @hidden */
  5092. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5093. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5094. if (canNotify && this.parent != null) {
  5095. this.parent._onPointerMove(target, coordinates, pointerId);
  5096. }
  5097. };
  5098. /** @hidden */
  5099. Control.prototype._onPointerEnter = function (target) {
  5100. if (!this._isEnabled) {
  5101. return false;
  5102. }
  5103. if (this._enterCount > 0) {
  5104. return false;
  5105. }
  5106. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5107. this._enterCount = 0;
  5108. }
  5109. this._enterCount++;
  5110. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5111. if (canNotify && this.parent != null) {
  5112. this.parent._onPointerEnter(target);
  5113. }
  5114. return true;
  5115. };
  5116. /** @hidden */
  5117. Control.prototype._onPointerOut = function (target, force) {
  5118. if (force === void 0) { force = false; }
  5119. if (!force && (!this._isEnabled || target === this)) {
  5120. return;
  5121. }
  5122. this._enterCount = 0;
  5123. var canNotify = true;
  5124. if (!target.isAscendant(this)) {
  5125. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5126. }
  5127. if (canNotify && this.parent != null) {
  5128. this.parent._onPointerOut(target, force);
  5129. }
  5130. };
  5131. /** @hidden */
  5132. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5133. // Prevent pointerout to lose control context.
  5134. // Event redundancy is checked inside the function.
  5135. this._onPointerEnter(this);
  5136. if (this._downCount !== 0) {
  5137. return false;
  5138. }
  5139. this._downCount++;
  5140. this._downPointerIds[pointerId] = true;
  5141. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5142. if (canNotify && this.parent != null) {
  5143. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5144. }
  5145. return true;
  5146. };
  5147. /** @hidden */
  5148. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5149. if (!this._isEnabled) {
  5150. return;
  5151. }
  5152. this._downCount = 0;
  5153. delete this._downPointerIds[pointerId];
  5154. var canNotifyClick = notifyClick;
  5155. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5156. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5157. }
  5158. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5159. if (canNotify && this.parent != null) {
  5160. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5161. }
  5162. };
  5163. /** @hidden */
  5164. Control.prototype._forcePointerUp = function (pointerId) {
  5165. if (pointerId === void 0) { pointerId = null; }
  5166. if (pointerId !== null) {
  5167. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5168. }
  5169. else {
  5170. for (var key in this._downPointerIds) {
  5171. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5172. }
  5173. }
  5174. };
  5175. /** @hidden */
  5176. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5177. if (!this._isEnabled) {
  5178. return false;
  5179. }
  5180. this._dummyVector2.copyFromFloats(x, y);
  5181. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5182. this._onPointerMove(this, this._dummyVector2, pointerId);
  5183. var previousControlOver = this._host._lastControlOver[pointerId];
  5184. if (previousControlOver && previousControlOver !== this) {
  5185. previousControlOver._onPointerOut(this);
  5186. }
  5187. if (previousControlOver !== this) {
  5188. this._onPointerEnter(this);
  5189. }
  5190. this._host._lastControlOver[pointerId] = this;
  5191. return true;
  5192. }
  5193. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5194. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5195. this._host._registerLastControlDown(this, pointerId);
  5196. this._host._lastPickedControl = this;
  5197. return true;
  5198. }
  5199. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5200. if (this._host._lastControlDown[pointerId]) {
  5201. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5202. }
  5203. delete this._host._lastControlDown[pointerId];
  5204. return true;
  5205. }
  5206. return false;
  5207. };
  5208. Control.prototype._prepareFont = function () {
  5209. if (!this._font && !this._fontSet) {
  5210. return;
  5211. }
  5212. if (this._style) {
  5213. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5214. }
  5215. else {
  5216. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5217. }
  5218. this._fontOffset = Control._GetFontOffset(this._font);
  5219. };
  5220. /** Releases associated resources */
  5221. Control.prototype.dispose = function () {
  5222. this.onDirtyObservable.clear();
  5223. this.onBeforeDrawObservable.clear();
  5224. this.onAfterDrawObservable.clear();
  5225. this.onPointerDownObservable.clear();
  5226. this.onPointerEnterObservable.clear();
  5227. this.onPointerMoveObservable.clear();
  5228. this.onPointerOutObservable.clear();
  5229. this.onPointerUpObservable.clear();
  5230. this.onPointerClickObservable.clear();
  5231. if (this._styleObserver && this._style) {
  5232. this._style.onChangedObservable.remove(this._styleObserver);
  5233. this._styleObserver = null;
  5234. }
  5235. if (this.parent) {
  5236. this.parent.removeControl(this);
  5237. this.parent = null;
  5238. }
  5239. if (this._host) {
  5240. var index = this._host._linkedControls.indexOf(this);
  5241. if (index > -1) {
  5242. this.linkWithMesh(null);
  5243. }
  5244. }
  5245. };
  5246. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5247. /** HORIZONTAL_ALIGNMENT_LEFT */
  5248. get: function () {
  5249. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5250. },
  5251. enumerable: true,
  5252. configurable: true
  5253. });
  5254. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5255. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5256. get: function () {
  5257. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5258. },
  5259. enumerable: true,
  5260. configurable: true
  5261. });
  5262. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5263. /** HORIZONTAL_ALIGNMENT_CENTER */
  5264. get: function () {
  5265. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5266. },
  5267. enumerable: true,
  5268. configurable: true
  5269. });
  5270. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5271. /** VERTICAL_ALIGNMENT_TOP */
  5272. get: function () {
  5273. return Control._VERTICAL_ALIGNMENT_TOP;
  5274. },
  5275. enumerable: true,
  5276. configurable: true
  5277. });
  5278. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5279. /** VERTICAL_ALIGNMENT_BOTTOM */
  5280. get: function () {
  5281. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5282. },
  5283. enumerable: true,
  5284. configurable: true
  5285. });
  5286. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5287. /** VERTICAL_ALIGNMENT_CENTER */
  5288. get: function () {
  5289. return Control._VERTICAL_ALIGNMENT_CENTER;
  5290. },
  5291. enumerable: true,
  5292. configurable: true
  5293. });
  5294. /** @hidden */
  5295. Control._GetFontOffset = function (font) {
  5296. if (Control._FontHeightSizes[font]) {
  5297. return Control._FontHeightSizes[font];
  5298. }
  5299. var text = document.createElement("span");
  5300. text.innerHTML = "Hg";
  5301. text.style.font = font;
  5302. var block = document.createElement("div");
  5303. block.style.display = "inline-block";
  5304. block.style.width = "1px";
  5305. block.style.height = "0px";
  5306. block.style.verticalAlign = "bottom";
  5307. var div = document.createElement("div");
  5308. div.appendChild(text);
  5309. div.appendChild(block);
  5310. document.body.appendChild(div);
  5311. var fontAscent = 0;
  5312. var fontHeight = 0;
  5313. try {
  5314. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5315. block.style.verticalAlign = "baseline";
  5316. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5317. }
  5318. finally {
  5319. document.body.removeChild(div);
  5320. }
  5321. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5322. Control._FontHeightSizes[font] = result;
  5323. return result;
  5324. };
  5325. /** @hidden */
  5326. Control.drawEllipse = function (x, y, width, height, context) {
  5327. context.translate(x, y);
  5328. context.scale(width, height);
  5329. context.beginPath();
  5330. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5331. context.closePath();
  5332. context.scale(1 / width, 1 / height);
  5333. context.translate(-x, -y);
  5334. };
  5335. /**
  5336. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5337. */
  5338. Control.AllowAlphaInheritance = false;
  5339. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5340. // Statics
  5341. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5342. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5343. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5344. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5345. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5346. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5347. Control._FontHeightSizes = {};
  5348. /**
  5349. * Creates a stack panel that can be used to render headers
  5350. * @param control defines the control to associate with the header
  5351. * @param text defines the text of the header
  5352. * @param size defines the size of the header
  5353. * @param options defines options used to configure the header
  5354. * @returns a new StackPanel
  5355. * @ignore
  5356. * @hidden
  5357. */
  5358. Control.AddHeader = function () { };
  5359. return Control;
  5360. }());
  5361. /***/ }),
  5362. /***/ "./2D/controls/displayGrid.ts":
  5363. /*!************************************!*\
  5364. !*** ./2D/controls/displayGrid.ts ***!
  5365. \************************************/
  5366. /*! exports provided: DisplayGrid */
  5367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5368. "use strict";
  5369. __webpack_require__.r(__webpack_exports__);
  5370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5371. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5372. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5373. /** Class used to render a grid */
  5374. var DisplayGrid = /** @class */ (function (_super) {
  5375. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5376. /**
  5377. * Creates a new GridDisplayRectangle
  5378. * @param name defines the control name
  5379. */
  5380. function DisplayGrid(name) {
  5381. var _this = _super.call(this, name) || this;
  5382. _this.name = name;
  5383. _this._cellWidth = 20;
  5384. _this._cellHeight = 20;
  5385. _this._minorLineTickness = 1;
  5386. _this._minorLineColor = "DarkGray";
  5387. _this._majorLineTickness = 2;
  5388. _this._majorLineColor = "White";
  5389. _this._majorLineFrequency = 5;
  5390. _this._background = "Black";
  5391. _this._displayMajorLines = true;
  5392. _this._displayMinorLines = true;
  5393. return _this;
  5394. }
  5395. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5396. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5397. get: function () {
  5398. return this._displayMinorLines;
  5399. },
  5400. set: function (value) {
  5401. if (this._displayMinorLines === value) {
  5402. return;
  5403. }
  5404. this._displayMinorLines = value;
  5405. this._markAsDirty();
  5406. },
  5407. enumerable: true,
  5408. configurable: true
  5409. });
  5410. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5411. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5412. get: function () {
  5413. return this._displayMajorLines;
  5414. },
  5415. set: function (value) {
  5416. if (this._displayMajorLines === value) {
  5417. return;
  5418. }
  5419. this._displayMajorLines = value;
  5420. this._markAsDirty();
  5421. },
  5422. enumerable: true,
  5423. configurable: true
  5424. });
  5425. Object.defineProperty(DisplayGrid.prototype, "background", {
  5426. /** Gets or sets background color (Black by default) */
  5427. get: function () {
  5428. return this._background;
  5429. },
  5430. set: function (value) {
  5431. if (this._background === value) {
  5432. return;
  5433. }
  5434. this._background = value;
  5435. this._markAsDirty();
  5436. },
  5437. enumerable: true,
  5438. configurable: true
  5439. });
  5440. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5441. /** Gets or sets the width of each cell (20 by default) */
  5442. get: function () {
  5443. return this._cellWidth;
  5444. },
  5445. set: function (value) {
  5446. this._cellWidth = value;
  5447. this._markAsDirty();
  5448. },
  5449. enumerable: true,
  5450. configurable: true
  5451. });
  5452. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5453. /** Gets or sets the height of each cell (20 by default) */
  5454. get: function () {
  5455. return this._cellHeight;
  5456. },
  5457. set: function (value) {
  5458. this._cellHeight = value;
  5459. this._markAsDirty();
  5460. },
  5461. enumerable: true,
  5462. configurable: true
  5463. });
  5464. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5465. /** Gets or sets the tickness of minor lines (1 by default) */
  5466. get: function () {
  5467. return this._minorLineTickness;
  5468. },
  5469. set: function (value) {
  5470. this._minorLineTickness = value;
  5471. this._markAsDirty();
  5472. },
  5473. enumerable: true,
  5474. configurable: true
  5475. });
  5476. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5477. /** Gets or sets the color of minor lines (DarkGray by default) */
  5478. get: function () {
  5479. return this._minorLineColor;
  5480. },
  5481. set: function (value) {
  5482. this._minorLineColor = value;
  5483. this._markAsDirty();
  5484. },
  5485. enumerable: true,
  5486. configurable: true
  5487. });
  5488. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5489. /** Gets or sets the tickness of major lines (2 by default) */
  5490. get: function () {
  5491. return this._majorLineTickness;
  5492. },
  5493. set: function (value) {
  5494. this._majorLineTickness = value;
  5495. this._markAsDirty();
  5496. },
  5497. enumerable: true,
  5498. configurable: true
  5499. });
  5500. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5501. /** Gets or sets the color of major lines (White by default) */
  5502. get: function () {
  5503. return this._majorLineColor;
  5504. },
  5505. set: function (value) {
  5506. this._majorLineColor = value;
  5507. this._markAsDirty();
  5508. },
  5509. enumerable: true,
  5510. configurable: true
  5511. });
  5512. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5513. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5514. get: function () {
  5515. return this._majorLineFrequency;
  5516. },
  5517. set: function (value) {
  5518. this._majorLineFrequency = value;
  5519. this._markAsDirty();
  5520. },
  5521. enumerable: true,
  5522. configurable: true
  5523. });
  5524. DisplayGrid.prototype._draw = function (context) {
  5525. context.save();
  5526. this._applyStates(context);
  5527. if (this._isEnabled) {
  5528. if (this._background) {
  5529. context.fillStyle = this._background;
  5530. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5531. }
  5532. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5533. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5534. // Minor lines
  5535. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5536. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5537. if (this._displayMinorLines) {
  5538. context.strokeStyle = this._minorLineColor;
  5539. context.lineWidth = this._minorLineTickness;
  5540. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5541. var cellX = left + x * this.cellWidth;
  5542. context.beginPath();
  5543. context.moveTo(cellX, this._currentMeasure.top);
  5544. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5545. context.stroke();
  5546. }
  5547. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5548. var cellY = top_1 + y * this.cellHeight;
  5549. context.beginPath();
  5550. context.moveTo(this._currentMeasure.left, cellY);
  5551. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5552. context.stroke();
  5553. }
  5554. }
  5555. // Major lines
  5556. if (this._displayMajorLines) {
  5557. context.strokeStyle = this._majorLineColor;
  5558. context.lineWidth = this._majorLineTickness;
  5559. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5560. var cellX = left + x * this.cellWidth;
  5561. context.beginPath();
  5562. context.moveTo(cellX, this._currentMeasure.top);
  5563. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5564. context.stroke();
  5565. }
  5566. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5567. var cellY = top_1 + y * this.cellHeight;
  5568. context.moveTo(this._currentMeasure.left, cellY);
  5569. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5570. context.closePath();
  5571. context.stroke();
  5572. }
  5573. }
  5574. }
  5575. context.restore();
  5576. };
  5577. DisplayGrid.prototype._getTypeName = function () {
  5578. return "DisplayGrid";
  5579. };
  5580. return DisplayGrid;
  5581. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5582. /***/ }),
  5583. /***/ "./2D/controls/ellipse.ts":
  5584. /*!********************************!*\
  5585. !*** ./2D/controls/ellipse.ts ***!
  5586. \********************************/
  5587. /*! exports provided: Ellipse */
  5588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5589. "use strict";
  5590. __webpack_require__.r(__webpack_exports__);
  5591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5592. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5593. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5594. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5595. /** Class used to create 2D ellipse containers */
  5596. var Ellipse = /** @class */ (function (_super) {
  5597. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5598. /**
  5599. * Creates a new Ellipse
  5600. * @param name defines the control name
  5601. */
  5602. function Ellipse(name) {
  5603. var _this = _super.call(this, name) || this;
  5604. _this.name = name;
  5605. _this._thickness = 1;
  5606. return _this;
  5607. }
  5608. Object.defineProperty(Ellipse.prototype, "thickness", {
  5609. /** Gets or sets border thickness */
  5610. get: function () {
  5611. return this._thickness;
  5612. },
  5613. set: function (value) {
  5614. if (this._thickness === value) {
  5615. return;
  5616. }
  5617. this._thickness = value;
  5618. this._markAsDirty();
  5619. },
  5620. enumerable: true,
  5621. configurable: true
  5622. });
  5623. Ellipse.prototype._getTypeName = function () {
  5624. return "Ellipse";
  5625. };
  5626. Ellipse.prototype._localDraw = function (context) {
  5627. context.save();
  5628. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5629. context.shadowColor = this.shadowColor;
  5630. context.shadowBlur = this.shadowBlur;
  5631. context.shadowOffsetX = this.shadowOffsetX;
  5632. context.shadowOffsetY = this.shadowOffsetY;
  5633. }
  5634. _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);
  5635. if (this._background) {
  5636. context.fillStyle = this._background;
  5637. context.fill();
  5638. }
  5639. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5640. context.shadowBlur = 0;
  5641. context.shadowOffsetX = 0;
  5642. context.shadowOffsetY = 0;
  5643. }
  5644. if (this._thickness) {
  5645. if (this.color) {
  5646. context.strokeStyle = this.color;
  5647. }
  5648. context.lineWidth = this._thickness;
  5649. context.stroke();
  5650. }
  5651. context.restore();
  5652. };
  5653. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5654. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5655. this._measureForChildren.width -= 2 * this._thickness;
  5656. this._measureForChildren.height -= 2 * this._thickness;
  5657. this._measureForChildren.left += this._thickness;
  5658. this._measureForChildren.top += this._thickness;
  5659. };
  5660. Ellipse.prototype._clipForChildren = function (context) {
  5661. _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);
  5662. context.clip();
  5663. };
  5664. return Ellipse;
  5665. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5666. /***/ }),
  5667. /***/ "./2D/controls/grid.ts":
  5668. /*!*****************************!*\
  5669. !*** ./2D/controls/grid.ts ***!
  5670. \*****************************/
  5671. /*! exports provided: Grid */
  5672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5673. "use strict";
  5674. __webpack_require__.r(__webpack_exports__);
  5675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5676. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5677. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5678. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5679. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5680. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  5681. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5682. /**
  5683. * Class used to create a 2D grid container
  5684. */
  5685. var Grid = /** @class */ (function (_super) {
  5686. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5687. /**
  5688. * Creates a new Grid
  5689. * @param name defines control name
  5690. */
  5691. function Grid(name) {
  5692. var _this = _super.call(this, name) || this;
  5693. _this.name = name;
  5694. _this._rowDefinitions = new Array();
  5695. _this._columnDefinitions = new Array();
  5696. _this._cells = {};
  5697. _this._childControls = new Array();
  5698. return _this;
  5699. }
  5700. Object.defineProperty(Grid.prototype, "columnCount", {
  5701. /**
  5702. * Gets the number of columns
  5703. */
  5704. get: function () {
  5705. return this._columnDefinitions.length;
  5706. },
  5707. enumerable: true,
  5708. configurable: true
  5709. });
  5710. Object.defineProperty(Grid.prototype, "rowCount", {
  5711. /**
  5712. * Gets the number of rows
  5713. */
  5714. get: function () {
  5715. return this._rowDefinitions.length;
  5716. },
  5717. enumerable: true,
  5718. configurable: true
  5719. });
  5720. Object.defineProperty(Grid.prototype, "children", {
  5721. /** Gets the list of children */
  5722. get: function () {
  5723. return this._childControls;
  5724. },
  5725. enumerable: true,
  5726. configurable: true
  5727. });
  5728. Object.defineProperty(Grid.prototype, "cells", {
  5729. /** Gets the list of cells (e.g. the containers) */
  5730. get: function () {
  5731. return this._cells;
  5732. },
  5733. enumerable: true,
  5734. configurable: true
  5735. });
  5736. /**
  5737. * Gets the definition of a specific row
  5738. * @param index defines the index of the row
  5739. * @returns the row definition
  5740. */
  5741. Grid.prototype.getRowDefinition = function (index) {
  5742. if (index < 0 || index >= this._rowDefinitions.length) {
  5743. return null;
  5744. }
  5745. return this._rowDefinitions[index];
  5746. };
  5747. /**
  5748. * Gets the definition of a specific column
  5749. * @param index defines the index of the column
  5750. * @returns the column definition
  5751. */
  5752. Grid.prototype.getColumnDefinition = function (index) {
  5753. if (index < 0 || index >= this._columnDefinitions.length) {
  5754. return null;
  5755. }
  5756. return this._columnDefinitions[index];
  5757. };
  5758. /**
  5759. * Adds a new row to the grid
  5760. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5761. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5762. * @returns the current grid
  5763. */
  5764. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5765. if (isPixel === void 0) { isPixel = false; }
  5766. 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));
  5767. this._markAsDirty();
  5768. return this;
  5769. };
  5770. /**
  5771. * Adds a new column to the grid
  5772. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5773. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5774. * @returns the current grid
  5775. */
  5776. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5777. if (isPixel === void 0) { isPixel = false; }
  5778. 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));
  5779. this._markAsDirty();
  5780. return this;
  5781. };
  5782. /**
  5783. * Update a row definition
  5784. * @param index defines the index of the row to update
  5785. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5786. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5787. * @returns the current grid
  5788. */
  5789. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5790. if (isPixel === void 0) { isPixel = false; }
  5791. if (index < 0 || index >= this._rowDefinitions.length) {
  5792. return this;
  5793. }
  5794. var current = this._rowDefinitions[index];
  5795. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5796. return this;
  5797. }
  5798. 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);
  5799. this._markAsDirty();
  5800. return this;
  5801. };
  5802. /**
  5803. * Update a column definition
  5804. * @param index defines the index of the column to update
  5805. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5806. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5807. * @returns the current grid
  5808. */
  5809. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5810. if (isPixel === void 0) { isPixel = false; }
  5811. if (index < 0 || index >= this._columnDefinitions.length) {
  5812. return this;
  5813. }
  5814. var current = this._columnDefinitions[index];
  5815. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5816. return this;
  5817. }
  5818. 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);
  5819. this._markAsDirty();
  5820. return this;
  5821. };
  5822. /**
  5823. * Gets the list of children stored in a specific cell
  5824. * @param row defines the row to check
  5825. * @param column defines the column to check
  5826. * @returns the list of controls
  5827. */
  5828. Grid.prototype.getChildrenAt = function (row, column) {
  5829. var cell = this._cells[row + ":" + column];
  5830. if (!cell) {
  5831. return null;
  5832. }
  5833. return cell.children;
  5834. };
  5835. /**
  5836. * Gets a string representing the child cell info (row x column)
  5837. * @param child defines the control to get info from
  5838. * @returns a string containing the child cell info (row x column)
  5839. */
  5840. Grid.prototype.getChildCellInfo = function (child) {
  5841. return child._tag;
  5842. };
  5843. Grid.prototype._removeCell = function (cell, key) {
  5844. if (!cell) {
  5845. return;
  5846. }
  5847. _super.prototype.removeControl.call(this, cell);
  5848. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5849. var control = _a[_i];
  5850. var childIndex = this._childControls.indexOf(control);
  5851. if (childIndex !== -1) {
  5852. this._childControls.splice(childIndex, 1);
  5853. }
  5854. }
  5855. delete this._cells[key];
  5856. };
  5857. Grid.prototype._offsetCell = function (previousKey, key) {
  5858. if (!this._cells[key]) {
  5859. return;
  5860. }
  5861. this._cells[previousKey] = this._cells[key];
  5862. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5863. var control = _a[_i];
  5864. control._tag = previousKey;
  5865. }
  5866. delete this._cells[key];
  5867. };
  5868. /**
  5869. * Remove a column definition at specified index
  5870. * @param index defines the index of the column to remove
  5871. * @returns the current grid
  5872. */
  5873. Grid.prototype.removeColumnDefinition = function (index) {
  5874. if (index < 0 || index >= this._columnDefinitions.length) {
  5875. return this;
  5876. }
  5877. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5878. var key = x + ":" + index;
  5879. var cell = this._cells[key];
  5880. this._removeCell(cell, key);
  5881. }
  5882. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5883. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5884. var previousKey = x + ":" + (y - 1);
  5885. var key = x + ":" + y;
  5886. this._offsetCell(previousKey, key);
  5887. }
  5888. }
  5889. this._columnDefinitions.splice(index, 1);
  5890. this._markAsDirty();
  5891. return this;
  5892. };
  5893. /**
  5894. * Remove a row definition at specified index
  5895. * @param index defines the index of the row to remove
  5896. * @returns the current grid
  5897. */
  5898. Grid.prototype.removeRowDefinition = function (index) {
  5899. if (index < 0 || index >= this._rowDefinitions.length) {
  5900. return this;
  5901. }
  5902. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5903. var key = index + ":" + y;
  5904. var cell = this._cells[key];
  5905. this._removeCell(cell, key);
  5906. }
  5907. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5908. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5909. var previousKey = x - 1 + ":" + y;
  5910. var key = x + ":" + y;
  5911. this._offsetCell(previousKey, key);
  5912. }
  5913. }
  5914. this._rowDefinitions.splice(index, 1);
  5915. this._markAsDirty();
  5916. return this;
  5917. };
  5918. /**
  5919. * Adds a new control to the current grid
  5920. * @param control defines the control to add
  5921. * @param row defines the row where to add the control (0 by default)
  5922. * @param column defines the column where to add the control (0 by default)
  5923. * @returns the current grid
  5924. */
  5925. Grid.prototype.addControl = function (control, row, column) {
  5926. if (row === void 0) { row = 0; }
  5927. if (column === void 0) { column = 0; }
  5928. if (this._rowDefinitions.length === 0) {
  5929. // Add default row definition
  5930. this.addRowDefinition(1, false);
  5931. }
  5932. if (this._columnDefinitions.length === 0) {
  5933. // Add default column definition
  5934. this.addColumnDefinition(1, false);
  5935. }
  5936. if (this._childControls.indexOf(control) !== -1) {
  5937. 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");
  5938. return this;
  5939. }
  5940. var x = Math.min(row, this._rowDefinitions.length - 1);
  5941. var y = Math.min(column, this._columnDefinitions.length - 1);
  5942. var key = x + ":" + y;
  5943. var goodContainer = this._cells[key];
  5944. if (!goodContainer) {
  5945. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5946. this._cells[key] = goodContainer;
  5947. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5948. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5949. _super.prototype.addControl.call(this, goodContainer);
  5950. }
  5951. goodContainer.addControl(control);
  5952. this._childControls.push(control);
  5953. control._tag = key;
  5954. control.parent = this;
  5955. this._markAsDirty();
  5956. return this;
  5957. };
  5958. /**
  5959. * Removes a control from the current container
  5960. * @param control defines the control to remove
  5961. * @returns the current container
  5962. */
  5963. Grid.prototype.removeControl = function (control) {
  5964. var index = this._childControls.indexOf(control);
  5965. if (index !== -1) {
  5966. this._childControls.splice(index, 1);
  5967. }
  5968. var cell = this._cells[control._tag];
  5969. if (cell) {
  5970. cell.removeControl(control);
  5971. control._tag = null;
  5972. }
  5973. this._markAsDirty();
  5974. return this;
  5975. };
  5976. Grid.prototype._getTypeName = function () {
  5977. return "Grid";
  5978. };
  5979. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5980. var widths = [];
  5981. var heights = [];
  5982. var lefts = [];
  5983. var tops = [];
  5984. var availableWidth = this._currentMeasure.width;
  5985. var globalWidthPercentage = 0;
  5986. var availableHeight = this._currentMeasure.height;
  5987. var globalHeightPercentage = 0;
  5988. // Heights
  5989. var index = 0;
  5990. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5991. var value = _a[_i];
  5992. if (value.isPixel) {
  5993. var height = value.getValue(this._host);
  5994. availableHeight -= height;
  5995. heights[index] = height;
  5996. }
  5997. else {
  5998. globalHeightPercentage += value.internalValue;
  5999. }
  6000. index++;
  6001. }
  6002. var top = 0;
  6003. index = 0;
  6004. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6005. var value = _c[_b];
  6006. tops.push(top);
  6007. if (!value.isPixel) {
  6008. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6009. top += height;
  6010. heights[index] = height;
  6011. }
  6012. else {
  6013. top += value.getValue(this._host);
  6014. }
  6015. index++;
  6016. }
  6017. // Widths
  6018. index = 0;
  6019. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6020. var value = _e[_d];
  6021. if (value.isPixel) {
  6022. var width = value.getValue(this._host);
  6023. availableWidth -= width;
  6024. widths[index] = width;
  6025. }
  6026. else {
  6027. globalWidthPercentage += value.internalValue;
  6028. }
  6029. index++;
  6030. }
  6031. var left = 0;
  6032. index = 0;
  6033. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6034. var value = _g[_f];
  6035. lefts.push(left);
  6036. if (!value.isPixel) {
  6037. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6038. left += width;
  6039. widths[index] = width;
  6040. }
  6041. else {
  6042. left += value.getValue(this._host);
  6043. }
  6044. index++;
  6045. }
  6046. definitionCallback(lefts, tops, widths, heights);
  6047. };
  6048. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6049. var _this = this;
  6050. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6051. // Setting child sizes
  6052. for (var key in _this._cells) {
  6053. if (!_this._cells.hasOwnProperty(key)) {
  6054. continue;
  6055. }
  6056. var split = key.split(":");
  6057. var x = parseInt(split[0]);
  6058. var y = parseInt(split[1]);
  6059. var cell = _this._cells[key];
  6060. cell.left = lefts[y] + "px";
  6061. cell.top = tops[x] + "px";
  6062. cell.width = widths[y] + "px";
  6063. cell.height = heights[x] + "px";
  6064. cell._left.ignoreAdaptiveScaling = true;
  6065. cell._top.ignoreAdaptiveScaling = true;
  6066. cell._width.ignoreAdaptiveScaling = true;
  6067. cell._height.ignoreAdaptiveScaling = true;
  6068. }
  6069. });
  6070. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6071. };
  6072. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6073. for (var key in this._cells) {
  6074. if (!this._cells.hasOwnProperty(key)) {
  6075. continue;
  6076. }
  6077. var child = this._cells[key];
  6078. child._markMatrixAsDirty();
  6079. }
  6080. };
  6081. Grid.prototype._renderHighlightSpecific = function (context) {
  6082. var _this = this;
  6083. _super.prototype._renderHighlightSpecific.call(this, context);
  6084. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6085. // Columns
  6086. for (var index = 0; index < lefts.length; index++) {
  6087. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6088. context.beginPath();
  6089. context.moveTo(left, _this._currentMeasure.top);
  6090. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6091. context.stroke();
  6092. }
  6093. // Rows
  6094. for (var index = 0; index < tops.length; index++) {
  6095. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6096. context.beginPath();
  6097. context.moveTo(_this._currentMeasure.left, top_1);
  6098. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6099. context.stroke();
  6100. }
  6101. });
  6102. context.restore();
  6103. };
  6104. /** Releases associated resources */
  6105. Grid.prototype.dispose = function () {
  6106. _super.prototype.dispose.call(this);
  6107. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6108. var control = _a[_i];
  6109. control.dispose();
  6110. }
  6111. this._childControls = [];
  6112. };
  6113. return Grid;
  6114. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6115. /***/ }),
  6116. /***/ "./2D/controls/image.ts":
  6117. /*!******************************!*\
  6118. !*** ./2D/controls/image.ts ***!
  6119. \******************************/
  6120. /*! exports provided: Image */
  6121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6122. "use strict";
  6123. __webpack_require__.r(__webpack_exports__);
  6124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6126. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6127. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6128. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6129. /**
  6130. * Class used to create 2D images
  6131. */
  6132. var Image = /** @class */ (function (_super) {
  6133. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6134. /**
  6135. * Creates a new Image
  6136. * @param name defines the control name
  6137. * @param url defines the image url
  6138. */
  6139. function Image(name, url) {
  6140. if (url === void 0) { url = null; }
  6141. var _this = _super.call(this, name) || this;
  6142. _this.name = name;
  6143. _this._loaded = false;
  6144. _this._stretch = Image.STRETCH_FILL;
  6145. _this._autoScale = false;
  6146. _this._sourceLeft = 0;
  6147. _this._sourceTop = 0;
  6148. _this._sourceWidth = 0;
  6149. _this._sourceHeight = 0;
  6150. _this._cellWidth = 0;
  6151. _this._cellHeight = 0;
  6152. _this._cellId = -1;
  6153. _this._populateNinePatchSlicesFromImage = false;
  6154. /**
  6155. * Observable notified when the content is loaded
  6156. */
  6157. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6158. _this.source = url;
  6159. return _this;
  6160. }
  6161. Object.defineProperty(Image.prototype, "isLoaded", {
  6162. /**
  6163. * Gets a boolean indicating that the content is loaded
  6164. */
  6165. get: function () {
  6166. return this._loaded;
  6167. },
  6168. enumerable: true,
  6169. configurable: true
  6170. });
  6171. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6172. /**
  6173. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6174. */
  6175. get: function () {
  6176. return this._populateNinePatchSlicesFromImage;
  6177. },
  6178. set: function (value) {
  6179. if (this._populateNinePatchSlicesFromImage === value) {
  6180. return;
  6181. }
  6182. this._populateNinePatchSlicesFromImage = value;
  6183. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6184. this._extractNinePatchSliceDataFromImage();
  6185. }
  6186. },
  6187. enumerable: true,
  6188. configurable: true
  6189. });
  6190. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6191. /**
  6192. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6193. * Beware using this as this will comsume more memory as the image has to be stored twice
  6194. */
  6195. get: function () {
  6196. return this._detectPointerOnOpaqueOnly;
  6197. },
  6198. set: function (value) {
  6199. if (this._detectPointerOnOpaqueOnly === value) {
  6200. return;
  6201. }
  6202. this._detectPointerOnOpaqueOnly = value;
  6203. },
  6204. enumerable: true,
  6205. configurable: true
  6206. });
  6207. Object.defineProperty(Image.prototype, "sliceLeft", {
  6208. /**
  6209. * Gets or sets the left value for slicing (9-patch)
  6210. */
  6211. get: function () {
  6212. return this._sliceLeft;
  6213. },
  6214. set: function (value) {
  6215. if (this._sliceLeft === value) {
  6216. return;
  6217. }
  6218. this._sliceLeft = value;
  6219. this._markAsDirty();
  6220. },
  6221. enumerable: true,
  6222. configurable: true
  6223. });
  6224. Object.defineProperty(Image.prototype, "sliceRight", {
  6225. /**
  6226. * Gets or sets the right value for slicing (9-patch)
  6227. */
  6228. get: function () {
  6229. return this._sliceRight;
  6230. },
  6231. set: function (value) {
  6232. if (this._sliceRight === value) {
  6233. return;
  6234. }
  6235. this._sliceRight = value;
  6236. this._markAsDirty();
  6237. },
  6238. enumerable: true,
  6239. configurable: true
  6240. });
  6241. Object.defineProperty(Image.prototype, "sliceTop", {
  6242. /**
  6243. * Gets or sets the top value for slicing (9-patch)
  6244. */
  6245. get: function () {
  6246. return this._sliceTop;
  6247. },
  6248. set: function (value) {
  6249. if (this._sliceTop === value) {
  6250. return;
  6251. }
  6252. this._sliceTop = value;
  6253. this._markAsDirty();
  6254. },
  6255. enumerable: true,
  6256. configurable: true
  6257. });
  6258. Object.defineProperty(Image.prototype, "sliceBottom", {
  6259. /**
  6260. * Gets or sets the bottom value for slicing (9-patch)
  6261. */
  6262. get: function () {
  6263. return this._sliceBottom;
  6264. },
  6265. set: function (value) {
  6266. if (this._sliceBottom === value) {
  6267. return;
  6268. }
  6269. this._sliceBottom = value;
  6270. this._markAsDirty();
  6271. },
  6272. enumerable: true,
  6273. configurable: true
  6274. });
  6275. Object.defineProperty(Image.prototype, "sourceLeft", {
  6276. /**
  6277. * Gets or sets the left coordinate in the source image
  6278. */
  6279. get: function () {
  6280. return this._sourceLeft;
  6281. },
  6282. set: function (value) {
  6283. if (this._sourceLeft === value) {
  6284. return;
  6285. }
  6286. this._sourceLeft = value;
  6287. this._markAsDirty();
  6288. },
  6289. enumerable: true,
  6290. configurable: true
  6291. });
  6292. Object.defineProperty(Image.prototype, "sourceTop", {
  6293. /**
  6294. * Gets or sets the top coordinate in the source image
  6295. */
  6296. get: function () {
  6297. return this._sourceTop;
  6298. },
  6299. set: function (value) {
  6300. if (this._sourceTop === value) {
  6301. return;
  6302. }
  6303. this._sourceTop = value;
  6304. this._markAsDirty();
  6305. },
  6306. enumerable: true,
  6307. configurable: true
  6308. });
  6309. Object.defineProperty(Image.prototype, "sourceWidth", {
  6310. /**
  6311. * Gets or sets the width to capture in the source image
  6312. */
  6313. get: function () {
  6314. return this._sourceWidth;
  6315. },
  6316. set: function (value) {
  6317. if (this._sourceWidth === value) {
  6318. return;
  6319. }
  6320. this._sourceWidth = value;
  6321. this._markAsDirty();
  6322. },
  6323. enumerable: true,
  6324. configurable: true
  6325. });
  6326. Object.defineProperty(Image.prototype, "sourceHeight", {
  6327. /**
  6328. * Gets or sets the height to capture in the source image
  6329. */
  6330. get: function () {
  6331. return this._sourceHeight;
  6332. },
  6333. set: function (value) {
  6334. if (this._sourceHeight === value) {
  6335. return;
  6336. }
  6337. this._sourceHeight = value;
  6338. this._markAsDirty();
  6339. },
  6340. enumerable: true,
  6341. configurable: true
  6342. });
  6343. Object.defineProperty(Image.prototype, "autoScale", {
  6344. /**
  6345. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6346. * @see http://doc.babylonjs.com/how_to/gui#image
  6347. */
  6348. get: function () {
  6349. return this._autoScale;
  6350. },
  6351. set: function (value) {
  6352. if (this._autoScale === value) {
  6353. return;
  6354. }
  6355. this._autoScale = value;
  6356. if (value && this._loaded) {
  6357. this.synchronizeSizeWithContent();
  6358. }
  6359. },
  6360. enumerable: true,
  6361. configurable: true
  6362. });
  6363. Object.defineProperty(Image.prototype, "stretch", {
  6364. /** Gets or sets the streching mode used by the image */
  6365. get: function () {
  6366. return this._stretch;
  6367. },
  6368. set: function (value) {
  6369. if (this._stretch === value) {
  6370. return;
  6371. }
  6372. this._stretch = value;
  6373. this._markAsDirty();
  6374. },
  6375. enumerable: true,
  6376. configurable: true
  6377. });
  6378. Object.defineProperty(Image.prototype, "domImage", {
  6379. get: function () {
  6380. return this._domImage;
  6381. },
  6382. /**
  6383. * Gets or sets the internal DOM image used to render the control
  6384. */
  6385. set: function (value) {
  6386. var _this = this;
  6387. this._domImage = value;
  6388. this._loaded = false;
  6389. if (this._domImage.width) {
  6390. this._onImageLoaded();
  6391. }
  6392. else {
  6393. this._domImage.onload = function () {
  6394. _this._onImageLoaded();
  6395. };
  6396. }
  6397. },
  6398. enumerable: true,
  6399. configurable: true
  6400. });
  6401. Image.prototype._onImageLoaded = function () {
  6402. this._imageWidth = this._domImage.width;
  6403. this._imageHeight = this._domImage.height;
  6404. this._loaded = true;
  6405. if (this._populateNinePatchSlicesFromImage) {
  6406. this._extractNinePatchSliceDataFromImage();
  6407. }
  6408. if (this._autoScale) {
  6409. this.synchronizeSizeWithContent();
  6410. }
  6411. this.onImageLoadedObservable.notifyObservers(this);
  6412. this._markAsDirty();
  6413. };
  6414. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6415. if (!Image._WorkingCanvas) {
  6416. Image._WorkingCanvas = document.createElement('canvas');
  6417. }
  6418. var canvas = Image._WorkingCanvas;
  6419. var context = canvas.getContext('2d');
  6420. var width = this._domImage.width;
  6421. var height = this._domImage.height;
  6422. canvas.width = width;
  6423. canvas.height = height;
  6424. context.drawImage(this._domImage, 0, 0, width, height);
  6425. var imageData = context.getImageData(0, 0, width, height);
  6426. // Left and right
  6427. this._sliceLeft = -1;
  6428. this._sliceRight = -1;
  6429. for (var x = 0; x < width; x++) {
  6430. var alpha = imageData.data[x * 4 + 3];
  6431. if (alpha > 127 && this._sliceLeft === -1) {
  6432. this._sliceLeft = x;
  6433. continue;
  6434. }
  6435. if (alpha < 127 && this._sliceLeft > -1) {
  6436. this._sliceRight = x;
  6437. break;
  6438. }
  6439. }
  6440. // top and bottom
  6441. this._sliceTop = -1;
  6442. this._sliceBottom = -1;
  6443. for (var y = 0; y < height; y++) {
  6444. var alpha = imageData.data[y * width * 4 + 3];
  6445. if (alpha > 127 && this._sliceTop === -1) {
  6446. this._sliceTop = y;
  6447. continue;
  6448. }
  6449. if (alpha < 127 && this._sliceTop > -1) {
  6450. this._sliceBottom = y;
  6451. break;
  6452. }
  6453. }
  6454. };
  6455. Object.defineProperty(Image.prototype, "source", {
  6456. /**
  6457. * Gets or sets image source url
  6458. */
  6459. set: function (value) {
  6460. var _this = this;
  6461. if (this._source === value) {
  6462. return;
  6463. }
  6464. this._loaded = false;
  6465. this._source = value;
  6466. this._domImage = document.createElement("img");
  6467. this._domImage.onload = function () {
  6468. _this._onImageLoaded();
  6469. };
  6470. if (value) {
  6471. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6472. this._domImage.src = value;
  6473. }
  6474. },
  6475. enumerable: true,
  6476. configurable: true
  6477. });
  6478. Object.defineProperty(Image.prototype, "cellWidth", {
  6479. /**
  6480. * Gets or sets the cell width to use when animation sheet is enabled
  6481. * @see http://doc.babylonjs.com/how_to/gui#image
  6482. */
  6483. get: function () {
  6484. return this._cellWidth;
  6485. },
  6486. set: function (value) {
  6487. if (this._cellWidth === value) {
  6488. return;
  6489. }
  6490. this._cellWidth = value;
  6491. this._markAsDirty();
  6492. },
  6493. enumerable: true,
  6494. configurable: true
  6495. });
  6496. Object.defineProperty(Image.prototype, "cellHeight", {
  6497. /**
  6498. * Gets or sets the cell height to use when animation sheet is enabled
  6499. * @see http://doc.babylonjs.com/how_to/gui#image
  6500. */
  6501. get: function () {
  6502. return this._cellHeight;
  6503. },
  6504. set: function (value) {
  6505. if (this._cellHeight === value) {
  6506. return;
  6507. }
  6508. this._cellHeight = value;
  6509. this._markAsDirty();
  6510. },
  6511. enumerable: true,
  6512. configurable: true
  6513. });
  6514. Object.defineProperty(Image.prototype, "cellId", {
  6515. /**
  6516. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6517. * @see http://doc.babylonjs.com/how_to/gui#image
  6518. */
  6519. get: function () {
  6520. return this._cellId;
  6521. },
  6522. set: function (value) {
  6523. if (this._cellId === value) {
  6524. return;
  6525. }
  6526. this._cellId = value;
  6527. this._markAsDirty();
  6528. },
  6529. enumerable: true,
  6530. configurable: true
  6531. });
  6532. /**
  6533. * Tests if a given coordinates belong to the current control
  6534. * @param x defines x coordinate to test
  6535. * @param y defines y coordinate to test
  6536. * @returns true if the coordinates are inside the control
  6537. */
  6538. Image.prototype.contains = function (x, y) {
  6539. if (!_super.prototype.contains.call(this, x, y)) {
  6540. return false;
  6541. }
  6542. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6543. return true;
  6544. }
  6545. var canvas = Image._WorkingCanvas;
  6546. var context = canvas.getContext("2d");
  6547. var width = this._currentMeasure.width | 0;
  6548. var height = this._currentMeasure.height | 0;
  6549. var imageData = context.getImageData(0, 0, width, height).data;
  6550. x = (x - this._currentMeasure.left) | 0;
  6551. y = (y - this._currentMeasure.top) | 0;
  6552. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6553. return pickedPixel > 0;
  6554. };
  6555. Image.prototype._getTypeName = function () {
  6556. return "Image";
  6557. };
  6558. /** Force the control to synchronize with its content */
  6559. Image.prototype.synchronizeSizeWithContent = function () {
  6560. if (!this._loaded) {
  6561. return;
  6562. }
  6563. this.width = this._domImage.width + "px";
  6564. this.height = this._domImage.height + "px";
  6565. };
  6566. Image.prototype._processMeasures = function (parentMeasure, context) {
  6567. if (this._loaded) {
  6568. switch (this._stretch) {
  6569. case Image.STRETCH_NONE:
  6570. break;
  6571. case Image.STRETCH_FILL:
  6572. break;
  6573. case Image.STRETCH_UNIFORM:
  6574. break;
  6575. case Image.STRETCH_NINE_PATCH:
  6576. break;
  6577. case Image.STRETCH_EXTEND:
  6578. if (this._autoScale) {
  6579. this.synchronizeSizeWithContent();
  6580. }
  6581. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6582. this.parent.adaptWidthToChildren = true;
  6583. this.parent.adaptHeightToChildren = true;
  6584. }
  6585. break;
  6586. }
  6587. }
  6588. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6589. };
  6590. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6591. if (!this._detectPointerOnOpaqueOnly) {
  6592. return;
  6593. }
  6594. if (!Image._WorkingCanvas) {
  6595. Image._WorkingCanvas = document.createElement('canvas');
  6596. }
  6597. var canvas = Image._WorkingCanvas;
  6598. var width = this._currentMeasure.width;
  6599. var height = this._currentMeasure.height;
  6600. var context = canvas.getContext("2d");
  6601. canvas.width = width;
  6602. canvas.height = height;
  6603. context.clearRect(0, 0, width, height);
  6604. };
  6605. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6606. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6607. if (!this._detectPointerOnOpaqueOnly) {
  6608. return;
  6609. }
  6610. var canvas = Image._WorkingCanvas;
  6611. context = canvas.getContext("2d");
  6612. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6613. };
  6614. Image.prototype._draw = function (context) {
  6615. context.save();
  6616. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6617. context.shadowColor = this.shadowColor;
  6618. context.shadowBlur = this.shadowBlur;
  6619. context.shadowOffsetX = this.shadowOffsetX;
  6620. context.shadowOffsetY = this.shadowOffsetY;
  6621. }
  6622. var x, y, width, height;
  6623. if (this.cellId == -1) {
  6624. x = this._sourceLeft;
  6625. y = this._sourceTop;
  6626. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6627. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6628. }
  6629. else {
  6630. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6631. var column = (this.cellId / rowCount) >> 0;
  6632. var row = this.cellId % rowCount;
  6633. x = this.cellWidth * row;
  6634. y = this.cellHeight * column;
  6635. width = this.cellWidth;
  6636. height = this.cellHeight;
  6637. }
  6638. this._prepareWorkingCanvasForOpaqueDetection();
  6639. this._applyStates(context);
  6640. if (this._loaded) {
  6641. switch (this._stretch) {
  6642. case Image.STRETCH_NONE:
  6643. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6644. break;
  6645. case Image.STRETCH_FILL:
  6646. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6647. break;
  6648. case Image.STRETCH_UNIFORM:
  6649. var hRatio = this._currentMeasure.width / width;
  6650. var vRatio = this._currentMeasure.height / height;
  6651. var ratio = Math.min(hRatio, vRatio);
  6652. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6653. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6654. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6655. break;
  6656. case Image.STRETCH_EXTEND:
  6657. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6658. break;
  6659. case Image.STRETCH_NINE_PATCH:
  6660. this._renderNinePatch(context);
  6661. break;
  6662. }
  6663. }
  6664. context.restore();
  6665. };
  6666. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6667. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6668. };
  6669. Image.prototype._renderNinePatch = function (context) {
  6670. var height = this._imageHeight;
  6671. var leftWidth = this._sliceLeft;
  6672. var topHeight = this._sliceTop;
  6673. var bottomHeight = this._imageHeight - this._sliceBottom;
  6674. var rightWidth = this._imageWidth - this._sliceRight;
  6675. var left = 0;
  6676. var top = 0;
  6677. if (this._populateNinePatchSlicesFromImage) {
  6678. left = 1;
  6679. top = 1;
  6680. height -= 2;
  6681. leftWidth -= 1;
  6682. topHeight -= 1;
  6683. bottomHeight -= 1;
  6684. rightWidth -= 1;
  6685. }
  6686. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6687. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6688. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6689. // Corners
  6690. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6691. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6692. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6693. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6694. // Center
  6695. 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);
  6696. // Borders
  6697. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6698. 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);
  6699. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6700. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6701. };
  6702. Image.prototype.dispose = function () {
  6703. _super.prototype.dispose.call(this);
  6704. this.onImageLoadedObservable.clear();
  6705. };
  6706. Image._WorkingCanvas = null;
  6707. // Static
  6708. /** STRETCH_NONE */
  6709. Image.STRETCH_NONE = 0;
  6710. /** STRETCH_FILL */
  6711. Image.STRETCH_FILL = 1;
  6712. /** STRETCH_UNIFORM */
  6713. Image.STRETCH_UNIFORM = 2;
  6714. /** STRETCH_EXTEND */
  6715. Image.STRETCH_EXTEND = 3;
  6716. /** NINE_PATCH */
  6717. Image.STRETCH_NINE_PATCH = 4;
  6718. return Image;
  6719. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6720. /***/ }),
  6721. /***/ "./2D/controls/index.ts":
  6722. /*!******************************!*\
  6723. !*** ./2D/controls/index.ts ***!
  6724. \******************************/
  6725. /*! 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 */
  6726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6727. "use strict";
  6728. __webpack_require__.r(__webpack_exports__);
  6729. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6731. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6733. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6735. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6737. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6739. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6741. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6743. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6745. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6747. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6749. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6751. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6753. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6755. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6757. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6763. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6765. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6768. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6771. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6773. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6775. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6777. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6779. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6781. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6783. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6785. /***/ }),
  6786. /***/ "./2D/controls/inputPassword.ts":
  6787. /*!**************************************!*\
  6788. !*** ./2D/controls/inputPassword.ts ***!
  6789. \**************************************/
  6790. /*! exports provided: InputPassword */
  6791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6792. "use strict";
  6793. __webpack_require__.r(__webpack_exports__);
  6794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6795. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6796. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6797. /**
  6798. * Class used to create a password control
  6799. */
  6800. var InputPassword = /** @class */ (function (_super) {
  6801. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6802. function InputPassword() {
  6803. return _super !== null && _super.apply(this, arguments) || this;
  6804. }
  6805. InputPassword.prototype._beforeRenderText = function (text) {
  6806. var txt = "";
  6807. for (var i = 0; i < text.length; i++) {
  6808. txt += "\u2022";
  6809. }
  6810. return txt;
  6811. };
  6812. return InputPassword;
  6813. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6814. /***/ }),
  6815. /***/ "./2D/controls/inputText.ts":
  6816. /*!**********************************!*\
  6817. !*** ./2D/controls/inputText.ts ***!
  6818. \**********************************/
  6819. /*! exports provided: InputText */
  6820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6821. "use strict";
  6822. __webpack_require__.r(__webpack_exports__);
  6823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6824. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6825. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6826. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6827. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6828. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6829. /**
  6830. * Class used to create input text control
  6831. */
  6832. var InputText = /** @class */ (function (_super) {
  6833. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6834. /**
  6835. * Creates a new InputText
  6836. * @param name defines the control name
  6837. * @param text defines the text of the control
  6838. */
  6839. function InputText(name, text) {
  6840. if (text === void 0) { text = ""; }
  6841. var _this = _super.call(this, name) || this;
  6842. _this.name = name;
  6843. _this._text = "";
  6844. _this._placeholderText = "";
  6845. _this._background = "#222222";
  6846. _this._focusedBackground = "#000000";
  6847. _this._focusedColor = "white";
  6848. _this._placeholderColor = "gray";
  6849. _this._thickness = 1;
  6850. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6851. _this._autoStretchWidth = true;
  6852. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6853. _this._isFocused = false;
  6854. _this._blinkIsEven = false;
  6855. _this._cursorOffset = 0;
  6856. _this._deadKey = false;
  6857. _this._addKey = true;
  6858. _this._currentKey = "";
  6859. _this._isTextHighlightOn = false;
  6860. _this._textHighlightColor = "#d5e0ff";
  6861. _this._highligherOpacity = 0.4;
  6862. _this._highlightedText = "";
  6863. _this._startHighlightIndex = 0;
  6864. _this._endHighlightIndex = 0;
  6865. _this._cursorIndex = -1;
  6866. _this._onFocusSelectAll = false;
  6867. _this._isPointerDown = false;
  6868. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6869. _this.promptMessage = "Please enter text:";
  6870. /** Force disable prompt on mobile device */
  6871. _this.disableMobilePrompt = false;
  6872. /** Observable raised when the text changes */
  6873. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6874. /** Observable raised just before an entered character is to be added */
  6875. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6876. /** Observable raised when the control gets the focus */
  6877. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6878. /** Observable raised when the control loses the focus */
  6879. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6880. /**Observable raised when the text is highlighted */
  6881. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6882. /**Observable raised when copy event is triggered */
  6883. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6884. /** Observable raised when cut event is triggered */
  6885. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6886. /** Observable raised when paste event is triggered */
  6887. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6888. /** Observable raised when a key event was processed */
  6889. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6890. _this.text = text;
  6891. _this.isPointerBlocker = true;
  6892. return _this;
  6893. }
  6894. Object.defineProperty(InputText.prototype, "maxWidth", {
  6895. /** Gets or sets the maximum width allowed by the control */
  6896. get: function () {
  6897. return this._maxWidth.toString(this._host);
  6898. },
  6899. set: function (value) {
  6900. if (this._maxWidth.toString(this._host) === value) {
  6901. return;
  6902. }
  6903. if (this._maxWidth.fromString(value)) {
  6904. this._markAsDirty();
  6905. }
  6906. },
  6907. enumerable: true,
  6908. configurable: true
  6909. });
  6910. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6911. /** Gets the maximum width allowed by the control in pixels */
  6912. get: function () {
  6913. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6914. },
  6915. enumerable: true,
  6916. configurable: true
  6917. });
  6918. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6919. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6920. get: function () {
  6921. return this._highligherOpacity;
  6922. },
  6923. set: function (value) {
  6924. if (this._highligherOpacity === value) {
  6925. return;
  6926. }
  6927. this._highligherOpacity = value;
  6928. this._markAsDirty();
  6929. },
  6930. enumerable: true,
  6931. configurable: true
  6932. });
  6933. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6934. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6935. get: function () {
  6936. return this._onFocusSelectAll;
  6937. },
  6938. set: function (value) {
  6939. if (this._onFocusSelectAll === value) {
  6940. return;
  6941. }
  6942. this._onFocusSelectAll = value;
  6943. this._markAsDirty();
  6944. },
  6945. enumerable: true,
  6946. configurable: true
  6947. });
  6948. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6949. /** Gets or sets the text hightlight color */
  6950. get: function () {
  6951. return this._textHighlightColor;
  6952. },
  6953. set: function (value) {
  6954. if (this._textHighlightColor === value) {
  6955. return;
  6956. }
  6957. this._textHighlightColor = value;
  6958. this._markAsDirty();
  6959. },
  6960. enumerable: true,
  6961. configurable: true
  6962. });
  6963. Object.defineProperty(InputText.prototype, "margin", {
  6964. /** Gets or sets control margin */
  6965. get: function () {
  6966. return this._margin.toString(this._host);
  6967. },
  6968. set: function (value) {
  6969. if (this._margin.toString(this._host) === value) {
  6970. return;
  6971. }
  6972. if (this._margin.fromString(value)) {
  6973. this._markAsDirty();
  6974. }
  6975. },
  6976. enumerable: true,
  6977. configurable: true
  6978. });
  6979. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6980. /** Gets control margin in pixels */
  6981. get: function () {
  6982. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6983. },
  6984. enumerable: true,
  6985. configurable: true
  6986. });
  6987. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6988. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6989. get: function () {
  6990. return this._autoStretchWidth;
  6991. },
  6992. set: function (value) {
  6993. if (this._autoStretchWidth === value) {
  6994. return;
  6995. }
  6996. this._autoStretchWidth = value;
  6997. this._markAsDirty();
  6998. },
  6999. enumerable: true,
  7000. configurable: true
  7001. });
  7002. Object.defineProperty(InputText.prototype, "thickness", {
  7003. /** Gets or sets border thickness */
  7004. get: function () {
  7005. return this._thickness;
  7006. },
  7007. set: function (value) {
  7008. if (this._thickness === value) {
  7009. return;
  7010. }
  7011. this._thickness = value;
  7012. this._markAsDirty();
  7013. },
  7014. enumerable: true,
  7015. configurable: true
  7016. });
  7017. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7018. /** Gets or sets the background color when focused */
  7019. get: function () {
  7020. return this._focusedBackground;
  7021. },
  7022. set: function (value) {
  7023. if (this._focusedBackground === value) {
  7024. return;
  7025. }
  7026. this._focusedBackground = value;
  7027. this._markAsDirty();
  7028. },
  7029. enumerable: true,
  7030. configurable: true
  7031. });
  7032. Object.defineProperty(InputText.prototype, "focusedColor", {
  7033. /** Gets or sets the background color when focused */
  7034. get: function () {
  7035. return this._focusedColor;
  7036. },
  7037. set: function (value) {
  7038. if (this._focusedColor === value) {
  7039. return;
  7040. }
  7041. this._focusedColor = value;
  7042. this._markAsDirty();
  7043. },
  7044. enumerable: true,
  7045. configurable: true
  7046. });
  7047. Object.defineProperty(InputText.prototype, "background", {
  7048. /** Gets or sets the background color */
  7049. get: function () {
  7050. return this._background;
  7051. },
  7052. set: function (value) {
  7053. if (this._background === value) {
  7054. return;
  7055. }
  7056. this._background = value;
  7057. this._markAsDirty();
  7058. },
  7059. enumerable: true,
  7060. configurable: true
  7061. });
  7062. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7063. /** Gets or sets the placeholder color */
  7064. get: function () {
  7065. return this._placeholderColor;
  7066. },
  7067. set: function (value) {
  7068. if (this._placeholderColor === value) {
  7069. return;
  7070. }
  7071. this._placeholderColor = value;
  7072. this._markAsDirty();
  7073. },
  7074. enumerable: true,
  7075. configurable: true
  7076. });
  7077. Object.defineProperty(InputText.prototype, "placeholderText", {
  7078. /** Gets or sets the text displayed when the control is empty */
  7079. get: function () {
  7080. return this._placeholderText;
  7081. },
  7082. set: function (value) {
  7083. if (this._placeholderText === value) {
  7084. return;
  7085. }
  7086. this._placeholderText = value;
  7087. this._markAsDirty();
  7088. },
  7089. enumerable: true,
  7090. configurable: true
  7091. });
  7092. Object.defineProperty(InputText.prototype, "deadKey", {
  7093. /** Gets or sets the dead key flag */
  7094. get: function () {
  7095. return this._deadKey;
  7096. },
  7097. set: function (flag) {
  7098. this._deadKey = flag;
  7099. },
  7100. enumerable: true,
  7101. configurable: true
  7102. });
  7103. Object.defineProperty(InputText.prototype, "highlightedText", {
  7104. /** Gets or sets the highlight text */
  7105. get: function () {
  7106. return this._highlightedText;
  7107. },
  7108. set: function (text) {
  7109. if (this._highlightedText === text) {
  7110. return;
  7111. }
  7112. this._highlightedText = text;
  7113. this._markAsDirty();
  7114. },
  7115. enumerable: true,
  7116. configurable: true
  7117. });
  7118. Object.defineProperty(InputText.prototype, "addKey", {
  7119. /** Gets or sets if the current key should be added */
  7120. get: function () {
  7121. return this._addKey;
  7122. },
  7123. set: function (flag) {
  7124. this._addKey = flag;
  7125. },
  7126. enumerable: true,
  7127. configurable: true
  7128. });
  7129. Object.defineProperty(InputText.prototype, "currentKey", {
  7130. /** Gets or sets the value of the current key being entered */
  7131. get: function () {
  7132. return this._currentKey;
  7133. },
  7134. set: function (key) {
  7135. this._currentKey = key;
  7136. },
  7137. enumerable: true,
  7138. configurable: true
  7139. });
  7140. Object.defineProperty(InputText.prototype, "text", {
  7141. /** Gets or sets the text displayed in the control */
  7142. get: function () {
  7143. return this._text;
  7144. },
  7145. set: function (value) {
  7146. var valueAsString = value.toString(); // Forcing convertion
  7147. if (this._text === valueAsString) {
  7148. return;
  7149. }
  7150. this._text = valueAsString;
  7151. this._markAsDirty();
  7152. this.onTextChangedObservable.notifyObservers(this);
  7153. },
  7154. enumerable: true,
  7155. configurable: true
  7156. });
  7157. Object.defineProperty(InputText.prototype, "width", {
  7158. /** Gets or sets control width */
  7159. get: function () {
  7160. return this._width.toString(this._host);
  7161. },
  7162. set: function (value) {
  7163. if (this._width.toString(this._host) === value) {
  7164. return;
  7165. }
  7166. if (this._width.fromString(value)) {
  7167. this._markAsDirty();
  7168. }
  7169. this.autoStretchWidth = false;
  7170. },
  7171. enumerable: true,
  7172. configurable: true
  7173. });
  7174. /** @hidden */
  7175. InputText.prototype.onBlur = function () {
  7176. this._isFocused = false;
  7177. this._scrollLeft = null;
  7178. this._cursorOffset = 0;
  7179. clearTimeout(this._blinkTimeout);
  7180. this._markAsDirty();
  7181. this.onBlurObservable.notifyObservers(this);
  7182. this._host.unRegisterClipboardEvents();
  7183. if (this._onClipboardObserver) {
  7184. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7185. }
  7186. var scene = this._host.getScene();
  7187. if (this._onPointerDblTapObserver && scene) {
  7188. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7189. }
  7190. };
  7191. /** @hidden */
  7192. InputText.prototype.onFocus = function () {
  7193. var _this = this;
  7194. if (!this._isEnabled) {
  7195. return;
  7196. }
  7197. this._scrollLeft = null;
  7198. this._isFocused = true;
  7199. this._blinkIsEven = false;
  7200. this._cursorOffset = 0;
  7201. this._markAsDirty();
  7202. this.onFocusObservable.notifyObservers(this);
  7203. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7204. var value = prompt(this.promptMessage);
  7205. if (value !== null) {
  7206. this.text = value;
  7207. }
  7208. this._host.focusedControl = null;
  7209. return;
  7210. }
  7211. this._host.registerClipboardEvents();
  7212. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7213. // process clipboard event, can be configured.
  7214. switch (clipboardInfo.type) {
  7215. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7216. _this._onCopyText(clipboardInfo.event);
  7217. _this.onTextCopyObservable.notifyObservers(_this);
  7218. break;
  7219. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7220. _this._onCutText(clipboardInfo.event);
  7221. _this.onTextCutObservable.notifyObservers(_this);
  7222. break;
  7223. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7224. _this._onPasteText(clipboardInfo.event);
  7225. _this.onTextPasteObservable.notifyObservers(_this);
  7226. break;
  7227. default: return;
  7228. }
  7229. });
  7230. var scene = this._host.getScene();
  7231. if (scene) {
  7232. //register the pointer double tap event
  7233. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7234. if (!_this._isFocused) {
  7235. return;
  7236. }
  7237. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7238. _this._processDblClick(pointerInfo);
  7239. }
  7240. });
  7241. }
  7242. if (this._onFocusSelectAll) {
  7243. this._selectAllText();
  7244. }
  7245. };
  7246. InputText.prototype._getTypeName = function () {
  7247. return "InputText";
  7248. };
  7249. /**
  7250. * Function called to get the list of controls that should not steal the focus from this control
  7251. * @returns an array of controls
  7252. */
  7253. InputText.prototype.keepsFocusWith = function () {
  7254. if (!this._connectedVirtualKeyboard) {
  7255. return null;
  7256. }
  7257. return [this._connectedVirtualKeyboard];
  7258. };
  7259. /** @hidden */
  7260. InputText.prototype.processKey = function (keyCode, key, evt) {
  7261. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7262. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7263. return;
  7264. }
  7265. //select all
  7266. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7267. this._selectAllText();
  7268. evt.preventDefault();
  7269. return;
  7270. }
  7271. // Specific cases
  7272. switch (keyCode) {
  7273. case 32: //SPACE
  7274. key = " "; //ie11 key for space is "Spacebar"
  7275. break;
  7276. case 191: //SLASH
  7277. if (evt) {
  7278. evt.preventDefault();
  7279. }
  7280. break;
  7281. case 8: // BACKSPACE
  7282. if (this._text && this._text.length > 0) {
  7283. //delete the highlighted text
  7284. if (this._isTextHighlightOn) {
  7285. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7286. this._isTextHighlightOn = false;
  7287. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7288. this._blinkIsEven = false;
  7289. if (evt) {
  7290. evt.preventDefault();
  7291. }
  7292. return;
  7293. }
  7294. //delete single character
  7295. if (this._cursorOffset === 0) {
  7296. this.text = this._text.substr(0, this._text.length - 1);
  7297. }
  7298. else {
  7299. var deletePosition = this._text.length - this._cursorOffset;
  7300. if (deletePosition > 0) {
  7301. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7302. }
  7303. }
  7304. }
  7305. if (evt) {
  7306. evt.preventDefault();
  7307. }
  7308. return;
  7309. case 46: // DELETE
  7310. if (this._isTextHighlightOn) {
  7311. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7312. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7313. while (decrementor > 0 && this._cursorOffset > 0) {
  7314. this._cursorOffset--;
  7315. }
  7316. this._isTextHighlightOn = false;
  7317. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7318. if (evt) {
  7319. evt.preventDefault();
  7320. }
  7321. return;
  7322. }
  7323. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7324. var deletePosition = this._text.length - this._cursorOffset;
  7325. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7326. this._cursorOffset--;
  7327. }
  7328. if (evt) {
  7329. evt.preventDefault();
  7330. }
  7331. return;
  7332. case 13: // RETURN
  7333. this._host.focusedControl = null;
  7334. this._isTextHighlightOn = false;
  7335. return;
  7336. case 35: // END
  7337. this._cursorOffset = 0;
  7338. this._blinkIsEven = false;
  7339. this._isTextHighlightOn = false;
  7340. this._markAsDirty();
  7341. return;
  7342. case 36: // HOME
  7343. this._cursorOffset = this._text.length;
  7344. this._blinkIsEven = false;
  7345. this._isTextHighlightOn = false;
  7346. this._markAsDirty();
  7347. return;
  7348. case 37: // LEFT
  7349. this._cursorOffset++;
  7350. if (this._cursorOffset > this._text.length) {
  7351. this._cursorOffset = this._text.length;
  7352. }
  7353. if (evt && evt.shiftKey) {
  7354. // update the cursor
  7355. this._blinkIsEven = false;
  7356. // shift + ctrl/cmd + <-
  7357. if (evt.ctrlKey || evt.metaKey) {
  7358. if (!this._isTextHighlightOn) {
  7359. if (this._text.length === this._cursorOffset) {
  7360. return;
  7361. }
  7362. else {
  7363. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7364. }
  7365. }
  7366. this._startHighlightIndex = 0;
  7367. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7368. this._cursorOffset = this._text.length;
  7369. this._isTextHighlightOn = true;
  7370. this._markAsDirty();
  7371. return;
  7372. }
  7373. //store the starting point
  7374. if (!this._isTextHighlightOn) {
  7375. this._isTextHighlightOn = true;
  7376. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7377. }
  7378. //if text is already highlighted
  7379. else if (this._cursorIndex === -1) {
  7380. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7381. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7382. }
  7383. //set the highlight indexes
  7384. if (this._cursorIndex < this._cursorOffset) {
  7385. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7386. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7387. }
  7388. else if (this._cursorIndex > this._cursorOffset) {
  7389. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7390. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7391. }
  7392. else {
  7393. this._isTextHighlightOn = false;
  7394. }
  7395. this._markAsDirty();
  7396. return;
  7397. }
  7398. if (this._isTextHighlightOn) {
  7399. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7400. this._isTextHighlightOn = false;
  7401. }
  7402. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7403. this._cursorOffset = this.text.length;
  7404. evt.preventDefault();
  7405. }
  7406. this._blinkIsEven = false;
  7407. this._isTextHighlightOn = false;
  7408. this._cursorIndex = -1;
  7409. this._markAsDirty();
  7410. return;
  7411. case 39: // RIGHT
  7412. this._cursorOffset--;
  7413. if (this._cursorOffset < 0) {
  7414. this._cursorOffset = 0;
  7415. }
  7416. if (evt && evt.shiftKey) {
  7417. //update the cursor
  7418. this._blinkIsEven = false;
  7419. //shift + ctrl/cmd + ->
  7420. if (evt.ctrlKey || evt.metaKey) {
  7421. if (!this._isTextHighlightOn) {
  7422. if (this._cursorOffset === 0) {
  7423. return;
  7424. }
  7425. else {
  7426. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7427. }
  7428. }
  7429. this._endHighlightIndex = this._text.length;
  7430. this._isTextHighlightOn = true;
  7431. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7432. this._cursorOffset = 0;
  7433. this._markAsDirty();
  7434. return;
  7435. }
  7436. if (!this._isTextHighlightOn) {
  7437. this._isTextHighlightOn = true;
  7438. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7439. }
  7440. //if text is already highlighted
  7441. else if (this._cursorIndex === -1) {
  7442. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7443. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7444. }
  7445. //set the highlight indexes
  7446. if (this._cursorIndex < this._cursorOffset) {
  7447. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7448. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7449. }
  7450. else if (this._cursorIndex > this._cursorOffset) {
  7451. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7452. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7453. }
  7454. else {
  7455. this._isTextHighlightOn = false;
  7456. }
  7457. this._markAsDirty();
  7458. return;
  7459. }
  7460. if (this._isTextHighlightOn) {
  7461. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7462. this._isTextHighlightOn = false;
  7463. }
  7464. //ctr + ->
  7465. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7466. this._cursorOffset = 0;
  7467. evt.preventDefault();
  7468. }
  7469. this._blinkIsEven = false;
  7470. this._isTextHighlightOn = false;
  7471. this._cursorIndex = -1;
  7472. this._markAsDirty();
  7473. return;
  7474. case 222: // Dead
  7475. if (evt) {
  7476. evt.preventDefault();
  7477. }
  7478. this._cursorIndex = -1;
  7479. this.deadKey = true;
  7480. break;
  7481. }
  7482. // Printable characters
  7483. if (key &&
  7484. ((keyCode === -1) || // Direct access
  7485. (keyCode === 32) || // Space
  7486. (keyCode > 47 && keyCode < 64) || // Numbers
  7487. (keyCode > 64 && keyCode < 91) || // Letters
  7488. (keyCode > 159 && keyCode < 193) || // Special characters
  7489. (keyCode > 218 && keyCode < 223) || // Special characters
  7490. (keyCode > 95 && keyCode < 112))) { // Numpad
  7491. this._currentKey = key;
  7492. this.onBeforeKeyAddObservable.notifyObservers(this);
  7493. key = this._currentKey;
  7494. if (this._addKey) {
  7495. if (this._isTextHighlightOn) {
  7496. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7497. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7498. this._isTextHighlightOn = false;
  7499. this._blinkIsEven = false;
  7500. this._markAsDirty();
  7501. }
  7502. else if (this._cursorOffset === 0) {
  7503. this.text += key;
  7504. }
  7505. else {
  7506. var insertPosition = this._text.length - this._cursorOffset;
  7507. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7508. }
  7509. }
  7510. }
  7511. };
  7512. /** @hidden */
  7513. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7514. //update the cursor
  7515. this._blinkIsEven = false;
  7516. if (this._cursorIndex === -1) {
  7517. this._cursorIndex = offset;
  7518. }
  7519. else {
  7520. if (this._cursorIndex < this._cursorOffset) {
  7521. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7522. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7523. }
  7524. else if (this._cursorIndex > this._cursorOffset) {
  7525. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7526. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7527. }
  7528. else {
  7529. this._isTextHighlightOn = false;
  7530. this._markAsDirty();
  7531. return;
  7532. }
  7533. }
  7534. this._isTextHighlightOn = true;
  7535. this._markAsDirty();
  7536. };
  7537. /** @hidden */
  7538. InputText.prototype._processDblClick = function (evt) {
  7539. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7540. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7541. this._endHighlightIndex = this._startHighlightIndex;
  7542. var rWord = /\w+/g, moveLeft, moveRight;
  7543. do {
  7544. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7545. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7546. } while (moveLeft || moveRight);
  7547. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7548. this.onTextHighlightObservable.notifyObservers(this);
  7549. this._isTextHighlightOn = true;
  7550. this._clickedCoordinate = null;
  7551. this._blinkIsEven = true;
  7552. this._cursorIndex = -1;
  7553. this._markAsDirty();
  7554. };
  7555. /** @hidden */
  7556. InputText.prototype._selectAllText = function () {
  7557. this._blinkIsEven = true;
  7558. this._isTextHighlightOn = true;
  7559. this._startHighlightIndex = 0;
  7560. this._endHighlightIndex = this._text.length;
  7561. this._cursorOffset = this._text.length;
  7562. this._cursorIndex = -1;
  7563. this._markAsDirty();
  7564. };
  7565. /**
  7566. * Handles the keyboard event
  7567. * @param evt Defines the KeyboardEvent
  7568. */
  7569. InputText.prototype.processKeyboard = function (evt) {
  7570. // process pressed key
  7571. this.processKey(evt.keyCode, evt.key, evt);
  7572. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7573. };
  7574. /** @hidden */
  7575. InputText.prototype._onCopyText = function (ev) {
  7576. this._isTextHighlightOn = false;
  7577. //when write permission to clipbaord data is denied
  7578. try {
  7579. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7580. }
  7581. catch (_a) { } //pass
  7582. this._host.clipboardData = this._highlightedText;
  7583. };
  7584. /** @hidden */
  7585. InputText.prototype._onCutText = function (ev) {
  7586. if (!this._highlightedText) {
  7587. return;
  7588. }
  7589. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7590. this._isTextHighlightOn = false;
  7591. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7592. //when write permission to clipbaord data is denied
  7593. try {
  7594. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7595. }
  7596. catch (_a) { } //pass
  7597. this._host.clipboardData = this._highlightedText;
  7598. this._highlightedText = "";
  7599. };
  7600. /** @hidden */
  7601. InputText.prototype._onPasteText = function (ev) {
  7602. var data = "";
  7603. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7604. data = ev.clipboardData.getData("text/plain");
  7605. }
  7606. else {
  7607. //get the cached data; returns blank string by default
  7608. data = this._host.clipboardData;
  7609. }
  7610. var insertPosition = this._text.length - this._cursorOffset;
  7611. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7612. };
  7613. InputText.prototype._draw = function (context) {
  7614. var _this = this;
  7615. context.save();
  7616. this._applyStates(context);
  7617. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7618. context.shadowColor = this.shadowColor;
  7619. context.shadowBlur = this.shadowBlur;
  7620. context.shadowOffsetX = this.shadowOffsetX;
  7621. context.shadowOffsetY = this.shadowOffsetY;
  7622. }
  7623. // Background
  7624. if (this._isFocused) {
  7625. if (this._focusedBackground) {
  7626. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7627. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7628. }
  7629. }
  7630. else if (this._background) {
  7631. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7632. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7633. }
  7634. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7635. context.shadowBlur = 0;
  7636. context.shadowOffsetX = 0;
  7637. context.shadowOffsetY = 0;
  7638. }
  7639. if (!this._fontOffset) {
  7640. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7641. }
  7642. // Text
  7643. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7644. if (this.color) {
  7645. context.fillStyle = this.color;
  7646. }
  7647. var text = this._beforeRenderText(this._text);
  7648. if (!this._isFocused && !this._text && this._placeholderText) {
  7649. text = this._placeholderText;
  7650. if (this._placeholderColor) {
  7651. context.fillStyle = this._placeholderColor;
  7652. }
  7653. }
  7654. this._textWidth = context.measureText(text).width;
  7655. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7656. if (this._autoStretchWidth) {
  7657. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7658. }
  7659. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7660. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7661. context.save();
  7662. context.beginPath();
  7663. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7664. context.clip();
  7665. if (this._isFocused && this._textWidth > availableWidth) {
  7666. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7667. if (!this._scrollLeft) {
  7668. this._scrollLeft = textLeft;
  7669. }
  7670. }
  7671. else {
  7672. this._scrollLeft = clipTextLeft;
  7673. }
  7674. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7675. // Cursor
  7676. if (this._isFocused) {
  7677. // Need to move cursor
  7678. if (this._clickedCoordinate) {
  7679. var rightPosition = this._scrollLeft + this._textWidth;
  7680. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7681. var currentSize = 0;
  7682. this._cursorOffset = 0;
  7683. var previousDist = 0;
  7684. do {
  7685. if (this._cursorOffset) {
  7686. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7687. }
  7688. this._cursorOffset++;
  7689. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7690. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7691. // Find closest move
  7692. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7693. this._cursorOffset--;
  7694. }
  7695. this._blinkIsEven = false;
  7696. this._clickedCoordinate = null;
  7697. }
  7698. // Render cursor
  7699. if (!this._blinkIsEven) {
  7700. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7701. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7702. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7703. if (cursorLeft < clipTextLeft) {
  7704. this._scrollLeft += (clipTextLeft - cursorLeft);
  7705. cursorLeft = clipTextLeft;
  7706. this._markAsDirty();
  7707. }
  7708. else if (cursorLeft > clipTextLeft + availableWidth) {
  7709. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7710. cursorLeft = clipTextLeft + availableWidth;
  7711. this._markAsDirty();
  7712. }
  7713. if (!this._isTextHighlightOn) {
  7714. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7715. }
  7716. }
  7717. clearTimeout(this._blinkTimeout);
  7718. this._blinkTimeout = setTimeout(function () {
  7719. _this._blinkIsEven = !_this._blinkIsEven;
  7720. _this._markAsDirty();
  7721. }, 500);
  7722. //show the highlighted text
  7723. if (this._isTextHighlightOn) {
  7724. clearTimeout(this._blinkTimeout);
  7725. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7726. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7727. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7728. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7729. if (highlightCursorLeft < clipTextLeft) {
  7730. width = width - (clipTextLeft - highlightCursorLeft);
  7731. if (!width) {
  7732. // when using left arrow on text.length > availableWidth;
  7733. // assigns the width of the first letter after clipTextLeft
  7734. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7735. }
  7736. highlightCursorLeft = clipTextLeft;
  7737. }
  7738. //for transparancy
  7739. context.globalAlpha = this._highligherOpacity;
  7740. context.fillStyle = this._textHighlightColor;
  7741. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7742. context.globalAlpha = 1.0;
  7743. }
  7744. }
  7745. context.restore();
  7746. // Border
  7747. if (this._thickness) {
  7748. if (this._isFocused) {
  7749. if (this.focusedColor) {
  7750. context.strokeStyle = this.focusedColor;
  7751. }
  7752. }
  7753. else {
  7754. if (this.color) {
  7755. context.strokeStyle = this.color;
  7756. }
  7757. }
  7758. context.lineWidth = this._thickness;
  7759. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7760. }
  7761. context.restore();
  7762. };
  7763. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7764. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7765. return false;
  7766. }
  7767. this._clickedCoordinate = coordinates.x;
  7768. this._isTextHighlightOn = false;
  7769. this._highlightedText = "";
  7770. this._cursorIndex = -1;
  7771. this._isPointerDown = true;
  7772. this._host._capturingControl[pointerId] = this;
  7773. if (this._host.focusedControl === this) {
  7774. // Move cursor
  7775. clearTimeout(this._blinkTimeout);
  7776. this._markAsDirty();
  7777. return true;
  7778. }
  7779. if (!this._isEnabled) {
  7780. return false;
  7781. }
  7782. this._host.focusedControl = this;
  7783. return true;
  7784. };
  7785. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7786. if (this._host.focusedControl === this && this._isPointerDown) {
  7787. this._clickedCoordinate = coordinates.x;
  7788. this._markAsDirty();
  7789. this._updateValueFromCursorIndex(this._cursorOffset);
  7790. }
  7791. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7792. };
  7793. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7794. this._isPointerDown = false;
  7795. delete this._host._capturingControl[pointerId];
  7796. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7797. };
  7798. InputText.prototype._beforeRenderText = function (text) {
  7799. return text;
  7800. };
  7801. InputText.prototype.dispose = function () {
  7802. _super.prototype.dispose.call(this);
  7803. this.onBlurObservable.clear();
  7804. this.onFocusObservable.clear();
  7805. this.onTextChangedObservable.clear();
  7806. this.onTextCopyObservable.clear();
  7807. this.onTextCutObservable.clear();
  7808. this.onTextPasteObservable.clear();
  7809. this.onTextHighlightObservable.clear();
  7810. this.onKeyboardEventProcessedObservable.clear();
  7811. };
  7812. return InputText;
  7813. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7814. /***/ }),
  7815. /***/ "./2D/controls/line.ts":
  7816. /*!*****************************!*\
  7817. !*** ./2D/controls/line.ts ***!
  7818. \*****************************/
  7819. /*! exports provided: Line */
  7820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7821. "use strict";
  7822. __webpack_require__.r(__webpack_exports__);
  7823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7824. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7825. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  7826. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7827. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7828. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7829. /** Class used to render 2D lines */
  7830. var Line = /** @class */ (function (_super) {
  7831. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7832. /**
  7833. * Creates a new Line
  7834. * @param name defines the control name
  7835. */
  7836. function Line(name) {
  7837. var _this = _super.call(this, name) || this;
  7838. _this.name = name;
  7839. _this._lineWidth = 1;
  7840. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7841. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7842. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7843. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7844. _this._dash = new Array();
  7845. _this.isHitTestVisible = false;
  7846. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7847. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7848. return _this;
  7849. }
  7850. Object.defineProperty(Line.prototype, "dash", {
  7851. /** Gets or sets the dash pattern */
  7852. get: function () {
  7853. return this._dash;
  7854. },
  7855. set: function (value) {
  7856. if (this._dash === value) {
  7857. return;
  7858. }
  7859. this._dash = value;
  7860. this._markAsDirty();
  7861. },
  7862. enumerable: true,
  7863. configurable: true
  7864. });
  7865. Object.defineProperty(Line.prototype, "connectedControl", {
  7866. /** Gets or sets the control connected with the line end */
  7867. get: function () {
  7868. return this._connectedControl;
  7869. },
  7870. set: function (value) {
  7871. var _this = this;
  7872. if (this._connectedControl === value) {
  7873. return;
  7874. }
  7875. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7876. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7877. this._connectedControlDirtyObserver = null;
  7878. }
  7879. if (value) {
  7880. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7881. }
  7882. this._connectedControl = value;
  7883. this._markAsDirty();
  7884. },
  7885. enumerable: true,
  7886. configurable: true
  7887. });
  7888. Object.defineProperty(Line.prototype, "x1", {
  7889. /** Gets or sets start coordinates on X axis */
  7890. get: function () {
  7891. return this._x1.toString(this._host);
  7892. },
  7893. set: function (value) {
  7894. if (this._x1.toString(this._host) === value) {
  7895. return;
  7896. }
  7897. if (this._x1.fromString(value)) {
  7898. this._markAsDirty();
  7899. }
  7900. },
  7901. enumerable: true,
  7902. configurable: true
  7903. });
  7904. Object.defineProperty(Line.prototype, "y1", {
  7905. /** Gets or sets start coordinates on Y axis */
  7906. get: function () {
  7907. return this._y1.toString(this._host);
  7908. },
  7909. set: function (value) {
  7910. if (this._y1.toString(this._host) === value) {
  7911. return;
  7912. }
  7913. if (this._y1.fromString(value)) {
  7914. this._markAsDirty();
  7915. }
  7916. },
  7917. enumerable: true,
  7918. configurable: true
  7919. });
  7920. Object.defineProperty(Line.prototype, "x2", {
  7921. /** Gets or sets end coordinates on X axis */
  7922. get: function () {
  7923. return this._x2.toString(this._host);
  7924. },
  7925. set: function (value) {
  7926. if (this._x2.toString(this._host) === value) {
  7927. return;
  7928. }
  7929. if (this._x2.fromString(value)) {
  7930. this._markAsDirty();
  7931. }
  7932. },
  7933. enumerable: true,
  7934. configurable: true
  7935. });
  7936. Object.defineProperty(Line.prototype, "y2", {
  7937. /** Gets or sets end coordinates on Y axis */
  7938. get: function () {
  7939. return this._y2.toString(this._host);
  7940. },
  7941. set: function (value) {
  7942. if (this._y2.toString(this._host) === value) {
  7943. return;
  7944. }
  7945. if (this._y2.fromString(value)) {
  7946. this._markAsDirty();
  7947. }
  7948. },
  7949. enumerable: true,
  7950. configurable: true
  7951. });
  7952. Object.defineProperty(Line.prototype, "lineWidth", {
  7953. /** Gets or sets line width */
  7954. get: function () {
  7955. return this._lineWidth;
  7956. },
  7957. set: function (value) {
  7958. if (this._lineWidth === value) {
  7959. return;
  7960. }
  7961. this._lineWidth = value;
  7962. this._markAsDirty();
  7963. },
  7964. enumerable: true,
  7965. configurable: true
  7966. });
  7967. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7968. /** Gets or sets horizontal alignment */
  7969. set: function (value) {
  7970. return;
  7971. },
  7972. enumerable: true,
  7973. configurable: true
  7974. });
  7975. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7976. /** Gets or sets vertical alignment */
  7977. set: function (value) {
  7978. return;
  7979. },
  7980. enumerable: true,
  7981. configurable: true
  7982. });
  7983. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7984. get: function () {
  7985. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7986. },
  7987. enumerable: true,
  7988. configurable: true
  7989. });
  7990. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7991. get: function () {
  7992. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7993. },
  7994. enumerable: true,
  7995. configurable: true
  7996. });
  7997. Line.prototype._getTypeName = function () {
  7998. return "Line";
  7999. };
  8000. Line.prototype._draw = function (context) {
  8001. context.save();
  8002. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8003. context.shadowColor = this.shadowColor;
  8004. context.shadowBlur = this.shadowBlur;
  8005. context.shadowOffsetX = this.shadowOffsetX;
  8006. context.shadowOffsetY = this.shadowOffsetY;
  8007. }
  8008. this._applyStates(context);
  8009. context.strokeStyle = this.color;
  8010. context.lineWidth = this._lineWidth;
  8011. context.setLineDash(this._dash);
  8012. context.beginPath();
  8013. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8014. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8015. context.stroke();
  8016. context.restore();
  8017. };
  8018. Line.prototype._measure = function () {
  8019. // Width / Height
  8020. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8021. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8022. };
  8023. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8024. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8025. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8026. };
  8027. /**
  8028. * Move one end of the line given 3D cartesian coordinates.
  8029. * @param position Targeted world position
  8030. * @param scene Scene
  8031. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8032. */
  8033. Line.prototype.moveToVector3 = function (position, scene, end) {
  8034. if (end === void 0) { end = false; }
  8035. if (!this._host || this.parent !== this._host._rootContainer) {
  8036. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8037. return;
  8038. }
  8039. var globalViewport = this._host._getGlobalViewport(scene);
  8040. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8041. this._moveToProjectedPosition(projectedPosition, end);
  8042. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8043. this.notRenderable = true;
  8044. return;
  8045. }
  8046. this.notRenderable = false;
  8047. };
  8048. /**
  8049. * Move one end of the line to a position in screen absolute space.
  8050. * @param projectedPosition Position in screen absolute space (X, Y)
  8051. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8052. */
  8053. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8054. if (end === void 0) { end = false; }
  8055. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8056. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8057. if (end) {
  8058. this.x2 = x;
  8059. this.y2 = y;
  8060. this._x2.ignoreAdaptiveScaling = true;
  8061. this._y2.ignoreAdaptiveScaling = true;
  8062. }
  8063. else {
  8064. this.x1 = x;
  8065. this.y1 = y;
  8066. this._x1.ignoreAdaptiveScaling = true;
  8067. this._y1.ignoreAdaptiveScaling = true;
  8068. }
  8069. };
  8070. return Line;
  8071. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8072. /***/ }),
  8073. /***/ "./2D/controls/multiLine.ts":
  8074. /*!**********************************!*\
  8075. !*** ./2D/controls/multiLine.ts ***!
  8076. \**********************************/
  8077. /*! exports provided: MultiLine */
  8078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8079. "use strict";
  8080. __webpack_require__.r(__webpack_exports__);
  8081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8082. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8083. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math");
  8084. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8085. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8086. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8087. /**
  8088. * Class used to create multi line control
  8089. */
  8090. var MultiLine = /** @class */ (function (_super) {
  8091. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8092. /**
  8093. * Creates a new MultiLine
  8094. * @param name defines the control name
  8095. */
  8096. function MultiLine(name) {
  8097. var _this = _super.call(this, name) || this;
  8098. _this.name = name;
  8099. _this._lineWidth = 1;
  8100. /** Function called when a point is updated */
  8101. _this.onPointUpdate = function () {
  8102. _this._markAsDirty();
  8103. };
  8104. _this.isHitTestVisible = false;
  8105. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8106. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8107. _this._dash = [];
  8108. _this._points = [];
  8109. return _this;
  8110. }
  8111. Object.defineProperty(MultiLine.prototype, "dash", {
  8112. /** Gets or sets dash pattern */
  8113. get: function () {
  8114. return this._dash;
  8115. },
  8116. set: function (value) {
  8117. if (this._dash === value) {
  8118. return;
  8119. }
  8120. this._dash = value;
  8121. this._markAsDirty();
  8122. },
  8123. enumerable: true,
  8124. configurable: true
  8125. });
  8126. /**
  8127. * Gets point stored at specified index
  8128. * @param index defines the index to look for
  8129. * @returns the requested point if found
  8130. */
  8131. MultiLine.prototype.getAt = function (index) {
  8132. if (!this._points[index]) {
  8133. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8134. }
  8135. return this._points[index];
  8136. };
  8137. /**
  8138. * Adds new points to the point collection
  8139. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8140. * @returns the list of created MultiLinePoint
  8141. */
  8142. MultiLine.prototype.add = function () {
  8143. var _this = this;
  8144. var items = [];
  8145. for (var _i = 0; _i < arguments.length; _i++) {
  8146. items[_i] = arguments[_i];
  8147. }
  8148. return items.map(function (item) { return _this.push(item); });
  8149. };
  8150. /**
  8151. * Adds a new point to the point collection
  8152. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8153. * @returns the created MultiLinePoint
  8154. */
  8155. MultiLine.prototype.push = function (item) {
  8156. var point = this.getAt(this._points.length);
  8157. if (item == null) {
  8158. return point;
  8159. }
  8160. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8161. point.mesh = item;
  8162. }
  8163. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8164. point.control = item;
  8165. }
  8166. else if (item.x != null && item.y != null) {
  8167. point.x = item.x;
  8168. point.y = item.y;
  8169. }
  8170. return point;
  8171. };
  8172. /**
  8173. * Remove a specific value or point from the active point collection
  8174. * @param value defines the value or point to remove
  8175. */
  8176. MultiLine.prototype.remove = function (value) {
  8177. var index;
  8178. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8179. index = this._points.indexOf(value);
  8180. if (index === -1) {
  8181. return;
  8182. }
  8183. }
  8184. else {
  8185. index = value;
  8186. }
  8187. var point = this._points[index];
  8188. if (!point) {
  8189. return;
  8190. }
  8191. point.dispose();
  8192. this._points.splice(index, 1);
  8193. };
  8194. /**
  8195. * Resets this object to initial state (no point)
  8196. */
  8197. MultiLine.prototype.reset = function () {
  8198. while (this._points.length > 0) {
  8199. this.remove(this._points.length - 1);
  8200. }
  8201. };
  8202. /**
  8203. * Resets all links
  8204. */
  8205. MultiLine.prototype.resetLinks = function () {
  8206. this._points.forEach(function (point) {
  8207. if (point != null) {
  8208. point.resetLinks();
  8209. }
  8210. });
  8211. };
  8212. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8213. /** Gets or sets line width */
  8214. get: function () {
  8215. return this._lineWidth;
  8216. },
  8217. set: function (value) {
  8218. if (this._lineWidth === value) {
  8219. return;
  8220. }
  8221. this._lineWidth = value;
  8222. this._markAsDirty();
  8223. },
  8224. enumerable: true,
  8225. configurable: true
  8226. });
  8227. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8228. set: function (value) {
  8229. return;
  8230. },
  8231. enumerable: true,
  8232. configurable: true
  8233. });
  8234. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8235. set: function (value) {
  8236. return;
  8237. },
  8238. enumerable: true,
  8239. configurable: true
  8240. });
  8241. MultiLine.prototype._getTypeName = function () {
  8242. return "MultiLine";
  8243. };
  8244. MultiLine.prototype._draw = function (context) {
  8245. context.save();
  8246. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8247. context.shadowColor = this.shadowColor;
  8248. context.shadowBlur = this.shadowBlur;
  8249. context.shadowOffsetX = this.shadowOffsetX;
  8250. context.shadowOffsetY = this.shadowOffsetY;
  8251. }
  8252. this._applyStates(context);
  8253. context.strokeStyle = this.color;
  8254. context.lineWidth = this._lineWidth;
  8255. context.setLineDash(this._dash);
  8256. context.beginPath();
  8257. var first = true; //first index is not necessarily 0
  8258. this._points.forEach(function (point) {
  8259. if (!point) {
  8260. return;
  8261. }
  8262. if (first) {
  8263. context.moveTo(point._point.x, point._point.y);
  8264. first = false;
  8265. }
  8266. else {
  8267. context.lineTo(point._point.x, point._point.y);
  8268. }
  8269. });
  8270. context.stroke();
  8271. context.restore();
  8272. };
  8273. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8274. var _this = this;
  8275. this._minX = null;
  8276. this._minY = null;
  8277. this._maxX = null;
  8278. this._maxY = null;
  8279. this._points.forEach(function (point, index) {
  8280. if (!point) {
  8281. return;
  8282. }
  8283. point.translate();
  8284. if (_this._minX == null || point._point.x < _this._minX) {
  8285. _this._minX = point._point.x;
  8286. }
  8287. if (_this._minY == null || point._point.y < _this._minY) {
  8288. _this._minY = point._point.y;
  8289. }
  8290. if (_this._maxX == null || point._point.x > _this._maxX) {
  8291. _this._maxX = point._point.x;
  8292. }
  8293. if (_this._maxY == null || point._point.y > _this._maxY) {
  8294. _this._maxY = point._point.y;
  8295. }
  8296. });
  8297. if (this._minX == null) {
  8298. this._minX = 0;
  8299. }
  8300. if (this._minY == null) {
  8301. this._minY = 0;
  8302. }
  8303. if (this._maxX == null) {
  8304. this._maxX = 0;
  8305. }
  8306. if (this._maxY == null) {
  8307. this._maxY = 0;
  8308. }
  8309. };
  8310. MultiLine.prototype._measure = function () {
  8311. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8312. return;
  8313. }
  8314. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8315. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8316. };
  8317. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8318. if (this._minX == null || this._minY == null) {
  8319. return;
  8320. }
  8321. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8322. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8323. };
  8324. MultiLine.prototype.dispose = function () {
  8325. this.reset();
  8326. _super.prototype.dispose.call(this);
  8327. };
  8328. return MultiLine;
  8329. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8330. /***/ }),
  8331. /***/ "./2D/controls/radioButton.ts":
  8332. /*!************************************!*\
  8333. !*** ./2D/controls/radioButton.ts ***!
  8334. \************************************/
  8335. /*! exports provided: RadioButton */
  8336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8337. "use strict";
  8338. __webpack_require__.r(__webpack_exports__);
  8339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8340. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8341. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  8342. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8343. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8344. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8345. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8346. /**
  8347. * Class used to create radio button controls
  8348. */
  8349. var RadioButton = /** @class */ (function (_super) {
  8350. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8351. /**
  8352. * Creates a new RadioButton
  8353. * @param name defines the control name
  8354. */
  8355. function RadioButton(name) {
  8356. var _this = _super.call(this, name) || this;
  8357. _this.name = name;
  8358. _this._isChecked = false;
  8359. _this._background = "black";
  8360. _this._checkSizeRatio = 0.8;
  8361. _this._thickness = 1;
  8362. /** Gets or sets group name */
  8363. _this.group = "";
  8364. /** Observable raised when isChecked is changed */
  8365. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8366. _this.isPointerBlocker = true;
  8367. return _this;
  8368. }
  8369. Object.defineProperty(RadioButton.prototype, "thickness", {
  8370. /** Gets or sets border thickness */
  8371. get: function () {
  8372. return this._thickness;
  8373. },
  8374. set: function (value) {
  8375. if (this._thickness === value) {
  8376. return;
  8377. }
  8378. this._thickness = value;
  8379. this._markAsDirty();
  8380. },
  8381. enumerable: true,
  8382. configurable: true
  8383. });
  8384. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8385. /** Gets or sets a value indicating the ratio between overall size and check size */
  8386. get: function () {
  8387. return this._checkSizeRatio;
  8388. },
  8389. set: function (value) {
  8390. value = Math.max(Math.min(1, value), 0);
  8391. if (this._checkSizeRatio === value) {
  8392. return;
  8393. }
  8394. this._checkSizeRatio = value;
  8395. this._markAsDirty();
  8396. },
  8397. enumerable: true,
  8398. configurable: true
  8399. });
  8400. Object.defineProperty(RadioButton.prototype, "background", {
  8401. /** Gets or sets background color */
  8402. get: function () {
  8403. return this._background;
  8404. },
  8405. set: function (value) {
  8406. if (this._background === value) {
  8407. return;
  8408. }
  8409. this._background = value;
  8410. this._markAsDirty();
  8411. },
  8412. enumerable: true,
  8413. configurable: true
  8414. });
  8415. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8416. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8417. get: function () {
  8418. return this._isChecked;
  8419. },
  8420. set: function (value) {
  8421. var _this = this;
  8422. if (this._isChecked === value) {
  8423. return;
  8424. }
  8425. this._isChecked = value;
  8426. this._markAsDirty();
  8427. this.onIsCheckedChangedObservable.notifyObservers(value);
  8428. if (this._isChecked && this._host) {
  8429. // Update all controls from same group
  8430. this._host.executeOnAllControls(function (control) {
  8431. if (control === _this) {
  8432. return;
  8433. }
  8434. if (control.group === undefined) {
  8435. return;
  8436. }
  8437. var childRadio = control;
  8438. if (childRadio.group === _this.group) {
  8439. childRadio.isChecked = false;
  8440. }
  8441. });
  8442. }
  8443. },
  8444. enumerable: true,
  8445. configurable: true
  8446. });
  8447. RadioButton.prototype._getTypeName = function () {
  8448. return "RadioButton";
  8449. };
  8450. RadioButton.prototype._draw = function (context) {
  8451. context.save();
  8452. this._applyStates(context);
  8453. var actualWidth = this._currentMeasure.width - this._thickness;
  8454. var actualHeight = this._currentMeasure.height - this._thickness;
  8455. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8456. context.shadowColor = this.shadowColor;
  8457. context.shadowBlur = this.shadowBlur;
  8458. context.shadowOffsetX = this.shadowOffsetX;
  8459. context.shadowOffsetY = this.shadowOffsetY;
  8460. }
  8461. // Outer
  8462. _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);
  8463. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8464. context.fill();
  8465. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8466. context.shadowBlur = 0;
  8467. context.shadowOffsetX = 0;
  8468. context.shadowOffsetY = 0;
  8469. }
  8470. context.strokeStyle = this.color;
  8471. context.lineWidth = this._thickness;
  8472. context.stroke();
  8473. // Inner
  8474. if (this._isChecked) {
  8475. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8476. var offsetWidth = actualWidth * this._checkSizeRatio;
  8477. var offseHeight = actualHeight * this._checkSizeRatio;
  8478. _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);
  8479. context.fill();
  8480. }
  8481. context.restore();
  8482. };
  8483. // Events
  8484. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8485. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8486. return false;
  8487. }
  8488. if (!this.isChecked) {
  8489. this.isChecked = true;
  8490. }
  8491. return true;
  8492. };
  8493. /**
  8494. * Utility function to easily create a radio button with a header
  8495. * @param title defines the label to use for the header
  8496. * @param group defines the group to use for the radio button
  8497. * @param isChecked defines the initial state of the radio button
  8498. * @param onValueChanged defines the callback to call when value changes
  8499. * @returns a StackPanel containing the radio button and a textBlock
  8500. */
  8501. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8502. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8503. panel.isVertical = false;
  8504. panel.height = "30px";
  8505. var radio = new RadioButton();
  8506. radio.width = "20px";
  8507. radio.height = "20px";
  8508. radio.isChecked = isChecked;
  8509. radio.color = "green";
  8510. radio.group = group;
  8511. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8512. panel.addControl(radio);
  8513. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8514. header.text = title;
  8515. header.width = "180px";
  8516. header.paddingLeft = "5px";
  8517. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8518. header.color = "white";
  8519. panel.addControl(header);
  8520. return panel;
  8521. };
  8522. return RadioButton;
  8523. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8524. /***/ }),
  8525. /***/ "./2D/controls/rectangle.ts":
  8526. /*!**********************************!*\
  8527. !*** ./2D/controls/rectangle.ts ***!
  8528. \**********************************/
  8529. /*! exports provided: Rectangle */
  8530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8531. "use strict";
  8532. __webpack_require__.r(__webpack_exports__);
  8533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8534. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8535. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8536. /** Class used to create rectangle container */
  8537. var Rectangle = /** @class */ (function (_super) {
  8538. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8539. /**
  8540. * Creates a new Rectangle
  8541. * @param name defines the control name
  8542. */
  8543. function Rectangle(name) {
  8544. var _this = _super.call(this, name) || this;
  8545. _this.name = name;
  8546. _this._thickness = 1;
  8547. _this._cornerRadius = 0;
  8548. return _this;
  8549. }
  8550. Object.defineProperty(Rectangle.prototype, "thickness", {
  8551. /** Gets or sets border thickness */
  8552. get: function () {
  8553. return this._thickness;
  8554. },
  8555. set: function (value) {
  8556. if (this._thickness === value) {
  8557. return;
  8558. }
  8559. this._thickness = value;
  8560. this._markAsDirty();
  8561. },
  8562. enumerable: true,
  8563. configurable: true
  8564. });
  8565. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8566. /** Gets or sets the corner radius angle */
  8567. get: function () {
  8568. return this._cornerRadius;
  8569. },
  8570. set: function (value) {
  8571. if (value < 0) {
  8572. value = 0;
  8573. }
  8574. if (this._cornerRadius === value) {
  8575. return;
  8576. }
  8577. this._cornerRadius = value;
  8578. this._markAsDirty();
  8579. },
  8580. enumerable: true,
  8581. configurable: true
  8582. });
  8583. Rectangle.prototype._getTypeName = function () {
  8584. return "Rectangle";
  8585. };
  8586. Rectangle.prototype._localDraw = function (context) {
  8587. context.save();
  8588. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8589. context.shadowColor = this.shadowColor;
  8590. context.shadowBlur = this.shadowBlur;
  8591. context.shadowOffsetX = this.shadowOffsetX;
  8592. context.shadowOffsetY = this.shadowOffsetY;
  8593. }
  8594. if (this._background) {
  8595. context.fillStyle = this._background;
  8596. if (this._cornerRadius) {
  8597. this._drawRoundedRect(context, this._thickness / 2);
  8598. context.fill();
  8599. }
  8600. else {
  8601. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8602. }
  8603. }
  8604. if (this._thickness) {
  8605. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8606. context.shadowBlur = 0;
  8607. context.shadowOffsetX = 0;
  8608. context.shadowOffsetY = 0;
  8609. }
  8610. if (this.color) {
  8611. context.strokeStyle = this.color;
  8612. }
  8613. context.lineWidth = this._thickness;
  8614. if (this._cornerRadius) {
  8615. this._drawRoundedRect(context, this._thickness / 2);
  8616. context.stroke();
  8617. }
  8618. else {
  8619. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8620. }
  8621. }
  8622. context.restore();
  8623. };
  8624. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8625. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8626. this._measureForChildren.width -= 2 * this._thickness;
  8627. this._measureForChildren.height -= 2 * this._thickness;
  8628. this._measureForChildren.left += this._thickness;
  8629. this._measureForChildren.top += this._thickness;
  8630. };
  8631. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8632. if (offset === void 0) { offset = 0; }
  8633. var x = this._currentMeasure.left + offset;
  8634. var y = this._currentMeasure.top + offset;
  8635. var width = this._currentMeasure.width - offset * 2;
  8636. var height = this._currentMeasure.height - offset * 2;
  8637. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8638. context.beginPath();
  8639. context.moveTo(x + radius, y);
  8640. context.lineTo(x + width - radius, y);
  8641. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8642. context.lineTo(x + width, y + height - radius);
  8643. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8644. context.lineTo(x + radius, y + height);
  8645. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8646. context.lineTo(x, y + radius);
  8647. context.quadraticCurveTo(x, y, x + radius, y);
  8648. context.closePath();
  8649. };
  8650. Rectangle.prototype._clipForChildren = function (context) {
  8651. if (this._cornerRadius) {
  8652. this._drawRoundedRect(context, this._thickness);
  8653. context.clip();
  8654. }
  8655. };
  8656. return Rectangle;
  8657. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8658. /***/ }),
  8659. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8660. /*!***************************************************!*\
  8661. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8662. \***************************************************/
  8663. /*! exports provided: ScrollViewer */
  8664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8665. "use strict";
  8666. __webpack_require__.r(__webpack_exports__);
  8667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8668. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8669. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Maths/math");
  8670. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8671. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8672. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8673. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8674. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8675. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8676. /**
  8677. * Class used to hold a viewer window and sliders in a grid
  8678. */
  8679. var ScrollViewer = /** @class */ (function (_super) {
  8680. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8681. /**
  8682. * Creates a new ScrollViewer
  8683. * @param name of ScrollViewer
  8684. */
  8685. function ScrollViewer(name) {
  8686. var _this = _super.call(this, name) || this;
  8687. _this._barSize = 20;
  8688. _this._pointerIsOver = false;
  8689. _this._wheelPrecision = 0.05;
  8690. _this.onDirtyObservable.add(function () {
  8691. _this._horizontalBarSpace.color = _this.color;
  8692. _this._verticalBarSpace.color = _this.color;
  8693. _this._dragSpace.color = _this.color;
  8694. });
  8695. _this.onPointerEnterObservable.add(function () {
  8696. _this._pointerIsOver = true;
  8697. });
  8698. _this.onPointerOutObservable.add(function () {
  8699. _this._pointerIsOver = false;
  8700. });
  8701. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8702. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8703. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8704. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8705. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8706. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8707. _this._grid.addColumnDefinition(1);
  8708. _this._grid.addColumnDefinition(0, true);
  8709. _this._grid.addRowDefinition(1);
  8710. _this._grid.addRowDefinition(0, true);
  8711. _super.prototype.addControl.call(_this, _this._grid);
  8712. _this._grid.addControl(_this._window, 0, 0);
  8713. _this._verticalBar.paddingLeft = 0;
  8714. _this._verticalBar.width = "100%";
  8715. _this._verticalBar.height = "100%";
  8716. _this._verticalBar.barOffset = 0;
  8717. _this._verticalBar.value = 0;
  8718. _this._verticalBar.maximum = 1;
  8719. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8720. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8721. _this._verticalBar.isVertical = true;
  8722. _this._verticalBar.rotation = Math.PI;
  8723. _this._verticalBar.isVisible = false;
  8724. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8725. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8726. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8727. _this._verticalBarSpace.thickness = 1;
  8728. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8729. _this._verticalBarSpace.addControl(_this._verticalBar);
  8730. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8731. _this._window.top = value * _this._endTop + "px";
  8732. });
  8733. _this._horizontalBar.paddingLeft = 0;
  8734. _this._horizontalBar.width = "100%";
  8735. _this._horizontalBar.height = "100%";
  8736. _this._horizontalBar.barOffset = 0;
  8737. _this._horizontalBar.value = 0;
  8738. _this._horizontalBar.maximum = 1;
  8739. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8740. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8741. _this._horizontalBar.isVisible = false;
  8742. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8743. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8744. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8745. _this._horizontalBarSpace.thickness = 1;
  8746. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8747. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8748. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8749. _this._window.left = value * _this._endLeft + "px";
  8750. });
  8751. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8752. _this._dragSpace.thickness = 1;
  8753. _this._grid.addControl(_this._dragSpace, 1, 1);
  8754. // Colors
  8755. _this.barColor = "grey";
  8756. _this.barBackground = "transparent";
  8757. return _this;
  8758. }
  8759. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8760. /**
  8761. * Gets the horizontal scrollbar
  8762. */
  8763. get: function () {
  8764. return this._horizontalBar;
  8765. },
  8766. enumerable: true,
  8767. configurable: true
  8768. });
  8769. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8770. /**
  8771. * Gets the vertical scrollbar
  8772. */
  8773. get: function () {
  8774. return this._verticalBar;
  8775. },
  8776. enumerable: true,
  8777. configurable: true
  8778. });
  8779. /**
  8780. * Adds a new control to the current container
  8781. * @param control defines the control to add
  8782. * @returns the current container
  8783. */
  8784. ScrollViewer.prototype.addControl = function (control) {
  8785. if (!control) {
  8786. return this;
  8787. }
  8788. this._window.addControl(control);
  8789. return this;
  8790. };
  8791. /**
  8792. * Removes a control from the current container
  8793. * @param control defines the control to remove
  8794. * @returns the current container
  8795. */
  8796. ScrollViewer.prototype.removeControl = function (control) {
  8797. this._window.removeControl(control);
  8798. return this;
  8799. };
  8800. Object.defineProperty(ScrollViewer.prototype, "children", {
  8801. /** Gets the list of children */
  8802. get: function () {
  8803. return this._window.children;
  8804. },
  8805. enumerable: true,
  8806. configurable: true
  8807. });
  8808. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8809. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8810. var child = _a[_i];
  8811. child._markMatrixAsDirty();
  8812. }
  8813. };
  8814. /** Reset the scroll viewer window to initial size */
  8815. ScrollViewer.prototype.resetWindow = function () {
  8816. this._window.width = "100%";
  8817. this._window.height = "100%";
  8818. };
  8819. ScrollViewer.prototype._getTypeName = function () {
  8820. return "ScrollViewer";
  8821. };
  8822. ScrollViewer.prototype._buildClientSizes = function () {
  8823. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8824. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8825. this._clientWidth = this._window.parentClientWidth;
  8826. this._clientHeight = this._window.parentClientHeight;
  8827. };
  8828. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8829. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8830. this._buildClientSizes();
  8831. };
  8832. ScrollViewer.prototype._postMeasure = function () {
  8833. _super.prototype._postMeasure.call(this);
  8834. this._updateScroller();
  8835. };
  8836. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8837. /**
  8838. * Gets or sets the mouse wheel precision
  8839. * from 0 to 1 with a default value of 0.05
  8840. * */
  8841. get: function () {
  8842. return this._wheelPrecision;
  8843. },
  8844. set: function (value) {
  8845. if (this._wheelPrecision === value) {
  8846. return;
  8847. }
  8848. if (value < 0) {
  8849. value = 0;
  8850. }
  8851. if (value > 1) {
  8852. value = 1;
  8853. }
  8854. this._wheelPrecision = value;
  8855. },
  8856. enumerable: true,
  8857. configurable: true
  8858. });
  8859. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8860. /** Gets or sets the bar color */
  8861. get: function () {
  8862. return this._barColor;
  8863. },
  8864. set: function (color) {
  8865. if (this._barColor === color) {
  8866. return;
  8867. }
  8868. this._barColor = color;
  8869. this._horizontalBar.color = color;
  8870. this._verticalBar.color = color;
  8871. },
  8872. enumerable: true,
  8873. configurable: true
  8874. });
  8875. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8876. /** Gets or sets the size of the bar */
  8877. get: function () {
  8878. return this._barSize;
  8879. },
  8880. set: function (value) {
  8881. if (this._barSize === value) {
  8882. return;
  8883. }
  8884. this._barSize = value;
  8885. this._markAsDirty();
  8886. if (this._horizontalBar.isVisible) {
  8887. this._grid.setRowDefinition(1, this._barSize, true);
  8888. }
  8889. if (this._verticalBar.isVisible) {
  8890. this._grid.setColumnDefinition(1, this._barSize, true);
  8891. }
  8892. },
  8893. enumerable: true,
  8894. configurable: true
  8895. });
  8896. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8897. /** Gets or sets the bar background */
  8898. get: function () {
  8899. return this._barBackground;
  8900. },
  8901. set: function (color) {
  8902. if (this._barBackground === color) {
  8903. return;
  8904. }
  8905. this._barBackground = color;
  8906. this._horizontalBar.background = color;
  8907. this._verticalBar.background = color;
  8908. this._dragSpace.background = color;
  8909. },
  8910. enumerable: true,
  8911. configurable: true
  8912. });
  8913. /** @hidden */
  8914. ScrollViewer.prototype._updateScroller = function () {
  8915. var windowContentsWidth = this._window._currentMeasure.width;
  8916. var windowContentsHeight = this._window._currentMeasure.height;
  8917. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8918. this._grid.setRowDefinition(1, 0, true);
  8919. this._horizontalBar.isVisible = false;
  8920. this._horizontalBar.value = 0;
  8921. this._rebuildLayout = true;
  8922. }
  8923. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8924. this._grid.setRowDefinition(1, this._barSize, true);
  8925. this._horizontalBar.isVisible = true;
  8926. this._rebuildLayout = true;
  8927. }
  8928. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8929. this._grid.setColumnDefinition(1, 0, true);
  8930. this._verticalBar.isVisible = false;
  8931. this._verticalBar.value = 0;
  8932. this._rebuildLayout = true;
  8933. }
  8934. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8935. this._grid.setColumnDefinition(1, this._barSize, true);
  8936. this._verticalBar.isVisible = true;
  8937. this._rebuildLayout = true;
  8938. }
  8939. this._buildClientSizes();
  8940. this._endLeft = this._clientWidth - windowContentsWidth;
  8941. this._endTop = this._clientHeight - windowContentsHeight;
  8942. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8943. var newTop = this._verticalBar.value * this._endTop + "px";
  8944. if (newLeft !== this._window.left) {
  8945. this._window.left = newLeft;
  8946. this._rebuildLayout = true;
  8947. }
  8948. if (newTop !== this._window.top) {
  8949. this._window.top = newTop;
  8950. this._rebuildLayout = true;
  8951. }
  8952. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8953. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8954. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8955. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8956. };
  8957. ScrollViewer.prototype._link = function (host) {
  8958. _super.prototype._link.call(this, host);
  8959. this._attachWheel();
  8960. };
  8961. /** @hidden */
  8962. ScrollViewer.prototype._attachWheel = function () {
  8963. var _this = this;
  8964. if (!this._host || this._onPointerObserver) {
  8965. return;
  8966. }
  8967. var scene = this._host.getScene();
  8968. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8969. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8970. return;
  8971. }
  8972. if (_this._verticalBar.isVisible == true) {
  8973. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8974. _this._verticalBar.value -= _this._wheelPrecision;
  8975. }
  8976. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8977. _this._verticalBar.value += _this._wheelPrecision;
  8978. }
  8979. }
  8980. if (_this._horizontalBar.isVisible == true) {
  8981. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8982. _this._horizontalBar.value += _this._wheelPrecision;
  8983. }
  8984. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8985. _this._horizontalBar.value -= _this._wheelPrecision;
  8986. }
  8987. }
  8988. });
  8989. };
  8990. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8991. if (!this.isHighlighted) {
  8992. return;
  8993. }
  8994. _super.prototype._renderHighlightSpecific.call(this, context);
  8995. this._grid._renderHighlightSpecific(context);
  8996. context.restore();
  8997. };
  8998. /** Releases associated resources */
  8999. ScrollViewer.prototype.dispose = function () {
  9000. var scene = this._host.getScene();
  9001. if (scene && this._onPointerObserver) {
  9002. scene.onPointerObservable.remove(this._onPointerObserver);
  9003. this._onPointerObserver = null;
  9004. }
  9005. _super.prototype.dispose.call(this);
  9006. };
  9007. return ScrollViewer;
  9008. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9009. /***/ }),
  9010. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9011. /*!*********************************************************!*\
  9012. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9013. \*********************************************************/
  9014. /*! exports provided: _ScrollViewerWindow */
  9015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9016. "use strict";
  9017. __webpack_require__.r(__webpack_exports__);
  9018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9019. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9020. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9021. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9022. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9023. /**
  9024. * Class used to hold a the container for ScrollViewer
  9025. * @hidden
  9026. */
  9027. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9028. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  9029. /**
  9030. * Creates a new ScrollViewerWindow
  9031. * @param name of ScrollViewerWindow
  9032. */
  9033. function _ScrollViewerWindow(name) {
  9034. return _super.call(this, name) || this;
  9035. }
  9036. _ScrollViewerWindow.prototype._getTypeName = function () {
  9037. return "ScrollViewerWindow";
  9038. };
  9039. /** @hidden */
  9040. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9041. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9042. this._measureForChildren.left = this._currentMeasure.left;
  9043. this._measureForChildren.top = this._currentMeasure.top;
  9044. this._measureForChildren.width = parentMeasure.width;
  9045. this._measureForChildren.height = parentMeasure.height;
  9046. };
  9047. _ScrollViewerWindow.prototype._postMeasure = function () {
  9048. var maxWidth = this.parentClientWidth;
  9049. var maxHeight = this.parentClientHeight;
  9050. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9051. var child = _a[_i];
  9052. if (!child.isVisible || child.notRenderable) {
  9053. continue;
  9054. }
  9055. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9056. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9057. }
  9058. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9059. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9060. }
  9061. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9062. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9063. }
  9064. if (this._currentMeasure.width !== maxWidth) {
  9065. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9066. this._currentMeasure.width = maxWidth;
  9067. this._rebuildLayout = true;
  9068. this._isDirty = true;
  9069. }
  9070. if (this._currentMeasure.height !== maxHeight) {
  9071. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9072. this._currentMeasure.height = maxHeight;
  9073. this._rebuildLayout = true;
  9074. this._isDirty = true;
  9075. }
  9076. _super.prototype._postMeasure.call(this);
  9077. };
  9078. return _ScrollViewerWindow;
  9079. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9080. /***/ }),
  9081. /***/ "./2D/controls/selector.ts":
  9082. /*!*********************************!*\
  9083. !*** ./2D/controls/selector.ts ***!
  9084. \*********************************/
  9085. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9087. "use strict";
  9088. __webpack_require__.r(__webpack_exports__);
  9089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9094. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9095. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9096. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9097. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9098. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9099. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9100. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9101. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9102. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9103. /** Class used to create a RadioGroup
  9104. * which contains groups of radio buttons
  9105. */
  9106. var SelectorGroup = /** @class */ (function () {
  9107. /**
  9108. * Creates a new SelectorGroup
  9109. * @param name of group, used as a group heading
  9110. */
  9111. function SelectorGroup(
  9112. /** name of SelectorGroup */
  9113. name) {
  9114. this.name = name;
  9115. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9116. this._selectors = new Array();
  9117. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9118. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9119. this._groupHeader = this._addGroupHeader(name);
  9120. }
  9121. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9122. /** Gets the groupPanel of the SelectorGroup */
  9123. get: function () {
  9124. return this._groupPanel;
  9125. },
  9126. enumerable: true,
  9127. configurable: true
  9128. });
  9129. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9130. /** Gets the selectors array */
  9131. get: function () {
  9132. return this._selectors;
  9133. },
  9134. enumerable: true,
  9135. configurable: true
  9136. });
  9137. Object.defineProperty(SelectorGroup.prototype, "header", {
  9138. /** Gets and sets the group header */
  9139. get: function () {
  9140. return this._groupHeader.text;
  9141. },
  9142. set: function (label) {
  9143. if (this._groupHeader.text === "label") {
  9144. return;
  9145. }
  9146. this._groupHeader.text = label;
  9147. },
  9148. enumerable: true,
  9149. configurable: true
  9150. });
  9151. /** @hidden */
  9152. SelectorGroup.prototype._addGroupHeader = function (text) {
  9153. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9154. groupHeading.width = 0.9;
  9155. groupHeading.height = "30px";
  9156. groupHeading.textWrapping = true;
  9157. groupHeading.color = "black";
  9158. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9159. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9160. groupHeading.left = "2px";
  9161. this._groupPanel.addControl(groupHeading);
  9162. return groupHeading;
  9163. };
  9164. /** @hidden*/
  9165. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9166. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9167. return;
  9168. }
  9169. return this._selectors[selectorNb];
  9170. };
  9171. /** Removes the selector at the given position
  9172. * @param selectorNb the position of the selector within the group
  9173. */
  9174. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9175. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9176. return;
  9177. }
  9178. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9179. this._selectors.splice(selectorNb, 1);
  9180. };
  9181. return SelectorGroup;
  9182. }());
  9183. /** Class used to create a CheckboxGroup
  9184. * which contains groups of checkbox buttons
  9185. */
  9186. var CheckboxGroup = /** @class */ (function (_super) {
  9187. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9188. function CheckboxGroup() {
  9189. return _super !== null && _super.apply(this, arguments) || this;
  9190. }
  9191. /** Adds a checkbox as a control
  9192. * @param text is the label for the selector
  9193. * @param func is the function called when the Selector is checked
  9194. * @param checked is true when Selector is checked
  9195. */
  9196. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9197. if (func === void 0) { func = function (s) { }; }
  9198. if (checked === void 0) { checked = false; }
  9199. var checked = checked || false;
  9200. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9201. button.width = "20px";
  9202. button.height = "20px";
  9203. button.color = "#364249";
  9204. button.background = "#CCCCCC";
  9205. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9206. button.onIsCheckedChangedObservable.add(function (state) {
  9207. func(state);
  9208. });
  9209. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9210. _selector.height = "30px";
  9211. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9212. _selector.left = "4px";
  9213. this.groupPanel.addControl(_selector);
  9214. this.selectors.push(_selector);
  9215. button.isChecked = checked;
  9216. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9217. button.color = this.groupPanel.parent.parent.buttonColor;
  9218. button.background = this.groupPanel.parent.parent.buttonBackground;
  9219. }
  9220. };
  9221. /** @hidden */
  9222. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9223. this.selectors[selectorNb].children[1].text = label;
  9224. };
  9225. /** @hidden */
  9226. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9227. this.selectors[selectorNb].children[1].color = color;
  9228. };
  9229. /** @hidden */
  9230. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9231. this.selectors[selectorNb].children[0].color = color;
  9232. };
  9233. /** @hidden */
  9234. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9235. this.selectors[selectorNb].children[0].background = color;
  9236. };
  9237. return CheckboxGroup;
  9238. }(SelectorGroup));
  9239. /** Class used to create a RadioGroup
  9240. * which contains groups of radio buttons
  9241. */
  9242. var RadioGroup = /** @class */ (function (_super) {
  9243. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9244. function RadioGroup() {
  9245. var _this = _super !== null && _super.apply(this, arguments) || this;
  9246. _this._selectNb = 0;
  9247. return _this;
  9248. }
  9249. /** Adds a radio button as a control
  9250. * @param label is the label for the selector
  9251. * @param func is the function called when the Selector is checked
  9252. * @param checked is true when Selector is checked
  9253. */
  9254. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9255. if (func === void 0) { func = function (n) { }; }
  9256. if (checked === void 0) { checked = false; }
  9257. var nb = this._selectNb++;
  9258. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9259. button.name = label;
  9260. button.width = "20px";
  9261. button.height = "20px";
  9262. button.color = "#364249";
  9263. button.background = "#CCCCCC";
  9264. button.group = this.name;
  9265. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9266. button.onIsCheckedChangedObservable.add(function (state) {
  9267. if (state) {
  9268. func(nb);
  9269. }
  9270. });
  9271. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9272. _selector.height = "30px";
  9273. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9274. _selector.left = "4px";
  9275. this.groupPanel.addControl(_selector);
  9276. this.selectors.push(_selector);
  9277. button.isChecked = checked;
  9278. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9279. button.color = this.groupPanel.parent.parent.buttonColor;
  9280. button.background = this.groupPanel.parent.parent.buttonBackground;
  9281. }
  9282. };
  9283. /** @hidden */
  9284. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9285. this.selectors[selectorNb].children[1].text = label;
  9286. };
  9287. /** @hidden */
  9288. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9289. this.selectors[selectorNb].children[1].color = color;
  9290. };
  9291. /** @hidden */
  9292. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9293. this.selectors[selectorNb].children[0].color = color;
  9294. };
  9295. /** @hidden */
  9296. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9297. this.selectors[selectorNb].children[0].background = color;
  9298. };
  9299. return RadioGroup;
  9300. }(SelectorGroup));
  9301. /** Class used to create a SliderGroup
  9302. * which contains groups of slider buttons
  9303. */
  9304. var SliderGroup = /** @class */ (function (_super) {
  9305. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9306. function SliderGroup() {
  9307. return _super !== null && _super.apply(this, arguments) || this;
  9308. }
  9309. /**
  9310. * Adds a slider to the SelectorGroup
  9311. * @param label is the label for the SliderBar
  9312. * @param func is the function called when the Slider moves
  9313. * @param unit is a string describing the units used, eg degrees or metres
  9314. * @param min is the minimum value for the Slider
  9315. * @param max is the maximum value for the Slider
  9316. * @param value is the start value for the Slider between min and max
  9317. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9318. */
  9319. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9320. if (func === void 0) { func = function (v) { }; }
  9321. if (unit === void 0) { unit = "Units"; }
  9322. if (min === void 0) { min = 0; }
  9323. if (max === void 0) { max = 0; }
  9324. if (value === void 0) { value = 0; }
  9325. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9326. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9327. button.name = unit;
  9328. button.value = value;
  9329. button.minimum = min;
  9330. button.maximum = max;
  9331. button.width = 0.9;
  9332. button.height = "20px";
  9333. button.color = "#364249";
  9334. button.background = "#CCCCCC";
  9335. button.borderColor = "black";
  9336. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9337. button.left = "4px";
  9338. button.paddingBottom = "4px";
  9339. button.onValueChangedObservable.add(function (value) {
  9340. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9341. func(value);
  9342. });
  9343. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9344. _selector.height = "60px";
  9345. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9346. _selector.left = "4px";
  9347. _selector.children[0].name = label;
  9348. this.groupPanel.addControl(_selector);
  9349. this.selectors.push(_selector);
  9350. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9351. button.color = this.groupPanel.parent.parent.buttonColor;
  9352. button.background = this.groupPanel.parent.parent.buttonBackground;
  9353. }
  9354. };
  9355. /** @hidden */
  9356. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9357. this.selectors[selectorNb].children[0].name = label;
  9358. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9359. };
  9360. /** @hidden */
  9361. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9362. this.selectors[selectorNb].children[0].color = color;
  9363. };
  9364. /** @hidden */
  9365. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9366. this.selectors[selectorNb].children[1].color = color;
  9367. };
  9368. /** @hidden */
  9369. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9370. this.selectors[selectorNb].children[1].background = color;
  9371. };
  9372. return SliderGroup;
  9373. }(SelectorGroup));
  9374. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9375. * @see http://doc.babylonjs.com/how_to/selector
  9376. */
  9377. var SelectionPanel = /** @class */ (function (_super) {
  9378. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9379. /**
  9380. * Creates a new SelectionPanel
  9381. * @param name of SelectionPanel
  9382. * @param groups is an array of SelectionGroups
  9383. */
  9384. function SelectionPanel(
  9385. /** name of SelectionPanel */
  9386. name,
  9387. /** an array of SelectionGroups */
  9388. groups) {
  9389. if (groups === void 0) { groups = []; }
  9390. var _this = _super.call(this, name) || this;
  9391. _this.name = name;
  9392. _this.groups = groups;
  9393. _this._buttonColor = "#364249";
  9394. _this._buttonBackground = "#CCCCCC";
  9395. _this._headerColor = "black";
  9396. _this._barColor = "white";
  9397. _this._barHeight = "2px";
  9398. _this._spacerHeight = "20px";
  9399. _this._bars = new Array();
  9400. _this._groups = groups;
  9401. _this.thickness = 2;
  9402. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9403. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9404. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9405. _this._panel.top = 5;
  9406. _this._panel.left = 5;
  9407. _this._panel.width = 0.95;
  9408. if (groups.length > 0) {
  9409. for (var i = 0; i < groups.length - 1; i++) {
  9410. _this._panel.addControl(groups[i].groupPanel);
  9411. _this._addSpacer();
  9412. }
  9413. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9414. }
  9415. _this.addControl(_this._panel);
  9416. return _this;
  9417. }
  9418. SelectionPanel.prototype._getTypeName = function () {
  9419. return "SelectionPanel";
  9420. };
  9421. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9422. /** Gets or sets the headerColor */
  9423. get: function () {
  9424. return this._headerColor;
  9425. },
  9426. set: function (color) {
  9427. if (this._headerColor === color) {
  9428. return;
  9429. }
  9430. this._headerColor = color;
  9431. this._setHeaderColor();
  9432. },
  9433. enumerable: true,
  9434. configurable: true
  9435. });
  9436. SelectionPanel.prototype._setHeaderColor = function () {
  9437. for (var i = 0; i < this._groups.length; i++) {
  9438. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9439. }
  9440. };
  9441. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9442. /** Gets or sets the button color */
  9443. get: function () {
  9444. return this._buttonColor;
  9445. },
  9446. set: function (color) {
  9447. if (this._buttonColor === color) {
  9448. return;
  9449. }
  9450. this._buttonColor = color;
  9451. this._setbuttonColor();
  9452. },
  9453. enumerable: true,
  9454. configurable: true
  9455. });
  9456. SelectionPanel.prototype._setbuttonColor = function () {
  9457. for (var i = 0; i < this._groups.length; i++) {
  9458. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9459. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9460. }
  9461. }
  9462. };
  9463. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9464. /** Gets or sets the label color */
  9465. get: function () {
  9466. return this._labelColor;
  9467. },
  9468. set: function (color) {
  9469. if (this._labelColor === color) {
  9470. return;
  9471. }
  9472. this._labelColor = color;
  9473. this._setLabelColor();
  9474. },
  9475. enumerable: true,
  9476. configurable: true
  9477. });
  9478. SelectionPanel.prototype._setLabelColor = function () {
  9479. for (var i = 0; i < this._groups.length; i++) {
  9480. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9481. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9482. }
  9483. }
  9484. };
  9485. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9486. /** Gets or sets the button background */
  9487. get: function () {
  9488. return this._buttonBackground;
  9489. },
  9490. set: function (color) {
  9491. if (this._buttonBackground === color) {
  9492. return;
  9493. }
  9494. this._buttonBackground = color;
  9495. this._setButtonBackground();
  9496. },
  9497. enumerable: true,
  9498. configurable: true
  9499. });
  9500. SelectionPanel.prototype._setButtonBackground = function () {
  9501. for (var i = 0; i < this._groups.length; i++) {
  9502. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9503. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9504. }
  9505. }
  9506. };
  9507. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9508. /** Gets or sets the color of separator bar */
  9509. get: function () {
  9510. return this._barColor;
  9511. },
  9512. set: function (color) {
  9513. if (this._barColor === color) {
  9514. return;
  9515. }
  9516. this._barColor = color;
  9517. this._setBarColor();
  9518. },
  9519. enumerable: true,
  9520. configurable: true
  9521. });
  9522. SelectionPanel.prototype._setBarColor = function () {
  9523. for (var i = 0; i < this._bars.length; i++) {
  9524. this._bars[i].children[0].background = this._barColor;
  9525. }
  9526. };
  9527. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9528. /** Gets or sets the height of separator bar */
  9529. get: function () {
  9530. return this._barHeight;
  9531. },
  9532. set: function (value) {
  9533. if (this._barHeight === value) {
  9534. return;
  9535. }
  9536. this._barHeight = value;
  9537. this._setBarHeight();
  9538. },
  9539. enumerable: true,
  9540. configurable: true
  9541. });
  9542. SelectionPanel.prototype._setBarHeight = function () {
  9543. for (var i = 0; i < this._bars.length; i++) {
  9544. this._bars[i].children[0].height = this._barHeight;
  9545. }
  9546. };
  9547. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9548. /** Gets or sets the height of spacers*/
  9549. get: function () {
  9550. return this._spacerHeight;
  9551. },
  9552. set: function (value) {
  9553. if (this._spacerHeight === value) {
  9554. return;
  9555. }
  9556. this._spacerHeight = value;
  9557. this._setSpacerHeight();
  9558. },
  9559. enumerable: true,
  9560. configurable: true
  9561. });
  9562. SelectionPanel.prototype._setSpacerHeight = function () {
  9563. for (var i = 0; i < this._bars.length; i++) {
  9564. this._bars[i].height = this._spacerHeight;
  9565. }
  9566. };
  9567. /** Adds a bar between groups */
  9568. SelectionPanel.prototype._addSpacer = function () {
  9569. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9570. separator.width = 1;
  9571. separator.height = this._spacerHeight;
  9572. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9573. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9574. bar.width = 1;
  9575. bar.height = this._barHeight;
  9576. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9577. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9578. bar.background = this._barColor;
  9579. bar.color = "transparent";
  9580. separator.addControl(bar);
  9581. this._panel.addControl(separator);
  9582. this._bars.push(separator);
  9583. };
  9584. /** Add a group to the selection panel
  9585. * @param group is the selector group to add
  9586. */
  9587. SelectionPanel.prototype.addGroup = function (group) {
  9588. if (this._groups.length > 0) {
  9589. this._addSpacer();
  9590. }
  9591. this._panel.addControl(group.groupPanel);
  9592. this._groups.push(group);
  9593. group.groupPanel.children[0].color = this._headerColor;
  9594. for (var j = 0; j < group.selectors.length; j++) {
  9595. group._setSelectorButtonColor(j, this._buttonColor);
  9596. group._setSelectorButtonBackground(j, this._buttonBackground);
  9597. }
  9598. };
  9599. /** Remove the group from the given position
  9600. * @param groupNb is the position of the group in the list
  9601. */
  9602. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9603. if (groupNb < 0 || groupNb >= this._groups.length) {
  9604. return;
  9605. }
  9606. var group = this._groups[groupNb];
  9607. this._panel.removeControl(group.groupPanel);
  9608. this._groups.splice(groupNb, 1);
  9609. if (groupNb < this._bars.length) {
  9610. this._panel.removeControl(this._bars[groupNb]);
  9611. this._bars.splice(groupNb, 1);
  9612. }
  9613. };
  9614. /** Change a group header label
  9615. * @param label is the new group header label
  9616. * @param groupNb is the number of the group to relabel
  9617. * */
  9618. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9619. if (groupNb < 0 || groupNb >= this._groups.length) {
  9620. return;
  9621. }
  9622. var group = this._groups[groupNb];
  9623. group.groupPanel.children[0].text = label;
  9624. };
  9625. /** Change selector label to the one given
  9626. * @param label is the new selector label
  9627. * @param groupNb is the number of the groupcontaining the selector
  9628. * @param selectorNb is the number of the selector within a group to relabel
  9629. * */
  9630. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9631. if (groupNb < 0 || groupNb >= this._groups.length) {
  9632. return;
  9633. }
  9634. var group = this._groups[groupNb];
  9635. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9636. return;
  9637. }
  9638. group._setSelectorLabel(selectorNb, label);
  9639. };
  9640. /** For a given group position remove the selector at the given position
  9641. * @param groupNb is the number of the group to remove the selector from
  9642. * @param selectorNb is the number of the selector within the group
  9643. */
  9644. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9645. if (groupNb < 0 || groupNb >= this._groups.length) {
  9646. return;
  9647. }
  9648. var group = this._groups[groupNb];
  9649. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9650. return;
  9651. }
  9652. group.removeSelector(selectorNb);
  9653. };
  9654. /** For a given group position of correct type add a checkbox button
  9655. * @param groupNb is the number of the group to remove the selector from
  9656. * @param label is the label for the selector
  9657. * @param func is the function called when the Selector is checked
  9658. * @param checked is true when Selector is checked
  9659. */
  9660. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9661. if (func === void 0) { func = function () { }; }
  9662. if (checked === void 0) { checked = false; }
  9663. if (groupNb < 0 || groupNb >= this._groups.length) {
  9664. return;
  9665. }
  9666. var group = this._groups[groupNb];
  9667. group.addCheckbox(label, func, checked);
  9668. };
  9669. /** For a given group position of correct type add a radio button
  9670. * @param groupNb is the number of the group to remove the selector from
  9671. * @param label is the label for the selector
  9672. * @param func is the function called when the Selector is checked
  9673. * @param checked is true when Selector is checked
  9674. */
  9675. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9676. if (func === void 0) { func = function () { }; }
  9677. if (checked === void 0) { checked = false; }
  9678. if (groupNb < 0 || groupNb >= this._groups.length) {
  9679. return;
  9680. }
  9681. var group = this._groups[groupNb];
  9682. group.addRadio(label, func, checked);
  9683. };
  9684. /**
  9685. * For a given slider group add a slider
  9686. * @param groupNb is the number of the group to add the slider to
  9687. * @param label is the label for the Slider
  9688. * @param func is the function called when the Slider moves
  9689. * @param unit is a string describing the units used, eg degrees or metres
  9690. * @param min is the minimum value for the Slider
  9691. * @param max is the maximum value for the Slider
  9692. * @param value is the start value for the Slider between min and max
  9693. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9694. */
  9695. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9696. if (func === void 0) { func = function () { }; }
  9697. if (unit === void 0) { unit = "Units"; }
  9698. if (min === void 0) { min = 0; }
  9699. if (max === void 0) { max = 0; }
  9700. if (value === void 0) { value = 0; }
  9701. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9702. if (groupNb < 0 || groupNb >= this._groups.length) {
  9703. return;
  9704. }
  9705. var group = this._groups[groupNb];
  9706. group.addSlider(label, func, unit, min, max, value, onVal);
  9707. };
  9708. return SelectionPanel;
  9709. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9710. /***/ }),
  9711. /***/ "./2D/controls/sliders/baseSlider.ts":
  9712. /*!*******************************************!*\
  9713. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9714. \*******************************************/
  9715. /*! exports provided: BaseSlider */
  9716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9717. "use strict";
  9718. __webpack_require__.r(__webpack_exports__);
  9719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9720. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9721. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  9722. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9723. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9724. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9725. /**
  9726. * Class used to create slider controls
  9727. */
  9728. var BaseSlider = /** @class */ (function (_super) {
  9729. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9730. /**
  9731. * Creates a new BaseSlider
  9732. * @param name defines the control name
  9733. */
  9734. function BaseSlider(name) {
  9735. var _this = _super.call(this, name) || this;
  9736. _this.name = name;
  9737. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9738. _this._minimum = 0;
  9739. _this._maximum = 100;
  9740. _this._value = 50;
  9741. _this._isVertical = false;
  9742. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9743. _this._isThumbClamped = false;
  9744. _this._displayThumb = true;
  9745. _this._step = 0;
  9746. _this._lastPointerDownID = -1;
  9747. // Shared rendering info
  9748. _this._effectiveBarOffset = 0;
  9749. /** Observable raised when the sldier value changes */
  9750. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9751. // Events
  9752. _this._pointerIsDown = false;
  9753. _this.isPointerBlocker = true;
  9754. return _this;
  9755. }
  9756. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9757. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9758. get: function () {
  9759. return this._displayThumb;
  9760. },
  9761. set: function (value) {
  9762. if (this._displayThumb === value) {
  9763. return;
  9764. }
  9765. this._displayThumb = value;
  9766. this._markAsDirty();
  9767. },
  9768. enumerable: true,
  9769. configurable: true
  9770. });
  9771. Object.defineProperty(BaseSlider.prototype, "step", {
  9772. /** Gets or sets a step to apply to values (0 by default) */
  9773. get: function () {
  9774. return this._step;
  9775. },
  9776. set: function (value) {
  9777. if (this._step === value) {
  9778. return;
  9779. }
  9780. this._step = value;
  9781. this._markAsDirty();
  9782. },
  9783. enumerable: true,
  9784. configurable: true
  9785. });
  9786. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9787. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9788. get: function () {
  9789. return this._barOffset.toString(this._host);
  9790. },
  9791. set: function (value) {
  9792. if (this._barOffset.toString(this._host) === value) {
  9793. return;
  9794. }
  9795. if (this._barOffset.fromString(value)) {
  9796. this._markAsDirty();
  9797. }
  9798. },
  9799. enumerable: true,
  9800. configurable: true
  9801. });
  9802. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9803. /** Gets main bar offset in pixels*/
  9804. get: function () {
  9805. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9806. },
  9807. enumerable: true,
  9808. configurable: true
  9809. });
  9810. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9811. /** Gets or sets thumb width */
  9812. get: function () {
  9813. return this._thumbWidth.toString(this._host);
  9814. },
  9815. set: function (value) {
  9816. if (this._thumbWidth.toString(this._host) === value) {
  9817. return;
  9818. }
  9819. if (this._thumbWidth.fromString(value)) {
  9820. this._markAsDirty();
  9821. }
  9822. },
  9823. enumerable: true,
  9824. configurable: true
  9825. });
  9826. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9827. /** Gets thumb width in pixels */
  9828. get: function () {
  9829. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9830. },
  9831. enumerable: true,
  9832. configurable: true
  9833. });
  9834. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9835. /** Gets or sets minimum value */
  9836. get: function () {
  9837. return this._minimum;
  9838. },
  9839. set: function (value) {
  9840. if (this._minimum === value) {
  9841. return;
  9842. }
  9843. this._minimum = value;
  9844. this._markAsDirty();
  9845. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9846. },
  9847. enumerable: true,
  9848. configurable: true
  9849. });
  9850. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9851. /** Gets or sets maximum value */
  9852. get: function () {
  9853. return this._maximum;
  9854. },
  9855. set: function (value) {
  9856. if (this._maximum === value) {
  9857. return;
  9858. }
  9859. this._maximum = value;
  9860. this._markAsDirty();
  9861. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9862. },
  9863. enumerable: true,
  9864. configurable: true
  9865. });
  9866. Object.defineProperty(BaseSlider.prototype, "value", {
  9867. /** Gets or sets current value */
  9868. get: function () {
  9869. return this._value;
  9870. },
  9871. set: function (value) {
  9872. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9873. if (this._value === value) {
  9874. return;
  9875. }
  9876. this._value = value;
  9877. this._markAsDirty();
  9878. this.onValueChangedObservable.notifyObservers(this._value);
  9879. },
  9880. enumerable: true,
  9881. configurable: true
  9882. });
  9883. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9884. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9885. get: function () {
  9886. return this._isVertical;
  9887. },
  9888. set: function (value) {
  9889. if (this._isVertical === value) {
  9890. return;
  9891. }
  9892. this._isVertical = value;
  9893. this._markAsDirty();
  9894. },
  9895. enumerable: true,
  9896. configurable: true
  9897. });
  9898. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9899. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9900. get: function () {
  9901. return this._isThumbClamped;
  9902. },
  9903. set: function (value) {
  9904. if (this._isThumbClamped === value) {
  9905. return;
  9906. }
  9907. this._isThumbClamped = value;
  9908. this._markAsDirty();
  9909. },
  9910. enumerable: true,
  9911. configurable: true
  9912. });
  9913. BaseSlider.prototype._getTypeName = function () {
  9914. return "BaseSlider";
  9915. };
  9916. BaseSlider.prototype._getThumbPosition = function () {
  9917. if (this.isVertical) {
  9918. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9919. }
  9920. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9921. };
  9922. BaseSlider.prototype._getThumbThickness = function (type) {
  9923. var thumbThickness = 0;
  9924. switch (type) {
  9925. case "circle":
  9926. if (this._thumbWidth.isPixel) {
  9927. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9928. }
  9929. else {
  9930. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9931. }
  9932. break;
  9933. case "rectangle":
  9934. if (this._thumbWidth.isPixel) {
  9935. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9936. }
  9937. else {
  9938. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9939. }
  9940. }
  9941. return thumbThickness;
  9942. };
  9943. BaseSlider.prototype._prepareRenderingData = function (type) {
  9944. // Main bar
  9945. this._effectiveBarOffset = 0;
  9946. this._renderLeft = this._currentMeasure.left;
  9947. this._renderTop = this._currentMeasure.top;
  9948. this._renderWidth = this._currentMeasure.width;
  9949. this._renderHeight = this._currentMeasure.height;
  9950. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9951. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9952. this._effectiveThumbThickness = this._getThumbThickness(type);
  9953. if (this.displayThumb) {
  9954. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9955. }
  9956. //throw error when height is less than width for vertical slider
  9957. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9958. console.error("Height should be greater than width");
  9959. return;
  9960. }
  9961. if (this._barOffset.isPixel) {
  9962. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9963. }
  9964. else {
  9965. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9966. }
  9967. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9968. if (this.isVertical) {
  9969. this._renderLeft += this._effectiveBarOffset;
  9970. if (!this.isThumbClamped && this.displayThumb) {
  9971. this._renderTop += (this._effectiveThumbThickness / 2);
  9972. }
  9973. this._renderHeight = this._backgroundBoxLength;
  9974. this._renderWidth = this._backgroundBoxThickness;
  9975. }
  9976. else {
  9977. this._renderTop += this._effectiveBarOffset;
  9978. if (!this.isThumbClamped && this.displayThumb) {
  9979. this._renderLeft += (this._effectiveThumbThickness / 2);
  9980. }
  9981. this._renderHeight = this._backgroundBoxThickness;
  9982. this._renderWidth = this._backgroundBoxLength;
  9983. }
  9984. };
  9985. /** @hidden */
  9986. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9987. if (this.rotation != 0) {
  9988. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9989. x = this._transformedPosition.x;
  9990. y = this._transformedPosition.y;
  9991. }
  9992. var value;
  9993. if (this._isVertical) {
  9994. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9995. }
  9996. else {
  9997. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9998. }
  9999. var mult = (1 / this._step) | 0;
  10000. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10001. };
  10002. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10003. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10004. return false;
  10005. }
  10006. this._pointerIsDown = true;
  10007. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10008. this._host._capturingControl[pointerId] = this;
  10009. this._lastPointerDownID = pointerId;
  10010. return true;
  10011. };
  10012. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10013. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10014. if (pointerId != this._lastPointerDownID) {
  10015. return;
  10016. }
  10017. if (this._pointerIsDown) {
  10018. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10019. }
  10020. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10021. };
  10022. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10023. this._pointerIsDown = false;
  10024. delete this._host._capturingControl[pointerId];
  10025. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10026. };
  10027. return BaseSlider;
  10028. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10029. /***/ }),
  10030. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10031. /*!*************************************************!*\
  10032. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10033. \*************************************************/
  10034. /*! exports provided: ImageBasedSlider */
  10035. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10036. "use strict";
  10037. __webpack_require__.r(__webpack_exports__);
  10038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10040. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10041. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10042. /**
  10043. * Class used to create slider controls based on images
  10044. */
  10045. var ImageBasedSlider = /** @class */ (function (_super) {
  10046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  10047. /**
  10048. * Creates a new ImageBasedSlider
  10049. * @param name defines the control name
  10050. */
  10051. function ImageBasedSlider(name) {
  10052. var _this = _super.call(this, name) || this;
  10053. _this.name = name;
  10054. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10055. return _this;
  10056. }
  10057. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10058. get: function () {
  10059. return this._displayThumb && this.thumbImage != null;
  10060. },
  10061. set: function (value) {
  10062. if (this._displayThumb === value) {
  10063. return;
  10064. }
  10065. this._displayThumb = value;
  10066. this._markAsDirty();
  10067. },
  10068. enumerable: true,
  10069. configurable: true
  10070. });
  10071. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10072. /**
  10073. * Gets or sets the image used to render the background
  10074. */
  10075. get: function () {
  10076. return this._backgroundImage;
  10077. },
  10078. set: function (value) {
  10079. var _this = this;
  10080. if (this._backgroundImage === value) {
  10081. return;
  10082. }
  10083. this._backgroundImage = value;
  10084. if (value && !value.isLoaded) {
  10085. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10086. }
  10087. this._markAsDirty();
  10088. },
  10089. enumerable: true,
  10090. configurable: true
  10091. });
  10092. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10093. /**
  10094. * Gets or sets the image used to render the value bar
  10095. */
  10096. get: function () {
  10097. return this._valueBarImage;
  10098. },
  10099. set: function (value) {
  10100. var _this = this;
  10101. if (this._valueBarImage === value) {
  10102. return;
  10103. }
  10104. this._valueBarImage = value;
  10105. if (value && !value.isLoaded) {
  10106. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10107. }
  10108. this._markAsDirty();
  10109. },
  10110. enumerable: true,
  10111. configurable: true
  10112. });
  10113. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10114. /**
  10115. * Gets or sets the image used to render the thumb
  10116. */
  10117. get: function () {
  10118. return this._thumbImage;
  10119. },
  10120. set: function (value) {
  10121. var _this = this;
  10122. if (this._thumbImage === value) {
  10123. return;
  10124. }
  10125. this._thumbImage = value;
  10126. if (value && !value.isLoaded) {
  10127. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10128. }
  10129. this._markAsDirty();
  10130. },
  10131. enumerable: true,
  10132. configurable: true
  10133. });
  10134. ImageBasedSlider.prototype._getTypeName = function () {
  10135. return "ImageBasedSlider";
  10136. };
  10137. ImageBasedSlider.prototype._draw = function (context) {
  10138. context.save();
  10139. this._applyStates(context);
  10140. this._prepareRenderingData("rectangle");
  10141. var thumbPosition = this._getThumbPosition();
  10142. var left = this._renderLeft;
  10143. var top = this._renderTop;
  10144. var width = this._renderWidth;
  10145. var height = this._renderHeight;
  10146. // Background
  10147. if (this._backgroundImage) {
  10148. this._tempMeasure.copyFromFloats(left, top, width, height);
  10149. if (this.isThumbClamped && this.displayThumb) {
  10150. if (this.isVertical) {
  10151. this._tempMeasure.height += this._effectiveThumbThickness;
  10152. }
  10153. else {
  10154. this._tempMeasure.width += this._effectiveThumbThickness;
  10155. }
  10156. }
  10157. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10158. this._backgroundImage._draw(context);
  10159. }
  10160. // Bar
  10161. if (this._valueBarImage) {
  10162. if (this.isVertical) {
  10163. if (this.isThumbClamped && this.displayThumb) {
  10164. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10165. }
  10166. else {
  10167. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10168. }
  10169. }
  10170. else {
  10171. if (this.isThumbClamped && this.displayThumb) {
  10172. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10173. }
  10174. else {
  10175. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10176. }
  10177. }
  10178. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10179. this._valueBarImage._draw(context);
  10180. }
  10181. // Thumb
  10182. if (this.displayThumb) {
  10183. if (this.isVertical) {
  10184. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10185. }
  10186. else {
  10187. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10188. }
  10189. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10190. this._thumbImage._draw(context);
  10191. }
  10192. context.restore();
  10193. };
  10194. return ImageBasedSlider;
  10195. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10196. /***/ }),
  10197. /***/ "./2D/controls/sliders/scrollBar.ts":
  10198. /*!******************************************!*\
  10199. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10200. \******************************************/
  10201. /*! exports provided: ScrollBar */
  10202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10203. "use strict";
  10204. __webpack_require__.r(__webpack_exports__);
  10205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10206. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10207. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10208. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10209. /**
  10210. * Class used to create slider controls
  10211. */
  10212. var ScrollBar = /** @class */ (function (_super) {
  10213. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10214. /**
  10215. * Creates a new Slider
  10216. * @param name defines the control name
  10217. */
  10218. function ScrollBar(name) {
  10219. var _this = _super.call(this, name) || this;
  10220. _this.name = name;
  10221. _this._background = "black";
  10222. _this._borderColor = "white";
  10223. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10224. return _this;
  10225. }
  10226. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10227. /** Gets or sets border color */
  10228. get: function () {
  10229. return this._borderColor;
  10230. },
  10231. set: function (value) {
  10232. if (this._borderColor === value) {
  10233. return;
  10234. }
  10235. this._borderColor = value;
  10236. this._markAsDirty();
  10237. },
  10238. enumerable: true,
  10239. configurable: true
  10240. });
  10241. Object.defineProperty(ScrollBar.prototype, "background", {
  10242. /** Gets or sets background color */
  10243. get: function () {
  10244. return this._background;
  10245. },
  10246. set: function (value) {
  10247. if (this._background === value) {
  10248. return;
  10249. }
  10250. this._background = value;
  10251. this._markAsDirty();
  10252. },
  10253. enumerable: true,
  10254. configurable: true
  10255. });
  10256. ScrollBar.prototype._getTypeName = function () {
  10257. return "Scrollbar";
  10258. };
  10259. ScrollBar.prototype._getThumbThickness = function () {
  10260. var thumbThickness = 0;
  10261. if (this._thumbWidth.isPixel) {
  10262. thumbThickness = this._thumbWidth.getValue(this._host);
  10263. }
  10264. else {
  10265. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10266. }
  10267. return thumbThickness;
  10268. };
  10269. ScrollBar.prototype._draw = function (context) {
  10270. context.save();
  10271. this._applyStates(context);
  10272. this._prepareRenderingData("rectangle");
  10273. var left = this._renderLeft;
  10274. var thumbPosition = this._getThumbPosition();
  10275. context.fillStyle = this._background;
  10276. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10277. // Value bar
  10278. context.fillStyle = this.color;
  10279. // Thumb
  10280. if (this.isVertical) {
  10281. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10282. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10283. this._thumbMeasure.width = this._currentMeasure.width;
  10284. this._thumbMeasure.height = this._effectiveThumbThickness;
  10285. }
  10286. else {
  10287. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10288. this._thumbMeasure.top = this._currentMeasure.top;
  10289. this._thumbMeasure.width = this._effectiveThumbThickness;
  10290. this._thumbMeasure.height = this._currentMeasure.height;
  10291. }
  10292. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10293. context.restore();
  10294. };
  10295. /** @hidden */
  10296. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10297. if (this.rotation != 0) {
  10298. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10299. x = this._transformedPosition.x;
  10300. y = this._transformedPosition.y;
  10301. }
  10302. if (this._first) {
  10303. this._first = false;
  10304. this._originX = x;
  10305. this._originY = y;
  10306. // Check if move is required
  10307. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10308. if (this.isVertical) {
  10309. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10310. }
  10311. else {
  10312. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10313. }
  10314. }
  10315. }
  10316. // Delta mode
  10317. var delta = 0;
  10318. if (this.isVertical) {
  10319. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10320. }
  10321. else {
  10322. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10323. }
  10324. this.value += delta * (this.maximum - this.minimum);
  10325. this._originX = x;
  10326. this._originY = y;
  10327. };
  10328. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10329. this._first = true;
  10330. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10331. };
  10332. return ScrollBar;
  10333. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10334. /***/ }),
  10335. /***/ "./2D/controls/sliders/slider.ts":
  10336. /*!***************************************!*\
  10337. !*** ./2D/controls/sliders/slider.ts ***!
  10338. \***************************************/
  10339. /*! exports provided: Slider */
  10340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10341. "use strict";
  10342. __webpack_require__.r(__webpack_exports__);
  10343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10344. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10345. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10346. /**
  10347. * Class used to create slider controls
  10348. */
  10349. var Slider = /** @class */ (function (_super) {
  10350. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10351. /**
  10352. * Creates a new Slider
  10353. * @param name defines the control name
  10354. */
  10355. function Slider(name) {
  10356. var _this = _super.call(this, name) || this;
  10357. _this.name = name;
  10358. _this._background = "black";
  10359. _this._borderColor = "white";
  10360. _this._isThumbCircle = false;
  10361. _this._displayValueBar = true;
  10362. return _this;
  10363. }
  10364. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10365. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10366. get: function () {
  10367. return this._displayValueBar;
  10368. },
  10369. set: function (value) {
  10370. if (this._displayValueBar === value) {
  10371. return;
  10372. }
  10373. this._displayValueBar = value;
  10374. this._markAsDirty();
  10375. },
  10376. enumerable: true,
  10377. configurable: true
  10378. });
  10379. Object.defineProperty(Slider.prototype, "borderColor", {
  10380. /** Gets or sets border color */
  10381. get: function () {
  10382. return this._borderColor;
  10383. },
  10384. set: function (value) {
  10385. if (this._borderColor === value) {
  10386. return;
  10387. }
  10388. this._borderColor = value;
  10389. this._markAsDirty();
  10390. },
  10391. enumerable: true,
  10392. configurable: true
  10393. });
  10394. Object.defineProperty(Slider.prototype, "background", {
  10395. /** Gets or sets background color */
  10396. get: function () {
  10397. return this._background;
  10398. },
  10399. set: function (value) {
  10400. if (this._background === value) {
  10401. return;
  10402. }
  10403. this._background = value;
  10404. this._markAsDirty();
  10405. },
  10406. enumerable: true,
  10407. configurable: true
  10408. });
  10409. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10410. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10411. get: function () {
  10412. return this._isThumbCircle;
  10413. },
  10414. set: function (value) {
  10415. if (this._isThumbCircle === value) {
  10416. return;
  10417. }
  10418. this._isThumbCircle = value;
  10419. this._markAsDirty();
  10420. },
  10421. enumerable: true,
  10422. configurable: true
  10423. });
  10424. Slider.prototype._getTypeName = function () {
  10425. return "Slider";
  10426. };
  10427. Slider.prototype._draw = function (context) {
  10428. context.save();
  10429. this._applyStates(context);
  10430. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10431. var left = this._renderLeft;
  10432. var top = this._renderTop;
  10433. var width = this._renderWidth;
  10434. var height = this._renderHeight;
  10435. var radius = 0;
  10436. if (this.isThumbClamped && this.isThumbCircle) {
  10437. if (this.isVertical) {
  10438. top += (this._effectiveThumbThickness / 2);
  10439. }
  10440. else {
  10441. left += (this._effectiveThumbThickness / 2);
  10442. }
  10443. radius = this._backgroundBoxThickness / 2;
  10444. }
  10445. else {
  10446. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10447. }
  10448. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10449. context.shadowColor = this.shadowColor;
  10450. context.shadowBlur = this.shadowBlur;
  10451. context.shadowOffsetX = this.shadowOffsetX;
  10452. context.shadowOffsetY = this.shadowOffsetY;
  10453. }
  10454. var thumbPosition = this._getThumbPosition();
  10455. context.fillStyle = this._background;
  10456. if (this.isVertical) {
  10457. if (this.isThumbClamped) {
  10458. if (this.isThumbCircle) {
  10459. context.beginPath();
  10460. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10461. context.fill();
  10462. context.fillRect(left, top, width, height);
  10463. }
  10464. else {
  10465. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10466. }
  10467. }
  10468. else {
  10469. context.fillRect(left, top, width, height);
  10470. }
  10471. }
  10472. else {
  10473. if (this.isThumbClamped) {
  10474. if (this.isThumbCircle) {
  10475. context.beginPath();
  10476. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10477. context.fill();
  10478. context.fillRect(left, top, width, height);
  10479. }
  10480. else {
  10481. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10482. }
  10483. }
  10484. else {
  10485. context.fillRect(left, top, width, height);
  10486. }
  10487. }
  10488. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10489. context.shadowBlur = 0;
  10490. context.shadowOffsetX = 0;
  10491. context.shadowOffsetY = 0;
  10492. }
  10493. // Value bar
  10494. context.fillStyle = this.color;
  10495. if (this._displayValueBar) {
  10496. if (this.isVertical) {
  10497. if (this.isThumbClamped) {
  10498. if (this.isThumbCircle) {
  10499. context.beginPath();
  10500. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10501. context.fill();
  10502. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10503. }
  10504. else {
  10505. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10506. }
  10507. }
  10508. else {
  10509. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10510. }
  10511. }
  10512. else {
  10513. if (this.isThumbClamped) {
  10514. if (this.isThumbCircle) {
  10515. context.beginPath();
  10516. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10517. context.fill();
  10518. context.fillRect(left, top, thumbPosition, height);
  10519. }
  10520. else {
  10521. context.fillRect(left, top, thumbPosition, height);
  10522. }
  10523. }
  10524. else {
  10525. context.fillRect(left, top, thumbPosition, height);
  10526. }
  10527. }
  10528. }
  10529. // Thumb
  10530. if (this.displayThumb) {
  10531. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10532. context.shadowColor = this.shadowColor;
  10533. context.shadowBlur = this.shadowBlur;
  10534. context.shadowOffsetX = this.shadowOffsetX;
  10535. context.shadowOffsetY = this.shadowOffsetY;
  10536. }
  10537. if (this._isThumbCircle) {
  10538. context.beginPath();
  10539. if (this.isVertical) {
  10540. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10541. }
  10542. else {
  10543. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10544. }
  10545. context.fill();
  10546. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10547. context.shadowBlur = 0;
  10548. context.shadowOffsetX = 0;
  10549. context.shadowOffsetY = 0;
  10550. }
  10551. context.strokeStyle = this._borderColor;
  10552. context.stroke();
  10553. }
  10554. else {
  10555. if (this.isVertical) {
  10556. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10557. }
  10558. else {
  10559. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10560. }
  10561. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10562. context.shadowBlur = 0;
  10563. context.shadowOffsetX = 0;
  10564. context.shadowOffsetY = 0;
  10565. }
  10566. context.strokeStyle = this._borderColor;
  10567. if (this.isVertical) {
  10568. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10569. }
  10570. else {
  10571. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10572. }
  10573. }
  10574. }
  10575. context.restore();
  10576. };
  10577. return Slider;
  10578. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10579. /***/ }),
  10580. /***/ "./2D/controls/stackPanel.ts":
  10581. /*!***********************************!*\
  10582. !*** ./2D/controls/stackPanel.ts ***!
  10583. \***********************************/
  10584. /*! exports provided: StackPanel */
  10585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10586. "use strict";
  10587. __webpack_require__.r(__webpack_exports__);
  10588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10590. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  10591. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10592. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10593. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10594. /**
  10595. * Class used to create a 2D stack panel container
  10596. */
  10597. var StackPanel = /** @class */ (function (_super) {
  10598. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10599. /**
  10600. * Creates a new StackPanel
  10601. * @param name defines control name
  10602. */
  10603. function StackPanel(name) {
  10604. var _this = _super.call(this, name) || this;
  10605. _this.name = name;
  10606. _this._isVertical = true;
  10607. _this._manualWidth = false;
  10608. _this._manualHeight = false;
  10609. _this._doNotTrackManualChanges = false;
  10610. return _this;
  10611. }
  10612. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10613. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10614. get: function () {
  10615. return this._isVertical;
  10616. },
  10617. set: function (value) {
  10618. if (this._isVertical === value) {
  10619. return;
  10620. }
  10621. this._isVertical = value;
  10622. this._markAsDirty();
  10623. },
  10624. enumerable: true,
  10625. configurable: true
  10626. });
  10627. Object.defineProperty(StackPanel.prototype, "width", {
  10628. get: function () {
  10629. return this._width.toString(this._host);
  10630. },
  10631. /**
  10632. * Gets or sets panel width.
  10633. * This value should not be set when in horizontal mode as it will be computed automatically
  10634. */
  10635. set: function (value) {
  10636. if (!this._doNotTrackManualChanges) {
  10637. this._manualWidth = true;
  10638. }
  10639. if (this._width.toString(this._host) === value) {
  10640. return;
  10641. }
  10642. if (this._width.fromString(value)) {
  10643. this._markAsDirty();
  10644. }
  10645. },
  10646. enumerable: true,
  10647. configurable: true
  10648. });
  10649. Object.defineProperty(StackPanel.prototype, "height", {
  10650. get: function () {
  10651. return this._height.toString(this._host);
  10652. },
  10653. /**
  10654. * Gets or sets panel height.
  10655. * This value should not be set when in vertical mode as it will be computed automatically
  10656. */
  10657. set: function (value) {
  10658. if (!this._doNotTrackManualChanges) {
  10659. this._manualHeight = true;
  10660. }
  10661. if (this._height.toString(this._host) === value) {
  10662. return;
  10663. }
  10664. if (this._height.fromString(value)) {
  10665. this._markAsDirty();
  10666. }
  10667. },
  10668. enumerable: true,
  10669. configurable: true
  10670. });
  10671. StackPanel.prototype._getTypeName = function () {
  10672. return "StackPanel";
  10673. };
  10674. /** @hidden */
  10675. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10676. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10677. var child = _a[_i];
  10678. if (this._isVertical) {
  10679. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10680. }
  10681. else {
  10682. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10683. }
  10684. }
  10685. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10686. };
  10687. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10688. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10689. this._measureForChildren.copyFrom(parentMeasure);
  10690. this._measureForChildren.left = this._currentMeasure.left;
  10691. this._measureForChildren.top = this._currentMeasure.top;
  10692. if (!this.isVertical || this._manualWidth) {
  10693. this._measureForChildren.width = this._currentMeasure.width;
  10694. }
  10695. if (this.isVertical || this._manualHeight) {
  10696. this._measureForChildren.height = this._currentMeasure.height;
  10697. }
  10698. };
  10699. StackPanel.prototype._postMeasure = function () {
  10700. var stackWidth = 0;
  10701. var stackHeight = 0;
  10702. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10703. var child = _a[_i];
  10704. if (!child.isVisible || child.notRenderable) {
  10705. continue;
  10706. }
  10707. if (this._isVertical) {
  10708. if (child.top !== stackHeight + "px") {
  10709. child.top = stackHeight + "px";
  10710. this._rebuildLayout = true;
  10711. child._top.ignoreAdaptiveScaling = true;
  10712. }
  10713. if (child._height.isPercentage) {
  10714. 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");
  10715. }
  10716. else {
  10717. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10718. }
  10719. }
  10720. else {
  10721. if (child.left !== stackWidth + "px") {
  10722. child.left = stackWidth + "px";
  10723. this._rebuildLayout = true;
  10724. child._left.ignoreAdaptiveScaling = true;
  10725. }
  10726. if (child._width.isPercentage) {
  10727. 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");
  10728. }
  10729. else {
  10730. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10731. }
  10732. }
  10733. }
  10734. this._doNotTrackManualChanges = true;
  10735. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10736. // User can now define their own height and width for stack panel.
  10737. var panelWidthChanged = false;
  10738. var panelHeightChanged = false;
  10739. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10740. var previousHeight = this.height;
  10741. this.height = stackHeight + "px";
  10742. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10743. }
  10744. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10745. var previousWidth = this.width;
  10746. this.width = stackWidth + "px";
  10747. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10748. }
  10749. if (panelHeightChanged) {
  10750. this._height.ignoreAdaptiveScaling = true;
  10751. }
  10752. if (panelWidthChanged) {
  10753. this._width.ignoreAdaptiveScaling = true;
  10754. }
  10755. this._doNotTrackManualChanges = false;
  10756. if (panelWidthChanged || panelHeightChanged) {
  10757. this._rebuildLayout = true;
  10758. }
  10759. _super.prototype._postMeasure.call(this);
  10760. };
  10761. return StackPanel;
  10762. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10763. /***/ }),
  10764. /***/ "./2D/controls/statics.ts":
  10765. /*!********************************!*\
  10766. !*** ./2D/controls/statics.ts ***!
  10767. \********************************/
  10768. /*! exports provided: name */
  10769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10770. "use strict";
  10771. __webpack_require__.r(__webpack_exports__);
  10772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10773. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10774. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10775. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10776. /**
  10777. * Forcing an export so that this code will execute
  10778. * @hidden
  10779. */
  10780. var name = "Statics";
  10781. /**
  10782. * Creates a stack panel that can be used to render headers
  10783. * @param control defines the control to associate with the header
  10784. * @param text defines the text of the header
  10785. * @param size defines the size of the header
  10786. * @param options defines options used to configure the header
  10787. * @returns a new StackPanel
  10788. */
  10789. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10790. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10791. var isHorizontal = options ? options.isHorizontal : true;
  10792. var controlFirst = options ? options.controlFirst : true;
  10793. panel.isVertical = !isHorizontal;
  10794. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10795. header.text = text;
  10796. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10797. if (isHorizontal) {
  10798. header.width = size;
  10799. }
  10800. else {
  10801. header.height = size;
  10802. }
  10803. if (controlFirst) {
  10804. panel.addControl(control);
  10805. panel.addControl(header);
  10806. header.paddingLeft = "5px";
  10807. }
  10808. else {
  10809. panel.addControl(header);
  10810. panel.addControl(control);
  10811. header.paddingRight = "5px";
  10812. }
  10813. header.shadowBlur = control.shadowBlur;
  10814. header.shadowColor = control.shadowColor;
  10815. header.shadowOffsetX = control.shadowOffsetX;
  10816. header.shadowOffsetY = control.shadowOffsetY;
  10817. return panel;
  10818. };
  10819. /***/ }),
  10820. /***/ "./2D/controls/textBlock.ts":
  10821. /*!**********************************!*\
  10822. !*** ./2D/controls/textBlock.ts ***!
  10823. \**********************************/
  10824. /*! exports provided: TextWrapping, TextBlock */
  10825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10826. "use strict";
  10827. __webpack_require__.r(__webpack_exports__);
  10828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10830. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10831. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  10832. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10833. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10834. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10835. /**
  10836. * Enum that determines the text-wrapping mode to use.
  10837. */
  10838. var TextWrapping;
  10839. (function (TextWrapping) {
  10840. /**
  10841. * Clip the text when it's larger than Control.width; this is the default mode.
  10842. */
  10843. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10844. /**
  10845. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10846. */
  10847. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10848. /**
  10849. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10850. */
  10851. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10852. })(TextWrapping || (TextWrapping = {}));
  10853. /**
  10854. * Class used to create text block control
  10855. */
  10856. var TextBlock = /** @class */ (function (_super) {
  10857. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10858. /**
  10859. * Creates a new TextBlock object
  10860. * @param name defines the name of the control
  10861. * @param text defines the text to display (emptry string by default)
  10862. */
  10863. function TextBlock(
  10864. /**
  10865. * Defines the name of the control
  10866. */
  10867. name, text) {
  10868. if (text === void 0) { text = ""; }
  10869. var _this = _super.call(this, name) || this;
  10870. _this.name = name;
  10871. _this._text = "";
  10872. _this._textWrapping = TextWrapping.Clip;
  10873. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10874. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10875. _this._resizeToFit = false;
  10876. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10877. _this._outlineWidth = 0;
  10878. _this._outlineColor = "white";
  10879. /**
  10880. * An event triggered after the text is changed
  10881. */
  10882. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10883. /**
  10884. * An event triggered after the text was broken up into lines
  10885. */
  10886. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10887. _this.text = text;
  10888. return _this;
  10889. }
  10890. Object.defineProperty(TextBlock.prototype, "lines", {
  10891. /**
  10892. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10893. */
  10894. get: function () {
  10895. return this._lines;
  10896. },
  10897. enumerable: true,
  10898. configurable: true
  10899. });
  10900. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10901. /**
  10902. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10903. */
  10904. get: function () {
  10905. return this._resizeToFit;
  10906. },
  10907. /**
  10908. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10909. */
  10910. set: function (value) {
  10911. if (this._resizeToFit === value) {
  10912. return;
  10913. }
  10914. this._resizeToFit = value;
  10915. if (this._resizeToFit) {
  10916. this._width.ignoreAdaptiveScaling = true;
  10917. this._height.ignoreAdaptiveScaling = true;
  10918. }
  10919. this._markAsDirty();
  10920. },
  10921. enumerable: true,
  10922. configurable: true
  10923. });
  10924. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10925. /**
  10926. * Gets or sets a boolean indicating if text must be wrapped
  10927. */
  10928. get: function () {
  10929. return this._textWrapping;
  10930. },
  10931. /**
  10932. * Gets or sets a boolean indicating if text must be wrapped
  10933. */
  10934. set: function (value) {
  10935. if (this._textWrapping === value) {
  10936. return;
  10937. }
  10938. this._textWrapping = +value;
  10939. this._markAsDirty();
  10940. },
  10941. enumerable: true,
  10942. configurable: true
  10943. });
  10944. Object.defineProperty(TextBlock.prototype, "text", {
  10945. /**
  10946. * Gets or sets text to display
  10947. */
  10948. get: function () {
  10949. return this._text;
  10950. },
  10951. /**
  10952. * Gets or sets text to display
  10953. */
  10954. set: function (value) {
  10955. if (this._text === value) {
  10956. return;
  10957. }
  10958. this._text = value;
  10959. this._markAsDirty();
  10960. this.onTextChangedObservable.notifyObservers(this);
  10961. },
  10962. enumerable: true,
  10963. configurable: true
  10964. });
  10965. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10966. /**
  10967. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10968. */
  10969. get: function () {
  10970. return this._textHorizontalAlignment;
  10971. },
  10972. /**
  10973. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10974. */
  10975. set: function (value) {
  10976. if (this._textHorizontalAlignment === value) {
  10977. return;
  10978. }
  10979. this._textHorizontalAlignment = value;
  10980. this._markAsDirty();
  10981. },
  10982. enumerable: true,
  10983. configurable: true
  10984. });
  10985. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10986. /**
  10987. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10988. */
  10989. get: function () {
  10990. return this._textVerticalAlignment;
  10991. },
  10992. /**
  10993. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10994. */
  10995. set: function (value) {
  10996. if (this._textVerticalAlignment === value) {
  10997. return;
  10998. }
  10999. this._textVerticalAlignment = value;
  11000. this._markAsDirty();
  11001. },
  11002. enumerable: true,
  11003. configurable: true
  11004. });
  11005. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11006. /**
  11007. * Gets or sets line spacing value
  11008. */
  11009. get: function () {
  11010. return this._lineSpacing.toString(this._host);
  11011. },
  11012. /**
  11013. * Gets or sets line spacing value
  11014. */
  11015. set: function (value) {
  11016. if (this._lineSpacing.fromString(value)) {
  11017. this._markAsDirty();
  11018. }
  11019. },
  11020. enumerable: true,
  11021. configurable: true
  11022. });
  11023. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11024. /**
  11025. * Gets or sets outlineWidth of the text to display
  11026. */
  11027. get: function () {
  11028. return this._outlineWidth;
  11029. },
  11030. /**
  11031. * Gets or sets outlineWidth of the text to display
  11032. */
  11033. set: function (value) {
  11034. if (this._outlineWidth === value) {
  11035. return;
  11036. }
  11037. this._outlineWidth = value;
  11038. this._markAsDirty();
  11039. },
  11040. enumerable: true,
  11041. configurable: true
  11042. });
  11043. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11044. /**
  11045. * Gets or sets outlineColor of the text to display
  11046. */
  11047. get: function () {
  11048. return this._outlineColor;
  11049. },
  11050. /**
  11051. * Gets or sets outlineColor of the text to display
  11052. */
  11053. set: function (value) {
  11054. if (this._outlineColor === value) {
  11055. return;
  11056. }
  11057. this._outlineColor = value;
  11058. this._markAsDirty();
  11059. },
  11060. enumerable: true,
  11061. configurable: true
  11062. });
  11063. TextBlock.prototype._getTypeName = function () {
  11064. return "TextBlock";
  11065. };
  11066. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11067. if (!this._fontOffset) {
  11068. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11069. }
  11070. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11071. // Prepare lines
  11072. this._lines = this._breakLines(this._currentMeasure.width, context);
  11073. this.onLinesReadyObservable.notifyObservers(this);
  11074. var maxLineWidth = 0;
  11075. for (var i = 0; i < this._lines.length; i++) {
  11076. var line = this._lines[i];
  11077. if (line.width > maxLineWidth) {
  11078. maxLineWidth = line.width;
  11079. }
  11080. }
  11081. if (this._resizeToFit) {
  11082. if (this._textWrapping === TextWrapping.Clip) {
  11083. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11084. if (newWidth !== this._width.internalValue) {
  11085. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11086. this._rebuildLayout = true;
  11087. }
  11088. }
  11089. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11090. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11091. var lineSpacing = 0;
  11092. if (this._lineSpacing.isPixel) {
  11093. lineSpacing = this._lineSpacing.getValue(this._host);
  11094. }
  11095. else {
  11096. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11097. }
  11098. newHeight += (this._lines.length - 1) * lineSpacing;
  11099. }
  11100. if (newHeight !== this._height.internalValue) {
  11101. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11102. this._rebuildLayout = true;
  11103. }
  11104. }
  11105. };
  11106. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11107. var width = this._currentMeasure.width;
  11108. var x = 0;
  11109. switch (this._textHorizontalAlignment) {
  11110. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11111. x = 0;
  11112. break;
  11113. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11114. x = width - textWidth;
  11115. break;
  11116. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11117. x = (width - textWidth) / 2;
  11118. break;
  11119. }
  11120. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11121. context.shadowColor = this.shadowColor;
  11122. context.shadowBlur = this.shadowBlur;
  11123. context.shadowOffsetX = this.shadowOffsetX;
  11124. context.shadowOffsetY = this.shadowOffsetY;
  11125. }
  11126. if (this.outlineWidth) {
  11127. context.strokeText(text, this._currentMeasure.left + x, y);
  11128. }
  11129. context.fillText(text, this._currentMeasure.left + x, y);
  11130. };
  11131. /** @hidden */
  11132. TextBlock.prototype._draw = function (context) {
  11133. context.save();
  11134. this._applyStates(context);
  11135. // Render lines
  11136. this._renderLines(context);
  11137. context.restore();
  11138. };
  11139. TextBlock.prototype._applyStates = function (context) {
  11140. _super.prototype._applyStates.call(this, context);
  11141. if (this.outlineWidth) {
  11142. context.lineWidth = this.outlineWidth;
  11143. context.strokeStyle = this.outlineColor;
  11144. }
  11145. };
  11146. TextBlock.prototype._breakLines = function (refWidth, context) {
  11147. var lines = [];
  11148. var _lines = this.text.split("\n");
  11149. if (this._textWrapping === TextWrapping.Ellipsis) {
  11150. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11151. var _line = _lines_1[_i];
  11152. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11153. }
  11154. }
  11155. else if (this._textWrapping === TextWrapping.WordWrap) {
  11156. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11157. var _line = _lines_2[_a];
  11158. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11159. }
  11160. }
  11161. else {
  11162. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11163. var _line = _lines_3[_b];
  11164. lines.push(this._parseLine(_line, context));
  11165. }
  11166. }
  11167. return lines;
  11168. };
  11169. TextBlock.prototype._parseLine = function (line, context) {
  11170. if (line === void 0) { line = ''; }
  11171. return { text: line, width: context.measureText(line).width };
  11172. };
  11173. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11174. if (line === void 0) { line = ''; }
  11175. var lineWidth = context.measureText(line).width;
  11176. if (lineWidth > width) {
  11177. line += '…';
  11178. }
  11179. while (line.length > 2 && lineWidth > width) {
  11180. line = line.slice(0, -2) + '…';
  11181. lineWidth = context.measureText(line).width;
  11182. }
  11183. return { text: line, width: lineWidth };
  11184. };
  11185. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11186. if (line === void 0) { line = ''; }
  11187. var lines = [];
  11188. var words = line.split(' ');
  11189. var lineWidth = 0;
  11190. for (var n = 0; n < words.length; n++) {
  11191. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11192. var metrics = context.measureText(testLine);
  11193. var testWidth = metrics.width;
  11194. if (testWidth > width && n > 0) {
  11195. lines.push({ text: line, width: lineWidth });
  11196. line = words[n];
  11197. lineWidth = context.measureText(line).width;
  11198. }
  11199. else {
  11200. lineWidth = testWidth;
  11201. line = testLine;
  11202. }
  11203. }
  11204. lines.push({ text: line, width: lineWidth });
  11205. return lines;
  11206. };
  11207. TextBlock.prototype._renderLines = function (context) {
  11208. var height = this._currentMeasure.height;
  11209. var rootY = 0;
  11210. switch (this._textVerticalAlignment) {
  11211. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11212. rootY = this._fontOffset.ascent;
  11213. break;
  11214. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11215. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11216. break;
  11217. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11218. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11219. break;
  11220. }
  11221. rootY += this._currentMeasure.top;
  11222. for (var i = 0; i < this._lines.length; i++) {
  11223. var line = this._lines[i];
  11224. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11225. if (this._lineSpacing.isPixel) {
  11226. rootY += this._lineSpacing.getValue(this._host);
  11227. }
  11228. else {
  11229. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11230. }
  11231. }
  11232. this._drawText(line.text, line.width, rootY, context);
  11233. rootY += this._fontOffset.height;
  11234. }
  11235. };
  11236. /**
  11237. * Given a width constraint applied on the text block, find the expected height
  11238. * @returns expected height
  11239. */
  11240. TextBlock.prototype.computeExpectedHeight = function () {
  11241. if (this.text && this.widthInPixels) {
  11242. var context_1 = document.createElement('canvas').getContext('2d');
  11243. if (context_1) {
  11244. this._applyStates(context_1);
  11245. if (!this._fontOffset) {
  11246. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11247. }
  11248. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11249. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11250. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11251. var lineSpacing = 0;
  11252. if (this._lineSpacing.isPixel) {
  11253. lineSpacing = this._lineSpacing.getValue(this._host);
  11254. }
  11255. else {
  11256. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11257. }
  11258. newHeight += (lines.length - 1) * lineSpacing;
  11259. }
  11260. return newHeight;
  11261. }
  11262. }
  11263. return 0;
  11264. };
  11265. TextBlock.prototype.dispose = function () {
  11266. _super.prototype.dispose.call(this);
  11267. this.onTextChangedObservable.clear();
  11268. };
  11269. return TextBlock;
  11270. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11271. /***/ }),
  11272. /***/ "./2D/controls/virtualKeyboard.ts":
  11273. /*!****************************************!*\
  11274. !*** ./2D/controls/virtualKeyboard.ts ***!
  11275. \****************************************/
  11276. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11278. "use strict";
  11279. __webpack_require__.r(__webpack_exports__);
  11280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11282. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11283. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11284. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11285. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11286. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11287. /**
  11288. * Class used to store key control properties
  11289. */
  11290. var KeyPropertySet = /** @class */ (function () {
  11291. function KeyPropertySet() {
  11292. }
  11293. return KeyPropertySet;
  11294. }());
  11295. /**
  11296. * Class used to create virtual keyboard
  11297. */
  11298. var VirtualKeyboard = /** @class */ (function (_super) {
  11299. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11300. function VirtualKeyboard() {
  11301. var _this = _super !== null && _super.apply(this, arguments) || this;
  11302. /** Observable raised when a key is pressed */
  11303. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11304. /** Gets or sets default key button width */
  11305. _this.defaultButtonWidth = "40px";
  11306. /** Gets or sets default key button height */
  11307. _this.defaultButtonHeight = "40px";
  11308. /** Gets or sets default key button left padding */
  11309. _this.defaultButtonPaddingLeft = "2px";
  11310. /** Gets or sets default key button right padding */
  11311. _this.defaultButtonPaddingRight = "2px";
  11312. /** Gets or sets default key button top padding */
  11313. _this.defaultButtonPaddingTop = "2px";
  11314. /** Gets or sets default key button bottom padding */
  11315. _this.defaultButtonPaddingBottom = "2px";
  11316. /** Gets or sets default key button foreground color */
  11317. _this.defaultButtonColor = "#DDD";
  11318. /** Gets or sets default key button background color */
  11319. _this.defaultButtonBackground = "#070707";
  11320. /** Gets or sets shift button foreground color */
  11321. _this.shiftButtonColor = "#7799FF";
  11322. /** Gets or sets shift button thickness*/
  11323. _this.selectedShiftThickness = 1;
  11324. /** Gets shift key state */
  11325. _this.shiftState = 0;
  11326. _this._currentlyConnectedInputText = null;
  11327. _this._connectedInputTexts = [];
  11328. _this._onKeyPressObserver = null;
  11329. return _this;
  11330. }
  11331. VirtualKeyboard.prototype._getTypeName = function () {
  11332. return "VirtualKeyboard";
  11333. };
  11334. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11335. var _this = this;
  11336. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11337. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11338. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11339. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11340. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11341. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11342. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11343. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11344. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11345. button.thickness = 0;
  11346. button.isFocusInvisible = true;
  11347. button.shadowColor = this.shadowColor;
  11348. button.shadowBlur = this.shadowBlur;
  11349. button.shadowOffsetX = this.shadowOffsetX;
  11350. button.shadowOffsetY = this.shadowOffsetY;
  11351. button.onPointerUpObservable.add(function () {
  11352. _this.onKeyPressObservable.notifyObservers(key);
  11353. });
  11354. return button;
  11355. };
  11356. /**
  11357. * Adds a new row of keys
  11358. * @param keys defines the list of keys to add
  11359. * @param propertySets defines the associated property sets
  11360. */
  11361. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11362. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11363. panel.isVertical = false;
  11364. panel.isFocusInvisible = true;
  11365. var maxKey = null;
  11366. for (var i = 0; i < keys.length; i++) {
  11367. var properties = null;
  11368. if (propertySets && propertySets.length === keys.length) {
  11369. properties = propertySets[i];
  11370. }
  11371. var key = this._createKey(keys[i], properties);
  11372. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11373. maxKey = key;
  11374. }
  11375. panel.addControl(key);
  11376. }
  11377. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11378. this.addControl(panel);
  11379. };
  11380. /**
  11381. * Set the shift key to a specific state
  11382. * @param shiftState defines the new shift state
  11383. */
  11384. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11385. if (!this.children) {
  11386. return;
  11387. }
  11388. for (var i = 0; i < this.children.length; i++) {
  11389. var row = this.children[i];
  11390. if (!row || !row.children) {
  11391. continue;
  11392. }
  11393. var rowContainer = row;
  11394. for (var j = 0; j < rowContainer.children.length; j++) {
  11395. var button = rowContainer.children[j];
  11396. if (!button || !button.children[0]) {
  11397. continue;
  11398. }
  11399. var button_tblock = button.children[0];
  11400. if (button_tblock.text === "\u21E7") {
  11401. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11402. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11403. }
  11404. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11405. }
  11406. }
  11407. };
  11408. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11409. /** Gets the input text control currently attached to the keyboard */
  11410. get: function () {
  11411. return this._currentlyConnectedInputText;
  11412. },
  11413. enumerable: true,
  11414. configurable: true
  11415. });
  11416. /**
  11417. * Connects the keyboard with an input text control
  11418. *
  11419. * @param input defines the target control
  11420. */
  11421. VirtualKeyboard.prototype.connect = function (input) {
  11422. var _this = this;
  11423. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11424. if (inputTextAlreadyConnected) {
  11425. return;
  11426. }
  11427. if (this._onKeyPressObserver === null) {
  11428. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11429. if (!_this._currentlyConnectedInputText) {
  11430. return;
  11431. }
  11432. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11433. switch (key) {
  11434. case "\u21E7":
  11435. _this.shiftState++;
  11436. if (_this.shiftState > 2) {
  11437. _this.shiftState = 0;
  11438. }
  11439. _this.applyShiftState(_this.shiftState);
  11440. return;
  11441. case "\u2190":
  11442. _this._currentlyConnectedInputText.processKey(8);
  11443. return;
  11444. case "\u21B5":
  11445. _this._currentlyConnectedInputText.processKey(13);
  11446. return;
  11447. }
  11448. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11449. if (_this.shiftState === 1) {
  11450. _this.shiftState = 0;
  11451. _this.applyShiftState(_this.shiftState);
  11452. }
  11453. });
  11454. }
  11455. this.isVisible = false;
  11456. this._currentlyConnectedInputText = input;
  11457. input._connectedVirtualKeyboard = this;
  11458. // Events hooking
  11459. var onFocusObserver = input.onFocusObservable.add(function () {
  11460. _this._currentlyConnectedInputText = input;
  11461. input._connectedVirtualKeyboard = _this;
  11462. _this.isVisible = true;
  11463. });
  11464. var onBlurObserver = input.onBlurObservable.add(function () {
  11465. input._connectedVirtualKeyboard = null;
  11466. _this._currentlyConnectedInputText = null;
  11467. _this.isVisible = false;
  11468. });
  11469. this._connectedInputTexts.push({
  11470. input: input,
  11471. onBlurObserver: onBlurObserver,
  11472. onFocusObserver: onFocusObserver
  11473. });
  11474. };
  11475. /**
  11476. * Disconnects the keyboard from connected InputText controls
  11477. *
  11478. * @param input optionally defines a target control, otherwise all are disconnected
  11479. */
  11480. VirtualKeyboard.prototype.disconnect = function (input) {
  11481. var _this = this;
  11482. if (input) {
  11483. // .find not available on IE
  11484. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11485. if (filtered.length === 1) {
  11486. this._removeConnectedInputObservables(filtered[0]);
  11487. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11488. if (this._currentlyConnectedInputText === input) {
  11489. this._currentlyConnectedInputText = null;
  11490. }
  11491. }
  11492. }
  11493. else {
  11494. this._connectedInputTexts.forEach(function (connectedInputText) {
  11495. _this._removeConnectedInputObservables(connectedInputText);
  11496. });
  11497. this._connectedInputTexts = [];
  11498. }
  11499. if (this._connectedInputTexts.length === 0) {
  11500. this._currentlyConnectedInputText = null;
  11501. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11502. this._onKeyPressObserver = null;
  11503. }
  11504. };
  11505. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11506. connectedInputText.input._connectedVirtualKeyboard = null;
  11507. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11508. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11509. };
  11510. /**
  11511. * Release all resources
  11512. */
  11513. VirtualKeyboard.prototype.dispose = function () {
  11514. _super.prototype.dispose.call(this);
  11515. this.disconnect();
  11516. };
  11517. // Statics
  11518. /**
  11519. * Creates a new keyboard using a default layout
  11520. *
  11521. * @param name defines control name
  11522. * @returns a new VirtualKeyboard
  11523. */
  11524. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11525. var returnValue = new VirtualKeyboard(name);
  11526. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11527. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11528. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11529. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11530. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11531. return returnValue;
  11532. };
  11533. return VirtualKeyboard;
  11534. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11535. /***/ }),
  11536. /***/ "./2D/index.ts":
  11537. /*!*********************!*\
  11538. !*** ./2D/index.ts ***!
  11539. \*********************/
  11540. /*! 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 */
  11541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11542. "use strict";
  11543. __webpack_require__.r(__webpack_exports__);
  11544. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11576. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11578. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11580. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11583. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11585. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11587. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11589. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11591. /***/ }),
  11592. /***/ "./2D/math2D.ts":
  11593. /*!**********************!*\
  11594. !*** ./2D/math2D.ts ***!
  11595. \**********************/
  11596. /*! exports provided: Vector2WithInfo, Matrix2D */
  11597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11598. "use strict";
  11599. __webpack_require__.r(__webpack_exports__);
  11600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11602. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11603. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11604. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11605. /**
  11606. * Class used to transport Vector2 information for pointer events
  11607. */
  11608. var Vector2WithInfo = /** @class */ (function (_super) {
  11609. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11610. /**
  11611. * Creates a new Vector2WithInfo
  11612. * @param source defines the vector2 data to transport
  11613. * @param buttonIndex defines the current mouse button index
  11614. */
  11615. function Vector2WithInfo(source,
  11616. /** defines the current mouse button index */
  11617. buttonIndex) {
  11618. if (buttonIndex === void 0) { buttonIndex = 0; }
  11619. var _this = _super.call(this, source.x, source.y) || this;
  11620. _this.buttonIndex = buttonIndex;
  11621. return _this;
  11622. }
  11623. return Vector2WithInfo;
  11624. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11625. /** Class used to provide 2D matrix features */
  11626. var Matrix2D = /** @class */ (function () {
  11627. /**
  11628. * Creates a new matrix
  11629. * @param m00 defines value for (0, 0)
  11630. * @param m01 defines value for (0, 1)
  11631. * @param m10 defines value for (1, 0)
  11632. * @param m11 defines value for (1, 1)
  11633. * @param m20 defines value for (2, 0)
  11634. * @param m21 defines value for (2, 1)
  11635. */
  11636. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11637. /** Gets the internal array of 6 floats used to store matrix data */
  11638. this.m = new Float32Array(6);
  11639. this.fromValues(m00, m01, m10, m11, m20, m21);
  11640. }
  11641. /**
  11642. * Fills the matrix from direct values
  11643. * @param m00 defines value for (0, 0)
  11644. * @param m01 defines value for (0, 1)
  11645. * @param m10 defines value for (1, 0)
  11646. * @param m11 defines value for (1, 1)
  11647. * @param m20 defines value for (2, 0)
  11648. * @param m21 defines value for (2, 1)
  11649. * @returns the current modified matrix
  11650. */
  11651. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11652. this.m[0] = m00;
  11653. this.m[1] = m01;
  11654. this.m[2] = m10;
  11655. this.m[3] = m11;
  11656. this.m[4] = m20;
  11657. this.m[5] = m21;
  11658. return this;
  11659. };
  11660. /**
  11661. * Gets matrix determinant
  11662. * @returns the determinant
  11663. */
  11664. Matrix2D.prototype.determinant = function () {
  11665. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11666. };
  11667. /**
  11668. * Inverses the matrix and stores it in a target matrix
  11669. * @param result defines the target matrix
  11670. * @returns the current matrix
  11671. */
  11672. Matrix2D.prototype.invertToRef = function (result) {
  11673. var l0 = this.m[0];
  11674. var l1 = this.m[1];
  11675. var l2 = this.m[2];
  11676. var l3 = this.m[3];
  11677. var l4 = this.m[4];
  11678. var l5 = this.m[5];
  11679. var det = this.determinant();
  11680. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11681. result.m[0] = 0;
  11682. result.m[1] = 0;
  11683. result.m[2] = 0;
  11684. result.m[3] = 0;
  11685. result.m[4] = 0;
  11686. result.m[5] = 0;
  11687. return this;
  11688. }
  11689. var detDiv = 1 / det;
  11690. var det4 = l2 * l5 - l3 * l4;
  11691. var det5 = l1 * l4 - l0 * l5;
  11692. result.m[0] = l3 * detDiv;
  11693. result.m[1] = -l1 * detDiv;
  11694. result.m[2] = -l2 * detDiv;
  11695. result.m[3] = l0 * detDiv;
  11696. result.m[4] = det4 * detDiv;
  11697. result.m[5] = det5 * detDiv;
  11698. return this;
  11699. };
  11700. /**
  11701. * Multiplies the current matrix with another one
  11702. * @param other defines the second operand
  11703. * @param result defines the target matrix
  11704. * @returns the current matrix
  11705. */
  11706. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11707. var l0 = this.m[0];
  11708. var l1 = this.m[1];
  11709. var l2 = this.m[2];
  11710. var l3 = this.m[3];
  11711. var l4 = this.m[4];
  11712. var l5 = this.m[5];
  11713. var r0 = other.m[0];
  11714. var r1 = other.m[1];
  11715. var r2 = other.m[2];
  11716. var r3 = other.m[3];
  11717. var r4 = other.m[4];
  11718. var r5 = other.m[5];
  11719. result.m[0] = l0 * r0 + l1 * r2;
  11720. result.m[1] = l0 * r1 + l1 * r3;
  11721. result.m[2] = l2 * r0 + l3 * r2;
  11722. result.m[3] = l2 * r1 + l3 * r3;
  11723. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11724. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11725. return this;
  11726. };
  11727. /**
  11728. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11729. * @param x defines the x coordinate to transform
  11730. * @param y defines the x coordinate to transform
  11731. * @param result defines the target vector2
  11732. * @returns the current matrix
  11733. */
  11734. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11735. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11736. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11737. return this;
  11738. };
  11739. // Statics
  11740. /**
  11741. * Creates an identity matrix
  11742. * @returns a new matrix
  11743. */
  11744. Matrix2D.Identity = function () {
  11745. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11746. };
  11747. /**
  11748. * Creates a translation matrix and stores it in a target matrix
  11749. * @param x defines the x coordinate of the translation
  11750. * @param y defines the y coordinate of the translation
  11751. * @param result defines the target matrix
  11752. */
  11753. Matrix2D.TranslationToRef = function (x, y, result) {
  11754. result.fromValues(1, 0, 0, 1, x, y);
  11755. };
  11756. /**
  11757. * Creates a scaling matrix and stores it in a target matrix
  11758. * @param x defines the x coordinate of the scaling
  11759. * @param y defines the y coordinate of the scaling
  11760. * @param result defines the target matrix
  11761. */
  11762. Matrix2D.ScalingToRef = function (x, y, result) {
  11763. result.fromValues(x, 0, 0, y, 0, 0);
  11764. };
  11765. /**
  11766. * Creates a rotation matrix and stores it in a target matrix
  11767. * @param angle defines the rotation angle
  11768. * @param result defines the target matrix
  11769. */
  11770. Matrix2D.RotationToRef = function (angle, result) {
  11771. var s = Math.sin(angle);
  11772. var c = Math.cos(angle);
  11773. result.fromValues(c, s, -s, c, 0, 0);
  11774. };
  11775. /**
  11776. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11777. * @param tx defines the x coordinate of the translation
  11778. * @param ty defines the y coordinate of the translation
  11779. * @param angle defines the rotation angle
  11780. * @param scaleX defines the x coordinate of the scaling
  11781. * @param scaleY defines the y coordinate of the scaling
  11782. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11783. * @param result defines the target matrix
  11784. */
  11785. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11786. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11787. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11788. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11789. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11790. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11791. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11792. if (parentMatrix) {
  11793. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11794. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11795. }
  11796. else {
  11797. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11798. }
  11799. };
  11800. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11801. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11802. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11803. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11804. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11805. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11806. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11807. return Matrix2D;
  11808. }());
  11809. /***/ }),
  11810. /***/ "./2D/measure.ts":
  11811. /*!***********************!*\
  11812. !*** ./2D/measure.ts ***!
  11813. \***********************/
  11814. /*! exports provided: Measure */
  11815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11816. "use strict";
  11817. __webpack_require__.r(__webpack_exports__);
  11818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11819. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11820. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11821. /**
  11822. * Class used to store 2D control sizes
  11823. */
  11824. var Measure = /** @class */ (function () {
  11825. /**
  11826. * Creates a new measure
  11827. * @param left defines left coordinate
  11828. * @param top defines top coordinate
  11829. * @param width defines width dimension
  11830. * @param height defines height dimension
  11831. */
  11832. function Measure(
  11833. /** defines left coordinate */
  11834. left,
  11835. /** defines top coordinate */
  11836. top,
  11837. /** defines width dimension */
  11838. width,
  11839. /** defines height dimension */
  11840. height) {
  11841. this.left = left;
  11842. this.top = top;
  11843. this.width = width;
  11844. this.height = height;
  11845. }
  11846. /**
  11847. * Copy from another measure
  11848. * @param other defines the other measure to copy from
  11849. */
  11850. Measure.prototype.copyFrom = function (other) {
  11851. this.left = other.left;
  11852. this.top = other.top;
  11853. this.width = other.width;
  11854. this.height = other.height;
  11855. };
  11856. /**
  11857. * Copy from a group of 4 floats
  11858. * @param left defines left coordinate
  11859. * @param top defines top coordinate
  11860. * @param width defines width dimension
  11861. * @param height defines height dimension
  11862. */
  11863. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11864. this.left = left;
  11865. this.top = top;
  11866. this.width = width;
  11867. this.height = height;
  11868. };
  11869. /**
  11870. * Computes the axis aligned bounding box measure for two given measures
  11871. * @param a Input measure
  11872. * @param b Input measure
  11873. * @param result the resulting bounding measure
  11874. */
  11875. Measure.CombineToRef = function (a, b, result) {
  11876. var left = Math.min(a.left, b.left);
  11877. var top = Math.min(a.top, b.top);
  11878. var right = Math.max(a.left + a.width, b.left + b.width);
  11879. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11880. result.left = left;
  11881. result.top = top;
  11882. result.width = right - left;
  11883. result.height = bottom - top;
  11884. };
  11885. /**
  11886. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11887. * @param transform the matrix to transform the measure before computing the AABB
  11888. * @param result the resulting AABB
  11889. */
  11890. Measure.prototype.transformToRef = function (transform, result) {
  11891. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11892. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11893. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11894. for (var i = 0; i < 4; i++) {
  11895. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11896. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11897. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11898. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11899. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11900. }
  11901. result.left = min.x;
  11902. result.top = min.y;
  11903. result.width = max.x - min.x;
  11904. result.height = max.y - min.y;
  11905. };
  11906. /**
  11907. * Check equality between this measure and another one
  11908. * @param other defines the other measures
  11909. * @returns true if both measures are equals
  11910. */
  11911. Measure.prototype.isEqualsTo = function (other) {
  11912. if (this.left !== other.left) {
  11913. return false;
  11914. }
  11915. if (this.top !== other.top) {
  11916. return false;
  11917. }
  11918. if (this.width !== other.width) {
  11919. return false;
  11920. }
  11921. if (this.height !== other.height) {
  11922. return false;
  11923. }
  11924. return true;
  11925. };
  11926. /**
  11927. * Creates an empty measure
  11928. * @returns a new measure
  11929. */
  11930. Measure.Empty = function () {
  11931. return new Measure(0, 0, 0, 0);
  11932. };
  11933. return Measure;
  11934. }());
  11935. /***/ }),
  11936. /***/ "./2D/multiLinePoint.ts":
  11937. /*!******************************!*\
  11938. !*** ./2D/multiLinePoint.ts ***!
  11939. \******************************/
  11940. /*! exports provided: MultiLinePoint */
  11941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11942. "use strict";
  11943. __webpack_require__.r(__webpack_exports__);
  11944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11945. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11946. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11947. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11948. /**
  11949. * Class used to store a point for a MultiLine object.
  11950. * The point can be pure 2D coordinates, a mesh or a control
  11951. */
  11952. var MultiLinePoint = /** @class */ (function () {
  11953. /**
  11954. * Creates a new MultiLinePoint
  11955. * @param multiLine defines the source MultiLine object
  11956. */
  11957. function MultiLinePoint(multiLine) {
  11958. this._multiLine = multiLine;
  11959. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11960. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11961. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11962. }
  11963. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11964. /** Gets or sets x coordinate */
  11965. get: function () {
  11966. return this._x.toString(this._multiLine._host);
  11967. },
  11968. set: function (value) {
  11969. if (this._x.toString(this._multiLine._host) === value) {
  11970. return;
  11971. }
  11972. if (this._x.fromString(value)) {
  11973. this._multiLine._markAsDirty();
  11974. }
  11975. },
  11976. enumerable: true,
  11977. configurable: true
  11978. });
  11979. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11980. /** Gets or sets y coordinate */
  11981. get: function () {
  11982. return this._y.toString(this._multiLine._host);
  11983. },
  11984. set: function (value) {
  11985. if (this._y.toString(this._multiLine._host) === value) {
  11986. return;
  11987. }
  11988. if (this._y.fromString(value)) {
  11989. this._multiLine._markAsDirty();
  11990. }
  11991. },
  11992. enumerable: true,
  11993. configurable: true
  11994. });
  11995. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11996. /** Gets or sets the control associated with this point */
  11997. get: function () {
  11998. return this._control;
  11999. },
  12000. set: function (value) {
  12001. if (this._control === value) {
  12002. return;
  12003. }
  12004. if (this._control && this._controlObserver) {
  12005. this._control.onDirtyObservable.remove(this._controlObserver);
  12006. this._controlObserver = null;
  12007. }
  12008. this._control = value;
  12009. if (this._control) {
  12010. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12011. }
  12012. this._multiLine._markAsDirty();
  12013. },
  12014. enumerable: true,
  12015. configurable: true
  12016. });
  12017. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12018. /** Gets or sets the mesh associated with this point */
  12019. get: function () {
  12020. return this._mesh;
  12021. },
  12022. set: function (value) {
  12023. if (this._mesh === value) {
  12024. return;
  12025. }
  12026. if (this._mesh && this._meshObserver) {
  12027. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12028. }
  12029. this._mesh = value;
  12030. if (this._mesh) {
  12031. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12032. }
  12033. this._multiLine._markAsDirty();
  12034. },
  12035. enumerable: true,
  12036. configurable: true
  12037. });
  12038. /** Resets links */
  12039. MultiLinePoint.prototype.resetLinks = function () {
  12040. this.control = null;
  12041. this.mesh = null;
  12042. };
  12043. /**
  12044. * Gets a translation vector
  12045. * @returns the translation vector
  12046. */
  12047. MultiLinePoint.prototype.translate = function () {
  12048. this._point = this._translatePoint();
  12049. return this._point;
  12050. };
  12051. MultiLinePoint.prototype._translatePoint = function () {
  12052. if (this._mesh != null) {
  12053. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12054. }
  12055. else if (this._control != null) {
  12056. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12057. }
  12058. else {
  12059. var host = this._multiLine._host;
  12060. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12061. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12062. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12063. }
  12064. };
  12065. /** Release associated resources */
  12066. MultiLinePoint.prototype.dispose = function () {
  12067. this.resetLinks();
  12068. };
  12069. return MultiLinePoint;
  12070. }());
  12071. /***/ }),
  12072. /***/ "./2D/style.ts":
  12073. /*!*********************!*\
  12074. !*** ./2D/style.ts ***!
  12075. \*********************/
  12076. /*! exports provided: Style */
  12077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12078. "use strict";
  12079. __webpack_require__.r(__webpack_exports__);
  12080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12081. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12082. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12083. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12084. /**
  12085. * Define a style used by control to automatically setup properties based on a template.
  12086. * Only support font related properties so far
  12087. */
  12088. var Style = /** @class */ (function () {
  12089. /**
  12090. * Creates a new style object
  12091. * @param host defines the AdvancedDynamicTexture which hosts this style
  12092. */
  12093. function Style(host) {
  12094. this._fontFamily = "Arial";
  12095. this._fontStyle = "";
  12096. this._fontWeight = "";
  12097. /** @hidden */
  12098. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12099. /**
  12100. * Observable raised when the style values are changed
  12101. */
  12102. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12103. this._host = host;
  12104. }
  12105. Object.defineProperty(Style.prototype, "fontSize", {
  12106. /**
  12107. * Gets or sets the font size
  12108. */
  12109. get: function () {
  12110. return this._fontSize.toString(this._host);
  12111. },
  12112. set: function (value) {
  12113. if (this._fontSize.toString(this._host) === value) {
  12114. return;
  12115. }
  12116. if (this._fontSize.fromString(value)) {
  12117. this.onChangedObservable.notifyObservers(this);
  12118. }
  12119. },
  12120. enumerable: true,
  12121. configurable: true
  12122. });
  12123. Object.defineProperty(Style.prototype, "fontFamily", {
  12124. /**
  12125. * Gets or sets the font family
  12126. */
  12127. get: function () {
  12128. return this._fontFamily;
  12129. },
  12130. set: function (value) {
  12131. if (this._fontFamily === value) {
  12132. return;
  12133. }
  12134. this._fontFamily = value;
  12135. this.onChangedObservable.notifyObservers(this);
  12136. },
  12137. enumerable: true,
  12138. configurable: true
  12139. });
  12140. Object.defineProperty(Style.prototype, "fontStyle", {
  12141. /**
  12142. * Gets or sets the font style
  12143. */
  12144. get: function () {
  12145. return this._fontStyle;
  12146. },
  12147. set: function (value) {
  12148. if (this._fontStyle === value) {
  12149. return;
  12150. }
  12151. this._fontStyle = value;
  12152. this.onChangedObservable.notifyObservers(this);
  12153. },
  12154. enumerable: true,
  12155. configurable: true
  12156. });
  12157. Object.defineProperty(Style.prototype, "fontWeight", {
  12158. /** Gets or sets font weight */
  12159. get: function () {
  12160. return this._fontWeight;
  12161. },
  12162. set: function (value) {
  12163. if (this._fontWeight === value) {
  12164. return;
  12165. }
  12166. this._fontWeight = value;
  12167. this.onChangedObservable.notifyObservers(this);
  12168. },
  12169. enumerable: true,
  12170. configurable: true
  12171. });
  12172. /** Dispose all associated resources */
  12173. Style.prototype.dispose = function () {
  12174. this.onChangedObservable.clear();
  12175. };
  12176. return Style;
  12177. }());
  12178. /***/ }),
  12179. /***/ "./2D/valueAndUnit.ts":
  12180. /*!****************************!*\
  12181. !*** ./2D/valueAndUnit.ts ***!
  12182. \****************************/
  12183. /*! exports provided: ValueAndUnit */
  12184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12185. "use strict";
  12186. __webpack_require__.r(__webpack_exports__);
  12187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12188. /**
  12189. * Class used to specific a value and its associated unit
  12190. */
  12191. var ValueAndUnit = /** @class */ (function () {
  12192. /**
  12193. * Creates a new ValueAndUnit
  12194. * @param value defines the value to store
  12195. * @param unit defines the unit to store
  12196. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12197. */
  12198. function ValueAndUnit(value,
  12199. /** defines the unit to store */
  12200. unit,
  12201. /** defines a boolean indicating if the value can be negative */
  12202. negativeValueAllowed) {
  12203. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12204. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12205. this.unit = unit;
  12206. this.negativeValueAllowed = negativeValueAllowed;
  12207. this._value = 1;
  12208. /**
  12209. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12210. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12211. */
  12212. this.ignoreAdaptiveScaling = false;
  12213. this._value = value;
  12214. this._originalUnit = unit;
  12215. }
  12216. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12217. /** Gets a boolean indicating if the value is a percentage */
  12218. get: function () {
  12219. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12220. },
  12221. enumerable: true,
  12222. configurable: true
  12223. });
  12224. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12225. /** Gets a boolean indicating if the value is store as pixel */
  12226. get: function () {
  12227. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12228. },
  12229. enumerable: true,
  12230. configurable: true
  12231. });
  12232. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12233. /** Gets direct internal value */
  12234. get: function () {
  12235. return this._value;
  12236. },
  12237. enumerable: true,
  12238. configurable: true
  12239. });
  12240. /**
  12241. * Gets value as pixel
  12242. * @param host defines the root host
  12243. * @param refValue defines the reference value for percentages
  12244. * @returns the value as pixel
  12245. */
  12246. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12247. if (this.isPixel) {
  12248. return this.getValue(host);
  12249. }
  12250. return this.getValue(host) * refValue;
  12251. };
  12252. /**
  12253. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12254. * @param value defines the value to store
  12255. * @param unit defines the unit to store
  12256. * @returns the current ValueAndUnit
  12257. */
  12258. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12259. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12260. this._value = value;
  12261. this.unit = unit;
  12262. return this;
  12263. };
  12264. /**
  12265. * Gets the value accordingly to its unit
  12266. * @param host defines the root host
  12267. * @returns the value
  12268. */
  12269. ValueAndUnit.prototype.getValue = function (host) {
  12270. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12271. var width = 0;
  12272. var height = 0;
  12273. if (host.idealWidth) {
  12274. width = (this._value * host.getSize().width) / host.idealWidth;
  12275. }
  12276. if (host.idealHeight) {
  12277. height = (this._value * host.getSize().height) / host.idealHeight;
  12278. }
  12279. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12280. return window.innerWidth < window.innerHeight ? width : height;
  12281. }
  12282. if (host.idealWidth) { // horizontal
  12283. return width;
  12284. }
  12285. if (host.idealHeight) { // vertical
  12286. return height;
  12287. }
  12288. }
  12289. return this._value;
  12290. };
  12291. /**
  12292. * Gets a string representation of the value
  12293. * @param host defines the root host
  12294. * @param decimals defines an optional number of decimals to display
  12295. * @returns a string
  12296. */
  12297. ValueAndUnit.prototype.toString = function (host, decimals) {
  12298. switch (this.unit) {
  12299. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12300. var percentage = this.getValue(host) * 100;
  12301. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12302. case ValueAndUnit.UNITMODE_PIXEL:
  12303. var pixels = this.getValue(host);
  12304. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12305. }
  12306. return this.unit.toString();
  12307. };
  12308. /**
  12309. * Store a value parsed from a string
  12310. * @param source defines the source string
  12311. * @returns true if the value was successfully parsed
  12312. */
  12313. ValueAndUnit.prototype.fromString = function (source) {
  12314. var match = ValueAndUnit._Regex.exec(source.toString());
  12315. if (!match || match.length === 0) {
  12316. return false;
  12317. }
  12318. var sourceValue = parseFloat(match[1]);
  12319. var sourceUnit = this._originalUnit;
  12320. if (!this.negativeValueAllowed) {
  12321. if (sourceValue < 0) {
  12322. sourceValue = 0;
  12323. }
  12324. }
  12325. if (match.length === 4) {
  12326. switch (match[3]) {
  12327. case "px":
  12328. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12329. break;
  12330. case "%":
  12331. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12332. sourceValue /= 100.0;
  12333. break;
  12334. }
  12335. }
  12336. if (sourceValue === this._value && sourceUnit === this.unit) {
  12337. return false;
  12338. }
  12339. this._value = sourceValue;
  12340. this.unit = sourceUnit;
  12341. return true;
  12342. };
  12343. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12344. /** UNITMODE_PERCENTAGE */
  12345. get: function () {
  12346. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12347. },
  12348. enumerable: true,
  12349. configurable: true
  12350. });
  12351. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12352. /** UNITMODE_PIXEL */
  12353. get: function () {
  12354. return ValueAndUnit._UNITMODE_PIXEL;
  12355. },
  12356. enumerable: true,
  12357. configurable: true
  12358. });
  12359. // Static
  12360. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12361. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12362. ValueAndUnit._UNITMODE_PIXEL = 1;
  12363. return ValueAndUnit;
  12364. }());
  12365. /***/ }),
  12366. /***/ "./3D/controls/abstractButton3D.ts":
  12367. /*!*****************************************!*\
  12368. !*** ./3D/controls/abstractButton3D.ts ***!
  12369. \*****************************************/
  12370. /*! exports provided: AbstractButton3D */
  12371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12372. "use strict";
  12373. __webpack_require__.r(__webpack_exports__);
  12374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12375. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12376. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  12377. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12378. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12379. /**
  12380. * Class used as a root to all buttons
  12381. */
  12382. var AbstractButton3D = /** @class */ (function (_super) {
  12383. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12384. /**
  12385. * Creates a new button
  12386. * @param name defines the control name
  12387. */
  12388. function AbstractButton3D(name) {
  12389. return _super.call(this, name) || this;
  12390. }
  12391. AbstractButton3D.prototype._getTypeName = function () {
  12392. return "AbstractButton3D";
  12393. };
  12394. // Mesh association
  12395. AbstractButton3D.prototype._createNode = function (scene) {
  12396. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12397. };
  12398. return AbstractButton3D;
  12399. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12400. /***/ }),
  12401. /***/ "./3D/controls/button3D.ts":
  12402. /*!*********************************!*\
  12403. !*** ./3D/controls/button3D.ts ***!
  12404. \*********************************/
  12405. /*! exports provided: Button3D */
  12406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12407. "use strict";
  12408. __webpack_require__.r(__webpack_exports__);
  12409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12410. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12411. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12412. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12413. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12414. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12415. /**
  12416. * Class used to create a button in 3D
  12417. */
  12418. var Button3D = /** @class */ (function (_super) {
  12419. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12420. /**
  12421. * Creates a new button
  12422. * @param name defines the control name
  12423. */
  12424. function Button3D(name) {
  12425. var _this = _super.call(this, name) || this;
  12426. _this._contentResolution = 512;
  12427. _this._contentScaleRatio = 2;
  12428. // Default animations
  12429. _this.pointerEnterAnimation = function () {
  12430. if (!_this.mesh) {
  12431. return;
  12432. }
  12433. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12434. };
  12435. _this.pointerOutAnimation = function () {
  12436. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12437. };
  12438. _this.pointerDownAnimation = function () {
  12439. if (!_this.mesh) {
  12440. return;
  12441. }
  12442. _this.mesh.scaling.scaleInPlace(0.95);
  12443. };
  12444. _this.pointerUpAnimation = function () {
  12445. if (!_this.mesh) {
  12446. return;
  12447. }
  12448. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12449. };
  12450. return _this;
  12451. }
  12452. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12453. /**
  12454. * Gets or sets the texture resolution used to render content (512 by default)
  12455. */
  12456. get: function () {
  12457. return this._contentResolution;
  12458. },
  12459. set: function (value) {
  12460. if (this._contentResolution === value) {
  12461. return;
  12462. }
  12463. this._contentResolution = value;
  12464. this._resetContent();
  12465. },
  12466. enumerable: true,
  12467. configurable: true
  12468. });
  12469. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12470. /**
  12471. * Gets or sets the texture scale ratio used to render content (2 by default)
  12472. */
  12473. get: function () {
  12474. return this._contentScaleRatio;
  12475. },
  12476. set: function (value) {
  12477. if (this._contentScaleRatio === value) {
  12478. return;
  12479. }
  12480. this._contentScaleRatio = value;
  12481. this._resetContent();
  12482. },
  12483. enumerable: true,
  12484. configurable: true
  12485. });
  12486. Button3D.prototype._disposeFacadeTexture = function () {
  12487. if (this._facadeTexture) {
  12488. this._facadeTexture.dispose();
  12489. this._facadeTexture = null;
  12490. }
  12491. };
  12492. Button3D.prototype._resetContent = function () {
  12493. this._disposeFacadeTexture();
  12494. this.content = this._content;
  12495. };
  12496. Object.defineProperty(Button3D.prototype, "content", {
  12497. /**
  12498. * Gets or sets the GUI 2D content used to display the button's facade
  12499. */
  12500. get: function () {
  12501. return this._content;
  12502. },
  12503. set: function (value) {
  12504. this._content = value;
  12505. if (!this._host || !this._host.utilityLayer) {
  12506. return;
  12507. }
  12508. if (!this._facadeTexture) {
  12509. 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);
  12510. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12511. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12512. this._facadeTexture.premulAlpha = true;
  12513. }
  12514. this._facadeTexture.addControl(value);
  12515. this._applyFacade(this._facadeTexture);
  12516. },
  12517. enumerable: true,
  12518. configurable: true
  12519. });
  12520. /**
  12521. * Apply the facade texture (created from the content property).
  12522. * This function can be overloaded by child classes
  12523. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12524. */
  12525. Button3D.prototype._applyFacade = function (facadeTexture) {
  12526. this._currentMaterial.emissiveTexture = facadeTexture;
  12527. };
  12528. Button3D.prototype._getTypeName = function () {
  12529. return "Button3D";
  12530. };
  12531. // Mesh association
  12532. Button3D.prototype._createNode = function (scene) {
  12533. var faceUV = new Array(6);
  12534. for (var i = 0; i < 6; i++) {
  12535. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12536. }
  12537. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12538. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12539. width: 1.0,
  12540. height: 1.0,
  12541. depth: 0.08,
  12542. faceUV: faceUV
  12543. }, scene);
  12544. return mesh;
  12545. };
  12546. Button3D.prototype._affectMaterial = function (mesh) {
  12547. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12548. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12549. mesh.material = material;
  12550. this._currentMaterial = material;
  12551. this._resetContent();
  12552. };
  12553. /**
  12554. * Releases all associated resources
  12555. */
  12556. Button3D.prototype.dispose = function () {
  12557. _super.prototype.dispose.call(this);
  12558. this._disposeFacadeTexture();
  12559. if (this._currentMaterial) {
  12560. this._currentMaterial.dispose();
  12561. }
  12562. };
  12563. return Button3D;
  12564. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12565. /***/ }),
  12566. /***/ "./3D/controls/container3D.ts":
  12567. /*!************************************!*\
  12568. !*** ./3D/controls/container3D.ts ***!
  12569. \************************************/
  12570. /*! exports provided: Container3D */
  12571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12572. "use strict";
  12573. __webpack_require__.r(__webpack_exports__);
  12574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12575. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12576. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  12577. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12578. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12579. /**
  12580. * Class used to create containers for controls
  12581. */
  12582. var Container3D = /** @class */ (function (_super) {
  12583. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12584. /**
  12585. * Creates a new container
  12586. * @param name defines the container name
  12587. */
  12588. function Container3D(name) {
  12589. var _this = _super.call(this, name) || this;
  12590. _this._blockLayout = false;
  12591. /**
  12592. * Gets the list of child controls
  12593. */
  12594. _this._children = new Array();
  12595. return _this;
  12596. }
  12597. Object.defineProperty(Container3D.prototype, "children", {
  12598. /**
  12599. * Gets the list of child controls
  12600. */
  12601. get: function () {
  12602. return this._children;
  12603. },
  12604. enumerable: true,
  12605. configurable: true
  12606. });
  12607. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12608. /**
  12609. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12610. * This is helpful to optimize layout operation when adding multiple children in a row
  12611. */
  12612. get: function () {
  12613. return this._blockLayout;
  12614. },
  12615. set: function (value) {
  12616. if (this._blockLayout === value) {
  12617. return;
  12618. }
  12619. this._blockLayout = value;
  12620. if (!this._blockLayout) {
  12621. this._arrangeChildren();
  12622. }
  12623. },
  12624. enumerable: true,
  12625. configurable: true
  12626. });
  12627. /**
  12628. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12629. * @returns the current container
  12630. */
  12631. Container3D.prototype.updateLayout = function () {
  12632. this._arrangeChildren();
  12633. return this;
  12634. };
  12635. /**
  12636. * Gets a boolean indicating if the given control is in the children of this control
  12637. * @param control defines the control to check
  12638. * @returns true if the control is in the child list
  12639. */
  12640. Container3D.prototype.containsControl = function (control) {
  12641. return this._children.indexOf(control) !== -1;
  12642. };
  12643. /**
  12644. * Adds a control to the children of this control
  12645. * @param control defines the control to add
  12646. * @returns the current container
  12647. */
  12648. Container3D.prototype.addControl = function (control) {
  12649. var index = this._children.indexOf(control);
  12650. if (index !== -1) {
  12651. return this;
  12652. }
  12653. control.parent = this;
  12654. control._host = this._host;
  12655. this._children.push(control);
  12656. if (this._host.utilityLayer) {
  12657. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12658. if (control.node) {
  12659. control.node.parent = this.node;
  12660. }
  12661. if (!this.blockLayout) {
  12662. this._arrangeChildren();
  12663. }
  12664. }
  12665. return this;
  12666. };
  12667. /**
  12668. * This function will be called everytime a new control is added
  12669. */
  12670. Container3D.prototype._arrangeChildren = function () {
  12671. };
  12672. Container3D.prototype._createNode = function (scene) {
  12673. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12674. };
  12675. /**
  12676. * Removes a control from the children of this control
  12677. * @param control defines the control to remove
  12678. * @returns the current container
  12679. */
  12680. Container3D.prototype.removeControl = function (control) {
  12681. var index = this._children.indexOf(control);
  12682. if (index !== -1) {
  12683. this._children.splice(index, 1);
  12684. control.parent = null;
  12685. control._disposeNode();
  12686. }
  12687. return this;
  12688. };
  12689. Container3D.prototype._getTypeName = function () {
  12690. return "Container3D";
  12691. };
  12692. /**
  12693. * Releases all associated resources
  12694. */
  12695. Container3D.prototype.dispose = function () {
  12696. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12697. var control = _a[_i];
  12698. control.dispose();
  12699. }
  12700. this._children = [];
  12701. _super.prototype.dispose.call(this);
  12702. };
  12703. /** Control rotation will remain unchanged */
  12704. Container3D.UNSET_ORIENTATION = 0;
  12705. /** Control will rotate to make it look at sphere central axis */
  12706. Container3D.FACEORIGIN_ORIENTATION = 1;
  12707. /** Control will rotate to make it look back at sphere central axis */
  12708. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12709. /** Control will rotate to look at z axis (0, 0, 1) */
  12710. Container3D.FACEFORWARD_ORIENTATION = 3;
  12711. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12712. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12713. return Container3D;
  12714. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12715. /***/ }),
  12716. /***/ "./3D/controls/control3D.ts":
  12717. /*!**********************************!*\
  12718. !*** ./3D/controls/control3D.ts ***!
  12719. \**********************************/
  12720. /*! exports provided: Control3D */
  12721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12722. "use strict";
  12723. __webpack_require__.r(__webpack_exports__);
  12724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12725. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12726. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12727. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12728. /**
  12729. * Class used as base class for controls
  12730. */
  12731. var Control3D = /** @class */ (function () {
  12732. /**
  12733. * Creates a new control
  12734. * @param name defines the control name
  12735. */
  12736. function Control3D(
  12737. /** Defines the control name */
  12738. name) {
  12739. this.name = name;
  12740. this._downCount = 0;
  12741. this._enterCount = -1;
  12742. this._downPointerIds = {};
  12743. this._isVisible = true;
  12744. /**
  12745. * An event triggered when the pointer move over the control
  12746. */
  12747. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12748. /**
  12749. * An event triggered when the pointer move out of the control
  12750. */
  12751. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12752. /**
  12753. * An event triggered when the pointer taps the control
  12754. */
  12755. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12756. /**
  12757. * An event triggered when pointer is up
  12758. */
  12759. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12760. /**
  12761. * An event triggered when a control is clicked on (with a mouse)
  12762. */
  12763. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12764. /**
  12765. * An event triggered when pointer enters the control
  12766. */
  12767. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12768. // Behaviors
  12769. this._behaviors = new Array();
  12770. }
  12771. Object.defineProperty(Control3D.prototype, "position", {
  12772. /** Gets or sets the control position in world space */
  12773. get: function () {
  12774. if (!this._node) {
  12775. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12776. }
  12777. return this._node.position;
  12778. },
  12779. set: function (value) {
  12780. if (!this._node) {
  12781. return;
  12782. }
  12783. this._node.position = value;
  12784. },
  12785. enumerable: true,
  12786. configurable: true
  12787. });
  12788. Object.defineProperty(Control3D.prototype, "scaling", {
  12789. /** Gets or sets the control scaling in world space */
  12790. get: function () {
  12791. if (!this._node) {
  12792. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12793. }
  12794. return this._node.scaling;
  12795. },
  12796. set: function (value) {
  12797. if (!this._node) {
  12798. return;
  12799. }
  12800. this._node.scaling = value;
  12801. },
  12802. enumerable: true,
  12803. configurable: true
  12804. });
  12805. Object.defineProperty(Control3D.prototype, "behaviors", {
  12806. /**
  12807. * Gets the list of attached behaviors
  12808. * @see http://doc.babylonjs.com/features/behaviour
  12809. */
  12810. get: function () {
  12811. return this._behaviors;
  12812. },
  12813. enumerable: true,
  12814. configurable: true
  12815. });
  12816. /**
  12817. * Attach a behavior to the control
  12818. * @see http://doc.babylonjs.com/features/behaviour
  12819. * @param behavior defines the behavior to attach
  12820. * @returns the current control
  12821. */
  12822. Control3D.prototype.addBehavior = function (behavior) {
  12823. var _this = this;
  12824. var index = this._behaviors.indexOf(behavior);
  12825. if (index !== -1) {
  12826. return this;
  12827. }
  12828. behavior.init();
  12829. var scene = this._host.scene;
  12830. if (scene.isLoading) {
  12831. // We defer the attach when the scene will be loaded
  12832. scene.onDataLoadedObservable.addOnce(function () {
  12833. behavior.attach(_this);
  12834. });
  12835. }
  12836. else {
  12837. behavior.attach(this);
  12838. }
  12839. this._behaviors.push(behavior);
  12840. return this;
  12841. };
  12842. /**
  12843. * Remove an attached behavior
  12844. * @see http://doc.babylonjs.com/features/behaviour
  12845. * @param behavior defines the behavior to attach
  12846. * @returns the current control
  12847. */
  12848. Control3D.prototype.removeBehavior = function (behavior) {
  12849. var index = this._behaviors.indexOf(behavior);
  12850. if (index === -1) {
  12851. return this;
  12852. }
  12853. this._behaviors[index].detach();
  12854. this._behaviors.splice(index, 1);
  12855. return this;
  12856. };
  12857. /**
  12858. * Gets an attached behavior by name
  12859. * @param name defines the name of the behavior to look for
  12860. * @see http://doc.babylonjs.com/features/behaviour
  12861. * @returns null if behavior was not found else the requested behavior
  12862. */
  12863. Control3D.prototype.getBehaviorByName = function (name) {
  12864. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12865. var behavior = _a[_i];
  12866. if (behavior.name === name) {
  12867. return behavior;
  12868. }
  12869. }
  12870. return null;
  12871. };
  12872. Object.defineProperty(Control3D.prototype, "isVisible", {
  12873. /** Gets or sets a boolean indicating if the control is visible */
  12874. get: function () {
  12875. return this._isVisible;
  12876. },
  12877. set: function (value) {
  12878. if (this._isVisible === value) {
  12879. return;
  12880. }
  12881. this._isVisible = value;
  12882. var mesh = this.mesh;
  12883. if (mesh) {
  12884. mesh.setEnabled(value);
  12885. }
  12886. },
  12887. enumerable: true,
  12888. configurable: true
  12889. });
  12890. Object.defineProperty(Control3D.prototype, "typeName", {
  12891. /**
  12892. * Gets a string representing the class name
  12893. */
  12894. get: function () {
  12895. return this._getTypeName();
  12896. },
  12897. enumerable: true,
  12898. configurable: true
  12899. });
  12900. /**
  12901. * Get the current class name of the control.
  12902. * @returns current class name
  12903. */
  12904. Control3D.prototype.getClassName = function () {
  12905. return this._getTypeName();
  12906. };
  12907. Control3D.prototype._getTypeName = function () {
  12908. return "Control3D";
  12909. };
  12910. Object.defineProperty(Control3D.prototype, "node", {
  12911. /**
  12912. * Gets the transform node used by this control
  12913. */
  12914. get: function () {
  12915. return this._node;
  12916. },
  12917. enumerable: true,
  12918. configurable: true
  12919. });
  12920. Object.defineProperty(Control3D.prototype, "mesh", {
  12921. /**
  12922. * Gets the mesh used to render this control
  12923. */
  12924. get: function () {
  12925. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12926. return this._node;
  12927. }
  12928. return null;
  12929. },
  12930. enumerable: true,
  12931. configurable: true
  12932. });
  12933. /**
  12934. * Link the control as child of the given node
  12935. * @param node defines the node to link to. Use null to unlink the control
  12936. * @returns the current control
  12937. */
  12938. Control3D.prototype.linkToTransformNode = function (node) {
  12939. if (this._node) {
  12940. this._node.parent = node;
  12941. }
  12942. return this;
  12943. };
  12944. /** @hidden **/
  12945. Control3D.prototype._prepareNode = function (scene) {
  12946. if (!this._node) {
  12947. this._node = this._createNode(scene);
  12948. if (!this.node) {
  12949. return;
  12950. }
  12951. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12952. this._node.position = this.position;
  12953. this._node.scaling = this.scaling;
  12954. var mesh = this.mesh;
  12955. if (mesh) {
  12956. mesh.isPickable = true;
  12957. this._affectMaterial(mesh);
  12958. }
  12959. }
  12960. };
  12961. /**
  12962. * Node creation.
  12963. * Can be overriden by children
  12964. * @param scene defines the scene where the node must be attached
  12965. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12966. */
  12967. Control3D.prototype._createNode = function (scene) {
  12968. // Do nothing by default
  12969. return null;
  12970. };
  12971. /**
  12972. * Affect a material to the given mesh
  12973. * @param mesh defines the mesh which will represent the control
  12974. */
  12975. Control3D.prototype._affectMaterial = function (mesh) {
  12976. mesh.material = null;
  12977. };
  12978. // Pointers
  12979. /** @hidden */
  12980. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12981. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12982. };
  12983. /** @hidden */
  12984. Control3D.prototype._onPointerEnter = function (target) {
  12985. if (this._enterCount > 0) {
  12986. return false;
  12987. }
  12988. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12989. this._enterCount = 0;
  12990. }
  12991. this._enterCount++;
  12992. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12993. if (this.pointerEnterAnimation) {
  12994. this.pointerEnterAnimation();
  12995. }
  12996. return true;
  12997. };
  12998. /** @hidden */
  12999. Control3D.prototype._onPointerOut = function (target) {
  13000. this._enterCount = 0;
  13001. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13002. if (this.pointerOutAnimation) {
  13003. this.pointerOutAnimation();
  13004. }
  13005. };
  13006. /** @hidden */
  13007. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13008. if (this._downCount !== 0) {
  13009. this._downCount++;
  13010. return false;
  13011. }
  13012. this._downCount++;
  13013. this._downPointerIds[pointerId] = true;
  13014. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13015. if (this.pointerDownAnimation) {
  13016. this.pointerDownAnimation();
  13017. }
  13018. return true;
  13019. };
  13020. /** @hidden */
  13021. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13022. this._downCount--;
  13023. delete this._downPointerIds[pointerId];
  13024. if (this._downCount < 0) {
  13025. // Handle if forcePointerUp was called prior to this
  13026. this._downCount = 0;
  13027. return;
  13028. }
  13029. if (this._downCount == 0) {
  13030. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13031. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13032. }
  13033. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13034. if (this.pointerUpAnimation) {
  13035. this.pointerUpAnimation();
  13036. }
  13037. }
  13038. };
  13039. /** @hidden */
  13040. Control3D.prototype.forcePointerUp = function (pointerId) {
  13041. if (pointerId === void 0) { pointerId = null; }
  13042. if (pointerId !== null) {
  13043. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13044. }
  13045. else {
  13046. for (var key in this._downPointerIds) {
  13047. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13048. }
  13049. if (this._downCount > 0) {
  13050. this._downCount = 1;
  13051. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13052. }
  13053. }
  13054. };
  13055. /** @hidden */
  13056. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13057. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13058. this._onPointerMove(this, pickedPoint);
  13059. var previousControlOver = this._host._lastControlOver[pointerId];
  13060. if (previousControlOver && previousControlOver !== this) {
  13061. previousControlOver._onPointerOut(this);
  13062. }
  13063. if (previousControlOver !== this) {
  13064. this._onPointerEnter(this);
  13065. }
  13066. this._host._lastControlOver[pointerId] = this;
  13067. return true;
  13068. }
  13069. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13070. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13071. this._host._lastControlDown[pointerId] = this;
  13072. this._host._lastPickedControl = this;
  13073. return true;
  13074. }
  13075. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13076. if (this._host._lastControlDown[pointerId]) {
  13077. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13078. }
  13079. delete this._host._lastControlDown[pointerId];
  13080. return true;
  13081. }
  13082. return false;
  13083. };
  13084. /** @hidden */
  13085. Control3D.prototype._disposeNode = function () {
  13086. if (this._node) {
  13087. this._node.dispose();
  13088. this._node = null;
  13089. }
  13090. };
  13091. /**
  13092. * Releases all associated resources
  13093. */
  13094. Control3D.prototype.dispose = function () {
  13095. this.onPointerDownObservable.clear();
  13096. this.onPointerEnterObservable.clear();
  13097. this.onPointerMoveObservable.clear();
  13098. this.onPointerOutObservable.clear();
  13099. this.onPointerUpObservable.clear();
  13100. this.onPointerClickObservable.clear();
  13101. this._disposeNode();
  13102. // Behaviors
  13103. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13104. var behavior = _a[_i];
  13105. behavior.detach();
  13106. }
  13107. };
  13108. return Control3D;
  13109. }());
  13110. /***/ }),
  13111. /***/ "./3D/controls/cylinderPanel.ts":
  13112. /*!**************************************!*\
  13113. !*** ./3D/controls/cylinderPanel.ts ***!
  13114. \**************************************/
  13115. /*! exports provided: CylinderPanel */
  13116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13117. "use strict";
  13118. __webpack_require__.r(__webpack_exports__);
  13119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13120. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13121. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13122. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13123. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13124. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13125. /**
  13126. * Class used to create a container panel deployed on the surface of a cylinder
  13127. */
  13128. var CylinderPanel = /** @class */ (function (_super) {
  13129. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13130. function CylinderPanel() {
  13131. var _this = _super !== null && _super.apply(this, arguments) || this;
  13132. _this._radius = 5.0;
  13133. return _this;
  13134. }
  13135. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13136. /**
  13137. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13138. */
  13139. get: function () {
  13140. return this._radius;
  13141. },
  13142. set: function (value) {
  13143. var _this = this;
  13144. if (this._radius === value) {
  13145. return;
  13146. }
  13147. this._radius = value;
  13148. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13149. _this._arrangeChildren();
  13150. });
  13151. },
  13152. enumerable: true,
  13153. configurable: true
  13154. });
  13155. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13156. var mesh = control.mesh;
  13157. if (!mesh) {
  13158. return;
  13159. }
  13160. var newPos = this._cylindricalMapping(nodePosition);
  13161. control.position = newPos;
  13162. switch (this.orientation) {
  13163. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13164. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13165. break;
  13166. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13167. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13168. break;
  13169. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13170. break;
  13171. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13172. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13173. break;
  13174. }
  13175. };
  13176. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13177. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13178. var yAngle = (source.x / this._radius);
  13179. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13180. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13181. };
  13182. return CylinderPanel;
  13183. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13184. /***/ }),
  13185. /***/ "./3D/controls/holographicButton.ts":
  13186. /*!******************************************!*\
  13187. !*** ./3D/controls/holographicButton.ts ***!
  13188. \******************************************/
  13189. /*! exports provided: HolographicButton */
  13190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13191. "use strict";
  13192. __webpack_require__.r(__webpack_exports__);
  13193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13194. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13195. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13196. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13197. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13198. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13199. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13200. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13201. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13202. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13203. /**
  13204. * Class used to create a holographic button in 3D
  13205. */
  13206. var HolographicButton = /** @class */ (function (_super) {
  13207. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13208. /**
  13209. * Creates a new button
  13210. * @param name defines the control name
  13211. */
  13212. function HolographicButton(name, shareMaterials) {
  13213. if (shareMaterials === void 0) { shareMaterials = true; }
  13214. var _this = _super.call(this, name) || this;
  13215. _this._shareMaterials = true;
  13216. _this._shareMaterials = shareMaterials;
  13217. // Default animations
  13218. _this.pointerEnterAnimation = function () {
  13219. if (!_this.mesh) {
  13220. return;
  13221. }
  13222. _this._frontPlate.setEnabled(true);
  13223. };
  13224. _this.pointerOutAnimation = function () {
  13225. if (!_this.mesh) {
  13226. return;
  13227. }
  13228. _this._frontPlate.setEnabled(false);
  13229. };
  13230. return _this;
  13231. }
  13232. HolographicButton.prototype._disposeTooltip = function () {
  13233. this._tooltipFade = null;
  13234. if (this._tooltipTextBlock) {
  13235. this._tooltipTextBlock.dispose();
  13236. }
  13237. if (this._tooltipTexture) {
  13238. this._tooltipTexture.dispose();
  13239. }
  13240. if (this._tooltipMesh) {
  13241. this._tooltipMesh.dispose();
  13242. }
  13243. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13244. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13245. };
  13246. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13247. get: function () {
  13248. if (this._tooltipTextBlock) {
  13249. return this._tooltipTextBlock.text;
  13250. }
  13251. return null;
  13252. },
  13253. /**
  13254. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13255. */
  13256. set: function (text) {
  13257. var _this = this;
  13258. if (!text) {
  13259. this._disposeTooltip();
  13260. return;
  13261. }
  13262. if (!this._tooltipFade) {
  13263. // Create tooltip with mesh and text
  13264. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13265. 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);
  13266. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13267. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13268. tooltipBackground.material = mat;
  13269. tooltipBackground.isPickable = false;
  13270. this._tooltipMesh.addChild(tooltipBackground);
  13271. tooltipBackground.position.z = 0.05;
  13272. this._tooltipMesh.scaling.y = 1 / 3;
  13273. this._tooltipMesh.position.y = 0.7;
  13274. this._tooltipMesh.position.z = -0.15;
  13275. this._tooltipMesh.isPickable = false;
  13276. this._tooltipMesh.parent = this._backPlate;
  13277. // Create text texture for the tooltip
  13278. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13279. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13280. this._tooltipTextBlock.scaleY = 3;
  13281. this._tooltipTextBlock.color = "white";
  13282. this._tooltipTextBlock.fontSize = 130;
  13283. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13284. // Add hover action to tooltip
  13285. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13286. this._tooltipFade.delay = 500;
  13287. this._tooltipMesh.addBehavior(this._tooltipFade);
  13288. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13289. if (_this._tooltipFade) {
  13290. _this._tooltipFade.fadeIn(true);
  13291. }
  13292. });
  13293. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13294. if (_this._tooltipFade) {
  13295. _this._tooltipFade.fadeIn(false);
  13296. }
  13297. });
  13298. }
  13299. if (this._tooltipTextBlock) {
  13300. this._tooltipTextBlock.text = text;
  13301. }
  13302. },
  13303. enumerable: true,
  13304. configurable: true
  13305. });
  13306. Object.defineProperty(HolographicButton.prototype, "text", {
  13307. /**
  13308. * Gets or sets text for the button
  13309. */
  13310. get: function () {
  13311. return this._text;
  13312. },
  13313. set: function (value) {
  13314. if (this._text === value) {
  13315. return;
  13316. }
  13317. this._text = value;
  13318. this._rebuildContent();
  13319. },
  13320. enumerable: true,
  13321. configurable: true
  13322. });
  13323. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13324. /**
  13325. * Gets or sets the image url for the button
  13326. */
  13327. get: function () {
  13328. return this._imageUrl;
  13329. },
  13330. set: function (value) {
  13331. if (this._imageUrl === value) {
  13332. return;
  13333. }
  13334. this._imageUrl = value;
  13335. this._rebuildContent();
  13336. },
  13337. enumerable: true,
  13338. configurable: true
  13339. });
  13340. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13341. /**
  13342. * Gets the back material used by this button
  13343. */
  13344. get: function () {
  13345. return this._backMaterial;
  13346. },
  13347. enumerable: true,
  13348. configurable: true
  13349. });
  13350. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13351. /**
  13352. * Gets the front material used by this button
  13353. */
  13354. get: function () {
  13355. return this._frontMaterial;
  13356. },
  13357. enumerable: true,
  13358. configurable: true
  13359. });
  13360. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13361. /**
  13362. * Gets the plate material used by this button
  13363. */
  13364. get: function () {
  13365. return this._plateMaterial;
  13366. },
  13367. enumerable: true,
  13368. configurable: true
  13369. });
  13370. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13371. /**
  13372. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13373. */
  13374. get: function () {
  13375. return this._shareMaterials;
  13376. },
  13377. enumerable: true,
  13378. configurable: true
  13379. });
  13380. HolographicButton.prototype._getTypeName = function () {
  13381. return "HolographicButton";
  13382. };
  13383. HolographicButton.prototype._rebuildContent = function () {
  13384. this._disposeFacadeTexture();
  13385. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13386. panel.isVertical = true;
  13387. if (this._imageUrl) {
  13388. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13389. image.source = this._imageUrl;
  13390. image.paddingTop = "40px";
  13391. image.height = "180px";
  13392. image.width = "100px";
  13393. image.paddingBottom = "40px";
  13394. panel.addControl(image);
  13395. }
  13396. if (this._text) {
  13397. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13398. text.text = this._text;
  13399. text.color = "white";
  13400. text.height = "30px";
  13401. text.fontSize = 24;
  13402. panel.addControl(text);
  13403. }
  13404. if (this._frontPlate) {
  13405. this.content = panel;
  13406. }
  13407. };
  13408. // Mesh association
  13409. HolographicButton.prototype._createNode = function (scene) {
  13410. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13411. width: 1.0,
  13412. height: 1.0,
  13413. depth: 0.08
  13414. }, scene);
  13415. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13416. width: 1.0,
  13417. height: 1.0,
  13418. depth: 0.08
  13419. }, scene);
  13420. this._frontPlate.parent = this._backPlate;
  13421. this._frontPlate.position.z = -0.08;
  13422. this._frontPlate.isPickable = false;
  13423. this._frontPlate.setEnabled(false);
  13424. this._textPlate = _super.prototype._createNode.call(this, scene);
  13425. this._textPlate.parent = this._backPlate;
  13426. this._textPlate.position.z = -0.08;
  13427. this._textPlate.isPickable = false;
  13428. return this._backPlate;
  13429. };
  13430. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13431. this._plateMaterial.emissiveTexture = facadeTexture;
  13432. this._plateMaterial.opacityTexture = facadeTexture;
  13433. };
  13434. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13435. var _this = this;
  13436. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13437. this._backMaterial.renderHoverLight = true;
  13438. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13439. if (pickedPoint) {
  13440. _this._backMaterial.hoverPosition = pickedPoint;
  13441. _this._backMaterial.hoverColor.a = 1.0;
  13442. }
  13443. else {
  13444. _this._backMaterial.hoverColor.a = 0;
  13445. }
  13446. });
  13447. };
  13448. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13449. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13450. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13451. this._frontMaterial.alpha = 0.5; // Additive
  13452. this._frontMaterial.renderBorders = true;
  13453. };
  13454. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13455. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13456. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13457. };
  13458. HolographicButton.prototype._affectMaterial = function (mesh) {
  13459. // Back
  13460. if (this._shareMaterials) {
  13461. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13462. this._createBackMaterial(mesh);
  13463. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13464. }
  13465. else {
  13466. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13467. }
  13468. // Front
  13469. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13470. this._createFrontMaterial(mesh);
  13471. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13472. }
  13473. else {
  13474. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13475. }
  13476. }
  13477. else {
  13478. this._createBackMaterial(mesh);
  13479. this._createFrontMaterial(mesh);
  13480. }
  13481. this._createPlateMaterial(mesh);
  13482. this._backPlate.material = this._backMaterial;
  13483. this._frontPlate.material = this._frontMaterial;
  13484. this._textPlate.material = this._plateMaterial;
  13485. this._rebuildContent();
  13486. };
  13487. /**
  13488. * Releases all associated resources
  13489. */
  13490. HolographicButton.prototype.dispose = function () {
  13491. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13492. this._disposeTooltip();
  13493. if (!this.shareMaterials) {
  13494. this._backMaterial.dispose();
  13495. this._frontMaterial.dispose();
  13496. this._plateMaterial.dispose();
  13497. if (this._pickedPointObserver) {
  13498. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13499. this._pickedPointObserver = null;
  13500. }
  13501. }
  13502. };
  13503. return HolographicButton;
  13504. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13505. /***/ }),
  13506. /***/ "./3D/controls/index.ts":
  13507. /*!******************************!*\
  13508. !*** ./3D/controls/index.ts ***!
  13509. \******************************/
  13510. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13512. "use strict";
  13513. __webpack_require__.r(__webpack_exports__);
  13514. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13516. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13518. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13520. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13522. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13524. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13526. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13528. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13530. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13532. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13534. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13536. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13538. /***/ }),
  13539. /***/ "./3D/controls/meshButton3D.ts":
  13540. /*!*************************************!*\
  13541. !*** ./3D/controls/meshButton3D.ts ***!
  13542. \*************************************/
  13543. /*! exports provided: MeshButton3D */
  13544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13545. "use strict";
  13546. __webpack_require__.r(__webpack_exports__);
  13547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13548. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13549. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13550. /**
  13551. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13552. */
  13553. var MeshButton3D = /** @class */ (function (_super) {
  13554. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13555. /**
  13556. * Creates a new 3D button based on a mesh
  13557. * @param mesh mesh to become a 3D button
  13558. * @param name defines the control name
  13559. */
  13560. function MeshButton3D(mesh, name) {
  13561. var _this = _super.call(this, name) || this;
  13562. _this._currentMesh = mesh;
  13563. /**
  13564. * Provides a default behavior on hover/out & up/down
  13565. * Override those function to create your own desired behavior specific to your mesh
  13566. */
  13567. _this.pointerEnterAnimation = function () {
  13568. if (!_this.mesh) {
  13569. return;
  13570. }
  13571. _this.mesh.scaling.scaleInPlace(1.1);
  13572. };
  13573. _this.pointerOutAnimation = function () {
  13574. if (!_this.mesh) {
  13575. return;
  13576. }
  13577. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13578. };
  13579. _this.pointerDownAnimation = function () {
  13580. if (!_this.mesh) {
  13581. return;
  13582. }
  13583. _this.mesh.scaling.scaleInPlace(0.95);
  13584. };
  13585. _this.pointerUpAnimation = function () {
  13586. if (!_this.mesh) {
  13587. return;
  13588. }
  13589. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13590. };
  13591. return _this;
  13592. }
  13593. MeshButton3D.prototype._getTypeName = function () {
  13594. return "MeshButton3D";
  13595. };
  13596. // Mesh association
  13597. MeshButton3D.prototype._createNode = function (scene) {
  13598. var _this = this;
  13599. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13600. mesh.metadata = _this;
  13601. });
  13602. return this._currentMesh;
  13603. };
  13604. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13605. };
  13606. return MeshButton3D;
  13607. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13608. /***/ }),
  13609. /***/ "./3D/controls/planePanel.ts":
  13610. /*!***********************************!*\
  13611. !*** ./3D/controls/planePanel.ts ***!
  13612. \***********************************/
  13613. /*! exports provided: PlanePanel */
  13614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13615. "use strict";
  13616. __webpack_require__.r(__webpack_exports__);
  13617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13618. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13619. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13620. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13621. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13622. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13623. /**
  13624. * Class used to create a container panel deployed on the surface of a plane
  13625. */
  13626. var PlanePanel = /** @class */ (function (_super) {
  13627. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13628. function PlanePanel() {
  13629. return _super !== null && _super.apply(this, arguments) || this;
  13630. }
  13631. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13632. var mesh = control.mesh;
  13633. if (!mesh) {
  13634. return;
  13635. }
  13636. control.position = nodePosition.clone();
  13637. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13638. target.copyFrom(nodePosition);
  13639. switch (this.orientation) {
  13640. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13641. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13642. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13643. mesh.lookAt(target);
  13644. break;
  13645. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13646. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13647. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13648. mesh.lookAt(target);
  13649. break;
  13650. }
  13651. };
  13652. return PlanePanel;
  13653. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13654. /***/ }),
  13655. /***/ "./3D/controls/scatterPanel.ts":
  13656. /*!*************************************!*\
  13657. !*** ./3D/controls/scatterPanel.ts ***!
  13658. \*************************************/
  13659. /*! exports provided: ScatterPanel */
  13660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13661. "use strict";
  13662. __webpack_require__.r(__webpack_exports__);
  13663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13664. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13665. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13666. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13667. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13668. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13669. /**
  13670. * Class used to create a container panel where items get randomized planar mapping
  13671. */
  13672. var ScatterPanel = /** @class */ (function (_super) {
  13673. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13674. function ScatterPanel() {
  13675. var _this = _super !== null && _super.apply(this, arguments) || this;
  13676. _this._iteration = 100.0;
  13677. return _this;
  13678. }
  13679. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13680. /**
  13681. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13682. */
  13683. get: function () {
  13684. return this._iteration;
  13685. },
  13686. set: function (value) {
  13687. var _this = this;
  13688. if (this._iteration === value) {
  13689. return;
  13690. }
  13691. this._iteration = value;
  13692. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13693. _this._arrangeChildren();
  13694. });
  13695. },
  13696. enumerable: true,
  13697. configurable: true
  13698. });
  13699. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13700. var mesh = control.mesh;
  13701. var newPos = this._scatterMapping(nodePosition);
  13702. if (!mesh) {
  13703. return;
  13704. }
  13705. switch (this.orientation) {
  13706. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13707. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13708. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13709. break;
  13710. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13711. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13712. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13713. break;
  13714. }
  13715. control.position = newPos;
  13716. };
  13717. ScatterPanel.prototype._scatterMapping = function (source) {
  13718. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13719. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13720. return source;
  13721. };
  13722. ScatterPanel.prototype._finalProcessing = function () {
  13723. var meshes = [];
  13724. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13725. var child = _a[_i];
  13726. if (!child.mesh) {
  13727. continue;
  13728. }
  13729. meshes.push(child.mesh);
  13730. }
  13731. for (var count = 0; count < this._iteration; count++) {
  13732. meshes.sort(function (a, b) {
  13733. var distance1 = a.position.lengthSquared();
  13734. var distance2 = b.position.lengthSquared();
  13735. if (distance1 < distance2) {
  13736. return 1;
  13737. }
  13738. else if (distance1 > distance2) {
  13739. return -1;
  13740. }
  13741. return 0;
  13742. });
  13743. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13744. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13745. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  13746. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13747. for (var i = 0; i < meshes.length - 1; i++) {
  13748. for (var j = i + 1; j < meshes.length; j++) {
  13749. if (i != j) {
  13750. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13751. // Ignore Z axis
  13752. difference2D.x = difference.x;
  13753. difference2D.y = difference.y;
  13754. var combinedRadius = cellSize;
  13755. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13756. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13757. distance -= minSeparation;
  13758. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13759. difference2D.normalize();
  13760. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13761. meshes[j].position.addInPlace(difference);
  13762. meshes[i].position.subtractInPlace(difference);
  13763. }
  13764. }
  13765. }
  13766. }
  13767. }
  13768. };
  13769. return ScatterPanel;
  13770. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13771. /***/ }),
  13772. /***/ "./3D/controls/spherePanel.ts":
  13773. /*!************************************!*\
  13774. !*** ./3D/controls/spherePanel.ts ***!
  13775. \************************************/
  13776. /*! exports provided: SpherePanel */
  13777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13778. "use strict";
  13779. __webpack_require__.r(__webpack_exports__);
  13780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13781. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13782. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13783. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13784. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13785. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13786. /**
  13787. * Class used to create a container panel deployed on the surface of a sphere
  13788. */
  13789. var SpherePanel = /** @class */ (function (_super) {
  13790. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13791. function SpherePanel() {
  13792. var _this = _super !== null && _super.apply(this, arguments) || this;
  13793. _this._radius = 5.0;
  13794. return _this;
  13795. }
  13796. Object.defineProperty(SpherePanel.prototype, "radius", {
  13797. /**
  13798. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13799. */
  13800. get: function () {
  13801. return this._radius;
  13802. },
  13803. set: function (value) {
  13804. var _this = this;
  13805. if (this._radius === value) {
  13806. return;
  13807. }
  13808. this._radius = value;
  13809. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13810. _this._arrangeChildren();
  13811. });
  13812. },
  13813. enumerable: true,
  13814. configurable: true
  13815. });
  13816. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13817. var mesh = control.mesh;
  13818. if (!mesh) {
  13819. return;
  13820. }
  13821. var newPos = this._sphericalMapping(nodePosition);
  13822. control.position = newPos;
  13823. switch (this.orientation) {
  13824. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13825. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13826. break;
  13827. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13828. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13829. break;
  13830. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13831. break;
  13832. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13833. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13834. break;
  13835. }
  13836. };
  13837. SpherePanel.prototype._sphericalMapping = function (source) {
  13838. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13839. var xAngle = (source.y / this._radius);
  13840. var yAngle = -(source.x / this._radius);
  13841. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13842. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13843. };
  13844. return SpherePanel;
  13845. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13846. /***/ }),
  13847. /***/ "./3D/controls/stackPanel3D.ts":
  13848. /*!*************************************!*\
  13849. !*** ./3D/controls/stackPanel3D.ts ***!
  13850. \*************************************/
  13851. /*! exports provided: StackPanel3D */
  13852. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13853. "use strict";
  13854. __webpack_require__.r(__webpack_exports__);
  13855. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13856. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13857. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13858. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13859. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13860. /**
  13861. * Class used to create a stack panel in 3D on XY plane
  13862. */
  13863. var StackPanel3D = /** @class */ (function (_super) {
  13864. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13865. /**
  13866. * Creates new StackPanel
  13867. * @param isVertical
  13868. */
  13869. function StackPanel3D(isVertical) {
  13870. if (isVertical === void 0) { isVertical = false; }
  13871. var _this = _super.call(this) || this;
  13872. _this._isVertical = false;
  13873. /**
  13874. * Gets or sets the distance between elements
  13875. */
  13876. _this.margin = 0.1;
  13877. _this._isVertical = isVertical;
  13878. return _this;
  13879. }
  13880. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13881. /**
  13882. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13883. */
  13884. get: function () {
  13885. return this._isVertical;
  13886. },
  13887. set: function (value) {
  13888. var _this = this;
  13889. if (this._isVertical === value) {
  13890. return;
  13891. }
  13892. this._isVertical = value;
  13893. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13894. _this._arrangeChildren();
  13895. });
  13896. },
  13897. enumerable: true,
  13898. configurable: true
  13899. });
  13900. StackPanel3D.prototype._arrangeChildren = function () {
  13901. var width = 0;
  13902. var height = 0;
  13903. var controlCount = 0;
  13904. var extendSizes = [];
  13905. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13906. // Measure
  13907. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13908. var child = _a[_i];
  13909. if (!child.mesh) {
  13910. continue;
  13911. }
  13912. controlCount++;
  13913. child.mesh.computeWorldMatrix(true);
  13914. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13915. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13916. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13917. extendSizes.push(extendSize);
  13918. if (this._isVertical) {
  13919. height += extendSize.y;
  13920. }
  13921. else {
  13922. width += extendSize.x;
  13923. }
  13924. }
  13925. if (this._isVertical) {
  13926. height += (controlCount - 1) * this.margin / 2;
  13927. }
  13928. else {
  13929. width += (controlCount - 1) * this.margin / 2;
  13930. }
  13931. // Arrange
  13932. var offset;
  13933. if (this._isVertical) {
  13934. offset = -height;
  13935. }
  13936. else {
  13937. offset = -width;
  13938. }
  13939. var index = 0;
  13940. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13941. var child = _c[_b];
  13942. if (!child.mesh) {
  13943. continue;
  13944. }
  13945. controlCount--;
  13946. var extendSize = extendSizes[index++];
  13947. if (this._isVertical) {
  13948. child.position.y = offset + extendSize.y;
  13949. child.position.x = 0;
  13950. offset += extendSize.y * 2;
  13951. }
  13952. else {
  13953. child.position.x = offset + extendSize.x;
  13954. child.position.y = 0;
  13955. offset += extendSize.x * 2;
  13956. }
  13957. offset += (controlCount > 0 ? this.margin : 0);
  13958. }
  13959. };
  13960. return StackPanel3D;
  13961. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13962. /***/ }),
  13963. /***/ "./3D/controls/volumeBasedPanel.ts":
  13964. /*!*****************************************!*\
  13965. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13966. \*****************************************/
  13967. /*! exports provided: VolumeBasedPanel */
  13968. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13969. "use strict";
  13970. __webpack_require__.r(__webpack_exports__);
  13971. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13972. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13973. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13974. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13975. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13976. /**
  13977. * Abstract class used to create a container panel deployed on the surface of a volume
  13978. */
  13979. var VolumeBasedPanel = /** @class */ (function (_super) {
  13980. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13981. /**
  13982. * Creates new VolumeBasedPanel
  13983. */
  13984. function VolumeBasedPanel() {
  13985. var _this = _super.call(this) || this;
  13986. _this._columns = 10;
  13987. _this._rows = 0;
  13988. _this._rowThenColum = true;
  13989. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13990. /**
  13991. * Gets or sets the distance between elements
  13992. */
  13993. _this.margin = 0;
  13994. return _this;
  13995. }
  13996. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13997. /**
  13998. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13999. * | Value | Type | Description |
  14000. * | ----- | ----------------------------------- | ----------- |
  14001. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14002. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14003. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14004. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14005. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14006. */
  14007. get: function () {
  14008. return this._orientation;
  14009. },
  14010. set: function (value) {
  14011. var _this = this;
  14012. if (this._orientation === value) {
  14013. return;
  14014. }
  14015. this._orientation = value;
  14016. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14017. _this._arrangeChildren();
  14018. });
  14019. },
  14020. enumerable: true,
  14021. configurable: true
  14022. });
  14023. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14024. /**
  14025. * Gets or sets the number of columns requested (10 by default).
  14026. * The panel will automatically compute the number of rows based on number of child controls.
  14027. */
  14028. get: function () {
  14029. return this._columns;
  14030. },
  14031. set: function (value) {
  14032. var _this = this;
  14033. if (this._columns === value) {
  14034. return;
  14035. }
  14036. this._columns = value;
  14037. this._rowThenColum = true;
  14038. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14039. _this._arrangeChildren();
  14040. });
  14041. },
  14042. enumerable: true,
  14043. configurable: true
  14044. });
  14045. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14046. /**
  14047. * Gets or sets a the number of rows requested.
  14048. * The panel will automatically compute the number of columns based on number of child controls.
  14049. */
  14050. get: function () {
  14051. return this._rows;
  14052. },
  14053. set: function (value) {
  14054. var _this = this;
  14055. if (this._rows === value) {
  14056. return;
  14057. }
  14058. this._rows = value;
  14059. this._rowThenColum = false;
  14060. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14061. _this._arrangeChildren();
  14062. });
  14063. },
  14064. enumerable: true,
  14065. configurable: true
  14066. });
  14067. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14068. this._cellWidth = 0;
  14069. this._cellHeight = 0;
  14070. var rows = 0;
  14071. var columns = 0;
  14072. var controlCount = 0;
  14073. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14074. // Measure
  14075. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14076. var child = _a[_i];
  14077. if (!child.mesh) {
  14078. continue;
  14079. }
  14080. controlCount++;
  14081. child.mesh.computeWorldMatrix(true);
  14082. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14083. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14084. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14085. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14086. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14087. diff.scaleInPlace(0.5);
  14088. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14089. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14090. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14091. }
  14092. this._cellWidth += this.margin * 2;
  14093. this._cellHeight += this.margin * 2;
  14094. // Arrange
  14095. if (this._rowThenColum) {
  14096. columns = this._columns;
  14097. rows = Math.ceil(controlCount / this._columns);
  14098. }
  14099. else {
  14100. rows = this._rows;
  14101. columns = Math.ceil(controlCount / this._rows);
  14102. }
  14103. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14104. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14105. var nodeGrid = [];
  14106. var cellCounter = 0;
  14107. if (this._rowThenColum) {
  14108. for (var r = 0; r < rows; r++) {
  14109. for (var c = 0; c < columns; c++) {
  14110. 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));
  14111. cellCounter++;
  14112. if (cellCounter > controlCount) {
  14113. break;
  14114. }
  14115. }
  14116. }
  14117. }
  14118. else {
  14119. for (var c = 0; c < columns; c++) {
  14120. for (var r = 0; r < rows; r++) {
  14121. 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));
  14122. cellCounter++;
  14123. if (cellCounter > controlCount) {
  14124. break;
  14125. }
  14126. }
  14127. }
  14128. }
  14129. cellCounter = 0;
  14130. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14131. var child = _c[_b];
  14132. if (!child.mesh) {
  14133. continue;
  14134. }
  14135. this._mapGridNode(child, nodeGrid[cellCounter]);
  14136. cellCounter++;
  14137. }
  14138. this._finalProcessing();
  14139. };
  14140. /** Child classes can implement this function to provide additional processing */
  14141. VolumeBasedPanel.prototype._finalProcessing = function () {
  14142. };
  14143. return VolumeBasedPanel;
  14144. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14145. /***/ }),
  14146. /***/ "./3D/gui3DManager.ts":
  14147. /*!****************************!*\
  14148. !*** ./3D/gui3DManager.ts ***!
  14149. \****************************/
  14150. /*! exports provided: GUI3DManager */
  14151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14152. "use strict";
  14153. __webpack_require__.r(__webpack_exports__);
  14154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14155. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  14156. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14157. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14158. /**
  14159. * Class used to manage 3D user interface
  14160. * @see http://doc.babylonjs.com/how_to/gui3d
  14161. */
  14162. var GUI3DManager = /** @class */ (function () {
  14163. /**
  14164. * Creates a new GUI3DManager
  14165. * @param scene
  14166. */
  14167. function GUI3DManager(scene) {
  14168. var _this = this;
  14169. /** @hidden */
  14170. this._lastControlOver = {};
  14171. /** @hidden */
  14172. this._lastControlDown = {};
  14173. /**
  14174. * Observable raised when the point picked by the pointer events changed
  14175. */
  14176. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14177. // Shared resources
  14178. /** @hidden */
  14179. this._sharedMaterials = {};
  14180. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14181. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14182. _this._sceneDisposeObserver = null;
  14183. _this._utilityLayer = null;
  14184. _this.dispose();
  14185. });
  14186. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14187. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14188. this._utilityLayer.pickUtilitySceneFirst = false;
  14189. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14190. return mesh && mesh.metadata && mesh.metadata._node;
  14191. };
  14192. // Root
  14193. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14194. this._rootContainer._host = this;
  14195. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14196. // Events
  14197. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14198. _this._handlePointerOut(pointerId, true);
  14199. });
  14200. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14201. _this._doPicking(pi);
  14202. });
  14203. // Scene
  14204. this._utilityLayer.utilityLayerScene.autoClear = false;
  14205. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14206. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14207. }
  14208. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14209. /** Gets the hosting scene */
  14210. get: function () {
  14211. return this._scene;
  14212. },
  14213. enumerable: true,
  14214. configurable: true
  14215. });
  14216. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14217. /** Gets associated utility layer */
  14218. get: function () {
  14219. return this._utilityLayer;
  14220. },
  14221. enumerable: true,
  14222. configurable: true
  14223. });
  14224. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14225. var previousControlOver = this._lastControlOver[pointerId];
  14226. if (previousControlOver) {
  14227. previousControlOver._onPointerOut(previousControlOver);
  14228. delete this._lastControlOver[pointerId];
  14229. }
  14230. if (isPointerUp) {
  14231. if (this._lastControlDown[pointerId]) {
  14232. this._lastControlDown[pointerId].forcePointerUp();
  14233. delete this._lastControlDown[pointerId];
  14234. }
  14235. }
  14236. this.onPickedPointChangedObservable.notifyObservers(null);
  14237. };
  14238. GUI3DManager.prototype._doPicking = function (pi) {
  14239. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14240. return false;
  14241. }
  14242. var pointerEvent = (pi.event);
  14243. var pointerId = pointerEvent.pointerId || 0;
  14244. var buttonIndex = pointerEvent.button;
  14245. var pickingInfo = pi.pickInfo;
  14246. if (!pickingInfo || !pickingInfo.hit) {
  14247. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14248. return false;
  14249. }
  14250. var control = (pickingInfo.pickedMesh.metadata);
  14251. if (pickingInfo.pickedPoint) {
  14252. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14253. }
  14254. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14255. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14256. if (this._lastControlOver[pointerId]) {
  14257. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14258. }
  14259. delete this._lastControlOver[pointerId];
  14260. }
  14261. }
  14262. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14263. if (this._lastControlDown[pointerEvent.pointerId]) {
  14264. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14265. delete this._lastControlDown[pointerEvent.pointerId];
  14266. }
  14267. if (pointerEvent.pointerType === "touch") {
  14268. this._handlePointerOut(pointerId, false);
  14269. }
  14270. }
  14271. return true;
  14272. };
  14273. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14274. /**
  14275. * Gets the root container
  14276. */
  14277. get: function () {
  14278. return this._rootContainer;
  14279. },
  14280. enumerable: true,
  14281. configurable: true
  14282. });
  14283. /**
  14284. * Gets a boolean indicating if the given control is in the root child list
  14285. * @param control defines the control to check
  14286. * @returns true if the control is in the root child list
  14287. */
  14288. GUI3DManager.prototype.containsControl = function (control) {
  14289. return this._rootContainer.containsControl(control);
  14290. };
  14291. /**
  14292. * Adds a control to the root child list
  14293. * @param control defines the control to add
  14294. * @returns the current manager
  14295. */
  14296. GUI3DManager.prototype.addControl = function (control) {
  14297. this._rootContainer.addControl(control);
  14298. return this;
  14299. };
  14300. /**
  14301. * Removes a control from the root child list
  14302. * @param control defines the control to remove
  14303. * @returns the current container
  14304. */
  14305. GUI3DManager.prototype.removeControl = function (control) {
  14306. this._rootContainer.removeControl(control);
  14307. return this;
  14308. };
  14309. /**
  14310. * Releases all associated resources
  14311. */
  14312. GUI3DManager.prototype.dispose = function () {
  14313. this._rootContainer.dispose();
  14314. for (var materialName in this._sharedMaterials) {
  14315. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14316. continue;
  14317. }
  14318. this._sharedMaterials[materialName].dispose();
  14319. }
  14320. this._sharedMaterials = {};
  14321. if (this._pointerOutObserver && this._utilityLayer) {
  14322. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14323. this._pointerOutObserver = null;
  14324. }
  14325. this.onPickedPointChangedObservable.clear();
  14326. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14327. if (utilityLayerScene) {
  14328. if (this._pointerObserver) {
  14329. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14330. this._pointerObserver = null;
  14331. }
  14332. }
  14333. if (this._scene) {
  14334. if (this._sceneDisposeObserver) {
  14335. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14336. this._sceneDisposeObserver = null;
  14337. }
  14338. }
  14339. if (this._utilityLayer) {
  14340. this._utilityLayer.dispose();
  14341. }
  14342. };
  14343. return GUI3DManager;
  14344. }());
  14345. /***/ }),
  14346. /***/ "./3D/index.ts":
  14347. /*!*********************!*\
  14348. !*** ./3D/index.ts ***!
  14349. \*********************/
  14350. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14352. "use strict";
  14353. __webpack_require__.r(__webpack_exports__);
  14354. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14367. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14370. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14372. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14374. /***/ }),
  14375. /***/ "./3D/materials/fluentMaterial.ts":
  14376. /*!****************************************!*\
  14377. !*** ./3D/materials/fluentMaterial.ts ***!
  14378. \****************************************/
  14379. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14381. "use strict";
  14382. __webpack_require__.r(__webpack_exports__);
  14383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14385. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14386. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math");
  14387. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14388. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14389. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14390. /** @hidden */
  14391. var FluentMaterialDefines = /** @class */ (function (_super) {
  14392. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14393. function FluentMaterialDefines() {
  14394. var _this = _super.call(this) || this;
  14395. _this.INNERGLOW = false;
  14396. _this.BORDER = false;
  14397. _this.HOVERLIGHT = false;
  14398. _this.TEXTURE = false;
  14399. _this.rebuild();
  14400. return _this;
  14401. }
  14402. return FluentMaterialDefines;
  14403. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14404. /**
  14405. * Class used to render controls with fluent desgin
  14406. */
  14407. var FluentMaterial = /** @class */ (function (_super) {
  14408. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14409. /**
  14410. * Creates a new Fluent material
  14411. * @param name defines the name of the material
  14412. * @param scene defines the hosting scene
  14413. */
  14414. function FluentMaterial(name, scene) {
  14415. var _this = _super.call(this, name, scene) || this;
  14416. /**
  14417. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14418. */
  14419. _this.innerGlowColorIntensity = 0.5;
  14420. /**
  14421. * Gets or sets the inner glow color (white by default)
  14422. */
  14423. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14424. /**
  14425. * Gets or sets alpha value (default is 1.0)
  14426. */
  14427. _this.alpha = 1.0;
  14428. /**
  14429. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14430. */
  14431. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14432. /**
  14433. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14434. */
  14435. _this.renderBorders = false;
  14436. /**
  14437. * Gets or sets border width (default is 0.5)
  14438. */
  14439. _this.borderWidth = 0.5;
  14440. /**
  14441. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14442. */
  14443. _this.edgeSmoothingValue = 0.02;
  14444. /**
  14445. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14446. */
  14447. _this.borderMinValue = 0.1;
  14448. /**
  14449. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14450. */
  14451. _this.renderHoverLight = false;
  14452. /**
  14453. * Gets or sets the radius used to render the hover light (default is 1.0)
  14454. */
  14455. _this.hoverRadius = 1.0;
  14456. /**
  14457. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14458. */
  14459. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14460. /**
  14461. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14462. */
  14463. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14464. return _this;
  14465. }
  14466. FluentMaterial.prototype.needAlphaBlending = function () {
  14467. return this.alpha !== 1.0;
  14468. };
  14469. FluentMaterial.prototype.needAlphaTesting = function () {
  14470. return false;
  14471. };
  14472. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14473. return null;
  14474. };
  14475. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14476. if (this.isFrozen) {
  14477. if (this._wasPreviouslyReady && subMesh.effect) {
  14478. return true;
  14479. }
  14480. }
  14481. if (!subMesh._materialDefines) {
  14482. subMesh._materialDefines = new FluentMaterialDefines();
  14483. }
  14484. var scene = this.getScene();
  14485. var defines = subMesh._materialDefines;
  14486. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14487. if (defines._renderId === scene.getRenderId()) {
  14488. return true;
  14489. }
  14490. }
  14491. if (defines._areTexturesDirty) {
  14492. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14493. defines.BORDER = this.renderBorders;
  14494. defines.HOVERLIGHT = this.renderHoverLight;
  14495. if (this._albedoTexture) {
  14496. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14497. return false;
  14498. }
  14499. else {
  14500. defines.TEXTURE = true;
  14501. }
  14502. }
  14503. else {
  14504. defines.TEXTURE = false;
  14505. }
  14506. }
  14507. var engine = scene.getEngine();
  14508. // Get correct effect
  14509. if (defines.isDirty) {
  14510. defines.markAsProcessed();
  14511. scene.resetCachedMaterial();
  14512. //Attributes
  14513. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14514. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14515. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14516. var shaderName = "fluent";
  14517. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14518. "hoverColor", "hoverPosition", "hoverRadius"
  14519. ];
  14520. var samplers = ["albedoSampler"];
  14521. var uniformBuffers = new Array();
  14522. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14523. uniformsNames: uniforms,
  14524. uniformBuffersNames: uniformBuffers,
  14525. samplers: samplers,
  14526. defines: defines,
  14527. maxSimultaneousLights: 4
  14528. });
  14529. var join = defines.toString();
  14530. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14531. attributes: attribs,
  14532. uniformsNames: uniforms,
  14533. uniformBuffersNames: uniformBuffers,
  14534. samplers: samplers,
  14535. defines: join,
  14536. fallbacks: null,
  14537. onCompiled: this.onCompiled,
  14538. onError: this.onError,
  14539. indexParameters: { maxSimultaneousLights: 4 }
  14540. }, engine));
  14541. }
  14542. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14543. return false;
  14544. }
  14545. defines._renderId = scene.getRenderId();
  14546. this._wasPreviouslyReady = true;
  14547. return true;
  14548. };
  14549. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14550. var scene = this.getScene();
  14551. var defines = subMesh._materialDefines;
  14552. if (!defines) {
  14553. return;
  14554. }
  14555. var effect = subMesh.effect;
  14556. if (!effect) {
  14557. return;
  14558. }
  14559. this._activeEffect = effect;
  14560. // Matrices
  14561. this.bindOnlyWorldMatrix(world);
  14562. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14563. if (this._mustRebind(scene, effect)) {
  14564. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14565. if (defines.INNERGLOW) {
  14566. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14567. }
  14568. if (defines.BORDER) {
  14569. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14570. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14571. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14572. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14573. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14574. }
  14575. if (defines.HOVERLIGHT) {
  14576. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14577. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14578. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14579. }
  14580. if (defines.TEXTURE) {
  14581. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14582. }
  14583. }
  14584. this._afterBind(mesh, this._activeEffect);
  14585. };
  14586. FluentMaterial.prototype.getActiveTextures = function () {
  14587. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14588. return activeTextures;
  14589. };
  14590. FluentMaterial.prototype.hasTexture = function (texture) {
  14591. if (_super.prototype.hasTexture.call(this, texture)) {
  14592. return true;
  14593. }
  14594. return false;
  14595. };
  14596. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14597. _super.prototype.dispose.call(this, forceDisposeEffect);
  14598. };
  14599. FluentMaterial.prototype.clone = function (name) {
  14600. var _this = this;
  14601. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14602. };
  14603. FluentMaterial.prototype.serialize = function () {
  14604. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14605. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14606. return serializationObject;
  14607. };
  14608. FluentMaterial.prototype.getClassName = function () {
  14609. return "FluentMaterial";
  14610. };
  14611. // Statics
  14612. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14613. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14614. };
  14615. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14616. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14617. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14618. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14620. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14621. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14623. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14624. ], FluentMaterial.prototype, "alpha", void 0);
  14625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14626. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14627. ], FluentMaterial.prototype, "albedoColor", void 0);
  14628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14629. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14630. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14631. ], FluentMaterial.prototype, "renderBorders", void 0);
  14632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14633. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14634. ], FluentMaterial.prototype, "borderWidth", void 0);
  14635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14636. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14637. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14639. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14640. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14642. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14643. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14644. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14646. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14647. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14649. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14650. ], FluentMaterial.prototype, "hoverColor", void 0);
  14651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14652. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14653. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14655. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14656. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14658. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14659. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14660. return FluentMaterial;
  14661. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14662. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14663. /***/ }),
  14664. /***/ "./3D/materials/index.ts":
  14665. /*!*******************************!*\
  14666. !*** ./3D/materials/index.ts ***!
  14667. \*******************************/
  14668. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14669. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14670. "use strict";
  14671. __webpack_require__.r(__webpack_exports__);
  14672. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14675. /***/ }),
  14676. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14677. /*!*************************************************!*\
  14678. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14679. \*************************************************/
  14680. /*! exports provided: fluentPixelShader */
  14681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14682. "use strict";
  14683. __webpack_require__.r(__webpack_exports__);
  14684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14685. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  14686. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14687. var name = 'fluentPixelShader';
  14688. 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}";
  14689. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14690. /** @hidden */
  14691. var fluentPixelShader = { name: name, shader: shader };
  14692. /***/ }),
  14693. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14694. /*!***********************************************!*\
  14695. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14696. \***********************************************/
  14697. /*! exports provided: fluentVertexShader */
  14698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14699. "use strict";
  14700. __webpack_require__.r(__webpack_exports__);
  14701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14702. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  14703. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14704. var name = 'fluentVertexShader';
  14705. 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";
  14706. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14707. /** @hidden */
  14708. var fluentVertexShader = { name: name, shader: shader };
  14709. /***/ }),
  14710. /***/ "./3D/vector3WithInfo.ts":
  14711. /*!*******************************!*\
  14712. !*** ./3D/vector3WithInfo.ts ***!
  14713. \*******************************/
  14714. /*! exports provided: Vector3WithInfo */
  14715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14716. "use strict";
  14717. __webpack_require__.r(__webpack_exports__);
  14718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14719. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14720. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14721. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14722. /**
  14723. * Class used to transport Vector3 information for pointer events
  14724. */
  14725. var Vector3WithInfo = /** @class */ (function (_super) {
  14726. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14727. /**
  14728. * Creates a new Vector3WithInfo
  14729. * @param source defines the vector3 data to transport
  14730. * @param buttonIndex defines the current mouse button index
  14731. */
  14732. function Vector3WithInfo(source,
  14733. /** defines the current mouse button index */
  14734. buttonIndex) {
  14735. if (buttonIndex === void 0) { buttonIndex = 0; }
  14736. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14737. _this.buttonIndex = buttonIndex;
  14738. return _this;
  14739. }
  14740. return Vector3WithInfo;
  14741. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14742. /***/ }),
  14743. /***/ "./index.ts":
  14744. /*!******************!*\
  14745. !*** ./index.ts ***!
  14746. \******************/
  14747. /*! 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 */
  14748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14749. "use strict";
  14750. __webpack_require__.r(__webpack_exports__);
  14751. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14791. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14808. /***/ }),
  14809. /***/ "./legacy/legacy.ts":
  14810. /*!**************************!*\
  14811. !*** ./legacy/legacy.ts ***!
  14812. \**************************/
  14813. /*! 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 */
  14814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14815. "use strict";
  14816. __webpack_require__.r(__webpack_exports__);
  14817. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14873. /**
  14874. * Legacy support, defining window.BABYLON.GUI (global variable).
  14875. *
  14876. * This is the entry point for the UMD module.
  14877. * The entry point for a future ESM package should be index.ts
  14878. */
  14879. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14880. if (typeof globalObject !== "undefined") {
  14881. globalObject.BABYLON = globalObject.BABYLON || {};
  14882. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14883. }
  14884. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14885. /***/ }),
  14886. /***/ "babylonjs/Maths/math":
  14887. /*!****************************************************************************************************!*\
  14888. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14889. \****************************************************************************************************/
  14890. /*! no static exports found */
  14891. /***/ (function(module, exports) {
  14892. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math__;
  14893. /***/ })
  14894. /******/ });
  14895. });
  14896. //# sourceMappingURL=babylon.gui.js.map