babylon.gui.js 679 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) {
  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. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../../node_modules/webpack/buildin/global.js":
  291. /*!***********************************!*\
  292. !*** (webpack)/buildin/global.js ***!
  293. \***********************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./2D/adtInstrumentation.ts":
  314. /*!**********************************!*\
  315. !*** ./2D/adtInstrumentation.ts ***!
  316. \**********************************/
  317. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  322. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/observable");
  323. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  324. /**
  325. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  326. */
  327. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  328. /**
  329. * Instantiates a new advanced dynamic texture instrumentation.
  330. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  331. * @param texture Defines the AdvancedDynamicTexture to instrument
  332. */
  333. function AdvancedDynamicTextureInstrumentation(
  334. /**
  335. * Define the instrumented AdvancedDynamicTexture.
  336. */
  337. texture) {
  338. this.texture = texture;
  339. this._captureRenderTime = false;
  340. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  341. this._captureLayoutTime = false;
  342. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  343. // Observers
  344. this._onBeginRenderObserver = null;
  345. this._onEndRenderObserver = null;
  346. this._onBeginLayoutObserver = null;
  347. this._onEndLayoutObserver = null;
  348. }
  349. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  350. // Properties
  351. /**
  352. * Gets the perf counter used to capture render time
  353. */
  354. get: function () {
  355. return this._renderTime;
  356. },
  357. enumerable: true,
  358. configurable: true
  359. });
  360. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  361. /**
  362. * Gets the perf counter used to capture layout time
  363. */
  364. get: function () {
  365. return this._layoutTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  371. /**
  372. * Enable or disable the render time capture
  373. */
  374. get: function () {
  375. return this._captureRenderTime;
  376. },
  377. set: function (value) {
  378. var _this = this;
  379. if (value === this._captureRenderTime) {
  380. return;
  381. }
  382. this._captureRenderTime = value;
  383. if (value) {
  384. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  385. _this._renderTime.beginMonitoring();
  386. });
  387. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  388. _this._renderTime.endMonitoring(true);
  389. });
  390. }
  391. else {
  392. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  393. this._onBeginRenderObserver = null;
  394. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  395. this._onEndRenderObserver = null;
  396. }
  397. },
  398. enumerable: true,
  399. configurable: true
  400. });
  401. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  402. /**
  403. * Enable or disable the layout time capture
  404. */
  405. get: function () {
  406. return this._captureLayoutTime;
  407. },
  408. set: function (value) {
  409. var _this = this;
  410. if (value === this._captureLayoutTime) {
  411. return;
  412. }
  413. this._captureLayoutTime = value;
  414. if (value) {
  415. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  416. _this._layoutTime.beginMonitoring();
  417. });
  418. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  419. _this._layoutTime.endMonitoring(true);
  420. });
  421. }
  422. else {
  423. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  424. this._onBeginLayoutObserver = null;
  425. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  426. this._onEndLayoutObserver = null;
  427. }
  428. },
  429. enumerable: true,
  430. configurable: true
  431. });
  432. /**
  433. * Dispose and release associated resources.
  434. */
  435. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  436. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  437. this._onBeginRenderObserver = null;
  438. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  439. this._onEndRenderObserver = null;
  440. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  441. this._onBeginLayoutObserver = null;
  442. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  443. this._onEndLayoutObserver = null;
  444. this.texture = null;
  445. };
  446. return AdvancedDynamicTextureInstrumentation;
  447. }());
  448. /***/ }),
  449. /***/ "./2D/advancedDynamicTexture.ts":
  450. /*!**************************************!*\
  451. !*** ./2D/advancedDynamicTexture.ts ***!
  452. \**************************************/
  453. /*! exports provided: AdvancedDynamicTexture */
  454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  455. "use strict";
  456. __webpack_require__.r(__webpack_exports__);
  457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  459. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  460. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  461. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  462. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  463. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  464. /**
  465. * Class used to create texture to support 2D GUI elements
  466. * @see http://doc.babylonjs.com/how_to/gui
  467. */
  468. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  470. /**
  471. * Creates a new AdvancedDynamicTexture
  472. * @param name defines the name of the texture
  473. * @param width defines the width of the texture
  474. * @param height defines the height of the texture
  475. * @param scene defines the hosting scene
  476. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  477. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  478. */
  479. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  480. if (width === void 0) { width = 0; }
  481. if (height === void 0) { height = 0; }
  482. if (generateMipMaps === void 0) { generateMipMaps = false; }
  483. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  484. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  485. _this._isDirty = false;
  486. /** @hidden */
  487. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  488. /** @hidden */
  489. _this._lastControlOver = {};
  490. /** @hidden */
  491. _this._lastControlDown = {};
  492. /** @hidden */
  493. _this._capturingControl = {};
  494. /** @hidden */
  495. _this._linkedControls = new Array();
  496. _this._isFullscreen = false;
  497. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  498. _this._idealWidth = 0;
  499. _this._idealHeight = 0;
  500. _this._useSmallestIdeal = false;
  501. _this._renderAtIdealSize = false;
  502. _this._blockNextFocusCheck = false;
  503. _this._renderScale = 1;
  504. _this._cursorChanged = false;
  505. /**
  506. * Define type to string to ensure compatibility across browsers
  507. * Safari doesn't support DataTransfer constructor
  508. */
  509. _this._clipboardData = "";
  510. /**
  511. * Observable event triggered each time an clipboard event is received from the rendering canvas
  512. */
  513. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  514. /**
  515. * Observable event triggered each time a pointer down is intercepted by a control
  516. */
  517. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  518. /**
  519. * Observable event triggered before layout is evaluated
  520. */
  521. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  522. /**
  523. * Observable event triggered after the layout was evaluated
  524. */
  525. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  526. /**
  527. * Observable event triggered before the texture is rendered
  528. */
  529. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  530. /**
  531. * Observable event triggered after the texture was rendered
  532. */
  533. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  534. /**
  535. * Gets or sets a boolean defining if alpha is stored as premultiplied
  536. */
  537. _this.premulAlpha = false;
  538. _this._useInvalidateRectOptimization = true;
  539. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  540. _this._invalidatedRectangle = null;
  541. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  542. /** @hidden */
  543. _this.onClipboardCopy = function (rawEvt) {
  544. var evt = rawEvt;
  545. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  546. _this.onClipboardObservable.notifyObservers(ev);
  547. evt.preventDefault();
  548. };
  549. /** @hidden */
  550. _this.onClipboardCut = function (rawEvt) {
  551. var evt = rawEvt;
  552. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  553. _this.onClipboardObservable.notifyObservers(ev);
  554. evt.preventDefault();
  555. };
  556. /** @hidden */
  557. _this.onClipboardPaste = function (rawEvt) {
  558. var evt = rawEvt;
  559. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  560. _this.onClipboardObservable.notifyObservers(ev);
  561. evt.preventDefault();
  562. };
  563. scene = _this.getScene();
  564. if (!scene || !_this._texture) {
  565. return _this;
  566. }
  567. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  568. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  569. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  570. if (!_this._focusedControl) {
  571. return;
  572. }
  573. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  574. _this._focusedControl.processKeyboard(info.event);
  575. }
  576. info.skipOnPointerObservable = true;
  577. });
  578. _this._rootContainer._link(_this);
  579. _this.hasAlpha = true;
  580. if (!width || !height) {
  581. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  582. _this._onResize();
  583. }
  584. _this._texture.isReady = true;
  585. return _this;
  586. }
  587. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  588. /**
  589. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  590. * Useful when you want more antialiasing
  591. */
  592. get: function () {
  593. return this._renderScale;
  594. },
  595. set: function (value) {
  596. if (value === this._renderScale) {
  597. return;
  598. }
  599. this._renderScale = value;
  600. this._onResize();
  601. },
  602. enumerable: true,
  603. configurable: true
  604. });
  605. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  606. /** Gets or sets the background color */
  607. get: function () {
  608. return this._background;
  609. },
  610. set: function (value) {
  611. if (this._background === value) {
  612. return;
  613. }
  614. this._background = value;
  615. this.markAsDirty();
  616. },
  617. enumerable: true,
  618. configurable: true
  619. });
  620. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  621. /**
  622. * Gets or sets the ideal width used to design controls.
  623. * The GUI will then rescale everything accordingly
  624. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  625. */
  626. get: function () {
  627. return this._idealWidth;
  628. },
  629. set: function (value) {
  630. if (this._idealWidth === value) {
  631. return;
  632. }
  633. this._idealWidth = value;
  634. this.markAsDirty();
  635. this._rootContainer._markAllAsDirty();
  636. },
  637. enumerable: true,
  638. configurable: true
  639. });
  640. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  641. /**
  642. * Gets or sets the ideal height used to design controls.
  643. * The GUI will then rescale everything accordingly
  644. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  645. */
  646. get: function () {
  647. return this._idealHeight;
  648. },
  649. set: function (value) {
  650. if (this._idealHeight === value) {
  651. return;
  652. }
  653. this._idealHeight = value;
  654. this.markAsDirty();
  655. this._rootContainer._markAllAsDirty();
  656. },
  657. enumerable: true,
  658. configurable: true
  659. });
  660. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  661. /**
  662. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  663. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  664. */
  665. get: function () {
  666. return this._useSmallestIdeal;
  667. },
  668. set: function (value) {
  669. if (this._useSmallestIdeal === value) {
  670. return;
  671. }
  672. this._useSmallestIdeal = value;
  673. this.markAsDirty();
  674. this._rootContainer._markAllAsDirty();
  675. },
  676. enumerable: true,
  677. configurable: true
  678. });
  679. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  680. /**
  681. * Gets or sets a boolean indicating if adaptive scaling must be used
  682. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  683. */
  684. get: function () {
  685. return this._renderAtIdealSize;
  686. },
  687. set: function (value) {
  688. if (this._renderAtIdealSize === value) {
  689. return;
  690. }
  691. this._renderAtIdealSize = value;
  692. this._onResize();
  693. },
  694. enumerable: true,
  695. configurable: true
  696. });
  697. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  698. /**
  699. * Gets the underlying layer used to render the texture when in fullscreen mode
  700. */
  701. get: function () {
  702. return this._layerToDispose;
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  708. /**
  709. * Gets the root container control
  710. */
  711. get: function () {
  712. return this._rootContainer;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. /**
  718. * Returns an array containing the root container.
  719. * This is mostly used to let the Inspector introspects the ADT
  720. * @returns an array containing the rootContainer
  721. */
  722. AdvancedDynamicTexture.prototype.getChildren = function () {
  723. return [this._rootContainer];
  724. };
  725. /**
  726. * Will return all controls that are inside this texture
  727. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  728. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  729. * @return all child controls
  730. */
  731. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  732. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  733. };
  734. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  735. /**
  736. * Gets or sets the current focused control
  737. */
  738. get: function () {
  739. return this._focusedControl;
  740. },
  741. set: function (control) {
  742. if (this._focusedControl == control) {
  743. return;
  744. }
  745. if (this._focusedControl) {
  746. this._focusedControl.onBlur();
  747. }
  748. if (control) {
  749. control.onFocus();
  750. }
  751. this._focusedControl = control;
  752. },
  753. enumerable: true,
  754. configurable: true
  755. });
  756. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  757. /**
  758. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  759. */
  760. get: function () {
  761. if (!this.layer) {
  762. return true;
  763. }
  764. return (!this.layer.isBackground);
  765. },
  766. set: function (value) {
  767. if (!this.layer) {
  768. return;
  769. }
  770. if (this.layer.isBackground === !value) {
  771. return;
  772. }
  773. this.layer.isBackground = !value;
  774. },
  775. enumerable: true,
  776. configurable: true
  777. });
  778. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  779. /**
  780. * Gets or set information about clipboardData
  781. */
  782. get: function () {
  783. return this._clipboardData;
  784. },
  785. set: function (value) {
  786. this._clipboardData = value;
  787. },
  788. enumerable: true,
  789. configurable: true
  790. });
  791. /**
  792. * Get the current class name of the texture useful for serialization or dynamic coding.
  793. * @returns "AdvancedDynamicTexture"
  794. */
  795. AdvancedDynamicTexture.prototype.getClassName = function () {
  796. return "AdvancedDynamicTexture";
  797. };
  798. /**
  799. * Function used to execute a function on all controls
  800. * @param func defines the function to execute
  801. * @param container defines the container where controls belong. If null the root container will be used
  802. */
  803. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  804. if (!container) {
  805. container = this._rootContainer;
  806. }
  807. func(container);
  808. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  809. var child = _a[_i];
  810. if (child.children) {
  811. this.executeOnAllControls(func, child);
  812. continue;
  813. }
  814. func(child);
  815. }
  816. };
  817. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  818. /**
  819. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  820. */
  821. get: function () {
  822. return this._useInvalidateRectOptimization;
  823. },
  824. set: function (value) {
  825. this._useInvalidateRectOptimization = value;
  826. },
  827. enumerable: true,
  828. configurable: true
  829. });
  830. /**
  831. * Invalidates a rectangle area on the gui texture
  832. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  833. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  834. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  835. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  836. */
  837. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  838. if (!this._useInvalidateRectOptimization) {
  839. return;
  840. }
  841. if (!this._invalidatedRectangle) {
  842. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  843. }
  844. else {
  845. // Compute intersection
  846. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  847. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  848. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  849. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  850. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  851. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  852. }
  853. };
  854. /**
  855. * Marks the texture as dirty forcing a complete update
  856. */
  857. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  858. this._isDirty = true;
  859. };
  860. /**
  861. * Helper function used to create a new style
  862. * @returns a new style
  863. * @see http://doc.babylonjs.com/how_to/gui#styles
  864. */
  865. AdvancedDynamicTexture.prototype.createStyle = function () {
  866. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  867. };
  868. /**
  869. * Adds a new control to the root container
  870. * @param control defines the control to add
  871. * @returns the current texture
  872. */
  873. AdvancedDynamicTexture.prototype.addControl = function (control) {
  874. this._rootContainer.addControl(control);
  875. return this;
  876. };
  877. /**
  878. * Removes a control from the root container
  879. * @param control defines the control to remove
  880. * @returns the current texture
  881. */
  882. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  883. this._rootContainer.removeControl(control);
  884. return this;
  885. };
  886. /**
  887. * Release all resources
  888. */
  889. AdvancedDynamicTexture.prototype.dispose = function () {
  890. var scene = this.getScene();
  891. if (!scene) {
  892. return;
  893. }
  894. this._rootCanvas = null;
  895. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  896. if (this._resizeObserver) {
  897. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  898. }
  899. if (this._pointerMoveObserver) {
  900. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  901. }
  902. if (this._pointerObserver) {
  903. scene.onPointerObservable.remove(this._pointerObserver);
  904. }
  905. if (this._preKeyboardObserver) {
  906. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  907. }
  908. if (this._canvasPointerOutObserver) {
  909. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  910. }
  911. if (this._layerToDispose) {
  912. this._layerToDispose.texture = null;
  913. this._layerToDispose.dispose();
  914. this._layerToDispose = null;
  915. }
  916. this._rootContainer.dispose();
  917. this.onClipboardObservable.clear();
  918. this.onControlPickedObservable.clear();
  919. this.onBeginRenderObservable.clear();
  920. this.onEndRenderObservable.clear();
  921. this.onBeginLayoutObservable.clear();
  922. this.onEndLayoutObservable.clear();
  923. _super.prototype.dispose.call(this);
  924. };
  925. AdvancedDynamicTexture.prototype._onResize = function () {
  926. var scene = this.getScene();
  927. if (!scene) {
  928. return;
  929. }
  930. // Check size
  931. var engine = scene.getEngine();
  932. var textureSize = this.getSize();
  933. var renderWidth = engine.getRenderWidth() * this._renderScale;
  934. var renderHeight = engine.getRenderHeight() * this._renderScale;
  935. if (this._renderAtIdealSize) {
  936. if (this._idealWidth) {
  937. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  938. renderWidth = this._idealWidth;
  939. }
  940. else if (this._idealHeight) {
  941. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  942. renderHeight = this._idealHeight;
  943. }
  944. }
  945. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  946. this.scaleTo(renderWidth, renderHeight);
  947. this.markAsDirty();
  948. if (this._idealWidth || this._idealHeight) {
  949. this._rootContainer._markAllAsDirty();
  950. }
  951. }
  952. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  953. };
  954. /** @hidden */
  955. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  956. var engine = scene.getEngine();
  957. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  958. };
  959. /**
  960. * Get screen coordinates for a vector3
  961. * @param position defines the position to project
  962. * @param worldMatrix defines the world matrix to use
  963. * @returns the projected position
  964. */
  965. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  966. var scene = this.getScene();
  967. if (!scene) {
  968. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  969. }
  970. var globalViewport = this._getGlobalViewport(scene);
  971. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  972. projectedPosition.scaleInPlace(this.renderScale);
  973. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  974. };
  975. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  976. if (this._layerToDispose) {
  977. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  978. return;
  979. }
  980. }
  981. if (this._isFullscreen && this._linkedControls.length) {
  982. var scene = this.getScene();
  983. if (!scene) {
  984. return;
  985. }
  986. var globalViewport = this._getGlobalViewport(scene);
  987. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  988. var control = _a[_i];
  989. if (!control.isVisible) {
  990. continue;
  991. }
  992. var mesh = control._linkedMesh;
  993. if (!mesh || mesh.isDisposed()) {
  994. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  995. control.linkWithMesh(null);
  996. });
  997. continue;
  998. }
  999. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1000. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1001. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1002. control.notRenderable = true;
  1003. continue;
  1004. }
  1005. control.notRenderable = false;
  1006. // Account for RenderScale.
  1007. projectedPosition.scaleInPlace(this.renderScale);
  1008. control._moveToProjectedPosition(projectedPosition);
  1009. }
  1010. }
  1011. if (!this._isDirty && !this._rootContainer.isDirty) {
  1012. return;
  1013. }
  1014. this._isDirty = false;
  1015. this._render();
  1016. this.update(true, this.premulAlpha);
  1017. };
  1018. AdvancedDynamicTexture.prototype._render = function () {
  1019. var textureSize = this.getSize();
  1020. var renderWidth = textureSize.width;
  1021. var renderHeight = textureSize.height;
  1022. var context = this.getContext();
  1023. context.font = "18px Arial";
  1024. context.strokeStyle = "white";
  1025. // Layout
  1026. this.onBeginLayoutObservable.notifyObservers(this);
  1027. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1028. this._rootContainer._layout(measure, context);
  1029. this.onEndLayoutObservable.notifyObservers(this);
  1030. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1031. // Clear
  1032. if (this._invalidatedRectangle) {
  1033. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1034. }
  1035. else {
  1036. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1037. }
  1038. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1039. if (this._background) {
  1040. context.save();
  1041. context.fillStyle = this._background;
  1042. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1043. context.restore();
  1044. }
  1045. // Render
  1046. this.onBeginRenderObservable.notifyObservers(this);
  1047. this._rootContainer._render(context, this._invalidatedRectangle);
  1048. this.onEndRenderObservable.notifyObservers(this);
  1049. this._invalidatedRectangle = null;
  1050. };
  1051. /** @hidden */
  1052. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1053. if (this._rootCanvas) {
  1054. this._rootCanvas.style.cursor = cursor;
  1055. this._cursorChanged = true;
  1056. }
  1057. };
  1058. /** @hidden */
  1059. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1060. this._lastControlDown[pointerId] = control;
  1061. this.onControlPickedObservable.notifyObservers(control);
  1062. };
  1063. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1064. var scene = this.getScene();
  1065. if (!scene) {
  1066. return;
  1067. }
  1068. var engine = scene.getEngine();
  1069. var textureSize = this.getSize();
  1070. if (this._isFullscreen) {
  1071. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1072. var viewport = camera.viewport;
  1073. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1074. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1075. }
  1076. if (this._capturingControl[pointerId]) {
  1077. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1078. return;
  1079. }
  1080. this._cursorChanged = false;
  1081. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1082. this._changeCursor("");
  1083. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1084. if (this._lastControlOver[pointerId]) {
  1085. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1086. delete this._lastControlOver[pointerId];
  1087. }
  1088. }
  1089. }
  1090. if (!this._cursorChanged) {
  1091. this._changeCursor("");
  1092. }
  1093. this._manageFocus();
  1094. };
  1095. /** @hidden */
  1096. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1097. for (var pointerId in list) {
  1098. if (!list.hasOwnProperty(pointerId)) {
  1099. continue;
  1100. }
  1101. var lastControlOver = list[pointerId];
  1102. if (lastControlOver === control) {
  1103. delete list[pointerId];
  1104. }
  1105. }
  1106. };
  1107. /** @hidden */
  1108. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1109. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1110. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1111. };
  1112. /** Attach to all scene events required to support pointer events */
  1113. AdvancedDynamicTexture.prototype.attach = function () {
  1114. var _this = this;
  1115. var scene = this.getScene();
  1116. if (!scene) {
  1117. return;
  1118. }
  1119. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1120. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1121. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1122. return;
  1123. }
  1124. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1125. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1126. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1127. return;
  1128. }
  1129. if (!scene) {
  1130. return;
  1131. }
  1132. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1133. var engine = scene.getEngine();
  1134. if (!camera) {
  1135. tempViewport.x = 0;
  1136. tempViewport.y = 0;
  1137. tempViewport.width = engine.getRenderWidth();
  1138. tempViewport.height = engine.getRenderHeight();
  1139. }
  1140. else {
  1141. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1142. }
  1143. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1144. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1145. _this._shouldBlockPointer = false;
  1146. // Do picking modifies _shouldBlockPointer
  1147. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1148. // Avoid overwriting a true skipOnPointerObservable to false
  1149. if (_this._shouldBlockPointer) {
  1150. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1151. }
  1152. });
  1153. this._attachToOnPointerOut(scene);
  1154. };
  1155. /**
  1156. * Register the clipboard Events onto the canvas
  1157. */
  1158. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1159. self.addEventListener("copy", this.onClipboardCopy, false);
  1160. self.addEventListener("cut", this.onClipboardCut, false);
  1161. self.addEventListener("paste", this.onClipboardPaste, false);
  1162. };
  1163. /**
  1164. * Unregister the clipboard Events from the canvas
  1165. */
  1166. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1167. self.removeEventListener("copy", this.onClipboardCopy);
  1168. self.removeEventListener("cut", this.onClipboardCut);
  1169. self.removeEventListener("paste", this.onClipboardPaste);
  1170. };
  1171. /**
  1172. * Connect the texture to a hosting mesh to enable interactions
  1173. * @param mesh defines the mesh to attach to
  1174. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1175. */
  1176. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1177. var _this = this;
  1178. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1179. var scene = this.getScene();
  1180. if (!scene) {
  1181. return;
  1182. }
  1183. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1184. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1185. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1186. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1187. return;
  1188. }
  1189. var pointerId = pi.event.pointerId || 0;
  1190. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1191. var uv = pi.pickInfo.getTextureCoordinates();
  1192. if (uv) {
  1193. var size = _this.getSize();
  1194. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1195. }
  1196. }
  1197. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1198. if (_this._lastControlDown[pointerId]) {
  1199. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1200. }
  1201. delete _this._lastControlDown[pointerId];
  1202. if (_this.focusedControl) {
  1203. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1204. var canMoveFocus = true;
  1205. if (friendlyControls) {
  1206. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1207. var control = friendlyControls_1[_i];
  1208. // Same host, no need to keep the focus
  1209. if (_this === control._host) {
  1210. continue;
  1211. }
  1212. // Different hosts
  1213. var otherHost = control._host;
  1214. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1215. canMoveFocus = false;
  1216. break;
  1217. }
  1218. }
  1219. }
  1220. if (canMoveFocus) {
  1221. _this.focusedControl = null;
  1222. }
  1223. }
  1224. }
  1225. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1226. if (_this._lastControlOver[pointerId]) {
  1227. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1228. }
  1229. delete _this._lastControlOver[pointerId];
  1230. }
  1231. });
  1232. mesh.enablePointerMoveEvents = supportPointerMove;
  1233. this._attachToOnPointerOut(scene);
  1234. };
  1235. /**
  1236. * Move the focus to a specific control
  1237. * @param control defines the control which will receive the focus
  1238. */
  1239. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1240. this.focusedControl = control;
  1241. this._lastPickedControl = control;
  1242. this._blockNextFocusCheck = true;
  1243. };
  1244. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1245. if (this._blockNextFocusCheck) {
  1246. this._blockNextFocusCheck = false;
  1247. this._lastPickedControl = this._focusedControl;
  1248. return;
  1249. }
  1250. // Focus management
  1251. if (this._focusedControl) {
  1252. if (this._focusedControl !== this._lastPickedControl) {
  1253. if (this._lastPickedControl.isFocusInvisible) {
  1254. return;
  1255. }
  1256. this.focusedControl = null;
  1257. }
  1258. }
  1259. };
  1260. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1261. var _this = this;
  1262. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1263. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1264. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1265. }
  1266. delete _this._lastControlOver[pointerEvent.pointerId];
  1267. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1268. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1269. delete _this._lastControlDown[pointerEvent.pointerId];
  1270. }
  1271. });
  1272. };
  1273. // Statics
  1274. /**
  1275. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1276. * @param mesh defines the mesh which will receive the texture
  1277. * @param width defines the texture width (1024 by default)
  1278. * @param height defines the texture height (1024 by default)
  1279. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1280. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1281. * @returns a new AdvancedDynamicTexture
  1282. */
  1283. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1284. if (width === void 0) { width = 1024; }
  1285. if (height === void 0) { height = 1024; }
  1286. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1287. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1288. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1289. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1290. material.backFaceCulling = false;
  1291. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1292. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1293. if (onlyAlphaTesting) {
  1294. material.diffuseTexture = result;
  1295. material.emissiveTexture = result;
  1296. result.hasAlpha = true;
  1297. }
  1298. else {
  1299. material.emissiveTexture = result;
  1300. material.opacityTexture = result;
  1301. }
  1302. mesh.material = material;
  1303. result.attachToMesh(mesh, supportPointerMove);
  1304. return result;
  1305. };
  1306. /**
  1307. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1308. * In this mode the texture will rely on a layer for its rendering.
  1309. * This allows it to be treated like any other layer.
  1310. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1311. * LayerMask is set through advancedTexture.layer.layerMask
  1312. * @param name defines name for the texture
  1313. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1314. * @param scene defines the hsoting scene
  1315. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1316. * @returns a new AdvancedDynamicTexture
  1317. */
  1318. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1319. if (foreground === void 0) { foreground = true; }
  1320. if (scene === void 0) { scene = null; }
  1321. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1322. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1323. // Display
  1324. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1325. layer.texture = result;
  1326. result._layerToDispose = layer;
  1327. result._isFullscreen = true;
  1328. // Attach
  1329. result.attach();
  1330. return result;
  1331. };
  1332. return AdvancedDynamicTexture;
  1333. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1334. /***/ }),
  1335. /***/ "./2D/controls/button.ts":
  1336. /*!*******************************!*\
  1337. !*** ./2D/controls/button.ts ***!
  1338. \*******************************/
  1339. /*! exports provided: Button */
  1340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1341. "use strict";
  1342. __webpack_require__.r(__webpack_exports__);
  1343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1344. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1345. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1346. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1347. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1348. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1349. /**
  1350. * Class used to create 2D buttons
  1351. */
  1352. var Button = /** @class */ (function (_super) {
  1353. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1354. /**
  1355. * Creates a new Button
  1356. * @param name defines the name of the button
  1357. */
  1358. function Button(name) {
  1359. var _this = _super.call(this, name) || this;
  1360. _this.name = name;
  1361. _this.thickness = 1;
  1362. _this.isPointerBlocker = true;
  1363. var alphaStore = null;
  1364. _this.pointerEnterAnimation = function () {
  1365. alphaStore = _this.alpha;
  1366. _this.alpha -= 0.1;
  1367. };
  1368. _this.pointerOutAnimation = function () {
  1369. if (alphaStore !== null) {
  1370. _this.alpha = alphaStore;
  1371. }
  1372. };
  1373. _this.pointerDownAnimation = function () {
  1374. _this.scaleX -= 0.05;
  1375. _this.scaleY -= 0.05;
  1376. };
  1377. _this.pointerUpAnimation = function () {
  1378. _this.scaleX += 0.05;
  1379. _this.scaleY += 0.05;
  1380. };
  1381. return _this;
  1382. }
  1383. Object.defineProperty(Button.prototype, "image", {
  1384. /**
  1385. * Returns the image part of the button (if any)
  1386. */
  1387. get: function () {
  1388. return this._image;
  1389. },
  1390. enumerable: true,
  1391. configurable: true
  1392. });
  1393. Object.defineProperty(Button.prototype, "textBlock", {
  1394. /**
  1395. * Returns the image part of the button (if any)
  1396. */
  1397. get: function () {
  1398. return this._textBlock;
  1399. },
  1400. enumerable: true,
  1401. configurable: true
  1402. });
  1403. Button.prototype._getTypeName = function () {
  1404. return "Button";
  1405. };
  1406. // While being a container, the button behaves like a control.
  1407. /** @hidden */
  1408. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1409. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1410. return false;
  1411. }
  1412. if (!_super.prototype.contains.call(this, x, y)) {
  1413. return false;
  1414. }
  1415. this._processObservables(type, x, y, pointerId, buttonIndex);
  1416. return true;
  1417. };
  1418. /** @hidden */
  1419. Button.prototype._onPointerEnter = function (target) {
  1420. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1421. return false;
  1422. }
  1423. if (this.pointerEnterAnimation) {
  1424. this.pointerEnterAnimation();
  1425. }
  1426. return true;
  1427. };
  1428. /** @hidden */
  1429. Button.prototype._onPointerOut = function (target, force) {
  1430. if (force === void 0) { force = false; }
  1431. if (this.pointerOutAnimation) {
  1432. this.pointerOutAnimation();
  1433. }
  1434. _super.prototype._onPointerOut.call(this, target, force);
  1435. };
  1436. /** @hidden */
  1437. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1438. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1439. return false;
  1440. }
  1441. if (this.pointerDownAnimation) {
  1442. this.pointerDownAnimation();
  1443. }
  1444. return true;
  1445. };
  1446. /** @hidden */
  1447. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1448. if (this.pointerUpAnimation) {
  1449. this.pointerUpAnimation();
  1450. }
  1451. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1452. };
  1453. // Statics
  1454. /**
  1455. * Creates a new button made with an image and a text
  1456. * @param name defines the name of the button
  1457. * @param text defines the text of the button
  1458. * @param imageUrl defines the url of the image
  1459. * @returns a new Button
  1460. */
  1461. Button.CreateImageButton = function (name, text, imageUrl) {
  1462. var result = new Button(name);
  1463. // Adding text
  1464. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1465. textBlock.textWrapping = true;
  1466. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1467. textBlock.paddingLeft = "20%";
  1468. result.addControl(textBlock);
  1469. // Adding image
  1470. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1471. iconImage.width = "20%";
  1472. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1473. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1474. result.addControl(iconImage);
  1475. // Store
  1476. result._image = iconImage;
  1477. result._textBlock = textBlock;
  1478. return result;
  1479. };
  1480. /**
  1481. * Creates a new button made with an image
  1482. * @param name defines the name of the button
  1483. * @param imageUrl defines the url of the image
  1484. * @returns a new Button
  1485. */
  1486. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1487. var result = new Button(name);
  1488. // Adding image
  1489. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1490. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1491. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1492. result.addControl(iconImage);
  1493. // Store
  1494. result._image = iconImage;
  1495. return result;
  1496. };
  1497. /**
  1498. * Creates a new button made with a text
  1499. * @param name defines the name of the button
  1500. * @param text defines the text of the button
  1501. * @returns a new Button
  1502. */
  1503. Button.CreateSimpleButton = function (name, text) {
  1504. var result = new Button(name);
  1505. // Adding text
  1506. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1507. textBlock.textWrapping = true;
  1508. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1509. result.addControl(textBlock);
  1510. // Store
  1511. result._textBlock = textBlock;
  1512. return result;
  1513. };
  1514. /**
  1515. * Creates a new button made with an image and a centered text
  1516. * @param name defines the name of the button
  1517. * @param text defines the text of the button
  1518. * @param imageUrl defines the url of the image
  1519. * @returns a new Button
  1520. */
  1521. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1522. var result = new Button(name);
  1523. // Adding image
  1524. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1525. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1526. result.addControl(iconImage);
  1527. // Adding text
  1528. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1529. textBlock.textWrapping = true;
  1530. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1531. result.addControl(textBlock);
  1532. // Store
  1533. result._image = iconImage;
  1534. result._textBlock = textBlock;
  1535. return result;
  1536. };
  1537. return Button;
  1538. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1539. /***/ }),
  1540. /***/ "./2D/controls/checkbox.ts":
  1541. /*!*********************************!*\
  1542. !*** ./2D/controls/checkbox.ts ***!
  1543. \*********************************/
  1544. /*! exports provided: Checkbox */
  1545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1546. "use strict";
  1547. __webpack_require__.r(__webpack_exports__);
  1548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1550. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1551. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1552. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1553. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1554. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1555. /**
  1556. * Class used to represent a 2D checkbox
  1557. */
  1558. var Checkbox = /** @class */ (function (_super) {
  1559. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1560. /**
  1561. * Creates a new CheckBox
  1562. * @param name defines the control name
  1563. */
  1564. function Checkbox(name) {
  1565. var _this = _super.call(this, name) || this;
  1566. _this.name = name;
  1567. _this._isChecked = false;
  1568. _this._background = "black";
  1569. _this._checkSizeRatio = 0.8;
  1570. _this._thickness = 1;
  1571. /**
  1572. * Observable raised when isChecked property changes
  1573. */
  1574. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1575. _this.isPointerBlocker = true;
  1576. return _this;
  1577. }
  1578. Object.defineProperty(Checkbox.prototype, "thickness", {
  1579. /** Gets or sets border thickness */
  1580. get: function () {
  1581. return this._thickness;
  1582. },
  1583. set: function (value) {
  1584. if (this._thickness === value) {
  1585. return;
  1586. }
  1587. this._thickness = value;
  1588. this._markAsDirty();
  1589. },
  1590. enumerable: true,
  1591. configurable: true
  1592. });
  1593. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1594. /** Gets or sets a value indicating the ratio between overall size and check size */
  1595. get: function () {
  1596. return this._checkSizeRatio;
  1597. },
  1598. set: function (value) {
  1599. value = Math.max(Math.min(1, value), 0);
  1600. if (this._checkSizeRatio === value) {
  1601. return;
  1602. }
  1603. this._checkSizeRatio = value;
  1604. this._markAsDirty();
  1605. },
  1606. enumerable: true,
  1607. configurable: true
  1608. });
  1609. Object.defineProperty(Checkbox.prototype, "background", {
  1610. /** Gets or sets background color */
  1611. get: function () {
  1612. return this._background;
  1613. },
  1614. set: function (value) {
  1615. if (this._background === value) {
  1616. return;
  1617. }
  1618. this._background = value;
  1619. this._markAsDirty();
  1620. },
  1621. enumerable: true,
  1622. configurable: true
  1623. });
  1624. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1625. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1626. get: function () {
  1627. return this._isChecked;
  1628. },
  1629. set: function (value) {
  1630. if (this._isChecked === value) {
  1631. return;
  1632. }
  1633. this._isChecked = value;
  1634. this._markAsDirty();
  1635. this.onIsCheckedChangedObservable.notifyObservers(value);
  1636. },
  1637. enumerable: true,
  1638. configurable: true
  1639. });
  1640. Checkbox.prototype._getTypeName = function () {
  1641. return "Checkbox";
  1642. };
  1643. /** @hidden */
  1644. Checkbox.prototype._draw = function (context) {
  1645. context.save();
  1646. this._applyStates(context);
  1647. var actualWidth = this._currentMeasure.width - this._thickness;
  1648. var actualHeight = this._currentMeasure.height - this._thickness;
  1649. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1650. context.shadowColor = this.shadowColor;
  1651. context.shadowBlur = this.shadowBlur;
  1652. context.shadowOffsetX = this.shadowOffsetX;
  1653. context.shadowOffsetY = this.shadowOffsetY;
  1654. }
  1655. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1656. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1657. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1658. context.shadowBlur = 0;
  1659. context.shadowOffsetX = 0;
  1660. context.shadowOffsetY = 0;
  1661. }
  1662. if (this._isChecked) {
  1663. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1664. var offsetWidth = actualWidth * this._checkSizeRatio;
  1665. var offseHeight = actualHeight * this._checkSizeRatio;
  1666. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1667. }
  1668. context.strokeStyle = this.color;
  1669. context.lineWidth = this._thickness;
  1670. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1671. context.restore();
  1672. };
  1673. // Events
  1674. /** @hidden */
  1675. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1676. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1677. return false;
  1678. }
  1679. this.isChecked = !this.isChecked;
  1680. return true;
  1681. };
  1682. /**
  1683. * Utility function to easily create a checkbox with a header
  1684. * @param title defines the label to use for the header
  1685. * @param onValueChanged defines the callback to call when value changes
  1686. * @returns a StackPanel containing the checkbox and a textBlock
  1687. */
  1688. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1689. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1690. panel.isVertical = false;
  1691. panel.height = "30px";
  1692. var checkbox = new Checkbox();
  1693. checkbox.width = "20px";
  1694. checkbox.height = "20px";
  1695. checkbox.isChecked = true;
  1696. checkbox.color = "green";
  1697. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1698. panel.addControl(checkbox);
  1699. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1700. header.text = title;
  1701. header.width = "180px";
  1702. header.paddingLeft = "5px";
  1703. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1704. header.color = "white";
  1705. panel.addControl(header);
  1706. return panel;
  1707. };
  1708. return Checkbox;
  1709. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1710. /***/ }),
  1711. /***/ "./2D/controls/colorpicker.ts":
  1712. /*!************************************!*\
  1713. !*** ./2D/controls/colorpicker.ts ***!
  1714. \************************************/
  1715. /*! exports provided: ColorPicker */
  1716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1717. "use strict";
  1718. __webpack_require__.r(__webpack_exports__);
  1719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1720. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1721. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1722. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1723. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1724. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1725. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1726. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1727. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1728. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1729. /** Class used to create color pickers */
  1730. var ColorPicker = /** @class */ (function (_super) {
  1731. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1732. /**
  1733. * Creates a new ColorPicker
  1734. * @param name defines the control name
  1735. */
  1736. function ColorPicker(name) {
  1737. var _this = _super.call(this, name) || this;
  1738. _this.name = name;
  1739. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1740. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1741. _this._pointerStartedOnSquare = false;
  1742. _this._pointerStartedOnWheel = false;
  1743. _this._squareLeft = 0;
  1744. _this._squareTop = 0;
  1745. _this._squareSize = 0;
  1746. _this._h = 360;
  1747. _this._s = 1;
  1748. _this._v = 1;
  1749. _this._lastPointerDownID = -1;
  1750. /**
  1751. * Observable raised when the value changes
  1752. */
  1753. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1754. // Events
  1755. _this._pointerIsDown = false;
  1756. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1757. _this.size = "200px";
  1758. _this.isPointerBlocker = true;
  1759. return _this;
  1760. }
  1761. Object.defineProperty(ColorPicker.prototype, "value", {
  1762. /** Gets or sets the color of the color picker */
  1763. get: function () {
  1764. return this._value;
  1765. },
  1766. set: function (value) {
  1767. if (this._value.equals(value)) {
  1768. return;
  1769. }
  1770. this._value.copyFrom(value);
  1771. this._value.toHSVToRef(this._tmpColor);
  1772. this._h = this._tmpColor.r;
  1773. this._s = Math.max(this._tmpColor.g, 0.00001);
  1774. this._v = Math.max(this._tmpColor.b, 0.00001);
  1775. this._markAsDirty();
  1776. if (this._value.r <= ColorPicker._Epsilon) {
  1777. this._value.r = 0;
  1778. }
  1779. if (this._value.g <= ColorPicker._Epsilon) {
  1780. this._value.g = 0;
  1781. }
  1782. if (this._value.b <= ColorPicker._Epsilon) {
  1783. this._value.b = 0;
  1784. }
  1785. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1786. this._value.r = 1.0;
  1787. }
  1788. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1789. this._value.g = 1.0;
  1790. }
  1791. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1792. this._value.b = 1.0;
  1793. }
  1794. this.onValueChangedObservable.notifyObservers(this._value);
  1795. },
  1796. enumerable: true,
  1797. configurable: true
  1798. });
  1799. Object.defineProperty(ColorPicker.prototype, "width", {
  1800. /**
  1801. * Gets or sets control width
  1802. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1803. */
  1804. get: function () {
  1805. return this._width.toString(this._host);
  1806. },
  1807. set: function (value) {
  1808. if (this._width.toString(this._host) === value) {
  1809. return;
  1810. }
  1811. if (this._width.fromString(value)) {
  1812. this._height.fromString(value);
  1813. this._markAsDirty();
  1814. }
  1815. },
  1816. enumerable: true,
  1817. configurable: true
  1818. });
  1819. Object.defineProperty(ColorPicker.prototype, "height", {
  1820. /**
  1821. * Gets or sets control height
  1822. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1823. */
  1824. get: function () {
  1825. return this._height.toString(this._host);
  1826. },
  1827. /** Gets or sets control height */
  1828. set: function (value) {
  1829. if (this._height.toString(this._host) === value) {
  1830. return;
  1831. }
  1832. if (this._height.fromString(value)) {
  1833. this._width.fromString(value);
  1834. this._markAsDirty();
  1835. }
  1836. },
  1837. enumerable: true,
  1838. configurable: true
  1839. });
  1840. Object.defineProperty(ColorPicker.prototype, "size", {
  1841. /** Gets or sets control size */
  1842. get: function () {
  1843. return this.width;
  1844. },
  1845. set: function (value) {
  1846. this.width = value;
  1847. },
  1848. enumerable: true,
  1849. configurable: true
  1850. });
  1851. ColorPicker.prototype._getTypeName = function () {
  1852. return "ColorPicker";
  1853. };
  1854. /** @hidden */
  1855. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1856. if (parentMeasure.width < parentMeasure.height) {
  1857. this._currentMeasure.height = parentMeasure.width;
  1858. }
  1859. else {
  1860. this._currentMeasure.width = parentMeasure.height;
  1861. }
  1862. };
  1863. ColorPicker.prototype._updateSquareProps = function () {
  1864. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1865. var wheelThickness = radius * .2;
  1866. var innerDiameter = (radius - wheelThickness) * 2;
  1867. var squareSize = innerDiameter / (Math.sqrt(2));
  1868. var offset = radius - squareSize * .5;
  1869. this._squareLeft = this._currentMeasure.left + offset;
  1870. this._squareTop = this._currentMeasure.top + offset;
  1871. this._squareSize = squareSize;
  1872. };
  1873. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1874. var lgh = context.createLinearGradient(left, top, width + left, top);
  1875. lgh.addColorStop(0, '#fff');
  1876. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1877. context.fillStyle = lgh;
  1878. context.fillRect(left, top, width, height);
  1879. var lgv = context.createLinearGradient(left, top, left, height + top);
  1880. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1881. lgv.addColorStop(1, '#000');
  1882. context.fillStyle = lgv;
  1883. context.fillRect(left, top, width, height);
  1884. };
  1885. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1886. context.beginPath();
  1887. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1888. context.lineWidth = 3;
  1889. context.strokeStyle = '#333333';
  1890. context.stroke();
  1891. context.beginPath();
  1892. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1893. context.lineWidth = 3;
  1894. context.strokeStyle = '#ffffff';
  1895. context.stroke();
  1896. };
  1897. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1898. var canvas = document.createElement("canvas");
  1899. canvas.width = radius * 2;
  1900. canvas.height = radius * 2;
  1901. var context = canvas.getContext("2d");
  1902. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1903. var data = image.data;
  1904. var color = this._tmpColor;
  1905. var maxDistSq = radius * radius;
  1906. var innerRadius = radius - thickness;
  1907. var minDistSq = innerRadius * innerRadius;
  1908. for (var x = -radius; x < radius; x++) {
  1909. for (var y = -radius; y < radius; y++) {
  1910. var distSq = x * x + y * y;
  1911. if (distSq > maxDistSq || distSq < minDistSq) {
  1912. continue;
  1913. }
  1914. var dist = Math.sqrt(distSq);
  1915. var ang = Math.atan2(y, x);
  1916. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1917. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1918. data[index] = color.r * 255;
  1919. data[index + 1] = color.g * 255;
  1920. data[index + 2] = color.b * 255;
  1921. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1922. //apply less alpha to bigger color pickers
  1923. var alphaAmount = .2;
  1924. var maxAlpha = .2;
  1925. var minAlpha = .04;
  1926. var lowerRadius = 50;
  1927. var upperRadius = 150;
  1928. if (radius < lowerRadius) {
  1929. alphaAmount = maxAlpha;
  1930. }
  1931. else if (radius > upperRadius) {
  1932. alphaAmount = minAlpha;
  1933. }
  1934. else {
  1935. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1936. }
  1937. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1938. if (alphaRatio < alphaAmount) {
  1939. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1940. }
  1941. else if (alphaRatio > 1 - alphaAmount) {
  1942. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1943. }
  1944. else {
  1945. data[index + 3] = 255;
  1946. }
  1947. }
  1948. }
  1949. context.putImageData(image, 0, 0);
  1950. return canvas;
  1951. };
  1952. /** @hidden */
  1953. ColorPicker.prototype._draw = function (context) {
  1954. context.save();
  1955. this._applyStates(context);
  1956. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1957. var wheelThickness = radius * .2;
  1958. var left = this._currentMeasure.left;
  1959. var top = this._currentMeasure.top;
  1960. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1961. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1962. }
  1963. this._updateSquareProps();
  1964. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1965. context.shadowColor = this.shadowColor;
  1966. context.shadowBlur = this.shadowBlur;
  1967. context.shadowOffsetX = this.shadowOffsetX;
  1968. context.shadowOffsetY = this.shadowOffsetY;
  1969. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  1970. }
  1971. context.drawImage(this._colorWheelCanvas, left, top);
  1972. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1973. context.shadowBlur = 0;
  1974. context.shadowOffsetX = 0;
  1975. context.shadowOffsetY = 0;
  1976. }
  1977. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  1978. var cx = this._squareLeft + this._squareSize * this._s;
  1979. var cy = this._squareTop + this._squareSize * (1 - this._v);
  1980. this._drawCircle(cx, cy, radius * .04, context);
  1981. var dist = radius - wheelThickness * .5;
  1982. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  1983. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  1984. this._drawCircle(cx, cy, wheelThickness * .35, context);
  1985. context.restore();
  1986. };
  1987. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  1988. if (this._pointerStartedOnWheel) {
  1989. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1990. var centerX = radius + this._currentMeasure.left;
  1991. var centerY = radius + this._currentMeasure.top;
  1992. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  1993. }
  1994. else if (this._pointerStartedOnSquare) {
  1995. this._updateSquareProps();
  1996. this._s = (x - this._squareLeft) / this._squareSize;
  1997. this._v = 1 - (y - this._squareTop) / this._squareSize;
  1998. this._s = Math.min(this._s, 1);
  1999. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2000. this._v = Math.min(this._v, 1);
  2001. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2002. }
  2003. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2004. this.value = this._tmpColor;
  2005. };
  2006. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2007. this._updateSquareProps();
  2008. var left = this._squareLeft;
  2009. var top = this._squareTop;
  2010. var size = this._squareSize;
  2011. if (x >= left && x <= left + size &&
  2012. y >= top && y <= top + size) {
  2013. return true;
  2014. }
  2015. return false;
  2016. };
  2017. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2018. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2019. var centerX = radius + this._currentMeasure.left;
  2020. var centerY = radius + this._currentMeasure.top;
  2021. var wheelThickness = radius * .2;
  2022. var innerRadius = radius - wheelThickness;
  2023. var radiusSq = radius * radius;
  2024. var innerRadiusSq = innerRadius * innerRadius;
  2025. var dx = x - centerX;
  2026. var dy = y - centerY;
  2027. var distSq = dx * dx + dy * dy;
  2028. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2029. return true;
  2030. }
  2031. return false;
  2032. };
  2033. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2034. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2035. return false;
  2036. }
  2037. this._pointerIsDown = true;
  2038. this._pointerStartedOnSquare = false;
  2039. this._pointerStartedOnWheel = false;
  2040. // Invert transform
  2041. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2042. var x = this._transformedPosition.x;
  2043. var y = this._transformedPosition.y;
  2044. if (this._isPointOnSquare(x, y)) {
  2045. this._pointerStartedOnSquare = true;
  2046. }
  2047. else if (this._isPointOnWheel(x, y)) {
  2048. this._pointerStartedOnWheel = true;
  2049. }
  2050. this._updateValueFromPointer(x, y);
  2051. this._host._capturingControl[pointerId] = this;
  2052. this._lastPointerDownID = pointerId;
  2053. return true;
  2054. };
  2055. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2056. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2057. if (pointerId != this._lastPointerDownID) {
  2058. return;
  2059. }
  2060. // Invert transform
  2061. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2062. var x = this._transformedPosition.x;
  2063. var y = this._transformedPosition.y;
  2064. if (this._pointerIsDown) {
  2065. this._updateValueFromPointer(x, y);
  2066. }
  2067. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2068. };
  2069. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2070. this._pointerIsDown = false;
  2071. delete this._host._capturingControl[pointerId];
  2072. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2073. };
  2074. /**
  2075. * This function expands the color picker by creating a color picker dialog with manual
  2076. * color value input and the ability to save colors into an array to be used later in
  2077. * subsequent launches of the dialogue.
  2078. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2079. * @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.
  2080. * @returns picked color as a hex string and the saved colors array as hex strings.
  2081. */
  2082. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2083. return new Promise(function (resolve, reject) {
  2084. // Default options
  2085. options.pickerWidth = options.pickerWidth || "640px";
  2086. options.pickerHeight = options.pickerHeight || "400px";
  2087. options.headerHeight = options.headerHeight || "35px";
  2088. options.lastColor = options.lastColor || "#000000";
  2089. options.swatchLimit = options.swatchLimit || 20;
  2090. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2091. // Window size settings
  2092. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2093. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2094. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2095. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2096. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2097. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2098. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2099. // Button Colors
  2100. var buttonColor = "#c0c0c0";
  2101. var buttonBackgroundColor = "#535353";
  2102. var buttonBackgroundHoverColor = "#414141";
  2103. var buttonBackgroundClickColor = "515151";
  2104. var buttonDisabledColor = "#555555";
  2105. var buttonDisabledBackgroundColor = "#454545";
  2106. var currentSwatchesOutlineColor = "#404040";
  2107. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2108. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2109. var iconColorDark = "#aaaaaa";
  2110. var iconColorLight = "#ffffff";
  2111. var closeIconColor;
  2112. // Button settings
  2113. var buttonFontSize;
  2114. var butEdit;
  2115. var buttonWidth;
  2116. var buttonHeight;
  2117. // Input Text Colors
  2118. var inputFieldLabels = ["R", "G", "B"];
  2119. var inputTextBackgroundColor = "#454545";
  2120. var inputTextColor = "#f0f0f0";
  2121. // This is the current color as set by either the picker or by entering a value
  2122. var currentColor;
  2123. // This int is used for naming swatches and serves as the index for calling them from the list
  2124. var swatchNumber;
  2125. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2126. var swatchDrawer;
  2127. var editSwatchMode = false;
  2128. // Color InputText fields that will be updated upon value change
  2129. var picker;
  2130. var rValInt;
  2131. var gValInt;
  2132. var bValInt;
  2133. var rValDec;
  2134. var gValDec;
  2135. var bValDec;
  2136. var hexVal;
  2137. var newSwatch;
  2138. var lastVal;
  2139. var activeField;
  2140. /**
  2141. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2142. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2143. * are will receive no update. This is to prevent the input from the user being overwritten.
  2144. */
  2145. function updateValues(value, inputField) {
  2146. activeField = inputField;
  2147. var pickedColor = value.toHexString();
  2148. newSwatch.background = pickedColor;
  2149. if (rValInt.name != activeField) {
  2150. rValInt.text = Math.floor(value.r * 255).toString();
  2151. }
  2152. if (gValInt.name != activeField) {
  2153. gValInt.text = Math.floor(value.g * 255).toString();
  2154. }
  2155. if (bValInt.name != activeField) {
  2156. bValInt.text = Math.floor(value.b * 255).toString();
  2157. }
  2158. if (rValDec.name != activeField) {
  2159. rValDec.text = value.r.toString();
  2160. }
  2161. if (gValDec.name != activeField) {
  2162. gValDec.text = value.g.toString();
  2163. }
  2164. if (bValDec.name != activeField) {
  2165. bValDec.text = value.b.toString();
  2166. }
  2167. if (hexVal.name != activeField) {
  2168. var minusPound = pickedColor.split("#");
  2169. hexVal.text = minusPound[1];
  2170. }
  2171. if (picker.name != activeField) {
  2172. picker.value = value;
  2173. }
  2174. }
  2175. // 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.
  2176. function updateInt(field, channel) {
  2177. var newValue = field.text;
  2178. var checkVal = /[^0-9]/g.test(newValue);
  2179. if (checkVal) {
  2180. field.text = lastVal;
  2181. return;
  2182. }
  2183. else {
  2184. if (newValue != "") {
  2185. if (Math.floor(parseInt(newValue)) < 0) {
  2186. newValue = "0";
  2187. }
  2188. else if (Math.floor(parseInt(newValue)) > 255) {
  2189. newValue = "255";
  2190. }
  2191. else if (isNaN(parseInt(newValue))) {
  2192. newValue = "0";
  2193. }
  2194. }
  2195. if (activeField == field.name) {
  2196. lastVal = newValue;
  2197. }
  2198. }
  2199. if (newValue != "") {
  2200. newValue = parseInt(newValue).toString();
  2201. field.text = newValue;
  2202. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2203. if (activeField == field.name) {
  2204. if (channel == "r") {
  2205. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2206. }
  2207. else if (channel == "g") {
  2208. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2209. }
  2210. else {
  2211. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2212. }
  2213. }
  2214. }
  2215. }
  2216. // 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.
  2217. function updateFloat(field, channel) {
  2218. var newValue = field.text;
  2219. var checkVal = /[^0-9\.]/g.test(newValue);
  2220. if (checkVal) {
  2221. field.text = lastVal;
  2222. return;
  2223. }
  2224. else {
  2225. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2226. if (parseFloat(newValue) < 0.0) {
  2227. newValue = "0.0";
  2228. }
  2229. else if (parseFloat(newValue) > 1.0) {
  2230. newValue = "1.0";
  2231. }
  2232. else if (isNaN(parseFloat(newValue))) {
  2233. newValue = "0.0";
  2234. }
  2235. }
  2236. if (activeField == field.name) {
  2237. lastVal = newValue;
  2238. }
  2239. }
  2240. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2241. newValue = parseFloat(newValue).toString();
  2242. field.text = newValue;
  2243. }
  2244. else {
  2245. newValue = "0.0";
  2246. }
  2247. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2248. if (activeField == field.name) {
  2249. if (channel == "r") {
  2250. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2251. }
  2252. else if (channel == "g") {
  2253. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2254. }
  2255. else {
  2256. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2257. }
  2258. }
  2259. }
  2260. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2261. function deleteSwatch(index) {
  2262. if (options.savedColors) {
  2263. options.savedColors.splice(index, 1);
  2264. }
  2265. if (options.savedColors && options.savedColors.length == 0) {
  2266. setEditButtonVisibility(false);
  2267. editSwatchMode = false;
  2268. }
  2269. }
  2270. // Creates and styles an individual swatch when updateSwatches is called.
  2271. function createSwatch() {
  2272. if (options.savedColors && options.savedColors[swatchNumber]) {
  2273. if (editSwatchMode) {
  2274. var icon = "b";
  2275. }
  2276. else {
  2277. var icon = "";
  2278. }
  2279. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2280. swatch.fontFamily = "BabylonJSglyphs";
  2281. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2282. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2283. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2284. if (swatchLuminence > luminanceLimit) {
  2285. swatch.color = iconColorDark;
  2286. }
  2287. else {
  2288. swatch.color = iconColorLight;
  2289. }
  2290. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2291. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2292. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2293. swatch.background = options.savedColors[swatchNumber];
  2294. swatch.thickness = 2;
  2295. var metadata_1 = swatchNumber;
  2296. swatch.pointerDownAnimation = function () {
  2297. swatch.thickness = 4;
  2298. };
  2299. swatch.pointerUpAnimation = function () {
  2300. swatch.thickness = 3;
  2301. };
  2302. swatch.pointerEnterAnimation = function () {
  2303. swatch.thickness = 3;
  2304. };
  2305. swatch.pointerOutAnimation = function () {
  2306. swatch.thickness = 2;
  2307. };
  2308. swatch.onPointerClickObservable.add(function () {
  2309. if (!editSwatchMode) {
  2310. if (options.savedColors) {
  2311. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2312. }
  2313. }
  2314. else {
  2315. deleteSwatch(metadata_1);
  2316. updateSwatches("", butSave);
  2317. }
  2318. });
  2319. return swatch;
  2320. }
  2321. else {
  2322. return null;
  2323. }
  2324. }
  2325. // Mode switch to render button text and close symbols on swatch controls
  2326. function editSwatches(mode) {
  2327. if (mode !== undefined) {
  2328. editSwatchMode = mode;
  2329. }
  2330. if (editSwatchMode) {
  2331. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2332. var thisButton = swatchDrawer.children[i];
  2333. thisButton.textBlock.text = "b";
  2334. }
  2335. if (butEdit !== undefined) {
  2336. butEdit.textBlock.text = "Done";
  2337. }
  2338. }
  2339. else {
  2340. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2341. var thisButton = swatchDrawer.children[i];
  2342. thisButton.textBlock.text = "";
  2343. }
  2344. if (butEdit !== undefined) {
  2345. butEdit.textBlock.text = "Edit";
  2346. }
  2347. }
  2348. }
  2349. /**
  2350. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2351. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2352. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2353. * saved colors there are and how many can be stored per row.
  2354. */
  2355. function updateSwatches(color, button) {
  2356. if (options.savedColors) {
  2357. if (color != "") {
  2358. options.savedColors.push(color);
  2359. }
  2360. swatchNumber = 0;
  2361. swatchDrawer.clearControls();
  2362. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2363. if (rowCount == 0) {
  2364. var gutterCount = 0;
  2365. }
  2366. else {
  2367. var gutterCount = rowCount + 1;
  2368. }
  2369. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2370. var currentRows = swatchDrawer.rowCount;
  2371. for (var i = 0; i < currentRows; i++) {
  2372. swatchDrawer.removeRowDefinition(0);
  2373. }
  2374. for (var i = 0; i < rowCount + gutterCount; i++) {
  2375. if (i % 2) {
  2376. swatchDrawer.addRowDefinition(swatchSize, true);
  2377. }
  2378. else {
  2379. swatchDrawer.addRowDefinition(gutterSize, true);
  2380. }
  2381. }
  2382. }
  2383. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2384. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2385. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2386. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2387. var totalButtonsThisRow = options.numSwatchesPerLine;
  2388. }
  2389. else {
  2390. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2391. }
  2392. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2393. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2394. if (x > options.numSwatchesPerLine) {
  2395. continue;
  2396. }
  2397. var swatch = createSwatch();
  2398. if (swatch != null) {
  2399. swatchDrawer.addControl(swatch, y, w);
  2400. w += 2;
  2401. swatchNumber++;
  2402. }
  2403. else {
  2404. continue;
  2405. }
  2406. }
  2407. }
  2408. if (options.savedColors.length >= options.swatchLimit) {
  2409. disableButton(button, true);
  2410. }
  2411. else {
  2412. disableButton(button, false);
  2413. }
  2414. }
  2415. }
  2416. // Shows or hides edit swatches button depending on if there are saved swatches
  2417. function setEditButtonVisibility(enableButton) {
  2418. if (enableButton) {
  2419. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2420. butEdit.width = buttonWidth;
  2421. butEdit.height = buttonHeight;
  2422. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2423. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2424. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2425. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2426. butEdit.thickness = 2;
  2427. butEdit.color = buttonColor;
  2428. butEdit.fontSize = buttonFontSize;
  2429. butEdit.background = buttonBackgroundColor;
  2430. butEdit.onPointerEnterObservable.add(function () {
  2431. butEdit.background = buttonBackgroundHoverColor;
  2432. });
  2433. butEdit.onPointerOutObservable.add(function () {
  2434. butEdit.background = buttonBackgroundColor;
  2435. });
  2436. butEdit.pointerDownAnimation = function () {
  2437. butEdit.background = buttonBackgroundClickColor;
  2438. };
  2439. butEdit.pointerUpAnimation = function () {
  2440. butEdit.background = buttonBackgroundHoverColor;
  2441. };
  2442. butEdit.onPointerClickObservable.add(function () {
  2443. if (editSwatchMode) {
  2444. editSwatchMode = false;
  2445. }
  2446. else {
  2447. editSwatchMode = true;
  2448. }
  2449. editSwatches();
  2450. });
  2451. pickerGrid.addControl(butEdit, 1, 0);
  2452. }
  2453. else {
  2454. pickerGrid.removeControl(butEdit);
  2455. }
  2456. }
  2457. // Called when the user hits the limit of saved colors in the drawer.
  2458. function disableButton(button, disabled) {
  2459. if (disabled) {
  2460. button.color = buttonDisabledColor;
  2461. button.background = buttonDisabledBackgroundColor;
  2462. }
  2463. else {
  2464. button.color = buttonColor;
  2465. button.background = buttonBackgroundColor;
  2466. }
  2467. }
  2468. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2469. function closePicker(color) {
  2470. if (options.savedColors && options.savedColors.length > 0) {
  2471. resolve({
  2472. savedColors: options.savedColors,
  2473. pickedColor: color
  2474. });
  2475. }
  2476. else {
  2477. resolve({
  2478. pickedColor: color
  2479. });
  2480. }
  2481. advancedTexture.removeControl(dialogContainer);
  2482. }
  2483. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2484. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2485. dialogContainer.name = "Dialog Container";
  2486. dialogContainer.width = options.pickerWidth;
  2487. if (options.savedColors) {
  2488. dialogContainer.height = containerSize;
  2489. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2490. dialogContainer.addRowDefinition(topRow, false);
  2491. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2492. }
  2493. else {
  2494. dialogContainer.height = options.pickerHeight;
  2495. dialogContainer.addRowDefinition(1.0, false);
  2496. }
  2497. advancedTexture.addControl(dialogContainer);
  2498. // Swatch drawer which contains all saved color buttons
  2499. if (options.savedColors) {
  2500. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2501. swatchDrawer.name = "Swatch Drawer";
  2502. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2503. swatchDrawer.background = buttonBackgroundColor;
  2504. swatchDrawer.width = options.pickerWidth;
  2505. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2506. if (initialRows == 0) {
  2507. var gutterCount = 0;
  2508. }
  2509. else {
  2510. var gutterCount = initialRows + 1;
  2511. }
  2512. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2513. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2514. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2515. if (i % 2 != 0) {
  2516. swatchDrawer.addRowDefinition(swatchSize, true);
  2517. }
  2518. else {
  2519. swatchDrawer.addRowDefinition(gutterSize, true);
  2520. }
  2521. }
  2522. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2523. if (i % 2 != 0) {
  2524. swatchDrawer.addColumnDefinition(swatchSize, true);
  2525. }
  2526. else {
  2527. swatchDrawer.addColumnDefinition(gutterSize, true);
  2528. }
  2529. }
  2530. dialogContainer.addControl(swatchDrawer, 1, 0);
  2531. }
  2532. // Picker container
  2533. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2534. pickerPanel.name = "Picker Panel";
  2535. pickerPanel.height = options.pickerHeight;
  2536. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2537. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2538. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2539. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2540. dialogContainer.addControl(pickerPanel, 0, 0);
  2541. // Picker container header
  2542. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2543. header.name = "Dialogue Header Bar";
  2544. header.background = "#cccccc";
  2545. header.thickness = 0;
  2546. pickerPanel.addControl(header, 0, 0);
  2547. // Header close button
  2548. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2549. closeButton.fontFamily = "BabylonJSglyphs";
  2550. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2551. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2552. closeButton.color = closeIconColor.toHexString();
  2553. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2554. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2555. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2556. closeButton.height = closeButton.width = options.headerHeight;
  2557. closeButton.background = header.background;
  2558. closeButton.thickness = 0;
  2559. closeButton.pointerDownAnimation = function () {
  2560. };
  2561. closeButton.pointerUpAnimation = function () {
  2562. closeButton.background = header.background;
  2563. };
  2564. closeButton.pointerEnterAnimation = function () {
  2565. closeButton.color = header.background;
  2566. closeButton.background = "red";
  2567. };
  2568. closeButton.pointerOutAnimation = function () {
  2569. closeButton.color = closeIconColor.toHexString();
  2570. closeButton.background = header.background;
  2571. };
  2572. closeButton.onPointerClickObservable.add(function () {
  2573. closePicker(currentSwatch.background);
  2574. });
  2575. pickerPanel.addControl(closeButton, 0, 0);
  2576. // Dialog container body
  2577. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2578. dialogBody.name = "Dialogue Body";
  2579. dialogBody.background = buttonBackgroundColor;
  2580. var dialogBodyCols = [0.4375, 0.5625];
  2581. dialogBody.addRowDefinition(1.0, false);
  2582. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2583. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2584. pickerPanel.addControl(dialogBody, 1, 0);
  2585. // Picker grid
  2586. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2587. pickerGrid.name = "Picker Grid";
  2588. pickerGrid.addRowDefinition(0.85, false);
  2589. pickerGrid.addRowDefinition(0.15, false);
  2590. dialogBody.addControl(pickerGrid, 0, 0);
  2591. // Picker control
  2592. picker = new ColorPicker();
  2593. picker.name = "GUI Color Picker";
  2594. if (options.pickerHeight < options.pickerWidth) {
  2595. picker.width = 0.89;
  2596. }
  2597. else {
  2598. picker.height = 0.89;
  2599. }
  2600. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2601. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2602. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2603. picker.onPointerDownObservable.add(function () {
  2604. activeField = picker.name;
  2605. lastVal = "";
  2606. editSwatches(false);
  2607. });
  2608. picker.onValueChangedObservable.add(function (value) {
  2609. if (activeField == picker.name) {
  2610. updateValues(value, picker.name);
  2611. }
  2612. });
  2613. pickerGrid.addControl(picker, 0, 0);
  2614. // Picker body right quarant
  2615. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2616. pickerBodyRight.name = "Dialogue Right Half";
  2617. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2618. var pickerBodyRightRows = [0.514, 0.486];
  2619. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2620. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2621. dialogBody.addControl(pickerBodyRight, 1, 1);
  2622. // Picker container swatches and buttons
  2623. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2624. pickerSwatchesButtons.name = "Swatches and Buttons";
  2625. var pickerButtonsCol = [0.417, 0.583];
  2626. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2627. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2628. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2629. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2630. // Picker Swatches quadrant
  2631. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2632. pickerSwatches.name = "New and Current Swatches";
  2633. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2634. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2635. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2636. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2637. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2638. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2639. // Active swatches
  2640. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2641. activeSwatches.name = "Active Swatches";
  2642. activeSwatches.width = 0.67;
  2643. activeSwatches.addRowDefinition(0.5, false);
  2644. activeSwatches.addRowDefinition(0.5, false);
  2645. pickerSwatches.addControl(activeSwatches, 2, 0);
  2646. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2647. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2648. if (options.pickerWidth > options.pickerHeight) {
  2649. var labelTextSize = labelHeight;
  2650. }
  2651. else {
  2652. var labelTextSize = labelWidth;
  2653. }
  2654. // New color swatch and previous color button
  2655. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2656. newText.text = "new";
  2657. newText.name = "New Color Label";
  2658. newText.color = buttonColor;
  2659. newText.fontSize = labelTextSize;
  2660. pickerSwatches.addControl(newText, 1, 0);
  2661. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2662. newSwatch.name = "New Color Swatch";
  2663. newSwatch.background = options.lastColor;
  2664. newSwatch.thickness = 0;
  2665. activeSwatches.addControl(newSwatch, 0, 0);
  2666. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2667. currentSwatch.background = options.lastColor;
  2668. currentSwatch.thickness = 0;
  2669. currentSwatch.onPointerClickObservable.add(function () {
  2670. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2671. updateValues(revertColor, currentSwatch.name);
  2672. editSwatches(false);
  2673. });
  2674. currentSwatch.pointerDownAnimation = function () { };
  2675. currentSwatch.pointerUpAnimation = function () { };
  2676. currentSwatch.pointerEnterAnimation = function () { };
  2677. currentSwatch.pointerOutAnimation = function () { };
  2678. activeSwatches.addControl(currentSwatch, 1, 0);
  2679. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2680. swatchOutline.name = "Swatch Outline";
  2681. swatchOutline.width = 0.67;
  2682. swatchOutline.thickness = 2;
  2683. swatchOutline.color = currentSwatchesOutlineColor;
  2684. swatchOutline.isHitTestVisible = false;
  2685. pickerSwatches.addControl(swatchOutline, 2, 0);
  2686. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2687. currentText.name = "Current Color Label";
  2688. currentText.text = "current";
  2689. currentText.color = buttonColor;
  2690. currentText.fontSize = labelTextSize;
  2691. pickerSwatches.addControl(currentText, 3, 0);
  2692. // Buttons grid
  2693. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2694. buttonGrid.name = "Button Grid";
  2695. buttonGrid.height = 0.8;
  2696. var buttonGridRows = 1 / 3;
  2697. buttonGrid.addRowDefinition(buttonGridRows, false);
  2698. buttonGrid.addRowDefinition(buttonGridRows, false);
  2699. buttonGrid.addRowDefinition(buttonGridRows, false);
  2700. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2701. // Determine pixel width and height for all buttons from overall panel dimensions
  2702. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2703. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2704. // Determine button type size
  2705. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2706. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2707. }
  2708. else {
  2709. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2710. }
  2711. // Panel Buttons
  2712. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2713. butOK.width = buttonWidth;
  2714. butOK.height = buttonHeight;
  2715. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2716. butOK.thickness = 2;
  2717. butOK.color = buttonColor;
  2718. butOK.fontSize = buttonFontSize;
  2719. butOK.background = buttonBackgroundColor;
  2720. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2721. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2722. butOK.pointerDownAnimation = function () {
  2723. butOK.background = buttonBackgroundClickColor;
  2724. };
  2725. butOK.pointerUpAnimation = function () {
  2726. butOK.background = buttonBackgroundHoverColor;
  2727. };
  2728. butOK.onPointerClickObservable.add(function () {
  2729. editSwatches(false);
  2730. closePicker(newSwatch.background);
  2731. });
  2732. buttonGrid.addControl(butOK, 0, 0);
  2733. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2734. butCancel.width = buttonWidth;
  2735. butCancel.height = buttonHeight;
  2736. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2737. butCancel.thickness = 2;
  2738. butCancel.color = buttonColor;
  2739. butCancel.fontSize = buttonFontSize;
  2740. butCancel.background = buttonBackgroundColor;
  2741. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2742. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2743. butCancel.pointerDownAnimation = function () {
  2744. butCancel.background = buttonBackgroundClickColor;
  2745. };
  2746. butCancel.pointerUpAnimation = function () {
  2747. butCancel.background = buttonBackgroundHoverColor;
  2748. };
  2749. butCancel.onPointerClickObservable.add(function () {
  2750. editSwatches(false);
  2751. closePicker(currentSwatch.background);
  2752. });
  2753. buttonGrid.addControl(butCancel, 1, 0);
  2754. if (options.savedColors) {
  2755. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2756. butSave.width = buttonWidth;
  2757. butSave.height = buttonHeight;
  2758. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2759. butSave.thickness = 2;
  2760. butSave.fontSize = buttonFontSize;
  2761. if (options.savedColors.length < options.swatchLimit) {
  2762. butSave.color = buttonColor;
  2763. butSave.background = buttonBackgroundColor;
  2764. }
  2765. else {
  2766. disableButton(butSave, true);
  2767. }
  2768. butSave.onPointerEnterObservable.add(function () {
  2769. if (options.savedColors) {
  2770. if (options.savedColors.length < options.swatchLimit) {
  2771. butSave.background = buttonBackgroundHoverColor;
  2772. }
  2773. }
  2774. });
  2775. butSave.onPointerOutObservable.add(function () {
  2776. if (options.savedColors) {
  2777. if (options.savedColors.length < options.swatchLimit) {
  2778. butSave.background = buttonBackgroundColor;
  2779. }
  2780. }
  2781. });
  2782. butSave.pointerDownAnimation = function () {
  2783. if (options.savedColors) {
  2784. if (options.savedColors.length < options.swatchLimit) {
  2785. butSave.background = buttonBackgroundClickColor;
  2786. }
  2787. }
  2788. };
  2789. butSave.pointerUpAnimation = function () {
  2790. if (options.savedColors) {
  2791. if (options.savedColors.length < options.swatchLimit) {
  2792. butSave.background = buttonBackgroundHoverColor;
  2793. }
  2794. }
  2795. };
  2796. butSave.onPointerClickObservable.add(function () {
  2797. if (options.savedColors) {
  2798. if (options.savedColors.length == 0) {
  2799. setEditButtonVisibility(true);
  2800. }
  2801. if (options.savedColors.length < options.swatchLimit) {
  2802. updateSwatches(newSwatch.background, butSave);
  2803. }
  2804. editSwatches(false);
  2805. }
  2806. });
  2807. if (options.savedColors.length > 0) {
  2808. setEditButtonVisibility(true);
  2809. }
  2810. buttonGrid.addControl(butSave, 2, 0);
  2811. }
  2812. // Picker color values input
  2813. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2814. pickerColorValues.name = "Dialog Lower Right";
  2815. pickerColorValues.addRowDefinition(0.02, false);
  2816. pickerColorValues.addRowDefinition(0.63, false);
  2817. pickerColorValues.addRowDefinition(0.21, false);
  2818. pickerColorValues.addRowDefinition(0.14, false);
  2819. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2820. // RGB values text boxes
  2821. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2822. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2823. rgbValuesQuadrant.name = "RGB Values";
  2824. rgbValuesQuadrant.width = 0.82;
  2825. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2826. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2827. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2828. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2829. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2830. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2831. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2832. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2833. for (var i = 0; i < inputFieldLabels.length; i++) {
  2834. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2835. labelText.text = inputFieldLabels[i];
  2836. labelText.color = buttonColor;
  2837. labelText.fontSize = buttonFontSize;
  2838. rgbValuesQuadrant.addControl(labelText, i, 0);
  2839. }
  2840. // Input fields for RGB values
  2841. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2842. rValInt.width = 0.83;
  2843. rValInt.height = 0.72;
  2844. rValInt.name = "rIntField";
  2845. rValInt.fontSize = buttonFontSize;
  2846. rValInt.text = (currentColor.r * 255).toString();
  2847. rValInt.color = inputTextColor;
  2848. rValInt.background = inputTextBackgroundColor;
  2849. rValInt.onFocusObservable.add(function () {
  2850. activeField = rValInt.name;
  2851. lastVal = rValInt.text;
  2852. editSwatches(false);
  2853. });
  2854. rValInt.onBlurObservable.add(function () {
  2855. if (rValInt.text == "") {
  2856. rValInt.text = "0";
  2857. }
  2858. updateInt(rValInt, "r");
  2859. if (activeField == rValInt.name) {
  2860. activeField = "";
  2861. }
  2862. });
  2863. rValInt.onTextChangedObservable.add(function () {
  2864. if (activeField == rValInt.name) {
  2865. updateInt(rValInt, "r");
  2866. }
  2867. });
  2868. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2869. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2870. gValInt.width = 0.83;
  2871. gValInt.height = 0.72;
  2872. gValInt.name = "gIntField";
  2873. gValInt.fontSize = buttonFontSize;
  2874. gValInt.text = (currentColor.g * 255).toString();
  2875. gValInt.color = inputTextColor;
  2876. gValInt.background = inputTextBackgroundColor;
  2877. gValInt.onFocusObservable.add(function () {
  2878. activeField = gValInt.name;
  2879. lastVal = gValInt.text;
  2880. editSwatches(false);
  2881. });
  2882. gValInt.onBlurObservable.add(function () {
  2883. if (gValInt.text == "") {
  2884. gValInt.text = "0";
  2885. }
  2886. updateInt(gValInt, "g");
  2887. if (activeField == gValInt.name) {
  2888. activeField = "";
  2889. }
  2890. });
  2891. gValInt.onTextChangedObservable.add(function () {
  2892. if (activeField == gValInt.name) {
  2893. updateInt(gValInt, "g");
  2894. }
  2895. });
  2896. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2897. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2898. bValInt.width = 0.83;
  2899. bValInt.height = 0.72;
  2900. bValInt.name = "bIntField";
  2901. bValInt.fontSize = buttonFontSize;
  2902. bValInt.text = (currentColor.b * 255).toString();
  2903. bValInt.color = inputTextColor;
  2904. bValInt.background = inputTextBackgroundColor;
  2905. bValInt.onFocusObservable.add(function () {
  2906. activeField = bValInt.name;
  2907. lastVal = bValInt.text;
  2908. editSwatches(false);
  2909. });
  2910. bValInt.onBlurObservable.add(function () {
  2911. if (bValInt.text == "") {
  2912. bValInt.text = "0";
  2913. }
  2914. updateInt(bValInt, "b");
  2915. if (activeField == bValInt.name) {
  2916. activeField = "";
  2917. }
  2918. });
  2919. bValInt.onTextChangedObservable.add(function () {
  2920. if (activeField == bValInt.name) {
  2921. updateInt(bValInt, "b");
  2922. }
  2923. });
  2924. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2925. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2926. rValDec.width = 0.95;
  2927. rValDec.height = 0.72;
  2928. rValDec.name = "rDecField";
  2929. rValDec.fontSize = buttonFontSize;
  2930. rValDec.text = currentColor.r.toString();
  2931. rValDec.color = inputTextColor;
  2932. rValDec.background = inputTextBackgroundColor;
  2933. rValDec.onFocusObservable.add(function () {
  2934. activeField = rValDec.name;
  2935. lastVal = rValDec.text;
  2936. editSwatches(false);
  2937. });
  2938. rValDec.onBlurObservable.add(function () {
  2939. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2940. rValDec.text = "0";
  2941. updateFloat(rValDec, "r");
  2942. }
  2943. if (activeField == rValDec.name) {
  2944. activeField = "";
  2945. }
  2946. });
  2947. rValDec.onTextChangedObservable.add(function () {
  2948. if (activeField == rValDec.name) {
  2949. updateFloat(rValDec, "r");
  2950. }
  2951. });
  2952. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2953. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2954. gValDec.width = 0.95;
  2955. gValDec.height = 0.72;
  2956. gValDec.name = "gDecField";
  2957. gValDec.fontSize = buttonFontSize;
  2958. gValDec.text = currentColor.g.toString();
  2959. gValDec.color = inputTextColor;
  2960. gValDec.background = inputTextBackgroundColor;
  2961. gValDec.onFocusObservable.add(function () {
  2962. activeField = gValDec.name;
  2963. lastVal = gValDec.text;
  2964. editSwatches(false);
  2965. });
  2966. gValDec.onBlurObservable.add(function () {
  2967. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2968. gValDec.text = "0";
  2969. updateFloat(gValDec, "g");
  2970. }
  2971. if (activeField == gValDec.name) {
  2972. activeField = "";
  2973. }
  2974. });
  2975. gValDec.onTextChangedObservable.add(function () {
  2976. if (activeField == gValDec.name) {
  2977. updateFloat(gValDec, "g");
  2978. }
  2979. });
  2980. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  2981. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2982. bValDec.width = 0.95;
  2983. bValDec.height = 0.72;
  2984. bValDec.name = "bDecField";
  2985. bValDec.fontSize = buttonFontSize;
  2986. bValDec.text = currentColor.b.toString();
  2987. bValDec.color = inputTextColor;
  2988. bValDec.background = inputTextBackgroundColor;
  2989. bValDec.onFocusObservable.add(function () {
  2990. activeField = bValDec.name;
  2991. lastVal = bValDec.text;
  2992. editSwatches(false);
  2993. });
  2994. bValDec.onBlurObservable.add(function () {
  2995. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  2996. bValDec.text = "0";
  2997. updateFloat(bValDec, "b");
  2998. }
  2999. if (activeField == bValDec.name) {
  3000. activeField = "";
  3001. }
  3002. });
  3003. bValDec.onTextChangedObservable.add(function () {
  3004. if (activeField == bValDec.name) {
  3005. updateFloat(bValDec, "b");
  3006. }
  3007. });
  3008. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3009. // Hex value input
  3010. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3011. hexValueQuadrant.name = "Hex Value";
  3012. hexValueQuadrant.width = 0.82;
  3013. hexValueQuadrant.addRowDefinition(1.0, false);
  3014. hexValueQuadrant.addColumnDefinition(0.1, false);
  3015. hexValueQuadrant.addColumnDefinition(0.9, false);
  3016. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3017. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3018. labelText.text = "#";
  3019. labelText.color = buttonColor;
  3020. labelText.fontSize = buttonFontSize;
  3021. hexValueQuadrant.addControl(labelText, 0, 0);
  3022. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3023. hexVal.width = 0.96;
  3024. hexVal.height = 0.72;
  3025. hexVal.name = "hexField";
  3026. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3027. hexVal.fontSize = buttonFontSize;
  3028. var minusPound = options.lastColor.split("#");
  3029. hexVal.text = minusPound[1];
  3030. hexVal.color = inputTextColor;
  3031. hexVal.background = inputTextBackgroundColor;
  3032. hexVal.onFocusObservable.add(function () {
  3033. activeField = hexVal.name;
  3034. lastVal = hexVal.text;
  3035. editSwatches(false);
  3036. });
  3037. hexVal.onBlurObservable.add(function () {
  3038. if (hexVal.text.length == 3) {
  3039. var val = hexVal.text.split("");
  3040. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3041. }
  3042. if (hexVal.text == "") {
  3043. hexVal.text = "000000";
  3044. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3045. }
  3046. if (activeField == hexVal.name) {
  3047. activeField = "";
  3048. }
  3049. });
  3050. hexVal.onTextChangedObservable.add(function () {
  3051. var newHexValue = hexVal.text;
  3052. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3053. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3054. hexVal.text = lastVal;
  3055. }
  3056. else {
  3057. if (hexVal.text.length < 6) {
  3058. var leadingZero = 6 - hexVal.text.length;
  3059. for (var i = 0; i < leadingZero; i++) {
  3060. newHexValue = "0" + newHexValue;
  3061. }
  3062. }
  3063. if (hexVal.text.length == 3) {
  3064. var val = hexVal.text.split("");
  3065. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3066. }
  3067. newHexValue = "#" + newHexValue;
  3068. if (activeField == hexVal.name) {
  3069. lastVal = hexVal.text;
  3070. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3071. }
  3072. }
  3073. });
  3074. hexValueQuadrant.addControl(hexVal, 0, 1);
  3075. if (options.savedColors && options.savedColors.length > 0) {
  3076. updateSwatches("", butSave);
  3077. }
  3078. });
  3079. };
  3080. ColorPicker._Epsilon = 0.000001;
  3081. return ColorPicker;
  3082. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3083. /***/ }),
  3084. /***/ "./2D/controls/container.ts":
  3085. /*!**********************************!*\
  3086. !*** ./2D/controls/container.ts ***!
  3087. \**********************************/
  3088. /*! exports provided: Container */
  3089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3090. "use strict";
  3091. __webpack_require__.r(__webpack_exports__);
  3092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3093. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3094. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3095. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3096. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3097. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3098. /**
  3099. * Root class for 2D containers
  3100. * @see http://doc.babylonjs.com/how_to/gui#containers
  3101. */
  3102. var Container = /** @class */ (function (_super) {
  3103. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3104. /**
  3105. * Creates a new Container
  3106. * @param name defines the name of the container
  3107. */
  3108. function Container(name) {
  3109. var _this = _super.call(this, name) || this;
  3110. _this.name = name;
  3111. /** @hidden */
  3112. _this._children = new Array();
  3113. /** @hidden */
  3114. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3115. /** @hidden */
  3116. _this._background = "";
  3117. /** @hidden */
  3118. _this._adaptWidthToChildren = false;
  3119. /** @hidden */
  3120. _this._adaptHeightToChildren = false;
  3121. return _this;
  3122. }
  3123. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3124. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3125. get: function () {
  3126. return this._adaptHeightToChildren;
  3127. },
  3128. set: function (value) {
  3129. if (this._adaptHeightToChildren === value) {
  3130. return;
  3131. }
  3132. this._adaptHeightToChildren = value;
  3133. if (value) {
  3134. this.height = "100%";
  3135. }
  3136. this._markAsDirty();
  3137. },
  3138. enumerable: true,
  3139. configurable: true
  3140. });
  3141. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3142. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3143. get: function () {
  3144. return this._adaptWidthToChildren;
  3145. },
  3146. set: function (value) {
  3147. if (this._adaptWidthToChildren === value) {
  3148. return;
  3149. }
  3150. this._adaptWidthToChildren = value;
  3151. if (value) {
  3152. this.width = "100%";
  3153. }
  3154. this._markAsDirty();
  3155. },
  3156. enumerable: true,
  3157. configurable: true
  3158. });
  3159. Object.defineProperty(Container.prototype, "background", {
  3160. /** Gets or sets background color */
  3161. get: function () {
  3162. return this._background;
  3163. },
  3164. set: function (value) {
  3165. if (this._background === value) {
  3166. return;
  3167. }
  3168. this._background = value;
  3169. this._markAsDirty();
  3170. },
  3171. enumerable: true,
  3172. configurable: true
  3173. });
  3174. Object.defineProperty(Container.prototype, "children", {
  3175. /** Gets the list of children */
  3176. get: function () {
  3177. return this._children;
  3178. },
  3179. enumerable: true,
  3180. configurable: true
  3181. });
  3182. Container.prototype._getTypeName = function () {
  3183. return "Container";
  3184. };
  3185. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3186. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3187. var child = _a[_i];
  3188. child._markMatrixAsDirty();
  3189. }
  3190. };
  3191. /**
  3192. * Gets a child using its name
  3193. * @param name defines the child name to look for
  3194. * @returns the child control if found
  3195. */
  3196. Container.prototype.getChildByName = function (name) {
  3197. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3198. var child = _a[_i];
  3199. if (child.name === name) {
  3200. return child;
  3201. }
  3202. }
  3203. return null;
  3204. };
  3205. /**
  3206. * Gets a child using its type and its name
  3207. * @param name defines the child name to look for
  3208. * @param type defines the child type to look for
  3209. * @returns the child control if found
  3210. */
  3211. Container.prototype.getChildByType = function (name, type) {
  3212. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3213. var child = _a[_i];
  3214. if (child.typeName === type) {
  3215. return child;
  3216. }
  3217. }
  3218. return null;
  3219. };
  3220. /**
  3221. * Search for a specific control in children
  3222. * @param control defines the control to look for
  3223. * @returns true if the control is in child list
  3224. */
  3225. Container.prototype.containsControl = function (control) {
  3226. return this.children.indexOf(control) !== -1;
  3227. };
  3228. /**
  3229. * Adds a new control to the current container
  3230. * @param control defines the control to add
  3231. * @returns the current container
  3232. */
  3233. Container.prototype.addControl = function (control) {
  3234. if (!control) {
  3235. return this;
  3236. }
  3237. var index = this._children.indexOf(control);
  3238. if (index !== -1) {
  3239. return this;
  3240. }
  3241. control._link(this._host);
  3242. control._markAllAsDirty();
  3243. this._reOrderControl(control);
  3244. this._markAsDirty();
  3245. return this;
  3246. };
  3247. /**
  3248. * Removes all controls from the current container
  3249. * @returns the current container
  3250. */
  3251. Container.prototype.clearControls = function () {
  3252. var children = this.children.slice();
  3253. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3254. var child = children_1[_i];
  3255. this.removeControl(child);
  3256. }
  3257. return this;
  3258. };
  3259. /**
  3260. * Removes a control from the current container
  3261. * @param control defines the control to remove
  3262. * @returns the current container
  3263. */
  3264. Container.prototype.removeControl = function (control) {
  3265. var index = this._children.indexOf(control);
  3266. if (index !== -1) {
  3267. this._children.splice(index, 1);
  3268. control.parent = null;
  3269. }
  3270. control.linkWithMesh(null);
  3271. if (this._host) {
  3272. this._host._cleanControlAfterRemoval(control);
  3273. }
  3274. this._markAsDirty();
  3275. return this;
  3276. };
  3277. /** @hidden */
  3278. Container.prototype._reOrderControl = function (control) {
  3279. this.removeControl(control);
  3280. var wasAdded = false;
  3281. for (var index = 0; index < this._children.length; index++) {
  3282. if (this._children[index].zIndex > control.zIndex) {
  3283. this._children.splice(index, 0, control);
  3284. wasAdded = true;
  3285. break;
  3286. }
  3287. }
  3288. if (!wasAdded) {
  3289. this._children.push(control);
  3290. }
  3291. control.parent = this;
  3292. this._markAsDirty();
  3293. };
  3294. /** @hidden */
  3295. Container.prototype._offsetLeft = function (offset) {
  3296. _super.prototype._offsetLeft.call(this, offset);
  3297. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3298. var child = _a[_i];
  3299. child._offsetLeft(offset);
  3300. }
  3301. };
  3302. /** @hidden */
  3303. Container.prototype._offsetTop = function (offset) {
  3304. _super.prototype._offsetTop.call(this, offset);
  3305. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3306. var child = _a[_i];
  3307. child._offsetTop(offset);
  3308. }
  3309. };
  3310. /** @hidden */
  3311. Container.prototype._markAllAsDirty = function () {
  3312. _super.prototype._markAllAsDirty.call(this);
  3313. for (var index = 0; index < this._children.length; index++) {
  3314. this._children[index]._markAllAsDirty();
  3315. }
  3316. };
  3317. /** @hidden */
  3318. Container.prototype._localDraw = function (context) {
  3319. if (this._background) {
  3320. context.save();
  3321. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3322. context.shadowColor = this.shadowColor;
  3323. context.shadowBlur = this.shadowBlur;
  3324. context.shadowOffsetX = this.shadowOffsetX;
  3325. context.shadowOffsetY = this.shadowOffsetY;
  3326. }
  3327. context.fillStyle = this._background;
  3328. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3329. context.restore();
  3330. }
  3331. };
  3332. /** @hidden */
  3333. Container.prototype._link = function (host) {
  3334. _super.prototype._link.call(this, host);
  3335. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3336. var child = _a[_i];
  3337. child._link(host);
  3338. }
  3339. };
  3340. /** @hidden */
  3341. Container.prototype._beforeLayout = function () {
  3342. // Do nothing
  3343. };
  3344. /** @hidden */
  3345. Container.prototype._processMeasures = function (parentMeasure, context) {
  3346. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3347. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3348. this._evaluateClippingState(parentMeasure);
  3349. }
  3350. };
  3351. /** @hidden */
  3352. Container.prototype._layout = function (parentMeasure, context) {
  3353. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3354. return false;
  3355. }
  3356. if (this._isDirty) {
  3357. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3358. }
  3359. var rebuildCount = 0;
  3360. context.save();
  3361. this._applyStates(context);
  3362. this._beforeLayout();
  3363. do {
  3364. var computedWidth = -1;
  3365. var computedHeight = -1;
  3366. this._rebuildLayout = false;
  3367. this._processMeasures(parentMeasure, context);
  3368. if (!this._isClipped) {
  3369. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3370. var child = _a[_i];
  3371. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3372. if (child._layout(this._measureForChildren, context)) {
  3373. if (this.adaptWidthToChildren && child._width.isPixel) {
  3374. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3375. }
  3376. if (this.adaptHeightToChildren && child._height.isPixel) {
  3377. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3378. }
  3379. }
  3380. }
  3381. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3382. if (this.width !== computedWidth + "px") {
  3383. this.width = computedWidth + "px";
  3384. this._rebuildLayout = true;
  3385. }
  3386. }
  3387. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3388. if (this.height !== computedHeight + "px") {
  3389. this.height = computedHeight + "px";
  3390. this._rebuildLayout = true;
  3391. }
  3392. }
  3393. this._postMeasure();
  3394. }
  3395. rebuildCount++;
  3396. } while (this._rebuildLayout && rebuildCount < 3);
  3397. if (rebuildCount >= 3) {
  3398. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3399. }
  3400. context.restore();
  3401. if (this._isDirty) {
  3402. this.invalidateRect();
  3403. this._isDirty = false;
  3404. }
  3405. return true;
  3406. };
  3407. Container.prototype._postMeasure = function () {
  3408. // Do nothing by default
  3409. };
  3410. /** @hidden */
  3411. Container.prototype._draw = function (context, invalidatedRectangle) {
  3412. this._localDraw(context);
  3413. if (this.clipChildren) {
  3414. this._clipForChildren(context);
  3415. }
  3416. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3417. var child = _a[_i];
  3418. // Only redraw parts of the screen that are invalidated
  3419. if (invalidatedRectangle) {
  3420. if (!child._intersectsRect(invalidatedRectangle)) {
  3421. continue;
  3422. }
  3423. }
  3424. child._render(context, invalidatedRectangle);
  3425. }
  3426. };
  3427. /** @hidden */
  3428. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3429. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3430. if (!this.children) {
  3431. return;
  3432. }
  3433. for (var index = 0; index < this.children.length; index++) {
  3434. var item = this.children[index];
  3435. if (!predicate || predicate(item)) {
  3436. results.push(item);
  3437. }
  3438. if (!directDescendantsOnly) {
  3439. item._getDescendants(results, false, predicate);
  3440. }
  3441. }
  3442. };
  3443. /** @hidden */
  3444. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3445. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3446. return false;
  3447. }
  3448. if (!_super.prototype.contains.call(this, x, y)) {
  3449. return false;
  3450. }
  3451. // Checking backwards to pick closest first
  3452. for (var index = this._children.length - 1; index >= 0; index--) {
  3453. var child = this._children[index];
  3454. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3455. if (child.hoverCursor) {
  3456. this._host._changeCursor(child.hoverCursor);
  3457. }
  3458. return true;
  3459. }
  3460. }
  3461. if (!this.isHitTestVisible) {
  3462. return false;
  3463. }
  3464. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3465. };
  3466. /** @hidden */
  3467. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3468. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3469. this._measureForChildren.copyFrom(this._currentMeasure);
  3470. };
  3471. /** Releases associated resources */
  3472. Container.prototype.dispose = function () {
  3473. _super.prototype.dispose.call(this);
  3474. for (var index = this.children.length - 1; index >= 0; index--) {
  3475. this.children[index].dispose();
  3476. }
  3477. };
  3478. return Container;
  3479. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3480. /***/ }),
  3481. /***/ "./2D/controls/control.ts":
  3482. /*!********************************!*\
  3483. !*** ./2D/controls/control.ts ***!
  3484. \********************************/
  3485. /*! exports provided: Control */
  3486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3487. "use strict";
  3488. __webpack_require__.r(__webpack_exports__);
  3489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3490. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3491. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3492. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3493. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3494. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3495. /**
  3496. * Root class used for all 2D controls
  3497. * @see http://doc.babylonjs.com/how_to/gui#controls
  3498. */
  3499. var Control = /** @class */ (function () {
  3500. // Functions
  3501. /**
  3502. * Creates a new control
  3503. * @param name defines the name of the control
  3504. */
  3505. function Control(
  3506. /** defines the name of the control */
  3507. name) {
  3508. this.name = name;
  3509. this._alpha = 1;
  3510. this._alphaSet = false;
  3511. this._zIndex = 0;
  3512. /** @hidden */
  3513. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3514. this._fontFamily = "Arial";
  3515. this._fontStyle = "";
  3516. this._fontWeight = "";
  3517. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3518. /** @hidden */
  3519. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3520. /** @hidden */
  3521. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3522. this._color = "";
  3523. this._style = null;
  3524. /** @hidden */
  3525. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3526. /** @hidden */
  3527. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3528. /** @hidden */
  3529. this._isDirty = true;
  3530. /** @hidden */
  3531. this._wasDirty = false;
  3532. /** @hidden */
  3533. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3534. /** @hidden */
  3535. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3536. /** @hidden */
  3537. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3538. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3539. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3540. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3541. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3542. /** @hidden */
  3543. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3544. /** @hidden */
  3545. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3546. this._scaleX = 1.0;
  3547. this._scaleY = 1.0;
  3548. this._rotation = 0;
  3549. this._transformCenterX = 0.5;
  3550. this._transformCenterY = 0.5;
  3551. /** @hidden */
  3552. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3553. /** @hidden */
  3554. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3555. /** @hidden */
  3556. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3557. this._isMatrixDirty = true;
  3558. this._isVisible = true;
  3559. this._isHighlighted = false;
  3560. this._fontSet = false;
  3561. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3562. this._downCount = 0;
  3563. this._enterCount = -1;
  3564. this._doNotRender = false;
  3565. this._downPointerIds = {};
  3566. this._isEnabled = true;
  3567. this._disabledColor = "#9a9a9a";
  3568. /** @hidden */
  3569. this._rebuildLayout = false;
  3570. /** @hidden */
  3571. this._isClipped = false;
  3572. /**
  3573. * Gets or sets an object used to store user defined information for the node
  3574. */
  3575. this.metadata = null;
  3576. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3577. this.isHitTestVisible = true;
  3578. /** Gets or sets a boolean indicating if the control can block pointer events */
  3579. this.isPointerBlocker = false;
  3580. /** Gets or sets a boolean indicating if the control can be focusable */
  3581. this.isFocusInvisible = false;
  3582. /**
  3583. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3584. * 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
  3585. */
  3586. this.clipChildren = true;
  3587. /**
  3588. * Gets or sets a boolean indicating that control content must be clipped
  3589. * 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
  3590. */
  3591. this.clipContent = true;
  3592. /**
  3593. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3594. */
  3595. this.useBitmapCache = false;
  3596. this._shadowOffsetX = 0;
  3597. this._shadowOffsetY = 0;
  3598. this._shadowBlur = 0;
  3599. this._shadowColor = 'black';
  3600. /** Gets or sets the cursor to use when the control is hovered */
  3601. this.hoverCursor = "";
  3602. /** @hidden */
  3603. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3604. /** @hidden */
  3605. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3606. /**
  3607. * An event triggered when the pointer move over the control.
  3608. */
  3609. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3610. /**
  3611. * An event triggered when the pointer move out of the control.
  3612. */
  3613. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3614. /**
  3615. * An event triggered when the pointer taps the control
  3616. */
  3617. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3618. /**
  3619. * An event triggered when pointer up
  3620. */
  3621. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3622. /**
  3623. * An event triggered when a control is clicked on
  3624. */
  3625. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3626. /**
  3627. * An event triggered when pointer enters the control
  3628. */
  3629. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3630. /**
  3631. * An event triggered when the control is marked as dirty
  3632. */
  3633. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3634. /**
  3635. * An event triggered before drawing the control
  3636. */
  3637. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3638. /**
  3639. * An event triggered after the control was drawn
  3640. */
  3641. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3642. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3643. }
  3644. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3645. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3646. get: function () {
  3647. return this._shadowOffsetX;
  3648. },
  3649. set: function (value) {
  3650. if (this._shadowOffsetX === value) {
  3651. return;
  3652. }
  3653. this._shadowOffsetX = value;
  3654. this._markAsDirty();
  3655. },
  3656. enumerable: true,
  3657. configurable: true
  3658. });
  3659. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3660. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3661. get: function () {
  3662. return this._shadowOffsetY;
  3663. },
  3664. set: function (value) {
  3665. if (this._shadowOffsetY === value) {
  3666. return;
  3667. }
  3668. this._shadowOffsetY = value;
  3669. this._markAsDirty();
  3670. },
  3671. enumerable: true,
  3672. configurable: true
  3673. });
  3674. Object.defineProperty(Control.prototype, "shadowBlur", {
  3675. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3676. get: function () {
  3677. return this._shadowBlur;
  3678. },
  3679. set: function (value) {
  3680. if (this._shadowBlur === value) {
  3681. return;
  3682. }
  3683. this._shadowBlur = value;
  3684. this._markAsDirty();
  3685. },
  3686. enumerable: true,
  3687. configurable: true
  3688. });
  3689. Object.defineProperty(Control.prototype, "shadowColor", {
  3690. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3691. get: function () {
  3692. return this._shadowColor;
  3693. },
  3694. set: function (value) {
  3695. if (this._shadowColor === value) {
  3696. return;
  3697. }
  3698. this._shadowColor = value;
  3699. this._markAsDirty();
  3700. },
  3701. enumerable: true,
  3702. configurable: true
  3703. });
  3704. Object.defineProperty(Control.prototype, "typeName", {
  3705. // Properties
  3706. /** Gets the control type name */
  3707. get: function () {
  3708. return this._getTypeName();
  3709. },
  3710. enumerable: true,
  3711. configurable: true
  3712. });
  3713. /**
  3714. * Get the current class name of the control.
  3715. * @returns current class name
  3716. */
  3717. Control.prototype.getClassName = function () {
  3718. return this._getTypeName();
  3719. };
  3720. Object.defineProperty(Control.prototype, "host", {
  3721. /**
  3722. * Get the hosting AdvancedDynamicTexture
  3723. */
  3724. get: function () {
  3725. return this._host;
  3726. },
  3727. enumerable: true,
  3728. configurable: true
  3729. });
  3730. Object.defineProperty(Control.prototype, "fontOffset", {
  3731. /** Gets or set information about font offsets (used to render and align text) */
  3732. get: function () {
  3733. return this._fontOffset;
  3734. },
  3735. set: function (offset) {
  3736. this._fontOffset = offset;
  3737. },
  3738. enumerable: true,
  3739. configurable: true
  3740. });
  3741. Object.defineProperty(Control.prototype, "alpha", {
  3742. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3743. get: function () {
  3744. return this._alpha;
  3745. },
  3746. set: function (value) {
  3747. if (this._alpha === value) {
  3748. return;
  3749. }
  3750. this._alphaSet = true;
  3751. this._alpha = value;
  3752. this._markAsDirty();
  3753. },
  3754. enumerable: true,
  3755. configurable: true
  3756. });
  3757. Object.defineProperty(Control.prototype, "isHighlighted", {
  3758. /**
  3759. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3760. */
  3761. get: function () {
  3762. return this._isHighlighted;
  3763. },
  3764. set: function (value) {
  3765. if (this._isHighlighted === value) {
  3766. return;
  3767. }
  3768. this._isHighlighted = value;
  3769. this._markAsDirty();
  3770. },
  3771. enumerable: true,
  3772. configurable: true
  3773. });
  3774. Object.defineProperty(Control.prototype, "scaleX", {
  3775. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3776. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3777. */
  3778. get: function () {
  3779. return this._scaleX;
  3780. },
  3781. set: function (value) {
  3782. if (this._scaleX === value) {
  3783. return;
  3784. }
  3785. this._scaleX = value;
  3786. this._markAsDirty();
  3787. this._markMatrixAsDirty();
  3788. },
  3789. enumerable: true,
  3790. configurable: true
  3791. });
  3792. Object.defineProperty(Control.prototype, "scaleY", {
  3793. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3794. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3795. */
  3796. get: function () {
  3797. return this._scaleY;
  3798. },
  3799. set: function (value) {
  3800. if (this._scaleY === value) {
  3801. return;
  3802. }
  3803. this._scaleY = value;
  3804. this._markAsDirty();
  3805. this._markMatrixAsDirty();
  3806. },
  3807. enumerable: true,
  3808. configurable: true
  3809. });
  3810. Object.defineProperty(Control.prototype, "rotation", {
  3811. /** Gets or sets the rotation angle (0 by default)
  3812. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3813. */
  3814. get: function () {
  3815. return this._rotation;
  3816. },
  3817. set: function (value) {
  3818. if (this._rotation === value) {
  3819. return;
  3820. }
  3821. this._rotation = value;
  3822. this._markAsDirty();
  3823. this._markMatrixAsDirty();
  3824. },
  3825. enumerable: true,
  3826. configurable: true
  3827. });
  3828. Object.defineProperty(Control.prototype, "transformCenterY", {
  3829. /** Gets or sets the transformation center on Y axis (0 by default)
  3830. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3831. */
  3832. get: function () {
  3833. return this._transformCenterY;
  3834. },
  3835. set: function (value) {
  3836. if (this._transformCenterY === value) {
  3837. return;
  3838. }
  3839. this._transformCenterY = value;
  3840. this._markAsDirty();
  3841. this._markMatrixAsDirty();
  3842. },
  3843. enumerable: true,
  3844. configurable: true
  3845. });
  3846. Object.defineProperty(Control.prototype, "transformCenterX", {
  3847. /** Gets or sets the transformation center on X axis (0 by default)
  3848. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3849. */
  3850. get: function () {
  3851. return this._transformCenterX;
  3852. },
  3853. set: function (value) {
  3854. if (this._transformCenterX === value) {
  3855. return;
  3856. }
  3857. this._transformCenterX = value;
  3858. this._markAsDirty();
  3859. this._markMatrixAsDirty();
  3860. },
  3861. enumerable: true,
  3862. configurable: true
  3863. });
  3864. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3865. /**
  3866. * Gets or sets the horizontal alignment
  3867. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3868. */
  3869. get: function () {
  3870. return this._horizontalAlignment;
  3871. },
  3872. set: function (value) {
  3873. if (this._horizontalAlignment === value) {
  3874. return;
  3875. }
  3876. this._horizontalAlignment = value;
  3877. this._markAsDirty();
  3878. },
  3879. enumerable: true,
  3880. configurable: true
  3881. });
  3882. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3883. /**
  3884. * Gets or sets the vertical alignment
  3885. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3886. */
  3887. get: function () {
  3888. return this._verticalAlignment;
  3889. },
  3890. set: function (value) {
  3891. if (this._verticalAlignment === value) {
  3892. return;
  3893. }
  3894. this._verticalAlignment = value;
  3895. this._markAsDirty();
  3896. },
  3897. enumerable: true,
  3898. configurable: true
  3899. });
  3900. Object.defineProperty(Control.prototype, "width", {
  3901. /**
  3902. * Gets or sets control width
  3903. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3904. */
  3905. get: function () {
  3906. return this._width.toString(this._host);
  3907. },
  3908. set: function (value) {
  3909. if (this._width.toString(this._host) === value) {
  3910. return;
  3911. }
  3912. if (this._width.fromString(value)) {
  3913. this._markAsDirty();
  3914. }
  3915. },
  3916. enumerable: true,
  3917. configurable: true
  3918. });
  3919. Object.defineProperty(Control.prototype, "widthInPixels", {
  3920. /**
  3921. * Gets or sets the control width in pixel
  3922. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3923. */
  3924. get: function () {
  3925. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3926. },
  3927. set: function (value) {
  3928. if (isNaN(value)) {
  3929. return;
  3930. }
  3931. this.width = value + "px";
  3932. },
  3933. enumerable: true,
  3934. configurable: true
  3935. });
  3936. Object.defineProperty(Control.prototype, "height", {
  3937. /**
  3938. * Gets or sets control height
  3939. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3940. */
  3941. get: function () {
  3942. return this._height.toString(this._host);
  3943. },
  3944. set: function (value) {
  3945. if (this._height.toString(this._host) === value) {
  3946. return;
  3947. }
  3948. if (this._height.fromString(value)) {
  3949. this._markAsDirty();
  3950. }
  3951. },
  3952. enumerable: true,
  3953. configurable: true
  3954. });
  3955. Object.defineProperty(Control.prototype, "heightInPixels", {
  3956. /**
  3957. * Gets or sets control height in pixel
  3958. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3959. */
  3960. get: function () {
  3961. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  3962. },
  3963. set: function (value) {
  3964. if (isNaN(value)) {
  3965. return;
  3966. }
  3967. this.height = value + "px";
  3968. },
  3969. enumerable: true,
  3970. configurable: true
  3971. });
  3972. Object.defineProperty(Control.prototype, "fontFamily", {
  3973. /** Gets or set font family */
  3974. get: function () {
  3975. if (!this._fontSet) {
  3976. return "";
  3977. }
  3978. return this._fontFamily;
  3979. },
  3980. set: function (value) {
  3981. if (this._fontFamily === value) {
  3982. return;
  3983. }
  3984. this._fontFamily = value;
  3985. this._resetFontCache();
  3986. },
  3987. enumerable: true,
  3988. configurable: true
  3989. });
  3990. Object.defineProperty(Control.prototype, "fontStyle", {
  3991. /** Gets or sets font style */
  3992. get: function () {
  3993. return this._fontStyle;
  3994. },
  3995. set: function (value) {
  3996. if (this._fontStyle === value) {
  3997. return;
  3998. }
  3999. this._fontStyle = value;
  4000. this._resetFontCache();
  4001. },
  4002. enumerable: true,
  4003. configurable: true
  4004. });
  4005. Object.defineProperty(Control.prototype, "fontWeight", {
  4006. /** Gets or sets font weight */
  4007. get: function () {
  4008. return this._fontWeight;
  4009. },
  4010. set: function (value) {
  4011. if (this._fontWeight === value) {
  4012. return;
  4013. }
  4014. this._fontWeight = value;
  4015. this._resetFontCache();
  4016. },
  4017. enumerable: true,
  4018. configurable: true
  4019. });
  4020. Object.defineProperty(Control.prototype, "style", {
  4021. /**
  4022. * Gets or sets style
  4023. * @see http://doc.babylonjs.com/how_to/gui#styles
  4024. */
  4025. get: function () {
  4026. return this._style;
  4027. },
  4028. set: function (value) {
  4029. var _this = this;
  4030. if (this._style) {
  4031. this._style.onChangedObservable.remove(this._styleObserver);
  4032. this._styleObserver = null;
  4033. }
  4034. this._style = value;
  4035. if (this._style) {
  4036. this._styleObserver = this._style.onChangedObservable.add(function () {
  4037. _this._markAsDirty();
  4038. _this._resetFontCache();
  4039. });
  4040. }
  4041. this._markAsDirty();
  4042. this._resetFontCache();
  4043. },
  4044. enumerable: true,
  4045. configurable: true
  4046. });
  4047. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4048. /** @hidden */
  4049. get: function () {
  4050. return this._fontSize.isPercentage;
  4051. },
  4052. enumerable: true,
  4053. configurable: true
  4054. });
  4055. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4056. /** Gets or sets font size in pixels */
  4057. get: function () {
  4058. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4059. if (fontSizeToUse.isPixel) {
  4060. return fontSizeToUse.getValue(this._host);
  4061. }
  4062. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4063. },
  4064. set: function (value) {
  4065. if (isNaN(value)) {
  4066. return;
  4067. }
  4068. this.fontSize = value + "px";
  4069. },
  4070. enumerable: true,
  4071. configurable: true
  4072. });
  4073. Object.defineProperty(Control.prototype, "fontSize", {
  4074. /** Gets or sets font size */
  4075. get: function () {
  4076. return this._fontSize.toString(this._host);
  4077. },
  4078. set: function (value) {
  4079. if (this._fontSize.toString(this._host) === value) {
  4080. return;
  4081. }
  4082. if (this._fontSize.fromString(value)) {
  4083. this._markAsDirty();
  4084. this._resetFontCache();
  4085. }
  4086. },
  4087. enumerable: true,
  4088. configurable: true
  4089. });
  4090. Object.defineProperty(Control.prototype, "color", {
  4091. /** Gets or sets foreground color */
  4092. get: function () {
  4093. return this._color;
  4094. },
  4095. set: function (value) {
  4096. if (this._color === value) {
  4097. return;
  4098. }
  4099. this._color = value;
  4100. this._markAsDirty();
  4101. },
  4102. enumerable: true,
  4103. configurable: true
  4104. });
  4105. Object.defineProperty(Control.prototype, "zIndex", {
  4106. /** Gets or sets z index which is used to reorder controls on the z axis */
  4107. get: function () {
  4108. return this._zIndex;
  4109. },
  4110. set: function (value) {
  4111. if (this.zIndex === value) {
  4112. return;
  4113. }
  4114. this._zIndex = value;
  4115. if (this.parent) {
  4116. this.parent._reOrderControl(this);
  4117. }
  4118. },
  4119. enumerable: true,
  4120. configurable: true
  4121. });
  4122. Object.defineProperty(Control.prototype, "notRenderable", {
  4123. /** Gets or sets a boolean indicating if the control can be rendered */
  4124. get: function () {
  4125. return this._doNotRender;
  4126. },
  4127. set: function (value) {
  4128. if (this._doNotRender === value) {
  4129. return;
  4130. }
  4131. this._doNotRender = value;
  4132. this._markAsDirty();
  4133. },
  4134. enumerable: true,
  4135. configurable: true
  4136. });
  4137. Object.defineProperty(Control.prototype, "isVisible", {
  4138. /** Gets or sets a boolean indicating if the control is visible */
  4139. get: function () {
  4140. return this._isVisible;
  4141. },
  4142. set: function (value) {
  4143. if (this._isVisible === value) {
  4144. return;
  4145. }
  4146. this._isVisible = value;
  4147. this._markAsDirty(true);
  4148. },
  4149. enumerable: true,
  4150. configurable: true
  4151. });
  4152. Object.defineProperty(Control.prototype, "isDirty", {
  4153. /** Gets a boolean indicating that the control needs to update its rendering */
  4154. get: function () {
  4155. return this._isDirty;
  4156. },
  4157. enumerable: true,
  4158. configurable: true
  4159. });
  4160. Object.defineProperty(Control.prototype, "linkedMesh", {
  4161. /**
  4162. * Gets the current linked mesh (or null if none)
  4163. */
  4164. get: function () {
  4165. return this._linkedMesh;
  4166. },
  4167. enumerable: true,
  4168. configurable: true
  4169. });
  4170. Object.defineProperty(Control.prototype, "paddingLeft", {
  4171. /**
  4172. * Gets or sets a value indicating the padding to use on the left of the control
  4173. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4174. */
  4175. get: function () {
  4176. return this._paddingLeft.toString(this._host);
  4177. },
  4178. set: function (value) {
  4179. if (this._paddingLeft.fromString(value)) {
  4180. this._markAsDirty();
  4181. }
  4182. },
  4183. enumerable: true,
  4184. configurable: true
  4185. });
  4186. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4187. /**
  4188. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4189. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4190. */
  4191. get: function () {
  4192. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4193. },
  4194. set: function (value) {
  4195. if (isNaN(value)) {
  4196. return;
  4197. }
  4198. this.paddingLeft = value + "px";
  4199. },
  4200. enumerable: true,
  4201. configurable: true
  4202. });
  4203. Object.defineProperty(Control.prototype, "paddingRight", {
  4204. /**
  4205. * Gets or sets a value indicating the padding to use on the right of the control
  4206. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4207. */
  4208. get: function () {
  4209. return this._paddingRight.toString(this._host);
  4210. },
  4211. set: function (value) {
  4212. if (this._paddingRight.fromString(value)) {
  4213. this._markAsDirty();
  4214. }
  4215. },
  4216. enumerable: true,
  4217. configurable: true
  4218. });
  4219. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4220. /**
  4221. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4222. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4223. */
  4224. get: function () {
  4225. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4226. },
  4227. set: function (value) {
  4228. if (isNaN(value)) {
  4229. return;
  4230. }
  4231. this.paddingRight = value + "px";
  4232. },
  4233. enumerable: true,
  4234. configurable: true
  4235. });
  4236. Object.defineProperty(Control.prototype, "paddingTop", {
  4237. /**
  4238. * Gets or sets a value indicating the padding to use on the top of the control
  4239. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4240. */
  4241. get: function () {
  4242. return this._paddingTop.toString(this._host);
  4243. },
  4244. set: function (value) {
  4245. if (this._paddingTop.fromString(value)) {
  4246. this._markAsDirty();
  4247. }
  4248. },
  4249. enumerable: true,
  4250. configurable: true
  4251. });
  4252. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4253. /**
  4254. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4255. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4256. */
  4257. get: function () {
  4258. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4259. },
  4260. set: function (value) {
  4261. if (isNaN(value)) {
  4262. return;
  4263. }
  4264. this.paddingTop = value + "px";
  4265. },
  4266. enumerable: true,
  4267. configurable: true
  4268. });
  4269. Object.defineProperty(Control.prototype, "paddingBottom", {
  4270. /**
  4271. * Gets or sets a value indicating the padding to use on the bottom of the control
  4272. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4273. */
  4274. get: function () {
  4275. return this._paddingBottom.toString(this._host);
  4276. },
  4277. set: function (value) {
  4278. if (this._paddingBottom.fromString(value)) {
  4279. this._markAsDirty();
  4280. }
  4281. },
  4282. enumerable: true,
  4283. configurable: true
  4284. });
  4285. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4286. /**
  4287. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4288. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4289. */
  4290. get: function () {
  4291. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4292. },
  4293. set: function (value) {
  4294. if (isNaN(value)) {
  4295. return;
  4296. }
  4297. this.paddingBottom = value + "px";
  4298. },
  4299. enumerable: true,
  4300. configurable: true
  4301. });
  4302. Object.defineProperty(Control.prototype, "left", {
  4303. /**
  4304. * Gets or sets a value indicating the left coordinate of the control
  4305. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4306. */
  4307. get: function () {
  4308. return this._left.toString(this._host);
  4309. },
  4310. set: function (value) {
  4311. if (this._left.fromString(value)) {
  4312. this._markAsDirty();
  4313. }
  4314. },
  4315. enumerable: true,
  4316. configurable: true
  4317. });
  4318. Object.defineProperty(Control.prototype, "leftInPixels", {
  4319. /**
  4320. * Gets or sets a value indicating the left coordinate in pixels of the control
  4321. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4322. */
  4323. get: function () {
  4324. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4325. },
  4326. set: function (value) {
  4327. if (isNaN(value)) {
  4328. return;
  4329. }
  4330. this.left = value + "px";
  4331. },
  4332. enumerable: true,
  4333. configurable: true
  4334. });
  4335. Object.defineProperty(Control.prototype, "top", {
  4336. /**
  4337. * Gets or sets a value indicating the top coordinate of the control
  4338. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4339. */
  4340. get: function () {
  4341. return this._top.toString(this._host);
  4342. },
  4343. set: function (value) {
  4344. if (this._top.fromString(value)) {
  4345. this._markAsDirty();
  4346. }
  4347. },
  4348. enumerable: true,
  4349. configurable: true
  4350. });
  4351. Object.defineProperty(Control.prototype, "topInPixels", {
  4352. /**
  4353. * Gets or sets a value indicating the top coordinate in pixels of the control
  4354. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4355. */
  4356. get: function () {
  4357. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4358. },
  4359. set: function (value) {
  4360. if (isNaN(value)) {
  4361. return;
  4362. }
  4363. this.top = value + "px";
  4364. },
  4365. enumerable: true,
  4366. configurable: true
  4367. });
  4368. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4369. /**
  4370. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4371. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4372. */
  4373. get: function () {
  4374. return this._linkOffsetX.toString(this._host);
  4375. },
  4376. set: function (value) {
  4377. if (this._linkOffsetX.fromString(value)) {
  4378. this._markAsDirty();
  4379. }
  4380. },
  4381. enumerable: true,
  4382. configurable: true
  4383. });
  4384. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4385. /**
  4386. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4387. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4388. */
  4389. get: function () {
  4390. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4391. },
  4392. set: function (value) {
  4393. if (isNaN(value)) {
  4394. return;
  4395. }
  4396. this.linkOffsetX = value + "px";
  4397. },
  4398. enumerable: true,
  4399. configurable: true
  4400. });
  4401. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4402. /**
  4403. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4404. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4405. */
  4406. get: function () {
  4407. return this._linkOffsetY.toString(this._host);
  4408. },
  4409. set: function (value) {
  4410. if (this._linkOffsetY.fromString(value)) {
  4411. this._markAsDirty();
  4412. }
  4413. },
  4414. enumerable: true,
  4415. configurable: true
  4416. });
  4417. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4418. /**
  4419. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4420. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4421. */
  4422. get: function () {
  4423. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4424. },
  4425. set: function (value) {
  4426. if (isNaN(value)) {
  4427. return;
  4428. }
  4429. this.linkOffsetY = value + "px";
  4430. },
  4431. enumerable: true,
  4432. configurable: true
  4433. });
  4434. Object.defineProperty(Control.prototype, "centerX", {
  4435. /** Gets the center coordinate on X axis */
  4436. get: function () {
  4437. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4438. },
  4439. enumerable: true,
  4440. configurable: true
  4441. });
  4442. Object.defineProperty(Control.prototype, "centerY", {
  4443. /** Gets the center coordinate on Y axis */
  4444. get: function () {
  4445. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4446. },
  4447. enumerable: true,
  4448. configurable: true
  4449. });
  4450. Object.defineProperty(Control.prototype, "isEnabled", {
  4451. /** Gets or sets if control is Enabled*/
  4452. get: function () {
  4453. return this._isEnabled;
  4454. },
  4455. set: function (value) {
  4456. if (this._isEnabled === value) {
  4457. return;
  4458. }
  4459. this._isEnabled = value;
  4460. this._markAsDirty();
  4461. },
  4462. enumerable: true,
  4463. configurable: true
  4464. });
  4465. Object.defineProperty(Control.prototype, "disabledColor", {
  4466. /** Gets or sets background color of control if it's disabled*/
  4467. get: function () {
  4468. return this._disabledColor;
  4469. },
  4470. set: function (value) {
  4471. if (this._disabledColor === value) {
  4472. return;
  4473. }
  4474. this._disabledColor = value;
  4475. this._markAsDirty();
  4476. },
  4477. enumerable: true,
  4478. configurable: true
  4479. });
  4480. /** @hidden */
  4481. Control.prototype._getTypeName = function () {
  4482. return "Control";
  4483. };
  4484. /**
  4485. * Gets the first ascendant in the hierarchy of the given type
  4486. * @param className defines the required type
  4487. * @returns the ascendant or null if not found
  4488. */
  4489. Control.prototype.getAscendantOfClass = function (className) {
  4490. if (!this.parent) {
  4491. return null;
  4492. }
  4493. if (this.parent.getClassName() === className) {
  4494. return this.parent;
  4495. }
  4496. return this.parent.getAscendantOfClass(className);
  4497. };
  4498. /** @hidden */
  4499. Control.prototype._resetFontCache = function () {
  4500. this._fontSet = true;
  4501. this._markAsDirty();
  4502. };
  4503. /**
  4504. * Determines if a container is an ascendant of the current control
  4505. * @param container defines the container to look for
  4506. * @returns true if the container is one of the ascendant of the control
  4507. */
  4508. Control.prototype.isAscendant = function (container) {
  4509. if (!this.parent) {
  4510. return false;
  4511. }
  4512. if (this.parent === container) {
  4513. return true;
  4514. }
  4515. return this.parent.isAscendant(container);
  4516. };
  4517. /**
  4518. * Gets coordinates in local control space
  4519. * @param globalCoordinates defines the coordinates to transform
  4520. * @returns the new coordinates in local space
  4521. */
  4522. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4523. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4524. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4525. return result;
  4526. };
  4527. /**
  4528. * Gets coordinates in local control space
  4529. * @param globalCoordinates defines the coordinates to transform
  4530. * @param result defines the target vector2 where to store the result
  4531. * @returns the current control
  4532. */
  4533. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4534. result.x = globalCoordinates.x - this._currentMeasure.left;
  4535. result.y = globalCoordinates.y - this._currentMeasure.top;
  4536. return this;
  4537. };
  4538. /**
  4539. * Gets coordinates in parent local control space
  4540. * @param globalCoordinates defines the coordinates to transform
  4541. * @returns the new coordinates in parent local space
  4542. */
  4543. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4544. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4545. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4546. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4547. return result;
  4548. };
  4549. /**
  4550. * Move the current control to a vector3 position projected onto the screen.
  4551. * @param position defines the target position
  4552. * @param scene defines the hosting scene
  4553. */
  4554. Control.prototype.moveToVector3 = function (position, scene) {
  4555. if (!this._host || this.parent !== this._host._rootContainer) {
  4556. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4557. return;
  4558. }
  4559. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4560. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4561. var globalViewport = this._host._getGlobalViewport(scene);
  4562. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4563. this._moveToProjectedPosition(projectedPosition);
  4564. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4565. this.notRenderable = true;
  4566. return;
  4567. }
  4568. this.notRenderable = false;
  4569. };
  4570. /** @hidden */
  4571. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4572. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4573. // Do nothing by default
  4574. };
  4575. /**
  4576. * Will return all controls that have this control as ascendant
  4577. * @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
  4578. * @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
  4579. * @return all child controls
  4580. */
  4581. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4582. var results = new Array();
  4583. this._getDescendants(results, directDescendantsOnly, predicate);
  4584. return results;
  4585. };
  4586. /**
  4587. * Link current control with a target mesh
  4588. * @param mesh defines the mesh to link with
  4589. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4590. */
  4591. Control.prototype.linkWithMesh = function (mesh) {
  4592. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4593. if (mesh) {
  4594. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4595. }
  4596. return;
  4597. }
  4598. var index = this._host._linkedControls.indexOf(this);
  4599. if (index !== -1) {
  4600. this._linkedMesh = mesh;
  4601. if (!mesh) {
  4602. this._host._linkedControls.splice(index, 1);
  4603. }
  4604. return;
  4605. }
  4606. else if (!mesh) {
  4607. return;
  4608. }
  4609. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4610. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4611. this._linkedMesh = mesh;
  4612. this._host._linkedControls.push(this);
  4613. };
  4614. /** @hidden */
  4615. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4616. var oldLeft = this._left.getValue(this._host);
  4617. var oldTop = this._top.getValue(this._host);
  4618. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4619. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4620. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4621. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4622. newLeft = oldLeft;
  4623. }
  4624. if (Math.abs(newTop - oldTop) < 0.5) {
  4625. newTop = oldTop;
  4626. }
  4627. }
  4628. this.left = newLeft + "px";
  4629. this.top = newTop + "px";
  4630. this._left.ignoreAdaptiveScaling = true;
  4631. this._top.ignoreAdaptiveScaling = true;
  4632. this._markAsDirty();
  4633. };
  4634. /** @hidden */
  4635. Control.prototype._offsetLeft = function (offset) {
  4636. this._isDirty = true;
  4637. this._currentMeasure.left += offset;
  4638. };
  4639. /** @hidden */
  4640. Control.prototype._offsetTop = function (offset) {
  4641. this._isDirty = true;
  4642. this._currentMeasure.top += offset;
  4643. };
  4644. /** @hidden */
  4645. Control.prototype._markMatrixAsDirty = function () {
  4646. this._isMatrixDirty = true;
  4647. this._flagDescendantsAsMatrixDirty();
  4648. };
  4649. /** @hidden */
  4650. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4651. // No child
  4652. };
  4653. /** @hidden */
  4654. Control.prototype._intersectsRect = function (rect) {
  4655. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4656. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4657. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4658. return false;
  4659. }
  4660. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4661. return false;
  4662. }
  4663. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4664. return false;
  4665. }
  4666. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4667. return false;
  4668. }
  4669. return true;
  4670. };
  4671. /** @hidden */
  4672. Control.prototype.invalidateRect = function () {
  4673. this._transform();
  4674. if (this.host && this.host.useInvalidateRectOptimization) {
  4675. // Rotate by transform to get the measure transformed to global space
  4676. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4677. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4678. // the previous measure is used to properly clear a control that is scaled down
  4679. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4680. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4681. // Expand rect based on shadows
  4682. var shadowOffsetX = this.shadowOffsetX;
  4683. var shadowOffsetY = this.shadowOffsetY;
  4684. var shadowBlur = this.shadowBlur;
  4685. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4686. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4687. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4688. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4689. 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));
  4690. }
  4691. else {
  4692. 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));
  4693. }
  4694. }
  4695. };
  4696. /** @hidden */
  4697. Control.prototype._markAsDirty = function (force) {
  4698. if (force === void 0) { force = false; }
  4699. if (!this._isVisible && !force) {
  4700. return;
  4701. }
  4702. this._isDirty = true;
  4703. // Redraw only this rectangle
  4704. if (this._host) {
  4705. this._host.markAsDirty();
  4706. }
  4707. };
  4708. /** @hidden */
  4709. Control.prototype._markAllAsDirty = function () {
  4710. this._markAsDirty();
  4711. if (this._font) {
  4712. this._prepareFont();
  4713. }
  4714. };
  4715. /** @hidden */
  4716. Control.prototype._link = function (host) {
  4717. this._host = host;
  4718. if (this._host) {
  4719. this.uniqueId = this._host.getScene().getUniqueId();
  4720. }
  4721. };
  4722. /** @hidden */
  4723. Control.prototype._transform = function (context) {
  4724. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4725. return;
  4726. }
  4727. // postTranslate
  4728. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4729. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4730. if (context) {
  4731. context.translate(offsetX, offsetY);
  4732. // rotate
  4733. context.rotate(this._rotation);
  4734. // scale
  4735. context.scale(this._scaleX, this._scaleY);
  4736. // preTranslate
  4737. context.translate(-offsetX, -offsetY);
  4738. }
  4739. // Need to update matrices?
  4740. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4741. this._cachedOffsetX = offsetX;
  4742. this._cachedOffsetY = offsetY;
  4743. this._isMatrixDirty = false;
  4744. this._flagDescendantsAsMatrixDirty();
  4745. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4746. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4747. }
  4748. };
  4749. /** @hidden */
  4750. Control.prototype._renderHighlight = function (context) {
  4751. if (!this.isHighlighted) {
  4752. return;
  4753. }
  4754. context.save();
  4755. context.strokeStyle = "#4affff";
  4756. context.lineWidth = 2;
  4757. this._renderHighlightSpecific(context);
  4758. context.restore();
  4759. };
  4760. /** @hidden */
  4761. Control.prototype._renderHighlightSpecific = function (context) {
  4762. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4763. };
  4764. /** @hidden */
  4765. Control.prototype._applyStates = function (context) {
  4766. if (this._isFontSizeInPercentage) {
  4767. this._fontSet = true;
  4768. }
  4769. if (this._fontSet) {
  4770. this._prepareFont();
  4771. this._fontSet = false;
  4772. }
  4773. if (this._font) {
  4774. context.font = this._font;
  4775. }
  4776. if (this._color) {
  4777. context.fillStyle = this._color;
  4778. }
  4779. if (Control.AllowAlphaInheritance) {
  4780. context.globalAlpha *= this._alpha;
  4781. }
  4782. else if (this._alphaSet) {
  4783. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4784. }
  4785. };
  4786. /** @hidden */
  4787. Control.prototype._layout = function (parentMeasure, context) {
  4788. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4789. return false;
  4790. }
  4791. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4792. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4793. context.save();
  4794. this._applyStates(context);
  4795. var rebuildCount = 0;
  4796. do {
  4797. this._rebuildLayout = false;
  4798. this._processMeasures(parentMeasure, context);
  4799. rebuildCount++;
  4800. } while (this._rebuildLayout && rebuildCount < 3);
  4801. if (rebuildCount >= 3) {
  4802. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4803. }
  4804. context.restore();
  4805. this.invalidateRect();
  4806. this._evaluateClippingState(parentMeasure);
  4807. }
  4808. this._wasDirty = this._isDirty;
  4809. this._isDirty = false;
  4810. return true;
  4811. };
  4812. /** @hidden */
  4813. Control.prototype._processMeasures = function (parentMeasure, context) {
  4814. this._currentMeasure.copyFrom(parentMeasure);
  4815. // Let children take some pre-measurement actions
  4816. this._preMeasure(parentMeasure, context);
  4817. this._measure();
  4818. this._computeAlignment(parentMeasure, context);
  4819. // Convert to int values
  4820. this._currentMeasure.left = this._currentMeasure.left | 0;
  4821. this._currentMeasure.top = this._currentMeasure.top | 0;
  4822. this._currentMeasure.width = this._currentMeasure.width | 0;
  4823. this._currentMeasure.height = this._currentMeasure.height | 0;
  4824. // Let children add more features
  4825. this._additionalProcessing(parentMeasure, context);
  4826. this._cachedParentMeasure.copyFrom(parentMeasure);
  4827. if (this.onDirtyObservable.hasObservers()) {
  4828. this.onDirtyObservable.notifyObservers(this);
  4829. }
  4830. };
  4831. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4832. if (this.parent && this.parent.clipChildren) {
  4833. // Early clip
  4834. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4835. this._isClipped = true;
  4836. return;
  4837. }
  4838. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4839. this._isClipped = true;
  4840. return;
  4841. }
  4842. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4843. this._isClipped = true;
  4844. return;
  4845. }
  4846. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4847. this._isClipped = true;
  4848. return;
  4849. }
  4850. }
  4851. this._isClipped = false;
  4852. };
  4853. /** @hidden */
  4854. Control.prototype._measure = function () {
  4855. // Width / Height
  4856. if (this._width.isPixel) {
  4857. this._currentMeasure.width = this._width.getValue(this._host);
  4858. }
  4859. else {
  4860. this._currentMeasure.width *= this._width.getValue(this._host);
  4861. }
  4862. if (this._height.isPixel) {
  4863. this._currentMeasure.height = this._height.getValue(this._host);
  4864. }
  4865. else {
  4866. this._currentMeasure.height *= this._height.getValue(this._host);
  4867. }
  4868. };
  4869. /** @hidden */
  4870. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4871. var width = this._currentMeasure.width;
  4872. var height = this._currentMeasure.height;
  4873. var parentWidth = parentMeasure.width;
  4874. var parentHeight = parentMeasure.height;
  4875. // Left / top
  4876. var x = 0;
  4877. var y = 0;
  4878. switch (this.horizontalAlignment) {
  4879. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4880. x = 0;
  4881. break;
  4882. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4883. x = parentWidth - width;
  4884. break;
  4885. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4886. x = (parentWidth - width) / 2;
  4887. break;
  4888. }
  4889. switch (this.verticalAlignment) {
  4890. case Control.VERTICAL_ALIGNMENT_TOP:
  4891. y = 0;
  4892. break;
  4893. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4894. y = parentHeight - height;
  4895. break;
  4896. case Control.VERTICAL_ALIGNMENT_CENTER:
  4897. y = (parentHeight - height) / 2;
  4898. break;
  4899. }
  4900. if (this._paddingLeft.isPixel) {
  4901. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4902. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4903. }
  4904. else {
  4905. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4906. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4907. }
  4908. if (this._paddingRight.isPixel) {
  4909. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4910. }
  4911. else {
  4912. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4913. }
  4914. if (this._paddingTop.isPixel) {
  4915. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4916. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4917. }
  4918. else {
  4919. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4920. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4921. }
  4922. if (this._paddingBottom.isPixel) {
  4923. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4924. }
  4925. else {
  4926. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4927. }
  4928. if (this._left.isPixel) {
  4929. this._currentMeasure.left += this._left.getValue(this._host);
  4930. }
  4931. else {
  4932. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4933. }
  4934. if (this._top.isPixel) {
  4935. this._currentMeasure.top += this._top.getValue(this._host);
  4936. }
  4937. else {
  4938. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4939. }
  4940. this._currentMeasure.left += x;
  4941. this._currentMeasure.top += y;
  4942. };
  4943. /** @hidden */
  4944. Control.prototype._preMeasure = function (parentMeasure, context) {
  4945. // Do nothing
  4946. };
  4947. /** @hidden */
  4948. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4949. // Do nothing
  4950. };
  4951. /** @hidden */
  4952. Control.prototype._clipForChildren = function (context) {
  4953. // DO nothing
  4954. };
  4955. Control.prototype._clip = function (context, invalidatedRectangle) {
  4956. context.beginPath();
  4957. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4958. if (invalidatedRectangle) {
  4959. // Rotate the invalidated rect into the control's space
  4960. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4961. // Get the intersection of the rect in context space and the current context
  4962. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4963. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4964. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4965. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4966. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4967. Control._ClipMeasure.copyFrom(intersection);
  4968. }
  4969. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4970. var shadowOffsetX = this.shadowOffsetX;
  4971. var shadowOffsetY = this.shadowOffsetY;
  4972. var shadowBlur = this.shadowBlur;
  4973. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4974. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4975. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4976. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4977. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  4978. }
  4979. else {
  4980. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  4981. }
  4982. context.clip();
  4983. };
  4984. /** @hidden */
  4985. Control.prototype._render = function (context, invalidatedRectangle) {
  4986. if (!this.isVisible || this.notRenderable || this._isClipped) {
  4987. this._isDirty = false;
  4988. return false;
  4989. }
  4990. context.save();
  4991. this._applyStates(context);
  4992. // Transform
  4993. this._transform(context);
  4994. // Clip
  4995. if (this.clipContent) {
  4996. this._clip(context, invalidatedRectangle);
  4997. }
  4998. if (this.onBeforeDrawObservable.hasObservers()) {
  4999. this.onBeforeDrawObservable.notifyObservers(this);
  5000. }
  5001. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5002. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5003. }
  5004. else {
  5005. this._draw(context, invalidatedRectangle);
  5006. }
  5007. if (this.useBitmapCache && this._wasDirty) {
  5008. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5009. }
  5010. this._renderHighlight(context);
  5011. if (this.onAfterDrawObservable.hasObservers()) {
  5012. this.onAfterDrawObservable.notifyObservers(this);
  5013. }
  5014. context.restore();
  5015. return true;
  5016. };
  5017. /** @hidden */
  5018. Control.prototype._draw = function (context, invalidatedRectangle) {
  5019. // Do nothing
  5020. };
  5021. /**
  5022. * Tests if a given coordinates belong to the current control
  5023. * @param x defines x coordinate to test
  5024. * @param y defines y coordinate to test
  5025. * @returns true if the coordinates are inside the control
  5026. */
  5027. Control.prototype.contains = function (x, y) {
  5028. // Invert transform
  5029. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5030. x = this._transformedPosition.x;
  5031. y = this._transformedPosition.y;
  5032. // Check
  5033. if (x < this._currentMeasure.left) {
  5034. return false;
  5035. }
  5036. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5037. return false;
  5038. }
  5039. if (y < this._currentMeasure.top) {
  5040. return false;
  5041. }
  5042. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5043. return false;
  5044. }
  5045. if (this.isPointerBlocker) {
  5046. this._host._shouldBlockPointer = true;
  5047. }
  5048. return true;
  5049. };
  5050. /** @hidden */
  5051. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5052. if (!this._isEnabled) {
  5053. return false;
  5054. }
  5055. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5056. return false;
  5057. }
  5058. if (!this.contains(x, y)) {
  5059. return false;
  5060. }
  5061. this._processObservables(type, x, y, pointerId, buttonIndex);
  5062. return true;
  5063. };
  5064. /** @hidden */
  5065. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5066. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5067. if (canNotify && this.parent != null) {
  5068. this.parent._onPointerMove(target, coordinates, pointerId);
  5069. }
  5070. };
  5071. /** @hidden */
  5072. Control.prototype._onPointerEnter = function (target) {
  5073. if (!this._isEnabled) {
  5074. return false;
  5075. }
  5076. if (this._enterCount > 0) {
  5077. return false;
  5078. }
  5079. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5080. this._enterCount = 0;
  5081. }
  5082. this._enterCount++;
  5083. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5084. if (canNotify && this.parent != null) {
  5085. this.parent._onPointerEnter(target);
  5086. }
  5087. return true;
  5088. };
  5089. /** @hidden */
  5090. Control.prototype._onPointerOut = function (target, force) {
  5091. if (force === void 0) { force = false; }
  5092. if (!force && (!this._isEnabled || target === this)) {
  5093. return;
  5094. }
  5095. this._enterCount = 0;
  5096. var canNotify = true;
  5097. if (!target.isAscendant(this)) {
  5098. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5099. }
  5100. if (canNotify && this.parent != null) {
  5101. this.parent._onPointerOut(target, force);
  5102. }
  5103. };
  5104. /** @hidden */
  5105. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5106. // Prevent pointerout to lose control context.
  5107. // Event redundancy is checked inside the function.
  5108. this._onPointerEnter(this);
  5109. if (this._downCount !== 0) {
  5110. return false;
  5111. }
  5112. this._downCount++;
  5113. this._downPointerIds[pointerId] = true;
  5114. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5115. if (canNotify && this.parent != null) {
  5116. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5117. }
  5118. return true;
  5119. };
  5120. /** @hidden */
  5121. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5122. if (!this._isEnabled) {
  5123. return;
  5124. }
  5125. this._downCount = 0;
  5126. delete this._downPointerIds[pointerId];
  5127. var canNotifyClick = notifyClick;
  5128. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5129. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5130. }
  5131. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5132. if (canNotify && this.parent != null) {
  5133. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5134. }
  5135. };
  5136. /** @hidden */
  5137. Control.prototype._forcePointerUp = function (pointerId) {
  5138. if (pointerId === void 0) { pointerId = null; }
  5139. if (pointerId !== null) {
  5140. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5141. }
  5142. else {
  5143. for (var key in this._downPointerIds) {
  5144. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5145. }
  5146. }
  5147. };
  5148. /** @hidden */
  5149. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5150. if (!this._isEnabled) {
  5151. return false;
  5152. }
  5153. this._dummyVector2.copyFromFloats(x, y);
  5154. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5155. this._onPointerMove(this, this._dummyVector2, pointerId);
  5156. var previousControlOver = this._host._lastControlOver[pointerId];
  5157. if (previousControlOver && previousControlOver !== this) {
  5158. previousControlOver._onPointerOut(this);
  5159. }
  5160. if (previousControlOver !== this) {
  5161. this._onPointerEnter(this);
  5162. }
  5163. this._host._lastControlOver[pointerId] = this;
  5164. return true;
  5165. }
  5166. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5167. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5168. this._host._registerLastControlDown(this, pointerId);
  5169. this._host._lastPickedControl = this;
  5170. return true;
  5171. }
  5172. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5173. if (this._host._lastControlDown[pointerId]) {
  5174. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5175. }
  5176. delete this._host._lastControlDown[pointerId];
  5177. return true;
  5178. }
  5179. return false;
  5180. };
  5181. Control.prototype._prepareFont = function () {
  5182. if (!this._font && !this._fontSet) {
  5183. return;
  5184. }
  5185. if (this._style) {
  5186. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5187. }
  5188. else {
  5189. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5190. }
  5191. this._fontOffset = Control._GetFontOffset(this._font);
  5192. };
  5193. /** Releases associated resources */
  5194. Control.prototype.dispose = function () {
  5195. this.onDirtyObservable.clear();
  5196. this.onBeforeDrawObservable.clear();
  5197. this.onAfterDrawObservable.clear();
  5198. this.onPointerDownObservable.clear();
  5199. this.onPointerEnterObservable.clear();
  5200. this.onPointerMoveObservable.clear();
  5201. this.onPointerOutObservable.clear();
  5202. this.onPointerUpObservable.clear();
  5203. this.onPointerClickObservable.clear();
  5204. if (this._styleObserver && this._style) {
  5205. this._style.onChangedObservable.remove(this._styleObserver);
  5206. this._styleObserver = null;
  5207. }
  5208. if (this.parent) {
  5209. this.parent.removeControl(this);
  5210. this.parent = null;
  5211. }
  5212. if (this._host) {
  5213. var index = this._host._linkedControls.indexOf(this);
  5214. if (index > -1) {
  5215. this.linkWithMesh(null);
  5216. }
  5217. }
  5218. };
  5219. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5220. /** HORIZONTAL_ALIGNMENT_LEFT */
  5221. get: function () {
  5222. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5223. },
  5224. enumerable: true,
  5225. configurable: true
  5226. });
  5227. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5228. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5229. get: function () {
  5230. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5231. },
  5232. enumerable: true,
  5233. configurable: true
  5234. });
  5235. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5236. /** HORIZONTAL_ALIGNMENT_CENTER */
  5237. get: function () {
  5238. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5239. },
  5240. enumerable: true,
  5241. configurable: true
  5242. });
  5243. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5244. /** VERTICAL_ALIGNMENT_TOP */
  5245. get: function () {
  5246. return Control._VERTICAL_ALIGNMENT_TOP;
  5247. },
  5248. enumerable: true,
  5249. configurable: true
  5250. });
  5251. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5252. /** VERTICAL_ALIGNMENT_BOTTOM */
  5253. get: function () {
  5254. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5255. },
  5256. enumerable: true,
  5257. configurable: true
  5258. });
  5259. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5260. /** VERTICAL_ALIGNMENT_CENTER */
  5261. get: function () {
  5262. return Control._VERTICAL_ALIGNMENT_CENTER;
  5263. },
  5264. enumerable: true,
  5265. configurable: true
  5266. });
  5267. /** @hidden */
  5268. Control._GetFontOffset = function (font) {
  5269. if (Control._FontHeightSizes[font]) {
  5270. return Control._FontHeightSizes[font];
  5271. }
  5272. var text = document.createElement("span");
  5273. text.innerHTML = "Hg";
  5274. text.style.font = font;
  5275. var block = document.createElement("div");
  5276. block.style.display = "inline-block";
  5277. block.style.width = "1px";
  5278. block.style.height = "0px";
  5279. block.style.verticalAlign = "bottom";
  5280. var div = document.createElement("div");
  5281. div.appendChild(text);
  5282. div.appendChild(block);
  5283. document.body.appendChild(div);
  5284. var fontAscent = 0;
  5285. var fontHeight = 0;
  5286. try {
  5287. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5288. block.style.verticalAlign = "baseline";
  5289. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5290. }
  5291. finally {
  5292. document.body.removeChild(div);
  5293. }
  5294. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5295. Control._FontHeightSizes[font] = result;
  5296. return result;
  5297. };
  5298. /** @hidden */
  5299. Control.drawEllipse = function (x, y, width, height, context) {
  5300. context.translate(x, y);
  5301. context.scale(width, height);
  5302. context.beginPath();
  5303. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5304. context.closePath();
  5305. context.scale(1 / width, 1 / height);
  5306. context.translate(-x, -y);
  5307. };
  5308. /**
  5309. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5310. */
  5311. Control.AllowAlphaInheritance = false;
  5312. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5313. // Statics
  5314. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5315. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5316. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5317. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5318. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5319. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5320. Control._FontHeightSizes = {};
  5321. /**
  5322. * Creates a stack panel that can be used to render headers
  5323. * @param control defines the control to associate with the header
  5324. * @param text defines the text of the header
  5325. * @param size defines the size of the header
  5326. * @param options defines options used to configure the header
  5327. * @returns a new StackPanel
  5328. * @ignore
  5329. * @hidden
  5330. */
  5331. Control.AddHeader = function () { };
  5332. return Control;
  5333. }());
  5334. /***/ }),
  5335. /***/ "./2D/controls/displayGrid.ts":
  5336. /*!************************************!*\
  5337. !*** ./2D/controls/displayGrid.ts ***!
  5338. \************************************/
  5339. /*! exports provided: DisplayGrid */
  5340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5341. "use strict";
  5342. __webpack_require__.r(__webpack_exports__);
  5343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5344. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5345. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5346. /** Class used to render a grid */
  5347. var DisplayGrid = /** @class */ (function (_super) {
  5348. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5349. /**
  5350. * Creates a new GridDisplayRectangle
  5351. * @param name defines the control name
  5352. */
  5353. function DisplayGrid(name) {
  5354. var _this = _super.call(this, name) || this;
  5355. _this.name = name;
  5356. _this._cellWidth = 20;
  5357. _this._cellHeight = 20;
  5358. _this._minorLineTickness = 1;
  5359. _this._minorLineColor = "DarkGray";
  5360. _this._majorLineTickness = 2;
  5361. _this._majorLineColor = "White";
  5362. _this._majorLineFrequency = 5;
  5363. _this._background = "Black";
  5364. _this._displayMajorLines = true;
  5365. _this._displayMinorLines = true;
  5366. return _this;
  5367. }
  5368. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5369. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5370. get: function () {
  5371. return this._displayMinorLines;
  5372. },
  5373. set: function (value) {
  5374. if (this._displayMinorLines === value) {
  5375. return;
  5376. }
  5377. this._displayMinorLines = value;
  5378. this._markAsDirty();
  5379. },
  5380. enumerable: true,
  5381. configurable: true
  5382. });
  5383. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5384. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5385. get: function () {
  5386. return this._displayMajorLines;
  5387. },
  5388. set: function (value) {
  5389. if (this._displayMajorLines === value) {
  5390. return;
  5391. }
  5392. this._displayMajorLines = value;
  5393. this._markAsDirty();
  5394. },
  5395. enumerable: true,
  5396. configurable: true
  5397. });
  5398. Object.defineProperty(DisplayGrid.prototype, "background", {
  5399. /** Gets or sets background color (Black by default) */
  5400. get: function () {
  5401. return this._background;
  5402. },
  5403. set: function (value) {
  5404. if (this._background === value) {
  5405. return;
  5406. }
  5407. this._background = value;
  5408. this._markAsDirty();
  5409. },
  5410. enumerable: true,
  5411. configurable: true
  5412. });
  5413. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5414. /** Gets or sets the width of each cell (20 by default) */
  5415. get: function () {
  5416. return this._cellWidth;
  5417. },
  5418. set: function (value) {
  5419. this._cellWidth = value;
  5420. this._markAsDirty();
  5421. },
  5422. enumerable: true,
  5423. configurable: true
  5424. });
  5425. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5426. /** Gets or sets the height of each cell (20 by default) */
  5427. get: function () {
  5428. return this._cellHeight;
  5429. },
  5430. set: function (value) {
  5431. this._cellHeight = value;
  5432. this._markAsDirty();
  5433. },
  5434. enumerable: true,
  5435. configurable: true
  5436. });
  5437. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5438. /** Gets or sets the tickness of minor lines (1 by default) */
  5439. get: function () {
  5440. return this._minorLineTickness;
  5441. },
  5442. set: function (value) {
  5443. this._minorLineTickness = value;
  5444. this._markAsDirty();
  5445. },
  5446. enumerable: true,
  5447. configurable: true
  5448. });
  5449. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5450. /** Gets or sets the color of minor lines (DarkGray by default) */
  5451. get: function () {
  5452. return this._minorLineColor;
  5453. },
  5454. set: function (value) {
  5455. this._minorLineColor = value;
  5456. this._markAsDirty();
  5457. },
  5458. enumerable: true,
  5459. configurable: true
  5460. });
  5461. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5462. /** Gets or sets the tickness of major lines (2 by default) */
  5463. get: function () {
  5464. return this._majorLineTickness;
  5465. },
  5466. set: function (value) {
  5467. this._majorLineTickness = value;
  5468. this._markAsDirty();
  5469. },
  5470. enumerable: true,
  5471. configurable: true
  5472. });
  5473. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5474. /** Gets or sets the color of major lines (White by default) */
  5475. get: function () {
  5476. return this._majorLineColor;
  5477. },
  5478. set: function (value) {
  5479. this._majorLineColor = value;
  5480. this._markAsDirty();
  5481. },
  5482. enumerable: true,
  5483. configurable: true
  5484. });
  5485. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5486. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5487. get: function () {
  5488. return this._majorLineFrequency;
  5489. },
  5490. set: function (value) {
  5491. this._majorLineFrequency = value;
  5492. this._markAsDirty();
  5493. },
  5494. enumerable: true,
  5495. configurable: true
  5496. });
  5497. DisplayGrid.prototype._draw = function (context) {
  5498. context.save();
  5499. this._applyStates(context);
  5500. if (this._isEnabled) {
  5501. if (this._background) {
  5502. context.fillStyle = this._background;
  5503. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5504. }
  5505. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5506. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5507. // Minor lines
  5508. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5509. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5510. if (this._displayMinorLines) {
  5511. context.strokeStyle = this._minorLineColor;
  5512. context.lineWidth = this._minorLineTickness;
  5513. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5514. var cellX = left + x * this.cellWidth;
  5515. context.beginPath();
  5516. context.moveTo(cellX, this._currentMeasure.top);
  5517. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5518. context.stroke();
  5519. }
  5520. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5521. var cellY = top_1 + y * this.cellHeight;
  5522. context.beginPath();
  5523. context.moveTo(this._currentMeasure.left, cellY);
  5524. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5525. context.stroke();
  5526. }
  5527. }
  5528. // Major lines
  5529. if (this._displayMajorLines) {
  5530. context.strokeStyle = this._majorLineColor;
  5531. context.lineWidth = this._majorLineTickness;
  5532. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5533. var cellX = left + x * this.cellWidth;
  5534. context.beginPath();
  5535. context.moveTo(cellX, this._currentMeasure.top);
  5536. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5537. context.stroke();
  5538. }
  5539. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5540. var cellY = top_1 + y * this.cellHeight;
  5541. context.moveTo(this._currentMeasure.left, cellY);
  5542. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5543. context.closePath();
  5544. context.stroke();
  5545. }
  5546. }
  5547. }
  5548. context.restore();
  5549. };
  5550. DisplayGrid.prototype._getTypeName = function () {
  5551. return "DisplayGrid";
  5552. };
  5553. return DisplayGrid;
  5554. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5555. /***/ }),
  5556. /***/ "./2D/controls/ellipse.ts":
  5557. /*!********************************!*\
  5558. !*** ./2D/controls/ellipse.ts ***!
  5559. \********************************/
  5560. /*! exports provided: Ellipse */
  5561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5562. "use strict";
  5563. __webpack_require__.r(__webpack_exports__);
  5564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5565. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5566. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5567. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5568. /** Class used to create 2D ellipse containers */
  5569. var Ellipse = /** @class */ (function (_super) {
  5570. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5571. /**
  5572. * Creates a new Ellipse
  5573. * @param name defines the control name
  5574. */
  5575. function Ellipse(name) {
  5576. var _this = _super.call(this, name) || this;
  5577. _this.name = name;
  5578. _this._thickness = 1;
  5579. return _this;
  5580. }
  5581. Object.defineProperty(Ellipse.prototype, "thickness", {
  5582. /** Gets or sets border thickness */
  5583. get: function () {
  5584. return this._thickness;
  5585. },
  5586. set: function (value) {
  5587. if (this._thickness === value) {
  5588. return;
  5589. }
  5590. this._thickness = value;
  5591. this._markAsDirty();
  5592. },
  5593. enumerable: true,
  5594. configurable: true
  5595. });
  5596. Ellipse.prototype._getTypeName = function () {
  5597. return "Ellipse";
  5598. };
  5599. Ellipse.prototype._localDraw = function (context) {
  5600. context.save();
  5601. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5602. context.shadowColor = this.shadowColor;
  5603. context.shadowBlur = this.shadowBlur;
  5604. context.shadowOffsetX = this.shadowOffsetX;
  5605. context.shadowOffsetY = this.shadowOffsetY;
  5606. }
  5607. _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);
  5608. if (this._background) {
  5609. context.fillStyle = this._background;
  5610. context.fill();
  5611. }
  5612. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5613. context.shadowBlur = 0;
  5614. context.shadowOffsetX = 0;
  5615. context.shadowOffsetY = 0;
  5616. }
  5617. if (this._thickness) {
  5618. if (this.color) {
  5619. context.strokeStyle = this.color;
  5620. }
  5621. context.lineWidth = this._thickness;
  5622. context.stroke();
  5623. }
  5624. context.restore();
  5625. };
  5626. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5627. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5628. this._measureForChildren.width -= 2 * this._thickness;
  5629. this._measureForChildren.height -= 2 * this._thickness;
  5630. this._measureForChildren.left += this._thickness;
  5631. this._measureForChildren.top += this._thickness;
  5632. };
  5633. Ellipse.prototype._clipForChildren = function (context) {
  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._currentMeasure.height / 2, context);
  5635. context.clip();
  5636. };
  5637. return Ellipse;
  5638. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5639. /***/ }),
  5640. /***/ "./2D/controls/grid.ts":
  5641. /*!*****************************!*\
  5642. !*** ./2D/controls/grid.ts ***!
  5643. \*****************************/
  5644. /*! exports provided: Grid */
  5645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5646. "use strict";
  5647. __webpack_require__.r(__webpack_exports__);
  5648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5649. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5650. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5651. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5652. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5653. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  5654. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5655. /**
  5656. * Class used to create a 2D grid container
  5657. */
  5658. var Grid = /** @class */ (function (_super) {
  5659. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5660. /**
  5661. * Creates a new Grid
  5662. * @param name defines control name
  5663. */
  5664. function Grid(name) {
  5665. var _this = _super.call(this, name) || this;
  5666. _this.name = name;
  5667. _this._rowDefinitions = new Array();
  5668. _this._columnDefinitions = new Array();
  5669. _this._cells = {};
  5670. _this._childControls = new Array();
  5671. return _this;
  5672. }
  5673. Object.defineProperty(Grid.prototype, "columnCount", {
  5674. /**
  5675. * Gets the number of columns
  5676. */
  5677. get: function () {
  5678. return this._columnDefinitions.length;
  5679. },
  5680. enumerable: true,
  5681. configurable: true
  5682. });
  5683. Object.defineProperty(Grid.prototype, "rowCount", {
  5684. /**
  5685. * Gets the number of rows
  5686. */
  5687. get: function () {
  5688. return this._rowDefinitions.length;
  5689. },
  5690. enumerable: true,
  5691. configurable: true
  5692. });
  5693. Object.defineProperty(Grid.prototype, "children", {
  5694. /** Gets the list of children */
  5695. get: function () {
  5696. return this._childControls;
  5697. },
  5698. enumerable: true,
  5699. configurable: true
  5700. });
  5701. Object.defineProperty(Grid.prototype, "cells", {
  5702. /** Gets the list of cells (e.g. the containers) */
  5703. get: function () {
  5704. return this._cells;
  5705. },
  5706. enumerable: true,
  5707. configurable: true
  5708. });
  5709. /**
  5710. * Gets the definition of a specific row
  5711. * @param index defines the index of the row
  5712. * @returns the row definition
  5713. */
  5714. Grid.prototype.getRowDefinition = function (index) {
  5715. if (index < 0 || index >= this._rowDefinitions.length) {
  5716. return null;
  5717. }
  5718. return this._rowDefinitions[index];
  5719. };
  5720. /**
  5721. * Gets the definition of a specific column
  5722. * @param index defines the index of the column
  5723. * @returns the column definition
  5724. */
  5725. Grid.prototype.getColumnDefinition = function (index) {
  5726. if (index < 0 || index >= this._columnDefinitions.length) {
  5727. return null;
  5728. }
  5729. return this._columnDefinitions[index];
  5730. };
  5731. /**
  5732. * Adds a new row to the grid
  5733. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5734. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5735. * @returns the current grid
  5736. */
  5737. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5738. if (isPixel === void 0) { isPixel = false; }
  5739. 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));
  5740. this._markAsDirty();
  5741. return this;
  5742. };
  5743. /**
  5744. * Adds a new column to the grid
  5745. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5746. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5747. * @returns the current grid
  5748. */
  5749. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5750. if (isPixel === void 0) { isPixel = false; }
  5751. 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));
  5752. this._markAsDirty();
  5753. return this;
  5754. };
  5755. /**
  5756. * Update a row definition
  5757. * @param index defines the index of the row to update
  5758. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5759. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5760. * @returns the current grid
  5761. */
  5762. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5763. if (isPixel === void 0) { isPixel = false; }
  5764. if (index < 0 || index >= this._rowDefinitions.length) {
  5765. return this;
  5766. }
  5767. var current = this._rowDefinitions[index];
  5768. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5769. return this;
  5770. }
  5771. 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);
  5772. this._markAsDirty();
  5773. return this;
  5774. };
  5775. /**
  5776. * Update a column definition
  5777. * @param index defines the index of the column to update
  5778. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5779. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5780. * @returns the current grid
  5781. */
  5782. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5783. if (isPixel === void 0) { isPixel = false; }
  5784. if (index < 0 || index >= this._columnDefinitions.length) {
  5785. return this;
  5786. }
  5787. var current = this._columnDefinitions[index];
  5788. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5789. return this;
  5790. }
  5791. 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);
  5792. this._markAsDirty();
  5793. return this;
  5794. };
  5795. /**
  5796. * Gets the list of children stored in a specific cell
  5797. * @param row defines the row to check
  5798. * @param column defines the column to check
  5799. * @returns the list of controls
  5800. */
  5801. Grid.prototype.getChildrenAt = function (row, column) {
  5802. var cell = this._cells[row + ":" + column];
  5803. if (!cell) {
  5804. return null;
  5805. }
  5806. return cell.children;
  5807. };
  5808. /**
  5809. * Gets a string representing the child cell info (row x column)
  5810. * @param child defines the control to get info from
  5811. * @returns a string containing the child cell info (row x column)
  5812. */
  5813. Grid.prototype.getChildCellInfo = function (child) {
  5814. return child._tag;
  5815. };
  5816. Grid.prototype._removeCell = function (cell, key) {
  5817. if (!cell) {
  5818. return;
  5819. }
  5820. _super.prototype.removeControl.call(this, cell);
  5821. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5822. var control = _a[_i];
  5823. var childIndex = this._childControls.indexOf(control);
  5824. if (childIndex !== -1) {
  5825. this._childControls.splice(childIndex, 1);
  5826. }
  5827. }
  5828. delete this._cells[key];
  5829. };
  5830. Grid.prototype._offsetCell = function (previousKey, key) {
  5831. if (!this._cells[key]) {
  5832. return;
  5833. }
  5834. this._cells[previousKey] = this._cells[key];
  5835. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5836. var control = _a[_i];
  5837. control._tag = previousKey;
  5838. }
  5839. delete this._cells[key];
  5840. };
  5841. /**
  5842. * Remove a column definition at specified index
  5843. * @param index defines the index of the column to remove
  5844. * @returns the current grid
  5845. */
  5846. Grid.prototype.removeColumnDefinition = function (index) {
  5847. if (index < 0 || index >= this._columnDefinitions.length) {
  5848. return this;
  5849. }
  5850. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5851. var key = x + ":" + index;
  5852. var cell = this._cells[key];
  5853. this._removeCell(cell, key);
  5854. }
  5855. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5856. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5857. var previousKey = x + ":" + (y - 1);
  5858. var key = x + ":" + y;
  5859. this._offsetCell(previousKey, key);
  5860. }
  5861. }
  5862. this._columnDefinitions.splice(index, 1);
  5863. this._markAsDirty();
  5864. return this;
  5865. };
  5866. /**
  5867. * Remove a row definition at specified index
  5868. * @param index defines the index of the row to remove
  5869. * @returns the current grid
  5870. */
  5871. Grid.prototype.removeRowDefinition = function (index) {
  5872. if (index < 0 || index >= this._rowDefinitions.length) {
  5873. return this;
  5874. }
  5875. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5876. var key = index + ":" + y;
  5877. var cell = this._cells[key];
  5878. this._removeCell(cell, key);
  5879. }
  5880. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5881. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5882. var previousKey = x - 1 + ":" + y;
  5883. var key = x + ":" + y;
  5884. this._offsetCell(previousKey, key);
  5885. }
  5886. }
  5887. this._rowDefinitions.splice(index, 1);
  5888. this._markAsDirty();
  5889. return this;
  5890. };
  5891. /**
  5892. * Adds a new control to the current grid
  5893. * @param control defines the control to add
  5894. * @param row defines the row where to add the control (0 by default)
  5895. * @param column defines the column where to add the control (0 by default)
  5896. * @returns the current grid
  5897. */
  5898. Grid.prototype.addControl = function (control, row, column) {
  5899. if (row === void 0) { row = 0; }
  5900. if (column === void 0) { column = 0; }
  5901. if (this._rowDefinitions.length === 0) {
  5902. // Add default row definition
  5903. this.addRowDefinition(1, false);
  5904. }
  5905. if (this._columnDefinitions.length === 0) {
  5906. // Add default column definition
  5907. this.addColumnDefinition(1, false);
  5908. }
  5909. if (this._childControls.indexOf(control) !== -1) {
  5910. 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");
  5911. return this;
  5912. }
  5913. var x = Math.min(row, this._rowDefinitions.length - 1);
  5914. var y = Math.min(column, this._columnDefinitions.length - 1);
  5915. var key = x + ":" + y;
  5916. var goodContainer = this._cells[key];
  5917. if (!goodContainer) {
  5918. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5919. this._cells[key] = goodContainer;
  5920. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5921. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5922. _super.prototype.addControl.call(this, goodContainer);
  5923. }
  5924. goodContainer.addControl(control);
  5925. this._childControls.push(control);
  5926. control._tag = key;
  5927. control.parent = this;
  5928. this._markAsDirty();
  5929. return this;
  5930. };
  5931. /**
  5932. * Removes a control from the current container
  5933. * @param control defines the control to remove
  5934. * @returns the current container
  5935. */
  5936. Grid.prototype.removeControl = function (control) {
  5937. var index = this._childControls.indexOf(control);
  5938. if (index !== -1) {
  5939. this._childControls.splice(index, 1);
  5940. }
  5941. var cell = this._cells[control._tag];
  5942. if (cell) {
  5943. cell.removeControl(control);
  5944. control._tag = null;
  5945. }
  5946. this._markAsDirty();
  5947. return this;
  5948. };
  5949. Grid.prototype._getTypeName = function () {
  5950. return "Grid";
  5951. };
  5952. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5953. var widths = [];
  5954. var heights = [];
  5955. var lefts = [];
  5956. var tops = [];
  5957. var availableWidth = this._currentMeasure.width;
  5958. var globalWidthPercentage = 0;
  5959. var availableHeight = this._currentMeasure.height;
  5960. var globalHeightPercentage = 0;
  5961. // Heights
  5962. var index = 0;
  5963. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5964. var value = _a[_i];
  5965. if (value.isPixel) {
  5966. var height = value.getValue(this._host);
  5967. availableHeight -= height;
  5968. heights[index] = height;
  5969. }
  5970. else {
  5971. globalHeightPercentage += value.internalValue;
  5972. }
  5973. index++;
  5974. }
  5975. var top = 0;
  5976. index = 0;
  5977. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  5978. var value = _c[_b];
  5979. tops.push(top);
  5980. if (!value.isPixel) {
  5981. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  5982. top += height;
  5983. heights[index] = height;
  5984. }
  5985. else {
  5986. top += value.getValue(this._host);
  5987. }
  5988. index++;
  5989. }
  5990. // Widths
  5991. index = 0;
  5992. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  5993. var value = _e[_d];
  5994. if (value.isPixel) {
  5995. var width = value.getValue(this._host);
  5996. availableWidth -= width;
  5997. widths[index] = width;
  5998. }
  5999. else {
  6000. globalWidthPercentage += value.internalValue;
  6001. }
  6002. index++;
  6003. }
  6004. var left = 0;
  6005. index = 0;
  6006. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6007. var value = _g[_f];
  6008. lefts.push(left);
  6009. if (!value.isPixel) {
  6010. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6011. left += width;
  6012. widths[index] = width;
  6013. }
  6014. else {
  6015. left += value.getValue(this._host);
  6016. }
  6017. index++;
  6018. }
  6019. definitionCallback(lefts, tops, widths, heights);
  6020. };
  6021. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6022. var _this = this;
  6023. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6024. // Setting child sizes
  6025. for (var key in _this._cells) {
  6026. if (!_this._cells.hasOwnProperty(key)) {
  6027. continue;
  6028. }
  6029. var split = key.split(":");
  6030. var x = parseInt(split[0]);
  6031. var y = parseInt(split[1]);
  6032. var cell = _this._cells[key];
  6033. cell.left = lefts[y] + "px";
  6034. cell.top = tops[x] + "px";
  6035. cell.width = widths[y] + "px";
  6036. cell.height = heights[x] + "px";
  6037. cell._left.ignoreAdaptiveScaling = true;
  6038. cell._top.ignoreAdaptiveScaling = true;
  6039. cell._width.ignoreAdaptiveScaling = true;
  6040. cell._height.ignoreAdaptiveScaling = true;
  6041. }
  6042. });
  6043. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6044. };
  6045. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6046. for (var key in this._cells) {
  6047. if (!this._cells.hasOwnProperty(key)) {
  6048. continue;
  6049. }
  6050. var child = this._cells[key];
  6051. child._markMatrixAsDirty();
  6052. }
  6053. };
  6054. Grid.prototype._renderHighlightSpecific = function (context) {
  6055. var _this = this;
  6056. _super.prototype._renderHighlightSpecific.call(this, context);
  6057. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6058. // Columns
  6059. for (var index = 0; index < lefts.length; index++) {
  6060. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6061. context.beginPath();
  6062. context.moveTo(left, _this._currentMeasure.top);
  6063. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6064. context.stroke();
  6065. }
  6066. // Rows
  6067. for (var index = 0; index < tops.length; index++) {
  6068. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6069. context.beginPath();
  6070. context.moveTo(_this._currentMeasure.left, top_1);
  6071. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6072. context.stroke();
  6073. }
  6074. });
  6075. context.restore();
  6076. };
  6077. /** Releases associated resources */
  6078. Grid.prototype.dispose = function () {
  6079. _super.prototype.dispose.call(this);
  6080. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6081. var control = _a[_i];
  6082. control.dispose();
  6083. }
  6084. this._childControls = [];
  6085. };
  6086. return Grid;
  6087. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6088. /***/ }),
  6089. /***/ "./2D/controls/image.ts":
  6090. /*!******************************!*\
  6091. !*** ./2D/controls/image.ts ***!
  6092. \******************************/
  6093. /*! exports provided: Image */
  6094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6095. "use strict";
  6096. __webpack_require__.r(__webpack_exports__);
  6097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6098. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6099. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6100. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6101. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6102. /**
  6103. * Class used to create 2D images
  6104. */
  6105. var Image = /** @class */ (function (_super) {
  6106. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6107. /**
  6108. * Creates a new Image
  6109. * @param name defines the control name
  6110. * @param url defines the image url
  6111. */
  6112. function Image(name, url) {
  6113. if (url === void 0) { url = null; }
  6114. var _this = _super.call(this, name) || this;
  6115. _this.name = name;
  6116. _this._loaded = false;
  6117. _this._stretch = Image.STRETCH_FILL;
  6118. _this._autoScale = false;
  6119. _this._sourceLeft = 0;
  6120. _this._sourceTop = 0;
  6121. _this._sourceWidth = 0;
  6122. _this._sourceHeight = 0;
  6123. _this._cellWidth = 0;
  6124. _this._cellHeight = 0;
  6125. _this._cellId = -1;
  6126. _this._populateNinePatchSlicesFromImage = false;
  6127. /**
  6128. * Observable notified when the content is loaded
  6129. */
  6130. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6131. _this.source = url;
  6132. return _this;
  6133. }
  6134. Object.defineProperty(Image.prototype, "isLoaded", {
  6135. /**
  6136. * Gets a boolean indicating that the content is loaded
  6137. */
  6138. get: function () {
  6139. return this._loaded;
  6140. },
  6141. enumerable: true,
  6142. configurable: true
  6143. });
  6144. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6145. /**
  6146. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6147. */
  6148. get: function () {
  6149. return this._populateNinePatchSlicesFromImage;
  6150. },
  6151. set: function (value) {
  6152. if (this._populateNinePatchSlicesFromImage === value) {
  6153. return;
  6154. }
  6155. this._populateNinePatchSlicesFromImage = value;
  6156. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6157. this._extractNinePatchSliceDataFromImage();
  6158. }
  6159. },
  6160. enumerable: true,
  6161. configurable: true
  6162. });
  6163. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6164. /**
  6165. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6166. * Beware using this as this will comsume more memory as the image has to be stored twice
  6167. */
  6168. get: function () {
  6169. return this._detectPointerOnOpaqueOnly;
  6170. },
  6171. set: function (value) {
  6172. if (this._detectPointerOnOpaqueOnly === value) {
  6173. return;
  6174. }
  6175. this._detectPointerOnOpaqueOnly = value;
  6176. },
  6177. enumerable: true,
  6178. configurable: true
  6179. });
  6180. Object.defineProperty(Image.prototype, "sliceLeft", {
  6181. /**
  6182. * Gets or sets the left value for slicing (9-patch)
  6183. */
  6184. get: function () {
  6185. return this._sliceLeft;
  6186. },
  6187. set: function (value) {
  6188. if (this._sliceLeft === value) {
  6189. return;
  6190. }
  6191. this._sliceLeft = value;
  6192. this._markAsDirty();
  6193. },
  6194. enumerable: true,
  6195. configurable: true
  6196. });
  6197. Object.defineProperty(Image.prototype, "sliceRight", {
  6198. /**
  6199. * Gets or sets the right value for slicing (9-patch)
  6200. */
  6201. get: function () {
  6202. return this._sliceRight;
  6203. },
  6204. set: function (value) {
  6205. if (this._sliceRight === value) {
  6206. return;
  6207. }
  6208. this._sliceRight = value;
  6209. this._markAsDirty();
  6210. },
  6211. enumerable: true,
  6212. configurable: true
  6213. });
  6214. Object.defineProperty(Image.prototype, "sliceTop", {
  6215. /**
  6216. * Gets or sets the top value for slicing (9-patch)
  6217. */
  6218. get: function () {
  6219. return this._sliceTop;
  6220. },
  6221. set: function (value) {
  6222. if (this._sliceTop === value) {
  6223. return;
  6224. }
  6225. this._sliceTop = value;
  6226. this._markAsDirty();
  6227. },
  6228. enumerable: true,
  6229. configurable: true
  6230. });
  6231. Object.defineProperty(Image.prototype, "sliceBottom", {
  6232. /**
  6233. * Gets or sets the bottom value for slicing (9-patch)
  6234. */
  6235. get: function () {
  6236. return this._sliceBottom;
  6237. },
  6238. set: function (value) {
  6239. if (this._sliceBottom === value) {
  6240. return;
  6241. }
  6242. this._sliceBottom = value;
  6243. this._markAsDirty();
  6244. },
  6245. enumerable: true,
  6246. configurable: true
  6247. });
  6248. Object.defineProperty(Image.prototype, "sourceLeft", {
  6249. /**
  6250. * Gets or sets the left coordinate in the source image
  6251. */
  6252. get: function () {
  6253. return this._sourceLeft;
  6254. },
  6255. set: function (value) {
  6256. if (this._sourceLeft === value) {
  6257. return;
  6258. }
  6259. this._sourceLeft = value;
  6260. this._markAsDirty();
  6261. },
  6262. enumerable: true,
  6263. configurable: true
  6264. });
  6265. Object.defineProperty(Image.prototype, "sourceTop", {
  6266. /**
  6267. * Gets or sets the top coordinate in the source image
  6268. */
  6269. get: function () {
  6270. return this._sourceTop;
  6271. },
  6272. set: function (value) {
  6273. if (this._sourceTop === value) {
  6274. return;
  6275. }
  6276. this._sourceTop = value;
  6277. this._markAsDirty();
  6278. },
  6279. enumerable: true,
  6280. configurable: true
  6281. });
  6282. Object.defineProperty(Image.prototype, "sourceWidth", {
  6283. /**
  6284. * Gets or sets the width to capture in the source image
  6285. */
  6286. get: function () {
  6287. return this._sourceWidth;
  6288. },
  6289. set: function (value) {
  6290. if (this._sourceWidth === value) {
  6291. return;
  6292. }
  6293. this._sourceWidth = value;
  6294. this._markAsDirty();
  6295. },
  6296. enumerable: true,
  6297. configurable: true
  6298. });
  6299. Object.defineProperty(Image.prototype, "sourceHeight", {
  6300. /**
  6301. * Gets or sets the height to capture in the source image
  6302. */
  6303. get: function () {
  6304. return this._sourceHeight;
  6305. },
  6306. set: function (value) {
  6307. if (this._sourceHeight === value) {
  6308. return;
  6309. }
  6310. this._sourceHeight = value;
  6311. this._markAsDirty();
  6312. },
  6313. enumerable: true,
  6314. configurable: true
  6315. });
  6316. Object.defineProperty(Image.prototype, "autoScale", {
  6317. /**
  6318. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6319. * @see http://doc.babylonjs.com/how_to/gui#image
  6320. */
  6321. get: function () {
  6322. return this._autoScale;
  6323. },
  6324. set: function (value) {
  6325. if (this._autoScale === value) {
  6326. return;
  6327. }
  6328. this._autoScale = value;
  6329. if (value && this._loaded) {
  6330. this.synchronizeSizeWithContent();
  6331. }
  6332. },
  6333. enumerable: true,
  6334. configurable: true
  6335. });
  6336. Object.defineProperty(Image.prototype, "stretch", {
  6337. /** Gets or sets the streching mode used by the image */
  6338. get: function () {
  6339. return this._stretch;
  6340. },
  6341. set: function (value) {
  6342. if (this._stretch === value) {
  6343. return;
  6344. }
  6345. this._stretch = value;
  6346. this._markAsDirty();
  6347. },
  6348. enumerable: true,
  6349. configurable: true
  6350. });
  6351. Object.defineProperty(Image.prototype, "domImage", {
  6352. get: function () {
  6353. return this._domImage;
  6354. },
  6355. /**
  6356. * Gets or sets the internal DOM image used to render the control
  6357. */
  6358. set: function (value) {
  6359. var _this = this;
  6360. this._domImage = value;
  6361. this._loaded = false;
  6362. if (this._domImage.width) {
  6363. this._onImageLoaded();
  6364. }
  6365. else {
  6366. this._domImage.onload = function () {
  6367. _this._onImageLoaded();
  6368. };
  6369. }
  6370. },
  6371. enumerable: true,
  6372. configurable: true
  6373. });
  6374. Image.prototype._onImageLoaded = function () {
  6375. this._imageWidth = this._domImage.width;
  6376. this._imageHeight = this._domImage.height;
  6377. this._loaded = true;
  6378. if (this._populateNinePatchSlicesFromImage) {
  6379. this._extractNinePatchSliceDataFromImage();
  6380. }
  6381. if (this._autoScale) {
  6382. this.synchronizeSizeWithContent();
  6383. }
  6384. this.onImageLoadedObservable.notifyObservers(this);
  6385. this._markAsDirty();
  6386. };
  6387. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6388. if (!Image._WorkingCanvas) {
  6389. Image._WorkingCanvas = document.createElement('canvas');
  6390. }
  6391. var canvas = Image._WorkingCanvas;
  6392. var context = canvas.getContext('2d');
  6393. var width = this._domImage.width;
  6394. var height = this._domImage.height;
  6395. canvas.width = width;
  6396. canvas.height = height;
  6397. context.drawImage(this._domImage, 0, 0, width, height);
  6398. var imageData = context.getImageData(0, 0, width, height);
  6399. // Left and right
  6400. this._sliceLeft = -1;
  6401. this._sliceRight = -1;
  6402. for (var x = 0; x < width; x++) {
  6403. var alpha = imageData.data[x * 4 + 3];
  6404. if (alpha > 127 && this._sliceLeft === -1) {
  6405. this._sliceLeft = x;
  6406. continue;
  6407. }
  6408. if (alpha < 127 && this._sliceLeft > -1) {
  6409. this._sliceRight = x;
  6410. break;
  6411. }
  6412. }
  6413. // top and bottom
  6414. this._sliceTop = -1;
  6415. this._sliceBottom = -1;
  6416. for (var y = 0; y < height; y++) {
  6417. var alpha = imageData.data[y * width * 4 + 3];
  6418. if (alpha > 127 && this._sliceTop === -1) {
  6419. this._sliceTop = y;
  6420. continue;
  6421. }
  6422. if (alpha < 127 && this._sliceTop > -1) {
  6423. this._sliceBottom = y;
  6424. break;
  6425. }
  6426. }
  6427. };
  6428. Object.defineProperty(Image.prototype, "source", {
  6429. /**
  6430. * Gets or sets image source url
  6431. */
  6432. set: function (value) {
  6433. var _this = this;
  6434. if (this._source === value) {
  6435. return;
  6436. }
  6437. this._loaded = false;
  6438. this._source = value;
  6439. this._domImage = document.createElement("img");
  6440. this._domImage.onload = function () {
  6441. _this._onImageLoaded();
  6442. };
  6443. if (value) {
  6444. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6445. this._domImage.src = value;
  6446. }
  6447. },
  6448. enumerable: true,
  6449. configurable: true
  6450. });
  6451. Object.defineProperty(Image.prototype, "cellWidth", {
  6452. /**
  6453. * Gets or sets the cell width to use when animation sheet is enabled
  6454. * @see http://doc.babylonjs.com/how_to/gui#image
  6455. */
  6456. get: function () {
  6457. return this._cellWidth;
  6458. },
  6459. set: function (value) {
  6460. if (this._cellWidth === value) {
  6461. return;
  6462. }
  6463. this._cellWidth = value;
  6464. this._markAsDirty();
  6465. },
  6466. enumerable: true,
  6467. configurable: true
  6468. });
  6469. Object.defineProperty(Image.prototype, "cellHeight", {
  6470. /**
  6471. * Gets or sets the cell height to use when animation sheet is enabled
  6472. * @see http://doc.babylonjs.com/how_to/gui#image
  6473. */
  6474. get: function () {
  6475. return this._cellHeight;
  6476. },
  6477. set: function (value) {
  6478. if (this._cellHeight === value) {
  6479. return;
  6480. }
  6481. this._cellHeight = value;
  6482. this._markAsDirty();
  6483. },
  6484. enumerable: true,
  6485. configurable: true
  6486. });
  6487. Object.defineProperty(Image.prototype, "cellId", {
  6488. /**
  6489. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6490. * @see http://doc.babylonjs.com/how_to/gui#image
  6491. */
  6492. get: function () {
  6493. return this._cellId;
  6494. },
  6495. set: function (value) {
  6496. if (this._cellId === value) {
  6497. return;
  6498. }
  6499. this._cellId = value;
  6500. this._markAsDirty();
  6501. },
  6502. enumerable: true,
  6503. configurable: true
  6504. });
  6505. /**
  6506. * Tests if a given coordinates belong to the current control
  6507. * @param x defines x coordinate to test
  6508. * @param y defines y coordinate to test
  6509. * @returns true if the coordinates are inside the control
  6510. */
  6511. Image.prototype.contains = function (x, y) {
  6512. if (!_super.prototype.contains.call(this, x, y)) {
  6513. return false;
  6514. }
  6515. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6516. return true;
  6517. }
  6518. var canvas = Image._WorkingCanvas;
  6519. var context = canvas.getContext("2d");
  6520. var width = this._currentMeasure.width | 0;
  6521. var height = this._currentMeasure.height | 0;
  6522. var imageData = context.getImageData(0, 0, width, height).data;
  6523. x = (x - this._currentMeasure.left) | 0;
  6524. y = (y - this._currentMeasure.top) | 0;
  6525. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6526. return pickedPixel > 0;
  6527. };
  6528. Image.prototype._getTypeName = function () {
  6529. return "Image";
  6530. };
  6531. /** Force the control to synchronize with its content */
  6532. Image.prototype.synchronizeSizeWithContent = function () {
  6533. if (!this._loaded) {
  6534. return;
  6535. }
  6536. this.width = this._domImage.width + "px";
  6537. this.height = this._domImage.height + "px";
  6538. };
  6539. Image.prototype._processMeasures = function (parentMeasure, context) {
  6540. if (this._loaded) {
  6541. switch (this._stretch) {
  6542. case Image.STRETCH_NONE:
  6543. break;
  6544. case Image.STRETCH_FILL:
  6545. break;
  6546. case Image.STRETCH_UNIFORM:
  6547. break;
  6548. case Image.STRETCH_NINE_PATCH:
  6549. break;
  6550. case Image.STRETCH_EXTEND:
  6551. if (this._autoScale) {
  6552. this.synchronizeSizeWithContent();
  6553. }
  6554. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6555. this.parent.adaptWidthToChildren = true;
  6556. this.parent.adaptHeightToChildren = true;
  6557. }
  6558. break;
  6559. }
  6560. }
  6561. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6562. };
  6563. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6564. if (!this._detectPointerOnOpaqueOnly) {
  6565. return;
  6566. }
  6567. if (!Image._WorkingCanvas) {
  6568. Image._WorkingCanvas = document.createElement('canvas');
  6569. }
  6570. var canvas = Image._WorkingCanvas;
  6571. var width = this._currentMeasure.width;
  6572. var height = this._currentMeasure.height;
  6573. var context = canvas.getContext("2d");
  6574. canvas.width = width;
  6575. canvas.height = height;
  6576. context.clearRect(0, 0, width, height);
  6577. };
  6578. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6579. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6580. if (!this._detectPointerOnOpaqueOnly) {
  6581. return;
  6582. }
  6583. var canvas = Image._WorkingCanvas;
  6584. context = canvas.getContext("2d");
  6585. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6586. };
  6587. Image.prototype._draw = function (context) {
  6588. context.save();
  6589. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6590. context.shadowColor = this.shadowColor;
  6591. context.shadowBlur = this.shadowBlur;
  6592. context.shadowOffsetX = this.shadowOffsetX;
  6593. context.shadowOffsetY = this.shadowOffsetY;
  6594. }
  6595. var x, y, width, height;
  6596. if (this.cellId == -1) {
  6597. x = this._sourceLeft;
  6598. y = this._sourceTop;
  6599. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6600. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6601. }
  6602. else {
  6603. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6604. var column = (this.cellId / rowCount) >> 0;
  6605. var row = this.cellId % rowCount;
  6606. x = this.cellWidth * row;
  6607. y = this.cellHeight * column;
  6608. width = this.cellWidth;
  6609. height = this.cellHeight;
  6610. }
  6611. this._prepareWorkingCanvasForOpaqueDetection();
  6612. this._applyStates(context);
  6613. if (this._loaded) {
  6614. switch (this._stretch) {
  6615. case Image.STRETCH_NONE:
  6616. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6617. break;
  6618. case Image.STRETCH_FILL:
  6619. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6620. break;
  6621. case Image.STRETCH_UNIFORM:
  6622. var hRatio = this._currentMeasure.width / width;
  6623. var vRatio = this._currentMeasure.height / height;
  6624. var ratio = Math.min(hRatio, vRatio);
  6625. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6626. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6627. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6628. break;
  6629. case Image.STRETCH_EXTEND:
  6630. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6631. break;
  6632. case Image.STRETCH_NINE_PATCH:
  6633. this._renderNinePatch(context);
  6634. break;
  6635. }
  6636. }
  6637. context.restore();
  6638. };
  6639. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6640. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6641. };
  6642. Image.prototype._renderNinePatch = function (context) {
  6643. var height = this._imageHeight;
  6644. var leftWidth = this._sliceLeft;
  6645. var topHeight = this._sliceTop;
  6646. var bottomHeight = this._imageHeight - this._sliceBottom;
  6647. var rightWidth = this._imageWidth - this._sliceRight;
  6648. var left = 0;
  6649. var top = 0;
  6650. if (this._populateNinePatchSlicesFromImage) {
  6651. left = 1;
  6652. top = 1;
  6653. height -= 2;
  6654. leftWidth -= 1;
  6655. topHeight -= 1;
  6656. bottomHeight -= 1;
  6657. rightWidth -= 1;
  6658. }
  6659. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6660. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6661. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6662. // Corners
  6663. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6664. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6665. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6666. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6667. // Center
  6668. 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);
  6669. // Borders
  6670. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6671. 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);
  6672. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6673. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6674. };
  6675. Image.prototype.dispose = function () {
  6676. _super.prototype.dispose.call(this);
  6677. this.onImageLoadedObservable.clear();
  6678. };
  6679. Image._WorkingCanvas = null;
  6680. // Static
  6681. /** STRETCH_NONE */
  6682. Image.STRETCH_NONE = 0;
  6683. /** STRETCH_FILL */
  6684. Image.STRETCH_FILL = 1;
  6685. /** STRETCH_UNIFORM */
  6686. Image.STRETCH_UNIFORM = 2;
  6687. /** STRETCH_EXTEND */
  6688. Image.STRETCH_EXTEND = 3;
  6689. /** NINE_PATCH */
  6690. Image.STRETCH_NINE_PATCH = 4;
  6691. return Image;
  6692. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6693. /***/ }),
  6694. /***/ "./2D/controls/index.ts":
  6695. /*!******************************!*\
  6696. !*** ./2D/controls/index.ts ***!
  6697. \******************************/
  6698. /*! 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 */
  6699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6700. "use strict";
  6701. __webpack_require__.r(__webpack_exports__);
  6702. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6704. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6706. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6708. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6710. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6712. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6714. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6716. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6718. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6720. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6722. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6724. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6726. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6728. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6730. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6736. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6738. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6741. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6744. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6746. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6748. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6750. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6752. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6754. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6756. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6758. /***/ }),
  6759. /***/ "./2D/controls/inputPassword.ts":
  6760. /*!**************************************!*\
  6761. !*** ./2D/controls/inputPassword.ts ***!
  6762. \**************************************/
  6763. /*! exports provided: InputPassword */
  6764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6765. "use strict";
  6766. __webpack_require__.r(__webpack_exports__);
  6767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6768. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6769. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6770. /**
  6771. * Class used to create a password control
  6772. */
  6773. var InputPassword = /** @class */ (function (_super) {
  6774. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6775. function InputPassword() {
  6776. return _super !== null && _super.apply(this, arguments) || this;
  6777. }
  6778. InputPassword.prototype._beforeRenderText = function (text) {
  6779. var txt = "";
  6780. for (var i = 0; i < text.length; i++) {
  6781. txt += "\u2022";
  6782. }
  6783. return txt;
  6784. };
  6785. return InputPassword;
  6786. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6787. /***/ }),
  6788. /***/ "./2D/controls/inputText.ts":
  6789. /*!**********************************!*\
  6790. !*** ./2D/controls/inputText.ts ***!
  6791. \**********************************/
  6792. /*! exports provided: InputText */
  6793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6794. "use strict";
  6795. __webpack_require__.r(__webpack_exports__);
  6796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6797. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6798. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6799. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6800. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6801. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6802. /**
  6803. * Class used to create input text control
  6804. */
  6805. var InputText = /** @class */ (function (_super) {
  6806. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6807. /**
  6808. * Creates a new InputText
  6809. * @param name defines the control name
  6810. * @param text defines the text of the control
  6811. */
  6812. function InputText(name, text) {
  6813. if (text === void 0) { text = ""; }
  6814. var _this = _super.call(this, name) || this;
  6815. _this.name = name;
  6816. _this._text = "";
  6817. _this._placeholderText = "";
  6818. _this._background = "#222222";
  6819. _this._focusedBackground = "#000000";
  6820. _this._focusedColor = "white";
  6821. _this._placeholderColor = "gray";
  6822. _this._thickness = 1;
  6823. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6824. _this._autoStretchWidth = true;
  6825. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6826. _this._isFocused = false;
  6827. _this._blinkIsEven = false;
  6828. _this._cursorOffset = 0;
  6829. _this._deadKey = false;
  6830. _this._addKey = true;
  6831. _this._currentKey = "";
  6832. _this._isTextHighlightOn = false;
  6833. _this._textHighlightColor = "#d5e0ff";
  6834. _this._highligherOpacity = 0.4;
  6835. _this._highlightedText = "";
  6836. _this._startHighlightIndex = 0;
  6837. _this._endHighlightIndex = 0;
  6838. _this._cursorIndex = -1;
  6839. _this._onFocusSelectAll = false;
  6840. _this._isPointerDown = false;
  6841. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6842. _this.promptMessage = "Please enter text:";
  6843. /** Observable raised when the text changes */
  6844. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6845. /** Observable raised just before an entered character is to be added */
  6846. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6847. /** Observable raised when the control gets the focus */
  6848. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6849. /** Observable raised when the control loses the focus */
  6850. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6851. /**Observable raised when the text is highlighted */
  6852. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6853. /**Observable raised when copy event is triggered */
  6854. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6855. /** Observable raised when cut event is triggered */
  6856. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6857. /** Observable raised when paste event is triggered */
  6858. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6859. /** Observable raised when a key event was processed */
  6860. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6861. _this.text = text;
  6862. _this.isPointerBlocker = true;
  6863. return _this;
  6864. }
  6865. Object.defineProperty(InputText.prototype, "maxWidth", {
  6866. /** Gets or sets the maximum width allowed by the control */
  6867. get: function () {
  6868. return this._maxWidth.toString(this._host);
  6869. },
  6870. set: function (value) {
  6871. if (this._maxWidth.toString(this._host) === value) {
  6872. return;
  6873. }
  6874. if (this._maxWidth.fromString(value)) {
  6875. this._markAsDirty();
  6876. }
  6877. },
  6878. enumerable: true,
  6879. configurable: true
  6880. });
  6881. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6882. /** Gets the maximum width allowed by the control in pixels */
  6883. get: function () {
  6884. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6885. },
  6886. enumerable: true,
  6887. configurable: true
  6888. });
  6889. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6890. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6891. get: function () {
  6892. return this._highligherOpacity;
  6893. },
  6894. set: function (value) {
  6895. if (this._highligherOpacity === value) {
  6896. return;
  6897. }
  6898. this._highligherOpacity = value;
  6899. this._markAsDirty();
  6900. },
  6901. enumerable: true,
  6902. configurable: true
  6903. });
  6904. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6905. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6906. get: function () {
  6907. return this._onFocusSelectAll;
  6908. },
  6909. set: function (value) {
  6910. if (this._onFocusSelectAll === value) {
  6911. return;
  6912. }
  6913. this._onFocusSelectAll = value;
  6914. this._markAsDirty();
  6915. },
  6916. enumerable: true,
  6917. configurable: true
  6918. });
  6919. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6920. /** Gets or sets the text hightlight color */
  6921. get: function () {
  6922. return this._textHighlightColor;
  6923. },
  6924. set: function (value) {
  6925. if (this._textHighlightColor === value) {
  6926. return;
  6927. }
  6928. this._textHighlightColor = value;
  6929. this._markAsDirty();
  6930. },
  6931. enumerable: true,
  6932. configurable: true
  6933. });
  6934. Object.defineProperty(InputText.prototype, "margin", {
  6935. /** Gets or sets control margin */
  6936. get: function () {
  6937. return this._margin.toString(this._host);
  6938. },
  6939. set: function (value) {
  6940. if (this._margin.toString(this._host) === value) {
  6941. return;
  6942. }
  6943. if (this._margin.fromString(value)) {
  6944. this._markAsDirty();
  6945. }
  6946. },
  6947. enumerable: true,
  6948. configurable: true
  6949. });
  6950. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6951. /** Gets control margin in pixels */
  6952. get: function () {
  6953. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6954. },
  6955. enumerable: true,
  6956. configurable: true
  6957. });
  6958. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6959. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6960. get: function () {
  6961. return this._autoStretchWidth;
  6962. },
  6963. set: function (value) {
  6964. if (this._autoStretchWidth === value) {
  6965. return;
  6966. }
  6967. this._autoStretchWidth = value;
  6968. this._markAsDirty();
  6969. },
  6970. enumerable: true,
  6971. configurable: true
  6972. });
  6973. Object.defineProperty(InputText.prototype, "thickness", {
  6974. /** Gets or sets border thickness */
  6975. get: function () {
  6976. return this._thickness;
  6977. },
  6978. set: function (value) {
  6979. if (this._thickness === value) {
  6980. return;
  6981. }
  6982. this._thickness = value;
  6983. this._markAsDirty();
  6984. },
  6985. enumerable: true,
  6986. configurable: true
  6987. });
  6988. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6989. /** Gets or sets the background color when focused */
  6990. get: function () {
  6991. return this._focusedBackground;
  6992. },
  6993. set: function (value) {
  6994. if (this._focusedBackground === value) {
  6995. return;
  6996. }
  6997. this._focusedBackground = value;
  6998. this._markAsDirty();
  6999. },
  7000. enumerable: true,
  7001. configurable: true
  7002. });
  7003. Object.defineProperty(InputText.prototype, "focusedColor", {
  7004. /** Gets or sets the background color when focused */
  7005. get: function () {
  7006. return this._focusedColor;
  7007. },
  7008. set: function (value) {
  7009. if (this._focusedColor === value) {
  7010. return;
  7011. }
  7012. this._focusedColor = value;
  7013. this._markAsDirty();
  7014. },
  7015. enumerable: true,
  7016. configurable: true
  7017. });
  7018. Object.defineProperty(InputText.prototype, "background", {
  7019. /** Gets or sets the background color */
  7020. get: function () {
  7021. return this._background;
  7022. },
  7023. set: function (value) {
  7024. if (this._background === value) {
  7025. return;
  7026. }
  7027. this._background = value;
  7028. this._markAsDirty();
  7029. },
  7030. enumerable: true,
  7031. configurable: true
  7032. });
  7033. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7034. /** Gets or sets the placeholder color */
  7035. get: function () {
  7036. return this._placeholderColor;
  7037. },
  7038. set: function (value) {
  7039. if (this._placeholderColor === value) {
  7040. return;
  7041. }
  7042. this._placeholderColor = value;
  7043. this._markAsDirty();
  7044. },
  7045. enumerable: true,
  7046. configurable: true
  7047. });
  7048. Object.defineProperty(InputText.prototype, "placeholderText", {
  7049. /** Gets or sets the text displayed when the control is empty */
  7050. get: function () {
  7051. return this._placeholderText;
  7052. },
  7053. set: function (value) {
  7054. if (this._placeholderText === value) {
  7055. return;
  7056. }
  7057. this._placeholderText = value;
  7058. this._markAsDirty();
  7059. },
  7060. enumerable: true,
  7061. configurable: true
  7062. });
  7063. Object.defineProperty(InputText.prototype, "deadKey", {
  7064. /** Gets or sets the dead key flag */
  7065. get: function () {
  7066. return this._deadKey;
  7067. },
  7068. set: function (flag) {
  7069. this._deadKey = flag;
  7070. },
  7071. enumerable: true,
  7072. configurable: true
  7073. });
  7074. Object.defineProperty(InputText.prototype, "highlightedText", {
  7075. /** Gets or sets the highlight text */
  7076. get: function () {
  7077. return this._highlightedText;
  7078. },
  7079. set: function (text) {
  7080. if (this._highlightedText === text) {
  7081. return;
  7082. }
  7083. this._highlightedText = text;
  7084. this._markAsDirty();
  7085. },
  7086. enumerable: true,
  7087. configurable: true
  7088. });
  7089. Object.defineProperty(InputText.prototype, "addKey", {
  7090. /** Gets or sets if the current key should be added */
  7091. get: function () {
  7092. return this._addKey;
  7093. },
  7094. set: function (flag) {
  7095. this._addKey = flag;
  7096. },
  7097. enumerable: true,
  7098. configurable: true
  7099. });
  7100. Object.defineProperty(InputText.prototype, "currentKey", {
  7101. /** Gets or sets the value of the current key being entered */
  7102. get: function () {
  7103. return this._currentKey;
  7104. },
  7105. set: function (key) {
  7106. this._currentKey = key;
  7107. },
  7108. enumerable: true,
  7109. configurable: true
  7110. });
  7111. Object.defineProperty(InputText.prototype, "text", {
  7112. /** Gets or sets the text displayed in the control */
  7113. get: function () {
  7114. return this._text;
  7115. },
  7116. set: function (value) {
  7117. var valueAsString = value.toString(); // Forcing convertion
  7118. if (this._text === valueAsString) {
  7119. return;
  7120. }
  7121. this._text = valueAsString;
  7122. this._markAsDirty();
  7123. this.onTextChangedObservable.notifyObservers(this);
  7124. },
  7125. enumerable: true,
  7126. configurable: true
  7127. });
  7128. Object.defineProperty(InputText.prototype, "width", {
  7129. /** Gets or sets control width */
  7130. get: function () {
  7131. return this._width.toString(this._host);
  7132. },
  7133. set: function (value) {
  7134. if (this._width.toString(this._host) === value) {
  7135. return;
  7136. }
  7137. if (this._width.fromString(value)) {
  7138. this._markAsDirty();
  7139. }
  7140. this.autoStretchWidth = false;
  7141. },
  7142. enumerable: true,
  7143. configurable: true
  7144. });
  7145. /** @hidden */
  7146. InputText.prototype.onBlur = function () {
  7147. this._isFocused = false;
  7148. this._scrollLeft = null;
  7149. this._cursorOffset = 0;
  7150. clearTimeout(this._blinkTimeout);
  7151. this._markAsDirty();
  7152. this.onBlurObservable.notifyObservers(this);
  7153. this._host.unRegisterClipboardEvents();
  7154. if (this._onClipboardObserver) {
  7155. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7156. }
  7157. var scene = this._host.getScene();
  7158. if (this._onPointerDblTapObserver && scene) {
  7159. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7160. }
  7161. };
  7162. /** @hidden */
  7163. InputText.prototype.onFocus = function () {
  7164. var _this = this;
  7165. if (!this._isEnabled) {
  7166. return;
  7167. }
  7168. this._scrollLeft = null;
  7169. this._isFocused = true;
  7170. this._blinkIsEven = false;
  7171. this._cursorOffset = 0;
  7172. this._markAsDirty();
  7173. this.onFocusObservable.notifyObservers(this);
  7174. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7175. var value = prompt(this.promptMessage);
  7176. if (value !== null) {
  7177. this.text = value;
  7178. }
  7179. this._host.focusedControl = null;
  7180. return;
  7181. }
  7182. this._host.registerClipboardEvents();
  7183. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7184. // process clipboard event, can be configured.
  7185. switch (clipboardInfo.type) {
  7186. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7187. _this._onCopyText(clipboardInfo.event);
  7188. _this.onTextCopyObservable.notifyObservers(_this);
  7189. break;
  7190. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7191. _this._onCutText(clipboardInfo.event);
  7192. _this.onTextCutObservable.notifyObservers(_this);
  7193. break;
  7194. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7195. _this._onPasteText(clipboardInfo.event);
  7196. _this.onTextPasteObservable.notifyObservers(_this);
  7197. break;
  7198. default: return;
  7199. }
  7200. });
  7201. var scene = this._host.getScene();
  7202. if (scene) {
  7203. //register the pointer double tap event
  7204. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7205. if (!_this._isFocused) {
  7206. return;
  7207. }
  7208. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7209. _this._processDblClick(pointerInfo);
  7210. }
  7211. });
  7212. }
  7213. if (this._onFocusSelectAll) {
  7214. this._selectAllText();
  7215. }
  7216. };
  7217. InputText.prototype._getTypeName = function () {
  7218. return "InputText";
  7219. };
  7220. /**
  7221. * Function called to get the list of controls that should not steal the focus from this control
  7222. * @returns an array of controls
  7223. */
  7224. InputText.prototype.keepsFocusWith = function () {
  7225. if (!this._connectedVirtualKeyboard) {
  7226. return null;
  7227. }
  7228. return [this._connectedVirtualKeyboard];
  7229. };
  7230. /** @hidden */
  7231. InputText.prototype.processKey = function (keyCode, key, evt) {
  7232. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7233. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7234. return;
  7235. }
  7236. //select all
  7237. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7238. this._selectAllText();
  7239. evt.preventDefault();
  7240. return;
  7241. }
  7242. // Specific cases
  7243. switch (keyCode) {
  7244. case 32: //SPACE
  7245. key = " "; //ie11 key for space is "Spacebar"
  7246. break;
  7247. case 191: //SLASH
  7248. if (evt) {
  7249. evt.preventDefault();
  7250. }
  7251. break;
  7252. case 8: // BACKSPACE
  7253. if (this._text && this._text.length > 0) {
  7254. //delete the highlighted text
  7255. if (this._isTextHighlightOn) {
  7256. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7257. this._isTextHighlightOn = false;
  7258. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7259. this._blinkIsEven = false;
  7260. if (evt) {
  7261. evt.preventDefault();
  7262. }
  7263. return;
  7264. }
  7265. //delete single character
  7266. if (this._cursorOffset === 0) {
  7267. this.text = this._text.substr(0, this._text.length - 1);
  7268. }
  7269. else {
  7270. var deletePosition = this._text.length - this._cursorOffset;
  7271. if (deletePosition > 0) {
  7272. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7273. }
  7274. }
  7275. }
  7276. if (evt) {
  7277. evt.preventDefault();
  7278. }
  7279. return;
  7280. case 46: // DELETE
  7281. if (this._isTextHighlightOn) {
  7282. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7283. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7284. while (decrementor > 0 && this._cursorOffset > 0) {
  7285. this._cursorOffset--;
  7286. }
  7287. this._isTextHighlightOn = false;
  7288. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7289. if (evt) {
  7290. evt.preventDefault();
  7291. }
  7292. return;
  7293. }
  7294. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7295. var deletePosition = this._text.length - this._cursorOffset;
  7296. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7297. this._cursorOffset--;
  7298. }
  7299. if (evt) {
  7300. evt.preventDefault();
  7301. }
  7302. return;
  7303. case 13: // RETURN
  7304. this._host.focusedControl = null;
  7305. this._isTextHighlightOn = false;
  7306. return;
  7307. case 35: // END
  7308. this._cursorOffset = 0;
  7309. this._blinkIsEven = false;
  7310. this._isTextHighlightOn = false;
  7311. this._markAsDirty();
  7312. return;
  7313. case 36: // HOME
  7314. this._cursorOffset = this._text.length;
  7315. this._blinkIsEven = false;
  7316. this._isTextHighlightOn = false;
  7317. this._markAsDirty();
  7318. return;
  7319. case 37: // LEFT
  7320. this._cursorOffset++;
  7321. if (this._cursorOffset > this._text.length) {
  7322. this._cursorOffset = this._text.length;
  7323. }
  7324. if (evt && evt.shiftKey) {
  7325. // update the cursor
  7326. this._blinkIsEven = false;
  7327. // shift + ctrl/cmd + <-
  7328. if (evt.ctrlKey || evt.metaKey) {
  7329. if (!this._isTextHighlightOn) {
  7330. if (this._text.length === this._cursorOffset) {
  7331. return;
  7332. }
  7333. else {
  7334. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7335. }
  7336. }
  7337. this._startHighlightIndex = 0;
  7338. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7339. this._cursorOffset = this._text.length;
  7340. this._isTextHighlightOn = true;
  7341. this._markAsDirty();
  7342. return;
  7343. }
  7344. //store the starting point
  7345. if (!this._isTextHighlightOn) {
  7346. this._isTextHighlightOn = true;
  7347. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7348. }
  7349. //if text is already highlighted
  7350. else if (this._cursorIndex === -1) {
  7351. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7352. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7353. }
  7354. //set the highlight indexes
  7355. if (this._cursorIndex < this._cursorOffset) {
  7356. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7357. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7358. }
  7359. else if (this._cursorIndex > this._cursorOffset) {
  7360. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7361. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7362. }
  7363. else {
  7364. this._isTextHighlightOn = false;
  7365. }
  7366. this._markAsDirty();
  7367. return;
  7368. }
  7369. if (this._isTextHighlightOn) {
  7370. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7371. this._isTextHighlightOn = false;
  7372. }
  7373. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7374. this._cursorOffset = this.text.length;
  7375. evt.preventDefault();
  7376. }
  7377. this._blinkIsEven = false;
  7378. this._isTextHighlightOn = false;
  7379. this._cursorIndex = -1;
  7380. this._markAsDirty();
  7381. return;
  7382. case 39: // RIGHT
  7383. this._cursorOffset--;
  7384. if (this._cursorOffset < 0) {
  7385. this._cursorOffset = 0;
  7386. }
  7387. if (evt && evt.shiftKey) {
  7388. //update the cursor
  7389. this._blinkIsEven = false;
  7390. //shift + ctrl/cmd + ->
  7391. if (evt.ctrlKey || evt.metaKey) {
  7392. if (!this._isTextHighlightOn) {
  7393. if (this._cursorOffset === 0) {
  7394. return;
  7395. }
  7396. else {
  7397. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7398. }
  7399. }
  7400. this._endHighlightIndex = this._text.length;
  7401. this._isTextHighlightOn = true;
  7402. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7403. this._cursorOffset = 0;
  7404. this._markAsDirty();
  7405. return;
  7406. }
  7407. if (!this._isTextHighlightOn) {
  7408. this._isTextHighlightOn = true;
  7409. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7410. }
  7411. //if text is already highlighted
  7412. else if (this._cursorIndex === -1) {
  7413. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7414. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7415. }
  7416. //set the highlight indexes
  7417. if (this._cursorIndex < this._cursorOffset) {
  7418. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7419. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7420. }
  7421. else if (this._cursorIndex > this._cursorOffset) {
  7422. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7423. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7424. }
  7425. else {
  7426. this._isTextHighlightOn = false;
  7427. }
  7428. this._markAsDirty();
  7429. return;
  7430. }
  7431. if (this._isTextHighlightOn) {
  7432. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7433. this._isTextHighlightOn = false;
  7434. }
  7435. //ctr + ->
  7436. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7437. this._cursorOffset = 0;
  7438. evt.preventDefault();
  7439. }
  7440. this._blinkIsEven = false;
  7441. this._isTextHighlightOn = false;
  7442. this._cursorIndex = -1;
  7443. this._markAsDirty();
  7444. return;
  7445. case 222: // Dead
  7446. if (evt) {
  7447. evt.preventDefault();
  7448. }
  7449. this._cursorIndex = -1;
  7450. this.deadKey = true;
  7451. break;
  7452. }
  7453. // Printable characters
  7454. if (key &&
  7455. ((keyCode === -1) || // Direct access
  7456. (keyCode === 32) || // Space
  7457. (keyCode > 47 && keyCode < 64) || // Numbers
  7458. (keyCode > 64 && keyCode < 91) || // Letters
  7459. (keyCode > 159 && keyCode < 193) || // Special characters
  7460. (keyCode > 218 && keyCode < 223) || // Special characters
  7461. (keyCode > 95 && keyCode < 112))) { // Numpad
  7462. this._currentKey = key;
  7463. this.onBeforeKeyAddObservable.notifyObservers(this);
  7464. key = this._currentKey;
  7465. if (this._addKey) {
  7466. if (this._isTextHighlightOn) {
  7467. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7468. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7469. this._isTextHighlightOn = false;
  7470. this._blinkIsEven = false;
  7471. this._markAsDirty();
  7472. }
  7473. else if (this._cursorOffset === 0) {
  7474. this.text += key;
  7475. }
  7476. else {
  7477. var insertPosition = this._text.length - this._cursorOffset;
  7478. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7479. }
  7480. }
  7481. }
  7482. };
  7483. /** @hidden */
  7484. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7485. //update the cursor
  7486. this._blinkIsEven = false;
  7487. if (this._cursorIndex === -1) {
  7488. this._cursorIndex = offset;
  7489. }
  7490. else {
  7491. if (this._cursorIndex < this._cursorOffset) {
  7492. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7493. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7494. }
  7495. else if (this._cursorIndex > this._cursorOffset) {
  7496. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7497. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7498. }
  7499. else {
  7500. this._isTextHighlightOn = false;
  7501. this._markAsDirty();
  7502. return;
  7503. }
  7504. }
  7505. this._isTextHighlightOn = true;
  7506. this._markAsDirty();
  7507. };
  7508. /** @hidden */
  7509. InputText.prototype._processDblClick = function (evt) {
  7510. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7511. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7512. this._endHighlightIndex = this._startHighlightIndex;
  7513. var rWord = /\w+/g, moveLeft, moveRight;
  7514. do {
  7515. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7516. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7517. } while (moveLeft || moveRight);
  7518. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7519. this.onTextHighlightObservable.notifyObservers(this);
  7520. this._isTextHighlightOn = true;
  7521. this._clickedCoordinate = null;
  7522. this._blinkIsEven = true;
  7523. this._cursorIndex = -1;
  7524. this._markAsDirty();
  7525. };
  7526. /** @hidden */
  7527. InputText.prototype._selectAllText = function () {
  7528. this._blinkIsEven = true;
  7529. this._isTextHighlightOn = true;
  7530. this._startHighlightIndex = 0;
  7531. this._endHighlightIndex = this._text.length;
  7532. this._cursorOffset = this._text.length;
  7533. this._cursorIndex = -1;
  7534. this._markAsDirty();
  7535. };
  7536. /**
  7537. * Handles the keyboard event
  7538. * @param evt Defines the KeyboardEvent
  7539. */
  7540. InputText.prototype.processKeyboard = function (evt) {
  7541. // process pressed key
  7542. this.processKey(evt.keyCode, evt.key, evt);
  7543. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7544. };
  7545. /** @hidden */
  7546. InputText.prototype._onCopyText = function (ev) {
  7547. this._isTextHighlightOn = false;
  7548. //when write permission to clipbaord data is denied
  7549. try {
  7550. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7551. }
  7552. catch (_a) { } //pass
  7553. this._host.clipboardData = this._highlightedText;
  7554. };
  7555. /** @hidden */
  7556. InputText.prototype._onCutText = function (ev) {
  7557. if (!this._highlightedText) {
  7558. return;
  7559. }
  7560. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7561. this._isTextHighlightOn = false;
  7562. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7563. //when write permission to clipbaord data is denied
  7564. try {
  7565. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7566. }
  7567. catch (_a) { } //pass
  7568. this._host.clipboardData = this._highlightedText;
  7569. this._highlightedText = "";
  7570. };
  7571. /** @hidden */
  7572. InputText.prototype._onPasteText = function (ev) {
  7573. var data = "";
  7574. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7575. data = ev.clipboardData.getData("text/plain");
  7576. }
  7577. else {
  7578. //get the cached data; returns blank string by default
  7579. data = this._host.clipboardData;
  7580. }
  7581. var insertPosition = this._text.length - this._cursorOffset;
  7582. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7583. };
  7584. InputText.prototype._draw = function (context) {
  7585. var _this = this;
  7586. context.save();
  7587. this._applyStates(context);
  7588. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7589. context.shadowColor = this.shadowColor;
  7590. context.shadowBlur = this.shadowBlur;
  7591. context.shadowOffsetX = this.shadowOffsetX;
  7592. context.shadowOffsetY = this.shadowOffsetY;
  7593. }
  7594. // Background
  7595. if (this._isFocused) {
  7596. if (this._focusedBackground) {
  7597. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7598. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7599. }
  7600. }
  7601. else if (this._background) {
  7602. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7603. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7604. }
  7605. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7606. context.shadowBlur = 0;
  7607. context.shadowOffsetX = 0;
  7608. context.shadowOffsetY = 0;
  7609. }
  7610. if (!this._fontOffset) {
  7611. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7612. }
  7613. // Text
  7614. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7615. if (this.color) {
  7616. context.fillStyle = this.color;
  7617. }
  7618. var text = this._beforeRenderText(this._text);
  7619. if (!this._isFocused && !this._text && this._placeholderText) {
  7620. text = this._placeholderText;
  7621. if (this._placeholderColor) {
  7622. context.fillStyle = this._placeholderColor;
  7623. }
  7624. }
  7625. this._textWidth = context.measureText(text).width;
  7626. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7627. if (this._autoStretchWidth) {
  7628. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7629. }
  7630. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7631. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7632. context.save();
  7633. context.beginPath();
  7634. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7635. context.clip();
  7636. if (this._isFocused && this._textWidth > availableWidth) {
  7637. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7638. if (!this._scrollLeft) {
  7639. this._scrollLeft = textLeft;
  7640. }
  7641. }
  7642. else {
  7643. this._scrollLeft = clipTextLeft;
  7644. }
  7645. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7646. // Cursor
  7647. if (this._isFocused) {
  7648. // Need to move cursor
  7649. if (this._clickedCoordinate) {
  7650. var rightPosition = this._scrollLeft + this._textWidth;
  7651. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7652. var currentSize = 0;
  7653. this._cursorOffset = 0;
  7654. var previousDist = 0;
  7655. do {
  7656. if (this._cursorOffset) {
  7657. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7658. }
  7659. this._cursorOffset++;
  7660. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7661. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7662. // Find closest move
  7663. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7664. this._cursorOffset--;
  7665. }
  7666. this._blinkIsEven = false;
  7667. this._clickedCoordinate = null;
  7668. }
  7669. // Render cursor
  7670. if (!this._blinkIsEven) {
  7671. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7672. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7673. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7674. if (cursorLeft < clipTextLeft) {
  7675. this._scrollLeft += (clipTextLeft - cursorLeft);
  7676. cursorLeft = clipTextLeft;
  7677. this._markAsDirty();
  7678. }
  7679. else if (cursorLeft > clipTextLeft + availableWidth) {
  7680. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7681. cursorLeft = clipTextLeft + availableWidth;
  7682. this._markAsDirty();
  7683. }
  7684. if (!this._isTextHighlightOn) {
  7685. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7686. }
  7687. }
  7688. clearTimeout(this._blinkTimeout);
  7689. this._blinkTimeout = setTimeout(function () {
  7690. _this._blinkIsEven = !_this._blinkIsEven;
  7691. _this._markAsDirty();
  7692. }, 500);
  7693. //show the highlighted text
  7694. if (this._isTextHighlightOn) {
  7695. clearTimeout(this._blinkTimeout);
  7696. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7697. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7698. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7699. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7700. if (highlightCursorLeft < clipTextLeft) {
  7701. width = width - (clipTextLeft - highlightCursorLeft);
  7702. if (!width) {
  7703. // when using left arrow on text.length > availableWidth;
  7704. // assigns the width of the first letter after clipTextLeft
  7705. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7706. }
  7707. highlightCursorLeft = clipTextLeft;
  7708. }
  7709. //for transparancy
  7710. context.globalAlpha = this._highligherOpacity;
  7711. context.fillStyle = this._textHighlightColor;
  7712. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7713. context.globalAlpha = 1.0;
  7714. }
  7715. }
  7716. context.restore();
  7717. // Border
  7718. if (this._thickness) {
  7719. if (this._isFocused) {
  7720. if (this.focusedColor) {
  7721. context.strokeStyle = this.focusedColor;
  7722. }
  7723. }
  7724. else {
  7725. if (this.color) {
  7726. context.strokeStyle = this.color;
  7727. }
  7728. }
  7729. context.lineWidth = this._thickness;
  7730. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7731. }
  7732. context.restore();
  7733. };
  7734. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7735. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7736. return false;
  7737. }
  7738. this._clickedCoordinate = coordinates.x;
  7739. this._isTextHighlightOn = false;
  7740. this._highlightedText = "";
  7741. this._cursorIndex = -1;
  7742. this._isPointerDown = true;
  7743. this._host._capturingControl[pointerId] = this;
  7744. if (this._host.focusedControl === this) {
  7745. // Move cursor
  7746. clearTimeout(this._blinkTimeout);
  7747. this._markAsDirty();
  7748. return true;
  7749. }
  7750. if (!this._isEnabled) {
  7751. return false;
  7752. }
  7753. this._host.focusedControl = this;
  7754. return true;
  7755. };
  7756. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7757. if (this._host.focusedControl === this && this._isPointerDown) {
  7758. this._clickedCoordinate = coordinates.x;
  7759. this._markAsDirty();
  7760. this._updateValueFromCursorIndex(this._cursorOffset);
  7761. }
  7762. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7763. };
  7764. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7765. this._isPointerDown = false;
  7766. delete this._host._capturingControl[pointerId];
  7767. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7768. };
  7769. InputText.prototype._beforeRenderText = function (text) {
  7770. return text;
  7771. };
  7772. InputText.prototype.dispose = function () {
  7773. _super.prototype.dispose.call(this);
  7774. this.onBlurObservable.clear();
  7775. this.onFocusObservable.clear();
  7776. this.onTextChangedObservable.clear();
  7777. this.onTextCopyObservable.clear();
  7778. this.onTextCutObservable.clear();
  7779. this.onTextPasteObservable.clear();
  7780. this.onTextHighlightObservable.clear();
  7781. this.onKeyboardEventProcessedObservable.clear();
  7782. };
  7783. return InputText;
  7784. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7785. /***/ }),
  7786. /***/ "./2D/controls/line.ts":
  7787. /*!*****************************!*\
  7788. !*** ./2D/controls/line.ts ***!
  7789. \*****************************/
  7790. /*! exports provided: Line */
  7791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7792. "use strict";
  7793. __webpack_require__.r(__webpack_exports__);
  7794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7795. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7796. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  7797. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7798. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7799. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7800. /** Class used to render 2D lines */
  7801. var Line = /** @class */ (function (_super) {
  7802. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7803. /**
  7804. * Creates a new Line
  7805. * @param name defines the control name
  7806. */
  7807. function Line(name) {
  7808. var _this = _super.call(this, name) || this;
  7809. _this.name = name;
  7810. _this._lineWidth = 1;
  7811. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7812. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7813. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7814. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7815. _this._dash = new Array();
  7816. _this.isHitTestVisible = false;
  7817. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7818. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7819. return _this;
  7820. }
  7821. Object.defineProperty(Line.prototype, "dash", {
  7822. /** Gets or sets the dash pattern */
  7823. get: function () {
  7824. return this._dash;
  7825. },
  7826. set: function (value) {
  7827. if (this._dash === value) {
  7828. return;
  7829. }
  7830. this._dash = value;
  7831. this._markAsDirty();
  7832. },
  7833. enumerable: true,
  7834. configurable: true
  7835. });
  7836. Object.defineProperty(Line.prototype, "connectedControl", {
  7837. /** Gets or sets the control connected with the line end */
  7838. get: function () {
  7839. return this._connectedControl;
  7840. },
  7841. set: function (value) {
  7842. var _this = this;
  7843. if (this._connectedControl === value) {
  7844. return;
  7845. }
  7846. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7847. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7848. this._connectedControlDirtyObserver = null;
  7849. }
  7850. if (value) {
  7851. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7852. }
  7853. this._connectedControl = value;
  7854. this._markAsDirty();
  7855. },
  7856. enumerable: true,
  7857. configurable: true
  7858. });
  7859. Object.defineProperty(Line.prototype, "x1", {
  7860. /** Gets or sets start coordinates on X axis */
  7861. get: function () {
  7862. return this._x1.toString(this._host);
  7863. },
  7864. set: function (value) {
  7865. if (this._x1.toString(this._host) === value) {
  7866. return;
  7867. }
  7868. if (this._x1.fromString(value)) {
  7869. this._markAsDirty();
  7870. }
  7871. },
  7872. enumerable: true,
  7873. configurable: true
  7874. });
  7875. Object.defineProperty(Line.prototype, "y1", {
  7876. /** Gets or sets start coordinates on Y axis */
  7877. get: function () {
  7878. return this._y1.toString(this._host);
  7879. },
  7880. set: function (value) {
  7881. if (this._y1.toString(this._host) === value) {
  7882. return;
  7883. }
  7884. if (this._y1.fromString(value)) {
  7885. this._markAsDirty();
  7886. }
  7887. },
  7888. enumerable: true,
  7889. configurable: true
  7890. });
  7891. Object.defineProperty(Line.prototype, "x2", {
  7892. /** Gets or sets end coordinates on X axis */
  7893. get: function () {
  7894. return this._x2.toString(this._host);
  7895. },
  7896. set: function (value) {
  7897. if (this._x2.toString(this._host) === value) {
  7898. return;
  7899. }
  7900. if (this._x2.fromString(value)) {
  7901. this._markAsDirty();
  7902. }
  7903. },
  7904. enumerable: true,
  7905. configurable: true
  7906. });
  7907. Object.defineProperty(Line.prototype, "y2", {
  7908. /** Gets or sets end coordinates on Y axis */
  7909. get: function () {
  7910. return this._y2.toString(this._host);
  7911. },
  7912. set: function (value) {
  7913. if (this._y2.toString(this._host) === value) {
  7914. return;
  7915. }
  7916. if (this._y2.fromString(value)) {
  7917. this._markAsDirty();
  7918. }
  7919. },
  7920. enumerable: true,
  7921. configurable: true
  7922. });
  7923. Object.defineProperty(Line.prototype, "lineWidth", {
  7924. /** Gets or sets line width */
  7925. get: function () {
  7926. return this._lineWidth;
  7927. },
  7928. set: function (value) {
  7929. if (this._lineWidth === value) {
  7930. return;
  7931. }
  7932. this._lineWidth = value;
  7933. this._markAsDirty();
  7934. },
  7935. enumerable: true,
  7936. configurable: true
  7937. });
  7938. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7939. /** Gets or sets horizontal alignment */
  7940. set: function (value) {
  7941. return;
  7942. },
  7943. enumerable: true,
  7944. configurable: true
  7945. });
  7946. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7947. /** Gets or sets vertical alignment */
  7948. set: function (value) {
  7949. return;
  7950. },
  7951. enumerable: true,
  7952. configurable: true
  7953. });
  7954. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7955. get: function () {
  7956. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7957. },
  7958. enumerable: true,
  7959. configurable: true
  7960. });
  7961. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7962. get: function () {
  7963. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7964. },
  7965. enumerable: true,
  7966. configurable: true
  7967. });
  7968. Line.prototype._getTypeName = function () {
  7969. return "Line";
  7970. };
  7971. Line.prototype._draw = function (context) {
  7972. context.save();
  7973. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7974. context.shadowColor = this.shadowColor;
  7975. context.shadowBlur = this.shadowBlur;
  7976. context.shadowOffsetX = this.shadowOffsetX;
  7977. context.shadowOffsetY = this.shadowOffsetY;
  7978. }
  7979. this._applyStates(context);
  7980. context.strokeStyle = this.color;
  7981. context.lineWidth = this._lineWidth;
  7982. context.setLineDash(this._dash);
  7983. context.beginPath();
  7984. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  7985. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  7986. context.stroke();
  7987. context.restore();
  7988. };
  7989. Line.prototype._measure = function () {
  7990. // Width / Height
  7991. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7992. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7993. };
  7994. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7995. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7996. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7997. };
  7998. /**
  7999. * Move one end of the line given 3D cartesian coordinates.
  8000. * @param position Targeted world position
  8001. * @param scene Scene
  8002. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8003. */
  8004. Line.prototype.moveToVector3 = function (position, scene, end) {
  8005. if (end === void 0) { end = false; }
  8006. if (!this._host || this.parent !== this._host._rootContainer) {
  8007. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8008. return;
  8009. }
  8010. var globalViewport = this._host._getGlobalViewport(scene);
  8011. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8012. this._moveToProjectedPosition(projectedPosition, end);
  8013. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8014. this.notRenderable = true;
  8015. return;
  8016. }
  8017. this.notRenderable = false;
  8018. };
  8019. /**
  8020. * Move one end of the line to a position in screen absolute space.
  8021. * @param projectedPosition Position in screen absolute space (X, Y)
  8022. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8023. */
  8024. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8025. if (end === void 0) { end = false; }
  8026. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8027. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8028. if (end) {
  8029. this.x2 = x;
  8030. this.y2 = y;
  8031. this._x2.ignoreAdaptiveScaling = true;
  8032. this._y2.ignoreAdaptiveScaling = true;
  8033. }
  8034. else {
  8035. this.x1 = x;
  8036. this.y1 = y;
  8037. this._x1.ignoreAdaptiveScaling = true;
  8038. this._y1.ignoreAdaptiveScaling = true;
  8039. }
  8040. };
  8041. return Line;
  8042. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8043. /***/ }),
  8044. /***/ "./2D/controls/multiLine.ts":
  8045. /*!**********************************!*\
  8046. !*** ./2D/controls/multiLine.ts ***!
  8047. \**********************************/
  8048. /*! exports provided: MultiLine */
  8049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8050. "use strict";
  8051. __webpack_require__.r(__webpack_exports__);
  8052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8053. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8054. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  8055. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8056. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8057. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8058. /**
  8059. * Class used to create multi line control
  8060. */
  8061. var MultiLine = /** @class */ (function (_super) {
  8062. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8063. /**
  8064. * Creates a new MultiLine
  8065. * @param name defines the control name
  8066. */
  8067. function MultiLine(name) {
  8068. var _this = _super.call(this, name) || this;
  8069. _this.name = name;
  8070. _this._lineWidth = 1;
  8071. /** Function called when a point is updated */
  8072. _this.onPointUpdate = function () {
  8073. _this._markAsDirty();
  8074. };
  8075. _this.isHitTestVisible = false;
  8076. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8077. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8078. _this._dash = [];
  8079. _this._points = [];
  8080. return _this;
  8081. }
  8082. Object.defineProperty(MultiLine.prototype, "dash", {
  8083. /** Gets or sets dash pattern */
  8084. get: function () {
  8085. return this._dash;
  8086. },
  8087. set: function (value) {
  8088. if (this._dash === value) {
  8089. return;
  8090. }
  8091. this._dash = value;
  8092. this._markAsDirty();
  8093. },
  8094. enumerable: true,
  8095. configurable: true
  8096. });
  8097. /**
  8098. * Gets point stored at specified index
  8099. * @param index defines the index to look for
  8100. * @returns the requested point if found
  8101. */
  8102. MultiLine.prototype.getAt = function (index) {
  8103. if (!this._points[index]) {
  8104. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8105. }
  8106. return this._points[index];
  8107. };
  8108. /**
  8109. * Adds new points to the point collection
  8110. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8111. * @returns the list of created MultiLinePoint
  8112. */
  8113. MultiLine.prototype.add = function () {
  8114. var _this = this;
  8115. var items = [];
  8116. for (var _i = 0; _i < arguments.length; _i++) {
  8117. items[_i] = arguments[_i];
  8118. }
  8119. return items.map(function (item) { return _this.push(item); });
  8120. };
  8121. /**
  8122. * Adds a new point to the point collection
  8123. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8124. * @returns the created MultiLinePoint
  8125. */
  8126. MultiLine.prototype.push = function (item) {
  8127. var point = this.getAt(this._points.length);
  8128. if (item == null) {
  8129. return point;
  8130. }
  8131. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8132. point.mesh = item;
  8133. }
  8134. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8135. point.control = item;
  8136. }
  8137. else if (item.x != null && item.y != null) {
  8138. point.x = item.x;
  8139. point.y = item.y;
  8140. }
  8141. return point;
  8142. };
  8143. /**
  8144. * Remove a specific value or point from the active point collection
  8145. * @param value defines the value or point to remove
  8146. */
  8147. MultiLine.prototype.remove = function (value) {
  8148. var index;
  8149. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8150. index = this._points.indexOf(value);
  8151. if (index === -1) {
  8152. return;
  8153. }
  8154. }
  8155. else {
  8156. index = value;
  8157. }
  8158. var point = this._points[index];
  8159. if (!point) {
  8160. return;
  8161. }
  8162. point.dispose();
  8163. this._points.splice(index, 1);
  8164. };
  8165. /**
  8166. * Resets this object to initial state (no point)
  8167. */
  8168. MultiLine.prototype.reset = function () {
  8169. while (this._points.length > 0) {
  8170. this.remove(this._points.length - 1);
  8171. }
  8172. };
  8173. /**
  8174. * Resets all links
  8175. */
  8176. MultiLine.prototype.resetLinks = function () {
  8177. this._points.forEach(function (point) {
  8178. if (point != null) {
  8179. point.resetLinks();
  8180. }
  8181. });
  8182. };
  8183. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8184. /** Gets or sets line width */
  8185. get: function () {
  8186. return this._lineWidth;
  8187. },
  8188. set: function (value) {
  8189. if (this._lineWidth === value) {
  8190. return;
  8191. }
  8192. this._lineWidth = value;
  8193. this._markAsDirty();
  8194. },
  8195. enumerable: true,
  8196. configurable: true
  8197. });
  8198. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8199. set: function (value) {
  8200. return;
  8201. },
  8202. enumerable: true,
  8203. configurable: true
  8204. });
  8205. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8206. set: function (value) {
  8207. return;
  8208. },
  8209. enumerable: true,
  8210. configurable: true
  8211. });
  8212. MultiLine.prototype._getTypeName = function () {
  8213. return "MultiLine";
  8214. };
  8215. MultiLine.prototype._draw = function (context) {
  8216. context.save();
  8217. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8218. context.shadowColor = this.shadowColor;
  8219. context.shadowBlur = this.shadowBlur;
  8220. context.shadowOffsetX = this.shadowOffsetX;
  8221. context.shadowOffsetY = this.shadowOffsetY;
  8222. }
  8223. this._applyStates(context);
  8224. context.strokeStyle = this.color;
  8225. context.lineWidth = this._lineWidth;
  8226. context.setLineDash(this._dash);
  8227. context.beginPath();
  8228. var first = true; //first index is not necessarily 0
  8229. this._points.forEach(function (point) {
  8230. if (!point) {
  8231. return;
  8232. }
  8233. if (first) {
  8234. context.moveTo(point._point.x, point._point.y);
  8235. first = false;
  8236. }
  8237. else {
  8238. context.lineTo(point._point.x, point._point.y);
  8239. }
  8240. });
  8241. context.stroke();
  8242. context.restore();
  8243. };
  8244. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8245. var _this = this;
  8246. this._minX = null;
  8247. this._minY = null;
  8248. this._maxX = null;
  8249. this._maxY = null;
  8250. this._points.forEach(function (point, index) {
  8251. if (!point) {
  8252. return;
  8253. }
  8254. point.translate();
  8255. if (_this._minX == null || point._point.x < _this._minX) {
  8256. _this._minX = point._point.x;
  8257. }
  8258. if (_this._minY == null || point._point.y < _this._minY) {
  8259. _this._minY = point._point.y;
  8260. }
  8261. if (_this._maxX == null || point._point.x > _this._maxX) {
  8262. _this._maxX = point._point.x;
  8263. }
  8264. if (_this._maxY == null || point._point.y > _this._maxY) {
  8265. _this._maxY = point._point.y;
  8266. }
  8267. });
  8268. if (this._minX == null) {
  8269. this._minX = 0;
  8270. }
  8271. if (this._minY == null) {
  8272. this._minY = 0;
  8273. }
  8274. if (this._maxX == null) {
  8275. this._maxX = 0;
  8276. }
  8277. if (this._maxY == null) {
  8278. this._maxY = 0;
  8279. }
  8280. };
  8281. MultiLine.prototype._measure = function () {
  8282. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8283. return;
  8284. }
  8285. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8286. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8287. };
  8288. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8289. if (this._minX == null || this._minY == null) {
  8290. return;
  8291. }
  8292. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8293. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8294. };
  8295. MultiLine.prototype.dispose = function () {
  8296. this.reset();
  8297. _super.prototype.dispose.call(this);
  8298. };
  8299. return MultiLine;
  8300. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8301. /***/ }),
  8302. /***/ "./2D/controls/radioButton.ts":
  8303. /*!************************************!*\
  8304. !*** ./2D/controls/radioButton.ts ***!
  8305. \************************************/
  8306. /*! exports provided: RadioButton */
  8307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8308. "use strict";
  8309. __webpack_require__.r(__webpack_exports__);
  8310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8311. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8312. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8313. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8314. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8315. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8316. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8317. /**
  8318. * Class used to create radio button controls
  8319. */
  8320. var RadioButton = /** @class */ (function (_super) {
  8321. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8322. /**
  8323. * Creates a new RadioButton
  8324. * @param name defines the control name
  8325. */
  8326. function RadioButton(name) {
  8327. var _this = _super.call(this, name) || this;
  8328. _this.name = name;
  8329. _this._isChecked = false;
  8330. _this._background = "black";
  8331. _this._checkSizeRatio = 0.8;
  8332. _this._thickness = 1;
  8333. /** Gets or sets group name */
  8334. _this.group = "";
  8335. /** Observable raised when isChecked is changed */
  8336. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8337. _this.isPointerBlocker = true;
  8338. return _this;
  8339. }
  8340. Object.defineProperty(RadioButton.prototype, "thickness", {
  8341. /** Gets or sets border thickness */
  8342. get: function () {
  8343. return this._thickness;
  8344. },
  8345. set: function (value) {
  8346. if (this._thickness === value) {
  8347. return;
  8348. }
  8349. this._thickness = value;
  8350. this._markAsDirty();
  8351. },
  8352. enumerable: true,
  8353. configurable: true
  8354. });
  8355. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8356. /** Gets or sets a value indicating the ratio between overall size and check size */
  8357. get: function () {
  8358. return this._checkSizeRatio;
  8359. },
  8360. set: function (value) {
  8361. value = Math.max(Math.min(1, value), 0);
  8362. if (this._checkSizeRatio === value) {
  8363. return;
  8364. }
  8365. this._checkSizeRatio = value;
  8366. this._markAsDirty();
  8367. },
  8368. enumerable: true,
  8369. configurable: true
  8370. });
  8371. Object.defineProperty(RadioButton.prototype, "background", {
  8372. /** Gets or sets background color */
  8373. get: function () {
  8374. return this._background;
  8375. },
  8376. set: function (value) {
  8377. if (this._background === value) {
  8378. return;
  8379. }
  8380. this._background = value;
  8381. this._markAsDirty();
  8382. },
  8383. enumerable: true,
  8384. configurable: true
  8385. });
  8386. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8387. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8388. get: function () {
  8389. return this._isChecked;
  8390. },
  8391. set: function (value) {
  8392. var _this = this;
  8393. if (this._isChecked === value) {
  8394. return;
  8395. }
  8396. this._isChecked = value;
  8397. this._markAsDirty();
  8398. this.onIsCheckedChangedObservable.notifyObservers(value);
  8399. if (this._isChecked && this._host) {
  8400. // Update all controls from same group
  8401. this._host.executeOnAllControls(function (control) {
  8402. if (control === _this) {
  8403. return;
  8404. }
  8405. if (control.group === undefined) {
  8406. return;
  8407. }
  8408. var childRadio = control;
  8409. if (childRadio.group === _this.group) {
  8410. childRadio.isChecked = false;
  8411. }
  8412. });
  8413. }
  8414. },
  8415. enumerable: true,
  8416. configurable: true
  8417. });
  8418. RadioButton.prototype._getTypeName = function () {
  8419. return "RadioButton";
  8420. };
  8421. RadioButton.prototype._draw = function (context) {
  8422. context.save();
  8423. this._applyStates(context);
  8424. var actualWidth = this._currentMeasure.width - this._thickness;
  8425. var actualHeight = this._currentMeasure.height - this._thickness;
  8426. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8427. context.shadowColor = this.shadowColor;
  8428. context.shadowBlur = this.shadowBlur;
  8429. context.shadowOffsetX = this.shadowOffsetX;
  8430. context.shadowOffsetY = this.shadowOffsetY;
  8431. }
  8432. // Outer
  8433. _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);
  8434. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8435. context.fill();
  8436. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8437. context.shadowBlur = 0;
  8438. context.shadowOffsetX = 0;
  8439. context.shadowOffsetY = 0;
  8440. }
  8441. context.strokeStyle = this.color;
  8442. context.lineWidth = this._thickness;
  8443. context.stroke();
  8444. // Inner
  8445. if (this._isChecked) {
  8446. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8447. var offsetWidth = actualWidth * this._checkSizeRatio;
  8448. var offseHeight = actualHeight * this._checkSizeRatio;
  8449. _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);
  8450. context.fill();
  8451. }
  8452. context.restore();
  8453. };
  8454. // Events
  8455. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8456. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8457. return false;
  8458. }
  8459. if (!this.isChecked) {
  8460. this.isChecked = true;
  8461. }
  8462. return true;
  8463. };
  8464. /**
  8465. * Utility function to easily create a radio button with a header
  8466. * @param title defines the label to use for the header
  8467. * @param group defines the group to use for the radio button
  8468. * @param isChecked defines the initial state of the radio button
  8469. * @param onValueChanged defines the callback to call when value changes
  8470. * @returns a StackPanel containing the radio button and a textBlock
  8471. */
  8472. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8473. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8474. panel.isVertical = false;
  8475. panel.height = "30px";
  8476. var radio = new RadioButton();
  8477. radio.width = "20px";
  8478. radio.height = "20px";
  8479. radio.isChecked = isChecked;
  8480. radio.color = "green";
  8481. radio.group = group;
  8482. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8483. panel.addControl(radio);
  8484. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8485. header.text = title;
  8486. header.width = "180px";
  8487. header.paddingLeft = "5px";
  8488. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8489. header.color = "white";
  8490. panel.addControl(header);
  8491. return panel;
  8492. };
  8493. return RadioButton;
  8494. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8495. /***/ }),
  8496. /***/ "./2D/controls/rectangle.ts":
  8497. /*!**********************************!*\
  8498. !*** ./2D/controls/rectangle.ts ***!
  8499. \**********************************/
  8500. /*! exports provided: Rectangle */
  8501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8502. "use strict";
  8503. __webpack_require__.r(__webpack_exports__);
  8504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8505. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8506. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8507. /** Class used to create rectangle container */
  8508. var Rectangle = /** @class */ (function (_super) {
  8509. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8510. /**
  8511. * Creates a new Rectangle
  8512. * @param name defines the control name
  8513. */
  8514. function Rectangle(name) {
  8515. var _this = _super.call(this, name) || this;
  8516. _this.name = name;
  8517. _this._thickness = 1;
  8518. _this._cornerRadius = 0;
  8519. return _this;
  8520. }
  8521. Object.defineProperty(Rectangle.prototype, "thickness", {
  8522. /** Gets or sets border thickness */
  8523. get: function () {
  8524. return this._thickness;
  8525. },
  8526. set: function (value) {
  8527. if (this._thickness === value) {
  8528. return;
  8529. }
  8530. this._thickness = value;
  8531. this._markAsDirty();
  8532. },
  8533. enumerable: true,
  8534. configurable: true
  8535. });
  8536. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8537. /** Gets or sets the corner radius angle */
  8538. get: function () {
  8539. return this._cornerRadius;
  8540. },
  8541. set: function (value) {
  8542. if (value < 0) {
  8543. value = 0;
  8544. }
  8545. if (this._cornerRadius === value) {
  8546. return;
  8547. }
  8548. this._cornerRadius = value;
  8549. this._markAsDirty();
  8550. },
  8551. enumerable: true,
  8552. configurable: true
  8553. });
  8554. Rectangle.prototype._getTypeName = function () {
  8555. return "Rectangle";
  8556. };
  8557. Rectangle.prototype._localDraw = function (context) {
  8558. context.save();
  8559. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8560. context.shadowColor = this.shadowColor;
  8561. context.shadowBlur = this.shadowBlur;
  8562. context.shadowOffsetX = this.shadowOffsetX;
  8563. context.shadowOffsetY = this.shadowOffsetY;
  8564. }
  8565. if (this._background) {
  8566. context.fillStyle = this._background;
  8567. if (this._cornerRadius) {
  8568. this._drawRoundedRect(context, this._thickness / 2);
  8569. context.fill();
  8570. }
  8571. else {
  8572. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8573. }
  8574. }
  8575. if (this._thickness) {
  8576. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8577. context.shadowBlur = 0;
  8578. context.shadowOffsetX = 0;
  8579. context.shadowOffsetY = 0;
  8580. }
  8581. if (this.color) {
  8582. context.strokeStyle = this.color;
  8583. }
  8584. context.lineWidth = this._thickness;
  8585. if (this._cornerRadius) {
  8586. this._drawRoundedRect(context, this._thickness / 2);
  8587. context.stroke();
  8588. }
  8589. else {
  8590. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8591. }
  8592. }
  8593. context.restore();
  8594. };
  8595. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8596. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8597. this._measureForChildren.width -= 2 * this._thickness;
  8598. this._measureForChildren.height -= 2 * this._thickness;
  8599. this._measureForChildren.left += this._thickness;
  8600. this._measureForChildren.top += this._thickness;
  8601. };
  8602. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8603. if (offset === void 0) { offset = 0; }
  8604. var x = this._currentMeasure.left + offset;
  8605. var y = this._currentMeasure.top + offset;
  8606. var width = this._currentMeasure.width - offset * 2;
  8607. var height = this._currentMeasure.height - offset * 2;
  8608. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8609. context.beginPath();
  8610. context.moveTo(x + radius, y);
  8611. context.lineTo(x + width - radius, y);
  8612. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8613. context.lineTo(x + width, y + height - radius);
  8614. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8615. context.lineTo(x + radius, y + height);
  8616. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8617. context.lineTo(x, y + radius);
  8618. context.quadraticCurveTo(x, y, x + radius, y);
  8619. context.closePath();
  8620. };
  8621. Rectangle.prototype._clipForChildren = function (context) {
  8622. if (this._cornerRadius) {
  8623. this._drawRoundedRect(context, this._thickness);
  8624. context.clip();
  8625. }
  8626. };
  8627. return Rectangle;
  8628. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8629. /***/ }),
  8630. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8631. /*!***************************************************!*\
  8632. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8633. \***************************************************/
  8634. /*! exports provided: ScrollViewer */
  8635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8636. "use strict";
  8637. __webpack_require__.r(__webpack_exports__);
  8638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8639. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8640. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/observable");
  8641. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8642. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8643. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8644. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8645. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8646. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8647. /**
  8648. * Class used to hold a viewer window and sliders in a grid
  8649. */
  8650. var ScrollViewer = /** @class */ (function (_super) {
  8651. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8652. /**
  8653. * Creates a new ScrollViewer
  8654. * @param name of ScrollViewer
  8655. */
  8656. function ScrollViewer(name) {
  8657. var _this = _super.call(this, name) || this;
  8658. _this._barSize = 20;
  8659. _this._pointerIsOver = false;
  8660. _this._wheelPrecision = 0.05;
  8661. _this.onDirtyObservable.add(function () {
  8662. _this._horizontalBarSpace.color = _this.color;
  8663. _this._verticalBarSpace.color = _this.color;
  8664. _this._dragSpace.color = _this.color;
  8665. });
  8666. _this.onPointerEnterObservable.add(function () {
  8667. _this._pointerIsOver = true;
  8668. });
  8669. _this.onPointerOutObservable.add(function () {
  8670. _this._pointerIsOver = false;
  8671. });
  8672. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8673. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8674. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8675. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8676. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8677. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8678. _this._grid.addColumnDefinition(1);
  8679. _this._grid.addColumnDefinition(0, true);
  8680. _this._grid.addRowDefinition(1);
  8681. _this._grid.addRowDefinition(0, true);
  8682. _super.prototype.addControl.call(_this, _this._grid);
  8683. _this._grid.addControl(_this._window, 0, 0);
  8684. _this._verticalBar.paddingLeft = 0;
  8685. _this._verticalBar.width = "100%";
  8686. _this._verticalBar.height = "100%";
  8687. _this._verticalBar.barOffset = 0;
  8688. _this._verticalBar.value = 0;
  8689. _this._verticalBar.maximum = 1;
  8690. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8691. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8692. _this._verticalBar.isVertical = true;
  8693. _this._verticalBar.rotation = Math.PI;
  8694. _this._verticalBar.isVisible = false;
  8695. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8696. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8697. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8698. _this._verticalBarSpace.thickness = 1;
  8699. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8700. _this._verticalBarSpace.addControl(_this._verticalBar);
  8701. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8702. _this._window.top = value * _this._endTop + "px";
  8703. });
  8704. _this._horizontalBar.paddingLeft = 0;
  8705. _this._horizontalBar.width = "100%";
  8706. _this._horizontalBar.height = "100%";
  8707. _this._horizontalBar.barOffset = 0;
  8708. _this._horizontalBar.value = 0;
  8709. _this._horizontalBar.maximum = 1;
  8710. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8711. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8712. _this._horizontalBar.isVisible = false;
  8713. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8714. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8715. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8716. _this._horizontalBarSpace.thickness = 1;
  8717. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8718. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8719. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8720. _this._window.left = value * _this._endLeft + "px";
  8721. });
  8722. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8723. _this._dragSpace.thickness = 1;
  8724. _this._grid.addControl(_this._dragSpace, 1, 1);
  8725. // Colors
  8726. _this.barColor = "grey";
  8727. _this.barBackground = "transparent";
  8728. return _this;
  8729. }
  8730. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8731. /**
  8732. * Gets the horizontal scrollbar
  8733. */
  8734. get: function () {
  8735. return this._horizontalBar;
  8736. },
  8737. enumerable: true,
  8738. configurable: true
  8739. });
  8740. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8741. /**
  8742. * Gets the vertical scrollbar
  8743. */
  8744. get: function () {
  8745. return this._verticalBar;
  8746. },
  8747. enumerable: true,
  8748. configurable: true
  8749. });
  8750. /**
  8751. * Adds a new control to the current container
  8752. * @param control defines the control to add
  8753. * @returns the current container
  8754. */
  8755. ScrollViewer.prototype.addControl = function (control) {
  8756. if (!control) {
  8757. return this;
  8758. }
  8759. this._window.addControl(control);
  8760. return this;
  8761. };
  8762. /**
  8763. * Removes a control from the current container
  8764. * @param control defines the control to remove
  8765. * @returns the current container
  8766. */
  8767. ScrollViewer.prototype.removeControl = function (control) {
  8768. this._window.removeControl(control);
  8769. return this;
  8770. };
  8771. Object.defineProperty(ScrollViewer.prototype, "children", {
  8772. /** Gets the list of children */
  8773. get: function () {
  8774. return this._window.children;
  8775. },
  8776. enumerable: true,
  8777. configurable: true
  8778. });
  8779. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8780. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8781. var child = _a[_i];
  8782. child._markMatrixAsDirty();
  8783. }
  8784. };
  8785. /** Reset the scroll viewer window to initial size */
  8786. ScrollViewer.prototype.resetWindow = function () {
  8787. this._window.width = "100%";
  8788. this._window.height = "100%";
  8789. };
  8790. ScrollViewer.prototype._getTypeName = function () {
  8791. return "ScrollViewer";
  8792. };
  8793. ScrollViewer.prototype._buildClientSizes = function () {
  8794. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8795. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8796. this._clientWidth = this._window.parentClientWidth;
  8797. this._clientHeight = this._window.parentClientHeight;
  8798. };
  8799. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8800. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8801. this._buildClientSizes();
  8802. };
  8803. ScrollViewer.prototype._postMeasure = function () {
  8804. _super.prototype._postMeasure.call(this);
  8805. this._updateScroller();
  8806. };
  8807. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8808. /**
  8809. * Gets or sets the mouse wheel precision
  8810. * from 0 to 1 with a default value of 0.05
  8811. * */
  8812. get: function () {
  8813. return this._wheelPrecision;
  8814. },
  8815. set: function (value) {
  8816. if (this._wheelPrecision === value) {
  8817. return;
  8818. }
  8819. if (value < 0) {
  8820. value = 0;
  8821. }
  8822. if (value > 1) {
  8823. value = 1;
  8824. }
  8825. this._wheelPrecision = value;
  8826. },
  8827. enumerable: true,
  8828. configurable: true
  8829. });
  8830. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8831. /** Gets or sets the bar color */
  8832. get: function () {
  8833. return this._barColor;
  8834. },
  8835. set: function (color) {
  8836. if (this._barColor === color) {
  8837. return;
  8838. }
  8839. this._barColor = color;
  8840. this._horizontalBar.color = color;
  8841. this._verticalBar.color = color;
  8842. },
  8843. enumerable: true,
  8844. configurable: true
  8845. });
  8846. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8847. /** Gets or sets the size of the bar */
  8848. get: function () {
  8849. return this._barSize;
  8850. },
  8851. set: function (value) {
  8852. if (this._barSize === value) {
  8853. return;
  8854. }
  8855. this._barSize = value;
  8856. this._markAsDirty();
  8857. if (this._horizontalBar.isVisible) {
  8858. this._grid.setRowDefinition(1, this._barSize, true);
  8859. }
  8860. if (this._verticalBar.isVisible) {
  8861. this._grid.setColumnDefinition(1, this._barSize, true);
  8862. }
  8863. },
  8864. enumerable: true,
  8865. configurable: true
  8866. });
  8867. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8868. /** Gets or sets the bar background */
  8869. get: function () {
  8870. return this._barBackground;
  8871. },
  8872. set: function (color) {
  8873. if (this._barBackground === color) {
  8874. return;
  8875. }
  8876. this._barBackground = color;
  8877. this._horizontalBar.background = color;
  8878. this._verticalBar.background = color;
  8879. this._dragSpace.background = color;
  8880. },
  8881. enumerable: true,
  8882. configurable: true
  8883. });
  8884. /** @hidden */
  8885. ScrollViewer.prototype._updateScroller = function () {
  8886. var windowContentsWidth = this._window._currentMeasure.width;
  8887. var windowContentsHeight = this._window._currentMeasure.height;
  8888. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8889. this._grid.setRowDefinition(1, 0, true);
  8890. this._horizontalBar.isVisible = false;
  8891. this._horizontalBar.value = 0;
  8892. this._rebuildLayout = true;
  8893. }
  8894. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8895. this._grid.setRowDefinition(1, this._barSize, true);
  8896. this._horizontalBar.isVisible = true;
  8897. this._rebuildLayout = true;
  8898. }
  8899. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8900. this._grid.setColumnDefinition(1, 0, true);
  8901. this._verticalBar.isVisible = false;
  8902. this._verticalBar.value = 0;
  8903. this._rebuildLayout = true;
  8904. }
  8905. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8906. this._grid.setColumnDefinition(1, this._barSize, true);
  8907. this._verticalBar.isVisible = true;
  8908. this._rebuildLayout = true;
  8909. }
  8910. this._buildClientSizes();
  8911. this._endLeft = this._clientWidth - windowContentsWidth;
  8912. this._endTop = this._clientHeight - windowContentsHeight;
  8913. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8914. var newTop = this._verticalBar.value * this._endTop + "px";
  8915. if (newLeft !== this._window.left) {
  8916. this._window.left = newLeft;
  8917. this._rebuildLayout = true;
  8918. }
  8919. if (newTop !== this._window.top) {
  8920. this._window.top = newTop;
  8921. this._rebuildLayout = true;
  8922. }
  8923. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8924. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8925. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8926. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8927. };
  8928. ScrollViewer.prototype._link = function (host) {
  8929. _super.prototype._link.call(this, host);
  8930. this._attachWheel();
  8931. };
  8932. /** @hidden */
  8933. ScrollViewer.prototype._attachWheel = function () {
  8934. var _this = this;
  8935. if (!this._host || this._onPointerObserver) {
  8936. return;
  8937. }
  8938. var scene = this._host.getScene();
  8939. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8940. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8941. return;
  8942. }
  8943. if (_this._verticalBar.isVisible == true) {
  8944. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8945. _this._verticalBar.value -= _this._wheelPrecision;
  8946. }
  8947. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8948. _this._verticalBar.value += _this._wheelPrecision;
  8949. }
  8950. }
  8951. if (_this._horizontalBar.isVisible == true) {
  8952. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8953. _this._horizontalBar.value += _this._wheelPrecision;
  8954. }
  8955. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8956. _this._horizontalBar.value -= _this._wheelPrecision;
  8957. }
  8958. }
  8959. });
  8960. };
  8961. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8962. if (!this.isHighlighted) {
  8963. return;
  8964. }
  8965. _super.prototype._renderHighlightSpecific.call(this, context);
  8966. this._grid._renderHighlightSpecific(context);
  8967. context.restore();
  8968. };
  8969. /** Releases associated resources */
  8970. ScrollViewer.prototype.dispose = function () {
  8971. var scene = this._host.getScene();
  8972. if (scene && this._onPointerObserver) {
  8973. scene.onPointerObservable.remove(this._onPointerObserver);
  8974. this._onPointerObserver = null;
  8975. }
  8976. _super.prototype.dispose.call(this);
  8977. };
  8978. return ScrollViewer;
  8979. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8980. /***/ }),
  8981. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8982. /*!*********************************************************!*\
  8983. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8984. \*********************************************************/
  8985. /*! exports provided: _ScrollViewerWindow */
  8986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8987. "use strict";
  8988. __webpack_require__.r(__webpack_exports__);
  8989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8990. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8991. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8992. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8993. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8994. /**
  8995. * Class used to hold a the container for ScrollViewer
  8996. * @hidden
  8997. */
  8998. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8999. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  9000. /**
  9001. * Creates a new ScrollViewerWindow
  9002. * @param name of ScrollViewerWindow
  9003. */
  9004. function _ScrollViewerWindow(name) {
  9005. return _super.call(this, name) || this;
  9006. }
  9007. _ScrollViewerWindow.prototype._getTypeName = function () {
  9008. return "ScrollViewerWindow";
  9009. };
  9010. /** @hidden */
  9011. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9012. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9013. this._measureForChildren.left = this._currentMeasure.left;
  9014. this._measureForChildren.top = this._currentMeasure.top;
  9015. this._measureForChildren.width = parentMeasure.width;
  9016. this._measureForChildren.height = parentMeasure.height;
  9017. };
  9018. _ScrollViewerWindow.prototype._postMeasure = function () {
  9019. var maxWidth = this.parentClientWidth;
  9020. var maxHeight = this.parentClientHeight;
  9021. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9022. var child = _a[_i];
  9023. if (!child.isVisible || child.notRenderable) {
  9024. continue;
  9025. }
  9026. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9027. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9028. }
  9029. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9030. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9031. }
  9032. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9033. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9034. }
  9035. if (this._currentMeasure.width !== maxWidth) {
  9036. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9037. this._currentMeasure.width = maxWidth;
  9038. this._rebuildLayout = true;
  9039. this._isDirty = true;
  9040. }
  9041. if (this._currentMeasure.height !== maxHeight) {
  9042. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9043. this._currentMeasure.height = maxHeight;
  9044. this._rebuildLayout = true;
  9045. this._isDirty = true;
  9046. }
  9047. _super.prototype._postMeasure.call(this);
  9048. };
  9049. return _ScrollViewerWindow;
  9050. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9051. /***/ }),
  9052. /***/ "./2D/controls/selector.ts":
  9053. /*!*********************************!*\
  9054. !*** ./2D/controls/selector.ts ***!
  9055. \*********************************/
  9056. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9058. "use strict";
  9059. __webpack_require__.r(__webpack_exports__);
  9060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9063. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9065. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9066. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9067. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9068. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9069. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9070. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9071. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9072. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9073. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9074. /** Class used to create a RadioGroup
  9075. * which contains groups of radio buttons
  9076. */
  9077. var SelectorGroup = /** @class */ (function () {
  9078. /**
  9079. * Creates a new SelectorGroup
  9080. * @param name of group, used as a group heading
  9081. */
  9082. function SelectorGroup(
  9083. /** name of SelectorGroup */
  9084. name) {
  9085. this.name = name;
  9086. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9087. this._selectors = new Array();
  9088. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9089. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9090. this._groupHeader = this._addGroupHeader(name);
  9091. }
  9092. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9093. /** Gets the groupPanel of the SelectorGroup */
  9094. get: function () {
  9095. return this._groupPanel;
  9096. },
  9097. enumerable: true,
  9098. configurable: true
  9099. });
  9100. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9101. /** Gets the selectors array */
  9102. get: function () {
  9103. return this._selectors;
  9104. },
  9105. enumerable: true,
  9106. configurable: true
  9107. });
  9108. Object.defineProperty(SelectorGroup.prototype, "header", {
  9109. /** Gets and sets the group header */
  9110. get: function () {
  9111. return this._groupHeader.text;
  9112. },
  9113. set: function (label) {
  9114. if (this._groupHeader.text === "label") {
  9115. return;
  9116. }
  9117. this._groupHeader.text = label;
  9118. },
  9119. enumerable: true,
  9120. configurable: true
  9121. });
  9122. /** @hidden */
  9123. SelectorGroup.prototype._addGroupHeader = function (text) {
  9124. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9125. groupHeading.width = 0.9;
  9126. groupHeading.height = "30px";
  9127. groupHeading.textWrapping = true;
  9128. groupHeading.color = "black";
  9129. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9130. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9131. groupHeading.left = "2px";
  9132. this._groupPanel.addControl(groupHeading);
  9133. return groupHeading;
  9134. };
  9135. /** @hidden*/
  9136. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9137. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9138. return;
  9139. }
  9140. return this._selectors[selectorNb];
  9141. };
  9142. /** Removes the selector at the given position
  9143. * @param selectorNb the position of the selector within the group
  9144. */
  9145. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9146. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9147. return;
  9148. }
  9149. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9150. this._selectors.splice(selectorNb, 1);
  9151. };
  9152. return SelectorGroup;
  9153. }());
  9154. /** Class used to create a CheckboxGroup
  9155. * which contains groups of checkbox buttons
  9156. */
  9157. var CheckboxGroup = /** @class */ (function (_super) {
  9158. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9159. function CheckboxGroup() {
  9160. return _super !== null && _super.apply(this, arguments) || this;
  9161. }
  9162. /** Adds a checkbox as a control
  9163. * @param text is the label for the selector
  9164. * @param func is the function called when the Selector is checked
  9165. * @param checked is true when Selector is checked
  9166. */
  9167. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9168. if (func === void 0) { func = function (s) { }; }
  9169. if (checked === void 0) { checked = false; }
  9170. var checked = checked || false;
  9171. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9172. button.width = "20px";
  9173. button.height = "20px";
  9174. button.color = "#364249";
  9175. button.background = "#CCCCCC";
  9176. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9177. button.onIsCheckedChangedObservable.add(function (state) {
  9178. func(state);
  9179. });
  9180. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9181. _selector.height = "30px";
  9182. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9183. _selector.left = "4px";
  9184. this.groupPanel.addControl(_selector);
  9185. this.selectors.push(_selector);
  9186. button.isChecked = checked;
  9187. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9188. button.color = this.groupPanel.parent.parent.buttonColor;
  9189. button.background = this.groupPanel.parent.parent.buttonBackground;
  9190. }
  9191. };
  9192. /** @hidden */
  9193. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9194. this.selectors[selectorNb].children[1].text = label;
  9195. };
  9196. /** @hidden */
  9197. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9198. this.selectors[selectorNb].children[1].color = color;
  9199. };
  9200. /** @hidden */
  9201. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9202. this.selectors[selectorNb].children[0].color = color;
  9203. };
  9204. /** @hidden */
  9205. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9206. this.selectors[selectorNb].children[0].background = color;
  9207. };
  9208. return CheckboxGroup;
  9209. }(SelectorGroup));
  9210. /** Class used to create a RadioGroup
  9211. * which contains groups of radio buttons
  9212. */
  9213. var RadioGroup = /** @class */ (function (_super) {
  9214. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9215. function RadioGroup() {
  9216. var _this = _super !== null && _super.apply(this, arguments) || this;
  9217. _this._selectNb = 0;
  9218. return _this;
  9219. }
  9220. /** Adds a radio button as a control
  9221. * @param label is the label for the selector
  9222. * @param func is the function called when the Selector is checked
  9223. * @param checked is true when Selector is checked
  9224. */
  9225. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9226. if (func === void 0) { func = function (n) { }; }
  9227. if (checked === void 0) { checked = false; }
  9228. var nb = this._selectNb++;
  9229. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9230. button.name = label;
  9231. button.width = "20px";
  9232. button.height = "20px";
  9233. button.color = "#364249";
  9234. button.background = "#CCCCCC";
  9235. button.group = this.name;
  9236. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9237. button.onIsCheckedChangedObservable.add(function (state) {
  9238. if (state) {
  9239. func(nb);
  9240. }
  9241. });
  9242. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9243. _selector.height = "30px";
  9244. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9245. _selector.left = "4px";
  9246. this.groupPanel.addControl(_selector);
  9247. this.selectors.push(_selector);
  9248. button.isChecked = checked;
  9249. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9250. button.color = this.groupPanel.parent.parent.buttonColor;
  9251. button.background = this.groupPanel.parent.parent.buttonBackground;
  9252. }
  9253. };
  9254. /** @hidden */
  9255. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9256. this.selectors[selectorNb].children[1].text = label;
  9257. };
  9258. /** @hidden */
  9259. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9260. this.selectors[selectorNb].children[1].color = color;
  9261. };
  9262. /** @hidden */
  9263. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9264. this.selectors[selectorNb].children[0].color = color;
  9265. };
  9266. /** @hidden */
  9267. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9268. this.selectors[selectorNb].children[0].background = color;
  9269. };
  9270. return RadioGroup;
  9271. }(SelectorGroup));
  9272. /** Class used to create a SliderGroup
  9273. * which contains groups of slider buttons
  9274. */
  9275. var SliderGroup = /** @class */ (function (_super) {
  9276. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9277. function SliderGroup() {
  9278. return _super !== null && _super.apply(this, arguments) || this;
  9279. }
  9280. /**
  9281. * Adds a slider to the SelectorGroup
  9282. * @param label is the label for the SliderBar
  9283. * @param func is the function called when the Slider moves
  9284. * @param unit is a string describing the units used, eg degrees or metres
  9285. * @param min is the minimum value for the Slider
  9286. * @param max is the maximum value for the Slider
  9287. * @param value is the start value for the Slider between min and max
  9288. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9289. */
  9290. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9291. if (func === void 0) { func = function (v) { }; }
  9292. if (unit === void 0) { unit = "Units"; }
  9293. if (min === void 0) { min = 0; }
  9294. if (max === void 0) { max = 0; }
  9295. if (value === void 0) { value = 0; }
  9296. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9297. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9298. button.name = unit;
  9299. button.value = value;
  9300. button.minimum = min;
  9301. button.maximum = max;
  9302. button.width = 0.9;
  9303. button.height = "20px";
  9304. button.color = "#364249";
  9305. button.background = "#CCCCCC";
  9306. button.borderColor = "black";
  9307. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9308. button.left = "4px";
  9309. button.paddingBottom = "4px";
  9310. button.onValueChangedObservable.add(function (value) {
  9311. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9312. func(value);
  9313. });
  9314. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9315. _selector.height = "60px";
  9316. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9317. _selector.left = "4px";
  9318. _selector.children[0].name = label;
  9319. this.groupPanel.addControl(_selector);
  9320. this.selectors.push(_selector);
  9321. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9322. button.color = this.groupPanel.parent.parent.buttonColor;
  9323. button.background = this.groupPanel.parent.parent.buttonBackground;
  9324. }
  9325. };
  9326. /** @hidden */
  9327. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9328. this.selectors[selectorNb].children[0].name = label;
  9329. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9330. };
  9331. /** @hidden */
  9332. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9333. this.selectors[selectorNb].children[0].color = color;
  9334. };
  9335. /** @hidden */
  9336. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9337. this.selectors[selectorNb].children[1].color = color;
  9338. };
  9339. /** @hidden */
  9340. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9341. this.selectors[selectorNb].children[1].background = color;
  9342. };
  9343. return SliderGroup;
  9344. }(SelectorGroup));
  9345. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9346. * @see http://doc.babylonjs.com/how_to/selector
  9347. */
  9348. var SelectionPanel = /** @class */ (function (_super) {
  9349. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9350. /**
  9351. * Creates a new SelectionPanel
  9352. * @param name of SelectionPanel
  9353. * @param groups is an array of SelectionGroups
  9354. */
  9355. function SelectionPanel(
  9356. /** name of SelectionPanel */
  9357. name,
  9358. /** an array of SelectionGroups */
  9359. groups) {
  9360. if (groups === void 0) { groups = []; }
  9361. var _this = _super.call(this, name) || this;
  9362. _this.name = name;
  9363. _this.groups = groups;
  9364. _this._buttonColor = "#364249";
  9365. _this._buttonBackground = "#CCCCCC";
  9366. _this._headerColor = "black";
  9367. _this._barColor = "white";
  9368. _this._barHeight = "2px";
  9369. _this._spacerHeight = "20px";
  9370. _this._bars = new Array();
  9371. _this._groups = groups;
  9372. _this.thickness = 2;
  9373. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9374. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9375. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9376. _this._panel.top = 5;
  9377. _this._panel.left = 5;
  9378. _this._panel.width = 0.95;
  9379. if (groups.length > 0) {
  9380. for (var i = 0; i < groups.length - 1; i++) {
  9381. _this._panel.addControl(groups[i].groupPanel);
  9382. _this._addSpacer();
  9383. }
  9384. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9385. }
  9386. _this.addControl(_this._panel);
  9387. return _this;
  9388. }
  9389. SelectionPanel.prototype._getTypeName = function () {
  9390. return "SelectionPanel";
  9391. };
  9392. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9393. /** Gets or sets the headerColor */
  9394. get: function () {
  9395. return this._headerColor;
  9396. },
  9397. set: function (color) {
  9398. if (this._headerColor === color) {
  9399. return;
  9400. }
  9401. this._headerColor = color;
  9402. this._setHeaderColor();
  9403. },
  9404. enumerable: true,
  9405. configurable: true
  9406. });
  9407. SelectionPanel.prototype._setHeaderColor = function () {
  9408. for (var i = 0; i < this._groups.length; i++) {
  9409. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9410. }
  9411. };
  9412. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9413. /** Gets or sets the button color */
  9414. get: function () {
  9415. return this._buttonColor;
  9416. },
  9417. set: function (color) {
  9418. if (this._buttonColor === color) {
  9419. return;
  9420. }
  9421. this._buttonColor = color;
  9422. this._setbuttonColor();
  9423. },
  9424. enumerable: true,
  9425. configurable: true
  9426. });
  9427. SelectionPanel.prototype._setbuttonColor = function () {
  9428. for (var i = 0; i < this._groups.length; i++) {
  9429. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9430. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9431. }
  9432. }
  9433. };
  9434. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9435. /** Gets or sets the label color */
  9436. get: function () {
  9437. return this._labelColor;
  9438. },
  9439. set: function (color) {
  9440. if (this._labelColor === color) {
  9441. return;
  9442. }
  9443. this._labelColor = color;
  9444. this._setLabelColor();
  9445. },
  9446. enumerable: true,
  9447. configurable: true
  9448. });
  9449. SelectionPanel.prototype._setLabelColor = function () {
  9450. for (var i = 0; i < this._groups.length; i++) {
  9451. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9452. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9453. }
  9454. }
  9455. };
  9456. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9457. /** Gets or sets the button background */
  9458. get: function () {
  9459. return this._buttonBackground;
  9460. },
  9461. set: function (color) {
  9462. if (this._buttonBackground === color) {
  9463. return;
  9464. }
  9465. this._buttonBackground = color;
  9466. this._setButtonBackground();
  9467. },
  9468. enumerable: true,
  9469. configurable: true
  9470. });
  9471. SelectionPanel.prototype._setButtonBackground = function () {
  9472. for (var i = 0; i < this._groups.length; i++) {
  9473. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9474. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9475. }
  9476. }
  9477. };
  9478. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9479. /** Gets or sets the color of separator bar */
  9480. get: function () {
  9481. return this._barColor;
  9482. },
  9483. set: function (color) {
  9484. if (this._barColor === color) {
  9485. return;
  9486. }
  9487. this._barColor = color;
  9488. this._setBarColor();
  9489. },
  9490. enumerable: true,
  9491. configurable: true
  9492. });
  9493. SelectionPanel.prototype._setBarColor = function () {
  9494. for (var i = 0; i < this._bars.length; i++) {
  9495. this._bars[i].children[0].background = this._barColor;
  9496. }
  9497. };
  9498. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9499. /** Gets or sets the height of separator bar */
  9500. get: function () {
  9501. return this._barHeight;
  9502. },
  9503. set: function (value) {
  9504. if (this._barHeight === value) {
  9505. return;
  9506. }
  9507. this._barHeight = value;
  9508. this._setBarHeight();
  9509. },
  9510. enumerable: true,
  9511. configurable: true
  9512. });
  9513. SelectionPanel.prototype._setBarHeight = function () {
  9514. for (var i = 0; i < this._bars.length; i++) {
  9515. this._bars[i].children[0].height = this._barHeight;
  9516. }
  9517. };
  9518. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9519. /** Gets or sets the height of spacers*/
  9520. get: function () {
  9521. return this._spacerHeight;
  9522. },
  9523. set: function (value) {
  9524. if (this._spacerHeight === value) {
  9525. return;
  9526. }
  9527. this._spacerHeight = value;
  9528. this._setSpacerHeight();
  9529. },
  9530. enumerable: true,
  9531. configurable: true
  9532. });
  9533. SelectionPanel.prototype._setSpacerHeight = function () {
  9534. for (var i = 0; i < this._bars.length; i++) {
  9535. this._bars[i].height = this._spacerHeight;
  9536. }
  9537. };
  9538. /** Adds a bar between groups */
  9539. SelectionPanel.prototype._addSpacer = function () {
  9540. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9541. separator.width = 1;
  9542. separator.height = this._spacerHeight;
  9543. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9544. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9545. bar.width = 1;
  9546. bar.height = this._barHeight;
  9547. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9548. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9549. bar.background = this._barColor;
  9550. bar.color = "transparent";
  9551. separator.addControl(bar);
  9552. this._panel.addControl(separator);
  9553. this._bars.push(separator);
  9554. };
  9555. /** Add a group to the selection panel
  9556. * @param group is the selector group to add
  9557. */
  9558. SelectionPanel.prototype.addGroup = function (group) {
  9559. if (this._groups.length > 0) {
  9560. this._addSpacer();
  9561. }
  9562. this._panel.addControl(group.groupPanel);
  9563. this._groups.push(group);
  9564. group.groupPanel.children[0].color = this._headerColor;
  9565. for (var j = 0; j < group.selectors.length; j++) {
  9566. group._setSelectorButtonColor(j, this._buttonColor);
  9567. group._setSelectorButtonBackground(j, this._buttonBackground);
  9568. }
  9569. };
  9570. /** Remove the group from the given position
  9571. * @param groupNb is the position of the group in the list
  9572. */
  9573. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9574. if (groupNb < 0 || groupNb >= this._groups.length) {
  9575. return;
  9576. }
  9577. var group = this._groups[groupNb];
  9578. this._panel.removeControl(group.groupPanel);
  9579. this._groups.splice(groupNb, 1);
  9580. if (groupNb < this._bars.length) {
  9581. this._panel.removeControl(this._bars[groupNb]);
  9582. this._bars.splice(groupNb, 1);
  9583. }
  9584. };
  9585. /** Change a group header label
  9586. * @param label is the new group header label
  9587. * @param groupNb is the number of the group to relabel
  9588. * */
  9589. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9590. if (groupNb < 0 || groupNb >= this._groups.length) {
  9591. return;
  9592. }
  9593. var group = this._groups[groupNb];
  9594. group.groupPanel.children[0].text = label;
  9595. };
  9596. /** Change selector label to the one given
  9597. * @param label is the new selector label
  9598. * @param groupNb is the number of the groupcontaining the selector
  9599. * @param selectorNb is the number of the selector within a group to relabel
  9600. * */
  9601. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9602. if (groupNb < 0 || groupNb >= this._groups.length) {
  9603. return;
  9604. }
  9605. var group = this._groups[groupNb];
  9606. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9607. return;
  9608. }
  9609. group._setSelectorLabel(selectorNb, label);
  9610. };
  9611. /** For a given group position remove the selector at the given position
  9612. * @param groupNb is the number of the group to remove the selector from
  9613. * @param selectorNb is the number of the selector within the group
  9614. */
  9615. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9616. if (groupNb < 0 || groupNb >= this._groups.length) {
  9617. return;
  9618. }
  9619. var group = this._groups[groupNb];
  9620. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9621. return;
  9622. }
  9623. group.removeSelector(selectorNb);
  9624. };
  9625. /** For a given group position of correct type add a checkbox button
  9626. * @param groupNb is the number of the group to remove the selector from
  9627. * @param label is the label for the selector
  9628. * @param func is the function called when the Selector is checked
  9629. * @param checked is true when Selector is checked
  9630. */
  9631. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9632. if (func === void 0) { func = function () { }; }
  9633. if (checked === void 0) { checked = false; }
  9634. if (groupNb < 0 || groupNb >= this._groups.length) {
  9635. return;
  9636. }
  9637. var group = this._groups[groupNb];
  9638. group.addCheckbox(label, func, checked);
  9639. };
  9640. /** For a given group position of correct type add a radio button
  9641. * @param groupNb is the number of the group to remove the selector from
  9642. * @param label is the label for the selector
  9643. * @param func is the function called when the Selector is checked
  9644. * @param checked is true when Selector is checked
  9645. */
  9646. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9647. if (func === void 0) { func = function () { }; }
  9648. if (checked === void 0) { checked = false; }
  9649. if (groupNb < 0 || groupNb >= this._groups.length) {
  9650. return;
  9651. }
  9652. var group = this._groups[groupNb];
  9653. group.addRadio(label, func, checked);
  9654. };
  9655. /**
  9656. * For a given slider group add a slider
  9657. * @param groupNb is the number of the group to add the slider to
  9658. * @param label is the label for the Slider
  9659. * @param func is the function called when the Slider moves
  9660. * @param unit is a string describing the units used, eg degrees or metres
  9661. * @param min is the minimum value for the Slider
  9662. * @param max is the maximum value for the Slider
  9663. * @param value is the start value for the Slider between min and max
  9664. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9665. */
  9666. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9667. if (func === void 0) { func = function () { }; }
  9668. if (unit === void 0) { unit = "Units"; }
  9669. if (min === void 0) { min = 0; }
  9670. if (max === void 0) { max = 0; }
  9671. if (value === void 0) { value = 0; }
  9672. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9673. if (groupNb < 0 || groupNb >= this._groups.length) {
  9674. return;
  9675. }
  9676. var group = this._groups[groupNb];
  9677. group.addSlider(label, func, unit, min, max, value, onVal);
  9678. };
  9679. return SelectionPanel;
  9680. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9681. /***/ }),
  9682. /***/ "./2D/controls/sliders/baseSlider.ts":
  9683. /*!*******************************************!*\
  9684. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9685. \*******************************************/
  9686. /*! exports provided: BaseSlider */
  9687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9688. "use strict";
  9689. __webpack_require__.r(__webpack_exports__);
  9690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9691. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9692. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  9693. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9694. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9695. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9696. /**
  9697. * Class used to create slider controls
  9698. */
  9699. var BaseSlider = /** @class */ (function (_super) {
  9700. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9701. /**
  9702. * Creates a new BaseSlider
  9703. * @param name defines the control name
  9704. */
  9705. function BaseSlider(name) {
  9706. var _this = _super.call(this, name) || this;
  9707. _this.name = name;
  9708. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9709. _this._minimum = 0;
  9710. _this._maximum = 100;
  9711. _this._value = 50;
  9712. _this._isVertical = false;
  9713. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9714. _this._isThumbClamped = false;
  9715. _this._displayThumb = true;
  9716. _this._step = 0;
  9717. _this._lastPointerDownID = -1;
  9718. // Shared rendering info
  9719. _this._effectiveBarOffset = 0;
  9720. /** Observable raised when the sldier value changes */
  9721. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9722. // Events
  9723. _this._pointerIsDown = false;
  9724. _this.isPointerBlocker = true;
  9725. return _this;
  9726. }
  9727. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9728. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9729. get: function () {
  9730. return this._displayThumb;
  9731. },
  9732. set: function (value) {
  9733. if (this._displayThumb === value) {
  9734. return;
  9735. }
  9736. this._displayThumb = value;
  9737. this._markAsDirty();
  9738. },
  9739. enumerable: true,
  9740. configurable: true
  9741. });
  9742. Object.defineProperty(BaseSlider.prototype, "step", {
  9743. /** Gets or sets a step to apply to values (0 by default) */
  9744. get: function () {
  9745. return this._step;
  9746. },
  9747. set: function (value) {
  9748. if (this._step === value) {
  9749. return;
  9750. }
  9751. this._step = value;
  9752. this._markAsDirty();
  9753. },
  9754. enumerable: true,
  9755. configurable: true
  9756. });
  9757. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9758. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9759. get: function () {
  9760. return this._barOffset.toString(this._host);
  9761. },
  9762. set: function (value) {
  9763. if (this._barOffset.toString(this._host) === value) {
  9764. return;
  9765. }
  9766. if (this._barOffset.fromString(value)) {
  9767. this._markAsDirty();
  9768. }
  9769. },
  9770. enumerable: true,
  9771. configurable: true
  9772. });
  9773. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9774. /** Gets main bar offset in pixels*/
  9775. get: function () {
  9776. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9777. },
  9778. enumerable: true,
  9779. configurable: true
  9780. });
  9781. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9782. /** Gets or sets thumb width */
  9783. get: function () {
  9784. return this._thumbWidth.toString(this._host);
  9785. },
  9786. set: function (value) {
  9787. if (this._thumbWidth.toString(this._host) === value) {
  9788. return;
  9789. }
  9790. if (this._thumbWidth.fromString(value)) {
  9791. this._markAsDirty();
  9792. }
  9793. },
  9794. enumerable: true,
  9795. configurable: true
  9796. });
  9797. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9798. /** Gets thumb width in pixels */
  9799. get: function () {
  9800. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9801. },
  9802. enumerable: true,
  9803. configurable: true
  9804. });
  9805. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9806. /** Gets or sets minimum value */
  9807. get: function () {
  9808. return this._minimum;
  9809. },
  9810. set: function (value) {
  9811. if (this._minimum === value) {
  9812. return;
  9813. }
  9814. this._minimum = value;
  9815. this._markAsDirty();
  9816. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9817. },
  9818. enumerable: true,
  9819. configurable: true
  9820. });
  9821. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9822. /** Gets or sets maximum value */
  9823. get: function () {
  9824. return this._maximum;
  9825. },
  9826. set: function (value) {
  9827. if (this._maximum === value) {
  9828. return;
  9829. }
  9830. this._maximum = value;
  9831. this._markAsDirty();
  9832. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9833. },
  9834. enumerable: true,
  9835. configurable: true
  9836. });
  9837. Object.defineProperty(BaseSlider.prototype, "value", {
  9838. /** Gets or sets current value */
  9839. get: function () {
  9840. return this._value;
  9841. },
  9842. set: function (value) {
  9843. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9844. if (this._value === value) {
  9845. return;
  9846. }
  9847. this._value = value;
  9848. this._markAsDirty();
  9849. this.onValueChangedObservable.notifyObservers(this._value);
  9850. },
  9851. enumerable: true,
  9852. configurable: true
  9853. });
  9854. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9855. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9856. get: function () {
  9857. return this._isVertical;
  9858. },
  9859. set: function (value) {
  9860. if (this._isVertical === value) {
  9861. return;
  9862. }
  9863. this._isVertical = value;
  9864. this._markAsDirty();
  9865. },
  9866. enumerable: true,
  9867. configurable: true
  9868. });
  9869. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9870. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9871. get: function () {
  9872. return this._isThumbClamped;
  9873. },
  9874. set: function (value) {
  9875. if (this._isThumbClamped === value) {
  9876. return;
  9877. }
  9878. this._isThumbClamped = value;
  9879. this._markAsDirty();
  9880. },
  9881. enumerable: true,
  9882. configurable: true
  9883. });
  9884. BaseSlider.prototype._getTypeName = function () {
  9885. return "BaseSlider";
  9886. };
  9887. BaseSlider.prototype._getThumbPosition = function () {
  9888. if (this.isVertical) {
  9889. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9890. }
  9891. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9892. };
  9893. BaseSlider.prototype._getThumbThickness = function (type) {
  9894. var thumbThickness = 0;
  9895. switch (type) {
  9896. case "circle":
  9897. if (this._thumbWidth.isPixel) {
  9898. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9899. }
  9900. else {
  9901. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9902. }
  9903. break;
  9904. case "rectangle":
  9905. if (this._thumbWidth.isPixel) {
  9906. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9907. }
  9908. else {
  9909. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9910. }
  9911. }
  9912. return thumbThickness;
  9913. };
  9914. BaseSlider.prototype._prepareRenderingData = function (type) {
  9915. // Main bar
  9916. this._effectiveBarOffset = 0;
  9917. this._renderLeft = this._currentMeasure.left;
  9918. this._renderTop = this._currentMeasure.top;
  9919. this._renderWidth = this._currentMeasure.width;
  9920. this._renderHeight = this._currentMeasure.height;
  9921. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9922. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9923. this._effectiveThumbThickness = this._getThumbThickness(type);
  9924. if (this.displayThumb) {
  9925. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9926. }
  9927. //throw error when height is less than width for vertical slider
  9928. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9929. console.error("Height should be greater than width");
  9930. return;
  9931. }
  9932. if (this._barOffset.isPixel) {
  9933. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9934. }
  9935. else {
  9936. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9937. }
  9938. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9939. if (this.isVertical) {
  9940. this._renderLeft += this._effectiveBarOffset;
  9941. if (!this.isThumbClamped && this.displayThumb) {
  9942. this._renderTop += (this._effectiveThumbThickness / 2);
  9943. }
  9944. this._renderHeight = this._backgroundBoxLength;
  9945. this._renderWidth = this._backgroundBoxThickness;
  9946. }
  9947. else {
  9948. this._renderTop += this._effectiveBarOffset;
  9949. if (!this.isThumbClamped && this.displayThumb) {
  9950. this._renderLeft += (this._effectiveThumbThickness / 2);
  9951. }
  9952. this._renderHeight = this._backgroundBoxThickness;
  9953. this._renderWidth = this._backgroundBoxLength;
  9954. }
  9955. };
  9956. /** @hidden */
  9957. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9958. if (this.rotation != 0) {
  9959. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9960. x = this._transformedPosition.x;
  9961. y = this._transformedPosition.y;
  9962. }
  9963. var value;
  9964. if (this._isVertical) {
  9965. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9966. }
  9967. else {
  9968. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9969. }
  9970. var mult = (1 / this._step) | 0;
  9971. this.value = this._step ? ((value * mult) | 0) / mult : value;
  9972. };
  9973. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9974. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9975. return false;
  9976. }
  9977. this._pointerIsDown = true;
  9978. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9979. this._host._capturingControl[pointerId] = this;
  9980. this._lastPointerDownID = pointerId;
  9981. return true;
  9982. };
  9983. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  9984. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  9985. if (pointerId != this._lastPointerDownID) {
  9986. return;
  9987. }
  9988. if (this._pointerIsDown) {
  9989. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9990. }
  9991. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  9992. };
  9993. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9994. this._pointerIsDown = false;
  9995. delete this._host._capturingControl[pointerId];
  9996. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9997. };
  9998. return BaseSlider;
  9999. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10000. /***/ }),
  10001. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10002. /*!*************************************************!*\
  10003. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10004. \*************************************************/
  10005. /*! exports provided: ImageBasedSlider */
  10006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10007. "use strict";
  10008. __webpack_require__.r(__webpack_exports__);
  10009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10011. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10012. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10013. /**
  10014. * Class used to create slider controls based on images
  10015. */
  10016. var ImageBasedSlider = /** @class */ (function (_super) {
  10017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  10018. /**
  10019. * Creates a new ImageBasedSlider
  10020. * @param name defines the control name
  10021. */
  10022. function ImageBasedSlider(name) {
  10023. var _this = _super.call(this, name) || this;
  10024. _this.name = name;
  10025. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10026. return _this;
  10027. }
  10028. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10029. get: function () {
  10030. return this._displayThumb && this.thumbImage != null;
  10031. },
  10032. set: function (value) {
  10033. if (this._displayThumb === value) {
  10034. return;
  10035. }
  10036. this._displayThumb = value;
  10037. this._markAsDirty();
  10038. },
  10039. enumerable: true,
  10040. configurable: true
  10041. });
  10042. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10043. /**
  10044. * Gets or sets the image used to render the background
  10045. */
  10046. get: function () {
  10047. return this._backgroundImage;
  10048. },
  10049. set: function (value) {
  10050. var _this = this;
  10051. if (this._backgroundImage === value) {
  10052. return;
  10053. }
  10054. this._backgroundImage = value;
  10055. if (value && !value.isLoaded) {
  10056. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10057. }
  10058. this._markAsDirty();
  10059. },
  10060. enumerable: true,
  10061. configurable: true
  10062. });
  10063. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10064. /**
  10065. * Gets or sets the image used to render the value bar
  10066. */
  10067. get: function () {
  10068. return this._valueBarImage;
  10069. },
  10070. set: function (value) {
  10071. var _this = this;
  10072. if (this._valueBarImage === value) {
  10073. return;
  10074. }
  10075. this._valueBarImage = value;
  10076. if (value && !value.isLoaded) {
  10077. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10078. }
  10079. this._markAsDirty();
  10080. },
  10081. enumerable: true,
  10082. configurable: true
  10083. });
  10084. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10085. /**
  10086. * Gets or sets the image used to render the thumb
  10087. */
  10088. get: function () {
  10089. return this._thumbImage;
  10090. },
  10091. set: function (value) {
  10092. var _this = this;
  10093. if (this._thumbImage === value) {
  10094. return;
  10095. }
  10096. this._thumbImage = value;
  10097. if (value && !value.isLoaded) {
  10098. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10099. }
  10100. this._markAsDirty();
  10101. },
  10102. enumerable: true,
  10103. configurable: true
  10104. });
  10105. ImageBasedSlider.prototype._getTypeName = function () {
  10106. return "ImageBasedSlider";
  10107. };
  10108. ImageBasedSlider.prototype._draw = function (context) {
  10109. context.save();
  10110. this._applyStates(context);
  10111. this._prepareRenderingData("rectangle");
  10112. var thumbPosition = this._getThumbPosition();
  10113. var left = this._renderLeft;
  10114. var top = this._renderTop;
  10115. var width = this._renderWidth;
  10116. var height = this._renderHeight;
  10117. // Background
  10118. if (this._backgroundImage) {
  10119. this._tempMeasure.copyFromFloats(left, top, width, height);
  10120. if (this.isThumbClamped && this.displayThumb) {
  10121. if (this.isVertical) {
  10122. this._tempMeasure.height += this._effectiveThumbThickness;
  10123. }
  10124. else {
  10125. this._tempMeasure.width += this._effectiveThumbThickness;
  10126. }
  10127. }
  10128. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10129. this._backgroundImage._draw(context);
  10130. }
  10131. // Bar
  10132. if (this._valueBarImage) {
  10133. if (this.isVertical) {
  10134. if (this.isThumbClamped && this.displayThumb) {
  10135. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10136. }
  10137. else {
  10138. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10139. }
  10140. }
  10141. else {
  10142. if (this.isThumbClamped && this.displayThumb) {
  10143. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10144. }
  10145. else {
  10146. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10147. }
  10148. }
  10149. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10150. this._valueBarImage._draw(context);
  10151. }
  10152. // Thumb
  10153. if (this.displayThumb) {
  10154. if (this.isVertical) {
  10155. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10156. }
  10157. else {
  10158. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10159. }
  10160. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10161. this._thumbImage._draw(context);
  10162. }
  10163. context.restore();
  10164. };
  10165. return ImageBasedSlider;
  10166. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10167. /***/ }),
  10168. /***/ "./2D/controls/sliders/scrollBar.ts":
  10169. /*!******************************************!*\
  10170. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10171. \******************************************/
  10172. /*! exports provided: ScrollBar */
  10173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10174. "use strict";
  10175. __webpack_require__.r(__webpack_exports__);
  10176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10177. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10178. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10179. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10180. /**
  10181. * Class used to create slider controls
  10182. */
  10183. var ScrollBar = /** @class */ (function (_super) {
  10184. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10185. /**
  10186. * Creates a new Slider
  10187. * @param name defines the control name
  10188. */
  10189. function ScrollBar(name) {
  10190. var _this = _super.call(this, name) || this;
  10191. _this.name = name;
  10192. _this._background = "black";
  10193. _this._borderColor = "white";
  10194. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10195. return _this;
  10196. }
  10197. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10198. /** Gets or sets border color */
  10199. get: function () {
  10200. return this._borderColor;
  10201. },
  10202. set: function (value) {
  10203. if (this._borderColor === value) {
  10204. return;
  10205. }
  10206. this._borderColor = value;
  10207. this._markAsDirty();
  10208. },
  10209. enumerable: true,
  10210. configurable: true
  10211. });
  10212. Object.defineProperty(ScrollBar.prototype, "background", {
  10213. /** Gets or sets background color */
  10214. get: function () {
  10215. return this._background;
  10216. },
  10217. set: function (value) {
  10218. if (this._background === value) {
  10219. return;
  10220. }
  10221. this._background = value;
  10222. this._markAsDirty();
  10223. },
  10224. enumerable: true,
  10225. configurable: true
  10226. });
  10227. ScrollBar.prototype._getTypeName = function () {
  10228. return "Scrollbar";
  10229. };
  10230. ScrollBar.prototype._getThumbThickness = function () {
  10231. var thumbThickness = 0;
  10232. if (this._thumbWidth.isPixel) {
  10233. thumbThickness = this._thumbWidth.getValue(this._host);
  10234. }
  10235. else {
  10236. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10237. }
  10238. return thumbThickness;
  10239. };
  10240. ScrollBar.prototype._draw = function (context) {
  10241. context.save();
  10242. this._applyStates(context);
  10243. this._prepareRenderingData("rectangle");
  10244. var left = this._renderLeft;
  10245. var thumbPosition = this._getThumbPosition();
  10246. context.fillStyle = this._background;
  10247. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10248. // Value bar
  10249. context.fillStyle = this.color;
  10250. // Thumb
  10251. if (this.isVertical) {
  10252. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10253. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10254. this._thumbMeasure.width = this._currentMeasure.width;
  10255. this._thumbMeasure.height = this._effectiveThumbThickness;
  10256. }
  10257. else {
  10258. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10259. this._thumbMeasure.top = this._currentMeasure.top;
  10260. this._thumbMeasure.width = this._effectiveThumbThickness;
  10261. this._thumbMeasure.height = this._currentMeasure.height;
  10262. }
  10263. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10264. context.restore();
  10265. };
  10266. /** @hidden */
  10267. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10268. if (this.rotation != 0) {
  10269. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10270. x = this._transformedPosition.x;
  10271. y = this._transformedPosition.y;
  10272. }
  10273. if (this._first) {
  10274. this._first = false;
  10275. this._originX = x;
  10276. this._originY = y;
  10277. // Check if move is required
  10278. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10279. if (this.isVertical) {
  10280. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10281. }
  10282. else {
  10283. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10284. }
  10285. }
  10286. }
  10287. // Delta mode
  10288. var delta = 0;
  10289. if (this.isVertical) {
  10290. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10291. }
  10292. else {
  10293. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10294. }
  10295. this.value += delta * (this.maximum - this.minimum);
  10296. this._originX = x;
  10297. this._originY = y;
  10298. };
  10299. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10300. this._first = true;
  10301. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10302. };
  10303. return ScrollBar;
  10304. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10305. /***/ }),
  10306. /***/ "./2D/controls/sliders/slider.ts":
  10307. /*!***************************************!*\
  10308. !*** ./2D/controls/sliders/slider.ts ***!
  10309. \***************************************/
  10310. /*! exports provided: Slider */
  10311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10312. "use strict";
  10313. __webpack_require__.r(__webpack_exports__);
  10314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10315. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10316. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10317. /**
  10318. * Class used to create slider controls
  10319. */
  10320. var Slider = /** @class */ (function (_super) {
  10321. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10322. /**
  10323. * Creates a new Slider
  10324. * @param name defines the control name
  10325. */
  10326. function Slider(name) {
  10327. var _this = _super.call(this, name) || this;
  10328. _this.name = name;
  10329. _this._background = "black";
  10330. _this._borderColor = "white";
  10331. _this._isThumbCircle = false;
  10332. _this._displayValueBar = true;
  10333. return _this;
  10334. }
  10335. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10336. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10337. get: function () {
  10338. return this._displayValueBar;
  10339. },
  10340. set: function (value) {
  10341. if (this._displayValueBar === value) {
  10342. return;
  10343. }
  10344. this._displayValueBar = value;
  10345. this._markAsDirty();
  10346. },
  10347. enumerable: true,
  10348. configurable: true
  10349. });
  10350. Object.defineProperty(Slider.prototype, "borderColor", {
  10351. /** Gets or sets border color */
  10352. get: function () {
  10353. return this._borderColor;
  10354. },
  10355. set: function (value) {
  10356. if (this._borderColor === value) {
  10357. return;
  10358. }
  10359. this._borderColor = value;
  10360. this._markAsDirty();
  10361. },
  10362. enumerable: true,
  10363. configurable: true
  10364. });
  10365. Object.defineProperty(Slider.prototype, "background", {
  10366. /** Gets or sets background color */
  10367. get: function () {
  10368. return this._background;
  10369. },
  10370. set: function (value) {
  10371. if (this._background === value) {
  10372. return;
  10373. }
  10374. this._background = value;
  10375. this._markAsDirty();
  10376. },
  10377. enumerable: true,
  10378. configurable: true
  10379. });
  10380. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10381. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10382. get: function () {
  10383. return this._isThumbCircle;
  10384. },
  10385. set: function (value) {
  10386. if (this._isThumbCircle === value) {
  10387. return;
  10388. }
  10389. this._isThumbCircle = value;
  10390. this._markAsDirty();
  10391. },
  10392. enumerable: true,
  10393. configurable: true
  10394. });
  10395. Slider.prototype._getTypeName = function () {
  10396. return "Slider";
  10397. };
  10398. Slider.prototype._draw = function (context) {
  10399. context.save();
  10400. this._applyStates(context);
  10401. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10402. var left = this._renderLeft;
  10403. var top = this._renderTop;
  10404. var width = this._renderWidth;
  10405. var height = this._renderHeight;
  10406. var radius = 0;
  10407. if (this.isThumbClamped && this.isThumbCircle) {
  10408. if (this.isVertical) {
  10409. top += (this._effectiveThumbThickness / 2);
  10410. }
  10411. else {
  10412. left += (this._effectiveThumbThickness / 2);
  10413. }
  10414. radius = this._backgroundBoxThickness / 2;
  10415. }
  10416. else {
  10417. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10418. }
  10419. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10420. context.shadowColor = this.shadowColor;
  10421. context.shadowBlur = this.shadowBlur;
  10422. context.shadowOffsetX = this.shadowOffsetX;
  10423. context.shadowOffsetY = this.shadowOffsetY;
  10424. }
  10425. var thumbPosition = this._getThumbPosition();
  10426. context.fillStyle = this._background;
  10427. if (this.isVertical) {
  10428. if (this.isThumbClamped) {
  10429. if (this.isThumbCircle) {
  10430. context.beginPath();
  10431. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10432. context.fill();
  10433. context.fillRect(left, top, width, height);
  10434. }
  10435. else {
  10436. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10437. }
  10438. }
  10439. else {
  10440. context.fillRect(left, top, width, height);
  10441. }
  10442. }
  10443. else {
  10444. if (this.isThumbClamped) {
  10445. if (this.isThumbCircle) {
  10446. context.beginPath();
  10447. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10448. context.fill();
  10449. context.fillRect(left, top, width, height);
  10450. }
  10451. else {
  10452. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10453. }
  10454. }
  10455. else {
  10456. context.fillRect(left, top, width, height);
  10457. }
  10458. }
  10459. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10460. context.shadowBlur = 0;
  10461. context.shadowOffsetX = 0;
  10462. context.shadowOffsetY = 0;
  10463. }
  10464. // Value bar
  10465. context.fillStyle = this.color;
  10466. if (this._displayValueBar) {
  10467. if (this.isVertical) {
  10468. if (this.isThumbClamped) {
  10469. if (this.isThumbCircle) {
  10470. context.beginPath();
  10471. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10472. context.fill();
  10473. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10474. }
  10475. else {
  10476. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10477. }
  10478. }
  10479. else {
  10480. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10481. }
  10482. }
  10483. else {
  10484. if (this.isThumbClamped) {
  10485. if (this.isThumbCircle) {
  10486. context.beginPath();
  10487. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10488. context.fill();
  10489. context.fillRect(left, top, thumbPosition, height);
  10490. }
  10491. else {
  10492. context.fillRect(left, top, thumbPosition, height);
  10493. }
  10494. }
  10495. else {
  10496. context.fillRect(left, top, thumbPosition, height);
  10497. }
  10498. }
  10499. }
  10500. // Thumb
  10501. if (this.displayThumb) {
  10502. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10503. context.shadowColor = this.shadowColor;
  10504. context.shadowBlur = this.shadowBlur;
  10505. context.shadowOffsetX = this.shadowOffsetX;
  10506. context.shadowOffsetY = this.shadowOffsetY;
  10507. }
  10508. if (this._isThumbCircle) {
  10509. context.beginPath();
  10510. if (this.isVertical) {
  10511. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10512. }
  10513. else {
  10514. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10515. }
  10516. context.fill();
  10517. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10518. context.shadowBlur = 0;
  10519. context.shadowOffsetX = 0;
  10520. context.shadowOffsetY = 0;
  10521. }
  10522. context.strokeStyle = this._borderColor;
  10523. context.stroke();
  10524. }
  10525. else {
  10526. if (this.isVertical) {
  10527. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10528. }
  10529. else {
  10530. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10531. }
  10532. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10533. context.shadowBlur = 0;
  10534. context.shadowOffsetX = 0;
  10535. context.shadowOffsetY = 0;
  10536. }
  10537. context.strokeStyle = this._borderColor;
  10538. if (this.isVertical) {
  10539. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10540. }
  10541. else {
  10542. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10543. }
  10544. }
  10545. }
  10546. context.restore();
  10547. };
  10548. return Slider;
  10549. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10550. /***/ }),
  10551. /***/ "./2D/controls/stackPanel.ts":
  10552. /*!***********************************!*\
  10553. !*** ./2D/controls/stackPanel.ts ***!
  10554. \***********************************/
  10555. /*! exports provided: StackPanel */
  10556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10557. "use strict";
  10558. __webpack_require__.r(__webpack_exports__);
  10559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10560. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10561. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  10562. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10563. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10564. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10565. /**
  10566. * Class used to create a 2D stack panel container
  10567. */
  10568. var StackPanel = /** @class */ (function (_super) {
  10569. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10570. /**
  10571. * Creates a new StackPanel
  10572. * @param name defines control name
  10573. */
  10574. function StackPanel(name) {
  10575. var _this = _super.call(this, name) || this;
  10576. _this.name = name;
  10577. _this._isVertical = true;
  10578. _this._manualWidth = false;
  10579. _this._manualHeight = false;
  10580. _this._doNotTrackManualChanges = false;
  10581. return _this;
  10582. }
  10583. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10584. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10585. get: function () {
  10586. return this._isVertical;
  10587. },
  10588. set: function (value) {
  10589. if (this._isVertical === value) {
  10590. return;
  10591. }
  10592. this._isVertical = value;
  10593. this._markAsDirty();
  10594. },
  10595. enumerable: true,
  10596. configurable: true
  10597. });
  10598. Object.defineProperty(StackPanel.prototype, "width", {
  10599. get: function () {
  10600. return this._width.toString(this._host);
  10601. },
  10602. /**
  10603. * Gets or sets panel width.
  10604. * This value should not be set when in horizontal mode as it will be computed automatically
  10605. */
  10606. set: function (value) {
  10607. if (!this._doNotTrackManualChanges) {
  10608. this._manualWidth = true;
  10609. }
  10610. if (this._width.toString(this._host) === value) {
  10611. return;
  10612. }
  10613. if (this._width.fromString(value)) {
  10614. this._markAsDirty();
  10615. }
  10616. },
  10617. enumerable: true,
  10618. configurable: true
  10619. });
  10620. Object.defineProperty(StackPanel.prototype, "height", {
  10621. get: function () {
  10622. return this._height.toString(this._host);
  10623. },
  10624. /**
  10625. * Gets or sets panel height.
  10626. * This value should not be set when in vertical mode as it will be computed automatically
  10627. */
  10628. set: function (value) {
  10629. if (!this._doNotTrackManualChanges) {
  10630. this._manualHeight = true;
  10631. }
  10632. if (this._height.toString(this._host) === value) {
  10633. return;
  10634. }
  10635. if (this._height.fromString(value)) {
  10636. this._markAsDirty();
  10637. }
  10638. },
  10639. enumerable: true,
  10640. configurable: true
  10641. });
  10642. StackPanel.prototype._getTypeName = function () {
  10643. return "StackPanel";
  10644. };
  10645. /** @hidden */
  10646. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10647. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10648. var child = _a[_i];
  10649. if (this._isVertical) {
  10650. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10651. }
  10652. else {
  10653. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10654. }
  10655. }
  10656. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10657. };
  10658. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10659. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10660. this._measureForChildren.copyFrom(parentMeasure);
  10661. this._measureForChildren.left = this._currentMeasure.left;
  10662. this._measureForChildren.top = this._currentMeasure.top;
  10663. if (!this.isVertical || this._manualWidth) {
  10664. this._measureForChildren.width = this._currentMeasure.width;
  10665. }
  10666. if (this.isVertical || this._manualHeight) {
  10667. this._measureForChildren.height = this._currentMeasure.height;
  10668. }
  10669. };
  10670. StackPanel.prototype._postMeasure = function () {
  10671. var stackWidth = 0;
  10672. var stackHeight = 0;
  10673. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10674. var child = _a[_i];
  10675. if (!child.isVisible || child.notRenderable) {
  10676. continue;
  10677. }
  10678. if (this._isVertical) {
  10679. if (child.top !== stackHeight + "px") {
  10680. child.top = stackHeight + "px";
  10681. this._rebuildLayout = true;
  10682. child._top.ignoreAdaptiveScaling = true;
  10683. }
  10684. if (child._height.isPercentage) {
  10685. 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");
  10686. }
  10687. else {
  10688. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10689. }
  10690. }
  10691. else {
  10692. if (child.left !== stackWidth + "px") {
  10693. child.left = stackWidth + "px";
  10694. this._rebuildLayout = true;
  10695. child._left.ignoreAdaptiveScaling = true;
  10696. }
  10697. if (child._width.isPercentage) {
  10698. 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");
  10699. }
  10700. else {
  10701. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10702. }
  10703. }
  10704. }
  10705. this._doNotTrackManualChanges = true;
  10706. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10707. // User can now define their own height and width for stack panel.
  10708. var panelWidthChanged = false;
  10709. var panelHeightChanged = false;
  10710. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10711. var previousHeight = this.height;
  10712. this.height = stackHeight + "px";
  10713. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10714. }
  10715. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10716. var previousWidth = this.width;
  10717. this.width = stackWidth + "px";
  10718. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10719. }
  10720. if (panelHeightChanged) {
  10721. this._height.ignoreAdaptiveScaling = true;
  10722. }
  10723. if (panelWidthChanged) {
  10724. this._width.ignoreAdaptiveScaling = true;
  10725. }
  10726. this._doNotTrackManualChanges = false;
  10727. if (panelWidthChanged || panelHeightChanged) {
  10728. this._rebuildLayout = true;
  10729. }
  10730. _super.prototype._postMeasure.call(this);
  10731. };
  10732. return StackPanel;
  10733. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10734. /***/ }),
  10735. /***/ "./2D/controls/statics.ts":
  10736. /*!********************************!*\
  10737. !*** ./2D/controls/statics.ts ***!
  10738. \********************************/
  10739. /*! exports provided: name */
  10740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10741. "use strict";
  10742. __webpack_require__.r(__webpack_exports__);
  10743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10744. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10745. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10746. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10747. /**
  10748. * Forcing an export so that this code will execute
  10749. * @hidden
  10750. */
  10751. var name = "Statics";
  10752. /**
  10753. * Creates a stack panel that can be used to render headers
  10754. * @param control defines the control to associate with the header
  10755. * @param text defines the text of the header
  10756. * @param size defines the size of the header
  10757. * @param options defines options used to configure the header
  10758. * @returns a new StackPanel
  10759. */
  10760. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10761. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10762. var isHorizontal = options ? options.isHorizontal : true;
  10763. var controlFirst = options ? options.controlFirst : true;
  10764. panel.isVertical = !isHorizontal;
  10765. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10766. header.text = text;
  10767. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10768. if (isHorizontal) {
  10769. header.width = size;
  10770. }
  10771. else {
  10772. header.height = size;
  10773. }
  10774. if (controlFirst) {
  10775. panel.addControl(control);
  10776. panel.addControl(header);
  10777. header.paddingLeft = "5px";
  10778. }
  10779. else {
  10780. panel.addControl(header);
  10781. panel.addControl(control);
  10782. header.paddingRight = "5px";
  10783. }
  10784. header.shadowBlur = control.shadowBlur;
  10785. header.shadowColor = control.shadowColor;
  10786. header.shadowOffsetX = control.shadowOffsetX;
  10787. header.shadowOffsetY = control.shadowOffsetY;
  10788. return panel;
  10789. };
  10790. /***/ }),
  10791. /***/ "./2D/controls/textBlock.ts":
  10792. /*!**********************************!*\
  10793. !*** ./2D/controls/textBlock.ts ***!
  10794. \**********************************/
  10795. /*! exports provided: TextWrapping, TextBlock */
  10796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10797. "use strict";
  10798. __webpack_require__.r(__webpack_exports__);
  10799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10801. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10802. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10803. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10804. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10805. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10806. /**
  10807. * Enum that determines the text-wrapping mode to use.
  10808. */
  10809. var TextWrapping;
  10810. (function (TextWrapping) {
  10811. /**
  10812. * Clip the text when it's larger than Control.width; this is the default mode.
  10813. */
  10814. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10815. /**
  10816. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10817. */
  10818. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10819. /**
  10820. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10821. */
  10822. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10823. })(TextWrapping || (TextWrapping = {}));
  10824. /**
  10825. * Class used to create text block control
  10826. */
  10827. var TextBlock = /** @class */ (function (_super) {
  10828. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10829. /**
  10830. * Creates a new TextBlock object
  10831. * @param name defines the name of the control
  10832. * @param text defines the text to display (emptry string by default)
  10833. */
  10834. function TextBlock(
  10835. /**
  10836. * Defines the name of the control
  10837. */
  10838. name, text) {
  10839. if (text === void 0) { text = ""; }
  10840. var _this = _super.call(this, name) || this;
  10841. _this.name = name;
  10842. _this._text = "";
  10843. _this._textWrapping = TextWrapping.Clip;
  10844. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10845. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10846. _this._resizeToFit = false;
  10847. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10848. _this._outlineWidth = 0;
  10849. _this._outlineColor = "white";
  10850. /**
  10851. * An event triggered after the text is changed
  10852. */
  10853. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10854. /**
  10855. * An event triggered after the text was broken up into lines
  10856. */
  10857. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10858. _this.text = text;
  10859. return _this;
  10860. }
  10861. Object.defineProperty(TextBlock.prototype, "lines", {
  10862. /**
  10863. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10864. */
  10865. get: function () {
  10866. return this._lines;
  10867. },
  10868. enumerable: true,
  10869. configurable: true
  10870. });
  10871. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10872. /**
  10873. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10874. */
  10875. get: function () {
  10876. return this._resizeToFit;
  10877. },
  10878. /**
  10879. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10880. */
  10881. set: function (value) {
  10882. if (this._resizeToFit === value) {
  10883. return;
  10884. }
  10885. this._resizeToFit = value;
  10886. if (this._resizeToFit) {
  10887. this._width.ignoreAdaptiveScaling = true;
  10888. this._height.ignoreAdaptiveScaling = true;
  10889. }
  10890. this._markAsDirty();
  10891. },
  10892. enumerable: true,
  10893. configurable: true
  10894. });
  10895. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10896. /**
  10897. * Gets or sets a boolean indicating if text must be wrapped
  10898. */
  10899. get: function () {
  10900. return this._textWrapping;
  10901. },
  10902. /**
  10903. * Gets or sets a boolean indicating if text must be wrapped
  10904. */
  10905. set: function (value) {
  10906. if (this._textWrapping === value) {
  10907. return;
  10908. }
  10909. this._textWrapping = +value;
  10910. this._markAsDirty();
  10911. },
  10912. enumerable: true,
  10913. configurable: true
  10914. });
  10915. Object.defineProperty(TextBlock.prototype, "text", {
  10916. /**
  10917. * Gets or sets text to display
  10918. */
  10919. get: function () {
  10920. return this._text;
  10921. },
  10922. /**
  10923. * Gets or sets text to display
  10924. */
  10925. set: function (value) {
  10926. if (this._text === value) {
  10927. return;
  10928. }
  10929. this._text = value;
  10930. this._markAsDirty();
  10931. this.onTextChangedObservable.notifyObservers(this);
  10932. },
  10933. enumerable: true,
  10934. configurable: true
  10935. });
  10936. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10937. /**
  10938. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10939. */
  10940. get: function () {
  10941. return this._textHorizontalAlignment;
  10942. },
  10943. /**
  10944. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10945. */
  10946. set: function (value) {
  10947. if (this._textHorizontalAlignment === value) {
  10948. return;
  10949. }
  10950. this._textHorizontalAlignment = value;
  10951. this._markAsDirty();
  10952. },
  10953. enumerable: true,
  10954. configurable: true
  10955. });
  10956. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10957. /**
  10958. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10959. */
  10960. get: function () {
  10961. return this._textVerticalAlignment;
  10962. },
  10963. /**
  10964. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10965. */
  10966. set: function (value) {
  10967. if (this._textVerticalAlignment === value) {
  10968. return;
  10969. }
  10970. this._textVerticalAlignment = value;
  10971. this._markAsDirty();
  10972. },
  10973. enumerable: true,
  10974. configurable: true
  10975. });
  10976. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10977. /**
  10978. * Gets or sets line spacing value
  10979. */
  10980. get: function () {
  10981. return this._lineSpacing.toString(this._host);
  10982. },
  10983. /**
  10984. * Gets or sets line spacing value
  10985. */
  10986. set: function (value) {
  10987. if (this._lineSpacing.fromString(value)) {
  10988. this._markAsDirty();
  10989. }
  10990. },
  10991. enumerable: true,
  10992. configurable: true
  10993. });
  10994. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10995. /**
  10996. * Gets or sets outlineWidth of the text to display
  10997. */
  10998. get: function () {
  10999. return this._outlineWidth;
  11000. },
  11001. /**
  11002. * Gets or sets outlineWidth of the text to display
  11003. */
  11004. set: function (value) {
  11005. if (this._outlineWidth === value) {
  11006. return;
  11007. }
  11008. this._outlineWidth = value;
  11009. this._markAsDirty();
  11010. },
  11011. enumerable: true,
  11012. configurable: true
  11013. });
  11014. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11015. /**
  11016. * Gets or sets outlineColor of the text to display
  11017. */
  11018. get: function () {
  11019. return this._outlineColor;
  11020. },
  11021. /**
  11022. * Gets or sets outlineColor of the text to display
  11023. */
  11024. set: function (value) {
  11025. if (this._outlineColor === value) {
  11026. return;
  11027. }
  11028. this._outlineColor = value;
  11029. this._markAsDirty();
  11030. },
  11031. enumerable: true,
  11032. configurable: true
  11033. });
  11034. TextBlock.prototype._getTypeName = function () {
  11035. return "TextBlock";
  11036. };
  11037. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11038. if (!this._fontOffset) {
  11039. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11040. }
  11041. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11042. // Prepare lines
  11043. this._lines = this._breakLines(this._currentMeasure.width, context);
  11044. this.onLinesReadyObservable.notifyObservers(this);
  11045. var maxLineWidth = 0;
  11046. for (var i = 0; i < this._lines.length; i++) {
  11047. var line = this._lines[i];
  11048. if (line.width > maxLineWidth) {
  11049. maxLineWidth = line.width;
  11050. }
  11051. }
  11052. if (this._resizeToFit) {
  11053. if (this._textWrapping === TextWrapping.Clip) {
  11054. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11055. if (newWidth !== this._width.internalValue) {
  11056. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11057. this._rebuildLayout = true;
  11058. }
  11059. }
  11060. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11061. if (newHeight !== this._height.internalValue) {
  11062. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11063. this._rebuildLayout = true;
  11064. }
  11065. }
  11066. };
  11067. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11068. var width = this._currentMeasure.width;
  11069. var x = 0;
  11070. switch (this._textHorizontalAlignment) {
  11071. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11072. x = 0;
  11073. break;
  11074. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11075. x = width - textWidth;
  11076. break;
  11077. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11078. x = (width - textWidth) / 2;
  11079. break;
  11080. }
  11081. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11082. context.shadowColor = this.shadowColor;
  11083. context.shadowBlur = this.shadowBlur;
  11084. context.shadowOffsetX = this.shadowOffsetX;
  11085. context.shadowOffsetY = this.shadowOffsetY;
  11086. }
  11087. if (this.outlineWidth) {
  11088. context.strokeText(text, this._currentMeasure.left + x, y);
  11089. }
  11090. context.fillText(text, this._currentMeasure.left + x, y);
  11091. };
  11092. /** @hidden */
  11093. TextBlock.prototype._draw = function (context) {
  11094. context.save();
  11095. this._applyStates(context);
  11096. // Render lines
  11097. this._renderLines(context);
  11098. context.restore();
  11099. };
  11100. TextBlock.prototype._applyStates = function (context) {
  11101. _super.prototype._applyStates.call(this, context);
  11102. if (this.outlineWidth) {
  11103. context.lineWidth = this.outlineWidth;
  11104. context.strokeStyle = this.outlineColor;
  11105. }
  11106. };
  11107. TextBlock.prototype._breakLines = function (refWidth, context) {
  11108. var lines = [];
  11109. var _lines = this.text.split("\n");
  11110. if (this._textWrapping === TextWrapping.Ellipsis) {
  11111. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11112. var _line = _lines_1[_i];
  11113. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11114. }
  11115. }
  11116. else if (this._textWrapping === TextWrapping.WordWrap) {
  11117. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11118. var _line = _lines_2[_a];
  11119. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11120. }
  11121. }
  11122. else {
  11123. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11124. var _line = _lines_3[_b];
  11125. lines.push(this._parseLine(_line, context));
  11126. }
  11127. }
  11128. return lines;
  11129. };
  11130. TextBlock.prototype._parseLine = function (line, context) {
  11131. if (line === void 0) { line = ''; }
  11132. return { text: line, width: context.measureText(line).width };
  11133. };
  11134. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11135. if (line === void 0) { line = ''; }
  11136. var lineWidth = context.measureText(line).width;
  11137. if (lineWidth > width) {
  11138. line += '…';
  11139. }
  11140. while (line.length > 2 && lineWidth > width) {
  11141. line = line.slice(0, -2) + '…';
  11142. lineWidth = context.measureText(line).width;
  11143. }
  11144. return { text: line, width: lineWidth };
  11145. };
  11146. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11147. if (line === void 0) { line = ''; }
  11148. var lines = [];
  11149. var words = line.split(' ');
  11150. var lineWidth = 0;
  11151. for (var n = 0; n < words.length; n++) {
  11152. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11153. var metrics = context.measureText(testLine);
  11154. var testWidth = metrics.width;
  11155. if (testWidth > width && n > 0) {
  11156. lines.push({ text: line, width: lineWidth });
  11157. line = words[n];
  11158. lineWidth = context.measureText(line).width;
  11159. }
  11160. else {
  11161. lineWidth = testWidth;
  11162. line = testLine;
  11163. }
  11164. }
  11165. lines.push({ text: line, width: lineWidth });
  11166. return lines;
  11167. };
  11168. TextBlock.prototype._renderLines = function (context) {
  11169. var height = this._currentMeasure.height;
  11170. var rootY = 0;
  11171. switch (this._textVerticalAlignment) {
  11172. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11173. rootY = this._fontOffset.ascent;
  11174. break;
  11175. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11176. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11177. break;
  11178. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11179. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11180. break;
  11181. }
  11182. rootY += this._currentMeasure.top;
  11183. for (var i = 0; i < this._lines.length; i++) {
  11184. var line = this._lines[i];
  11185. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11186. if (this._lineSpacing.isPixel) {
  11187. rootY += this._lineSpacing.getValue(this._host);
  11188. }
  11189. else {
  11190. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11191. }
  11192. }
  11193. this._drawText(line.text, line.width, rootY, context);
  11194. rootY += this._fontOffset.height;
  11195. }
  11196. };
  11197. /**
  11198. * Given a width constraint applied on the text block, find the expected height
  11199. * @returns expected height
  11200. */
  11201. TextBlock.prototype.computeExpectedHeight = function () {
  11202. if (this.text && this.widthInPixels) {
  11203. var context_1 = document.createElement('canvas').getContext('2d');
  11204. if (context_1) {
  11205. this._applyStates(context_1);
  11206. if (!this._fontOffset) {
  11207. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11208. }
  11209. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11210. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11211. }
  11212. }
  11213. return 0;
  11214. };
  11215. TextBlock.prototype.dispose = function () {
  11216. _super.prototype.dispose.call(this);
  11217. this.onTextChangedObservable.clear();
  11218. };
  11219. return TextBlock;
  11220. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11221. /***/ }),
  11222. /***/ "./2D/controls/virtualKeyboard.ts":
  11223. /*!****************************************!*\
  11224. !*** ./2D/controls/virtualKeyboard.ts ***!
  11225. \****************************************/
  11226. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11228. "use strict";
  11229. __webpack_require__.r(__webpack_exports__);
  11230. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11231. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11232. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11233. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11234. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11235. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11236. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11237. /**
  11238. * Class used to store key control properties
  11239. */
  11240. var KeyPropertySet = /** @class */ (function () {
  11241. function KeyPropertySet() {
  11242. }
  11243. return KeyPropertySet;
  11244. }());
  11245. /**
  11246. * Class used to create virtual keyboard
  11247. */
  11248. var VirtualKeyboard = /** @class */ (function (_super) {
  11249. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11250. function VirtualKeyboard() {
  11251. var _this = _super !== null && _super.apply(this, arguments) || this;
  11252. /** Observable raised when a key is pressed */
  11253. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11254. /** Gets or sets default key button width */
  11255. _this.defaultButtonWidth = "40px";
  11256. /** Gets or sets default key button height */
  11257. _this.defaultButtonHeight = "40px";
  11258. /** Gets or sets default key button left padding */
  11259. _this.defaultButtonPaddingLeft = "2px";
  11260. /** Gets or sets default key button right padding */
  11261. _this.defaultButtonPaddingRight = "2px";
  11262. /** Gets or sets default key button top padding */
  11263. _this.defaultButtonPaddingTop = "2px";
  11264. /** Gets or sets default key button bottom padding */
  11265. _this.defaultButtonPaddingBottom = "2px";
  11266. /** Gets or sets default key button foreground color */
  11267. _this.defaultButtonColor = "#DDD";
  11268. /** Gets or sets default key button background color */
  11269. _this.defaultButtonBackground = "#070707";
  11270. /** Gets or sets shift button foreground color */
  11271. _this.shiftButtonColor = "#7799FF";
  11272. /** Gets or sets shift button thickness*/
  11273. _this.selectedShiftThickness = 1;
  11274. /** Gets shift key state */
  11275. _this.shiftState = 0;
  11276. _this._currentlyConnectedInputText = null;
  11277. _this._connectedInputTexts = [];
  11278. _this._onKeyPressObserver = null;
  11279. return _this;
  11280. }
  11281. VirtualKeyboard.prototype._getTypeName = function () {
  11282. return "VirtualKeyboard";
  11283. };
  11284. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11285. var _this = this;
  11286. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11287. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11288. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11289. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11290. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11291. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11292. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11293. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11294. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11295. button.thickness = 0;
  11296. button.isFocusInvisible = true;
  11297. button.shadowColor = this.shadowColor;
  11298. button.shadowBlur = this.shadowBlur;
  11299. button.shadowOffsetX = this.shadowOffsetX;
  11300. button.shadowOffsetY = this.shadowOffsetY;
  11301. button.onPointerUpObservable.add(function () {
  11302. _this.onKeyPressObservable.notifyObservers(key);
  11303. });
  11304. return button;
  11305. };
  11306. /**
  11307. * Adds a new row of keys
  11308. * @param keys defines the list of keys to add
  11309. * @param propertySets defines the associated property sets
  11310. */
  11311. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11312. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11313. panel.isVertical = false;
  11314. panel.isFocusInvisible = true;
  11315. var maxKey = null;
  11316. for (var i = 0; i < keys.length; i++) {
  11317. var properties = null;
  11318. if (propertySets && propertySets.length === keys.length) {
  11319. properties = propertySets[i];
  11320. }
  11321. var key = this._createKey(keys[i], properties);
  11322. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11323. maxKey = key;
  11324. }
  11325. panel.addControl(key);
  11326. }
  11327. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11328. this.addControl(panel);
  11329. };
  11330. /**
  11331. * Set the shift key to a specific state
  11332. * @param shiftState defines the new shift state
  11333. */
  11334. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11335. if (!this.children) {
  11336. return;
  11337. }
  11338. for (var i = 0; i < this.children.length; i++) {
  11339. var row = this.children[i];
  11340. if (!row || !row.children) {
  11341. continue;
  11342. }
  11343. var rowContainer = row;
  11344. for (var j = 0; j < rowContainer.children.length; j++) {
  11345. var button = rowContainer.children[j];
  11346. if (!button || !button.children[0]) {
  11347. continue;
  11348. }
  11349. var button_tblock = button.children[0];
  11350. if (button_tblock.text === "\u21E7") {
  11351. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11352. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11353. }
  11354. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11355. }
  11356. }
  11357. };
  11358. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11359. /** Gets the input text control currently attached to the keyboard */
  11360. get: function () {
  11361. return this._currentlyConnectedInputText;
  11362. },
  11363. enumerable: true,
  11364. configurable: true
  11365. });
  11366. /**
  11367. * Connects the keyboard with an input text control
  11368. *
  11369. * @param input defines the target control
  11370. */
  11371. VirtualKeyboard.prototype.connect = function (input) {
  11372. var _this = this;
  11373. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11374. if (inputTextAlreadyConnected) {
  11375. return;
  11376. }
  11377. if (this._onKeyPressObserver === null) {
  11378. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11379. if (!_this._currentlyConnectedInputText) {
  11380. return;
  11381. }
  11382. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11383. switch (key) {
  11384. case "\u21E7":
  11385. _this.shiftState++;
  11386. if (_this.shiftState > 2) {
  11387. _this.shiftState = 0;
  11388. }
  11389. _this.applyShiftState(_this.shiftState);
  11390. return;
  11391. case "\u2190":
  11392. _this._currentlyConnectedInputText.processKey(8);
  11393. return;
  11394. case "\u21B5":
  11395. _this._currentlyConnectedInputText.processKey(13);
  11396. return;
  11397. }
  11398. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11399. if (_this.shiftState === 1) {
  11400. _this.shiftState = 0;
  11401. _this.applyShiftState(_this.shiftState);
  11402. }
  11403. });
  11404. }
  11405. this.isVisible = false;
  11406. this._currentlyConnectedInputText = input;
  11407. input._connectedVirtualKeyboard = this;
  11408. // Events hooking
  11409. var onFocusObserver = input.onFocusObservable.add(function () {
  11410. _this._currentlyConnectedInputText = input;
  11411. input._connectedVirtualKeyboard = _this;
  11412. _this.isVisible = true;
  11413. });
  11414. var onBlurObserver = input.onBlurObservable.add(function () {
  11415. input._connectedVirtualKeyboard = null;
  11416. _this._currentlyConnectedInputText = null;
  11417. _this.isVisible = false;
  11418. });
  11419. this._connectedInputTexts.push({
  11420. input: input,
  11421. onBlurObserver: onBlurObserver,
  11422. onFocusObserver: onFocusObserver
  11423. });
  11424. };
  11425. /**
  11426. * Disconnects the keyboard from connected InputText controls
  11427. *
  11428. * @param input optionally defines a target control, otherwise all are disconnected
  11429. */
  11430. VirtualKeyboard.prototype.disconnect = function (input) {
  11431. var _this = this;
  11432. if (input) {
  11433. // .find not available on IE
  11434. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11435. if (filtered.length === 1) {
  11436. this._removeConnectedInputObservables(filtered[0]);
  11437. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11438. if (this._currentlyConnectedInputText === input) {
  11439. this._currentlyConnectedInputText = null;
  11440. }
  11441. }
  11442. }
  11443. else {
  11444. this._connectedInputTexts.forEach(function (connectedInputText) {
  11445. _this._removeConnectedInputObservables(connectedInputText);
  11446. });
  11447. this._connectedInputTexts = [];
  11448. }
  11449. if (this._connectedInputTexts.length === 0) {
  11450. this._currentlyConnectedInputText = null;
  11451. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11452. this._onKeyPressObserver = null;
  11453. }
  11454. };
  11455. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11456. connectedInputText.input._connectedVirtualKeyboard = null;
  11457. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11458. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11459. };
  11460. /**
  11461. * Release all resources
  11462. */
  11463. VirtualKeyboard.prototype.dispose = function () {
  11464. _super.prototype.dispose.call(this);
  11465. this.disconnect();
  11466. };
  11467. // Statics
  11468. /**
  11469. * Creates a new keyboard using a default layout
  11470. *
  11471. * @param name defines control name
  11472. * @returns a new VirtualKeyboard
  11473. */
  11474. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11475. var returnValue = new VirtualKeyboard(name);
  11476. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11477. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11478. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11479. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11480. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11481. return returnValue;
  11482. };
  11483. return VirtualKeyboard;
  11484. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11485. /***/ }),
  11486. /***/ "./2D/index.ts":
  11487. /*!*********************!*\
  11488. !*** ./2D/index.ts ***!
  11489. \*********************/
  11490. /*! 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 */
  11491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11492. "use strict";
  11493. __webpack_require__.r(__webpack_exports__);
  11494. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11526. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11528. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11530. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11533. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11535. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11537. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11539. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11541. /***/ }),
  11542. /***/ "./2D/math2D.ts":
  11543. /*!**********************!*\
  11544. !*** ./2D/math2D.ts ***!
  11545. \**********************/
  11546. /*! exports provided: Vector2WithInfo, Matrix2D */
  11547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11548. "use strict";
  11549. __webpack_require__.r(__webpack_exports__);
  11550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11552. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11553. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11554. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11555. /**
  11556. * Class used to transport Vector2 information for pointer events
  11557. */
  11558. var Vector2WithInfo = /** @class */ (function (_super) {
  11559. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11560. /**
  11561. * Creates a new Vector2WithInfo
  11562. * @param source defines the vector2 data to transport
  11563. * @param buttonIndex defines the current mouse button index
  11564. */
  11565. function Vector2WithInfo(source,
  11566. /** defines the current mouse button index */
  11567. buttonIndex) {
  11568. if (buttonIndex === void 0) { buttonIndex = 0; }
  11569. var _this = _super.call(this, source.x, source.y) || this;
  11570. _this.buttonIndex = buttonIndex;
  11571. return _this;
  11572. }
  11573. return Vector2WithInfo;
  11574. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11575. /** Class used to provide 2D matrix features */
  11576. var Matrix2D = /** @class */ (function () {
  11577. /**
  11578. * Creates a new matrix
  11579. * @param m00 defines value for (0, 0)
  11580. * @param m01 defines value for (0, 1)
  11581. * @param m10 defines value for (1, 0)
  11582. * @param m11 defines value for (1, 1)
  11583. * @param m20 defines value for (2, 0)
  11584. * @param m21 defines value for (2, 1)
  11585. */
  11586. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11587. /** Gets the internal array of 6 floats used to store matrix data */
  11588. this.m = new Float32Array(6);
  11589. this.fromValues(m00, m01, m10, m11, m20, m21);
  11590. }
  11591. /**
  11592. * Fills the matrix from direct values
  11593. * @param m00 defines value for (0, 0)
  11594. * @param m01 defines value for (0, 1)
  11595. * @param m10 defines value for (1, 0)
  11596. * @param m11 defines value for (1, 1)
  11597. * @param m20 defines value for (2, 0)
  11598. * @param m21 defines value for (2, 1)
  11599. * @returns the current modified matrix
  11600. */
  11601. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11602. this.m[0] = m00;
  11603. this.m[1] = m01;
  11604. this.m[2] = m10;
  11605. this.m[3] = m11;
  11606. this.m[4] = m20;
  11607. this.m[5] = m21;
  11608. return this;
  11609. };
  11610. /**
  11611. * Gets matrix determinant
  11612. * @returns the determinant
  11613. */
  11614. Matrix2D.prototype.determinant = function () {
  11615. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11616. };
  11617. /**
  11618. * Inverses the matrix and stores it in a target matrix
  11619. * @param result defines the target matrix
  11620. * @returns the current matrix
  11621. */
  11622. Matrix2D.prototype.invertToRef = function (result) {
  11623. var l0 = this.m[0];
  11624. var l1 = this.m[1];
  11625. var l2 = this.m[2];
  11626. var l3 = this.m[3];
  11627. var l4 = this.m[4];
  11628. var l5 = this.m[5];
  11629. var det = this.determinant();
  11630. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11631. result.m[0] = 0;
  11632. result.m[1] = 0;
  11633. result.m[2] = 0;
  11634. result.m[3] = 0;
  11635. result.m[4] = 0;
  11636. result.m[5] = 0;
  11637. return this;
  11638. }
  11639. var detDiv = 1 / det;
  11640. var det4 = l2 * l5 - l3 * l4;
  11641. var det5 = l1 * l4 - l0 * l5;
  11642. result.m[0] = l3 * detDiv;
  11643. result.m[1] = -l1 * detDiv;
  11644. result.m[2] = -l2 * detDiv;
  11645. result.m[3] = l0 * detDiv;
  11646. result.m[4] = det4 * detDiv;
  11647. result.m[5] = det5 * detDiv;
  11648. return this;
  11649. };
  11650. /**
  11651. * Multiplies the current matrix with another one
  11652. * @param other defines the second operand
  11653. * @param result defines the target matrix
  11654. * @returns the current matrix
  11655. */
  11656. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11657. var l0 = this.m[0];
  11658. var l1 = this.m[1];
  11659. var l2 = this.m[2];
  11660. var l3 = this.m[3];
  11661. var l4 = this.m[4];
  11662. var l5 = this.m[5];
  11663. var r0 = other.m[0];
  11664. var r1 = other.m[1];
  11665. var r2 = other.m[2];
  11666. var r3 = other.m[3];
  11667. var r4 = other.m[4];
  11668. var r5 = other.m[5];
  11669. result.m[0] = l0 * r0 + l1 * r2;
  11670. result.m[1] = l0 * r1 + l1 * r3;
  11671. result.m[2] = l2 * r0 + l3 * r2;
  11672. result.m[3] = l2 * r1 + l3 * r3;
  11673. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11674. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11675. return this;
  11676. };
  11677. /**
  11678. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11679. * @param x defines the x coordinate to transform
  11680. * @param y defines the x coordinate to transform
  11681. * @param result defines the target vector2
  11682. * @returns the current matrix
  11683. */
  11684. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11685. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11686. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11687. return this;
  11688. };
  11689. // Statics
  11690. /**
  11691. * Creates an identity matrix
  11692. * @returns a new matrix
  11693. */
  11694. Matrix2D.Identity = function () {
  11695. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11696. };
  11697. /**
  11698. * Creates a translation matrix and stores it in a target matrix
  11699. * @param x defines the x coordinate of the translation
  11700. * @param y defines the y coordinate of the translation
  11701. * @param result defines the target matrix
  11702. */
  11703. Matrix2D.TranslationToRef = function (x, y, result) {
  11704. result.fromValues(1, 0, 0, 1, x, y);
  11705. };
  11706. /**
  11707. * Creates a scaling matrix and stores it in a target matrix
  11708. * @param x defines the x coordinate of the scaling
  11709. * @param y defines the y coordinate of the scaling
  11710. * @param result defines the target matrix
  11711. */
  11712. Matrix2D.ScalingToRef = function (x, y, result) {
  11713. result.fromValues(x, 0, 0, y, 0, 0);
  11714. };
  11715. /**
  11716. * Creates a rotation matrix and stores it in a target matrix
  11717. * @param angle defines the rotation angle
  11718. * @param result defines the target matrix
  11719. */
  11720. Matrix2D.RotationToRef = function (angle, result) {
  11721. var s = Math.sin(angle);
  11722. var c = Math.cos(angle);
  11723. result.fromValues(c, s, -s, c, 0, 0);
  11724. };
  11725. /**
  11726. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11727. * @param tx defines the x coordinate of the translation
  11728. * @param ty defines the y coordinate of the translation
  11729. * @param angle defines the rotation angle
  11730. * @param scaleX defines the x coordinate of the scaling
  11731. * @param scaleY defines the y coordinate of the scaling
  11732. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11733. * @param result defines the target matrix
  11734. */
  11735. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11736. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11737. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11738. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11739. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11740. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11741. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11742. if (parentMatrix) {
  11743. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11744. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11745. }
  11746. else {
  11747. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11748. }
  11749. };
  11750. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11751. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11752. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11753. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11754. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11755. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11756. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11757. return Matrix2D;
  11758. }());
  11759. /***/ }),
  11760. /***/ "./2D/measure.ts":
  11761. /*!***********************!*\
  11762. !*** ./2D/measure.ts ***!
  11763. \***********************/
  11764. /*! exports provided: Measure */
  11765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11766. "use strict";
  11767. __webpack_require__.r(__webpack_exports__);
  11768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11769. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11770. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11771. /**
  11772. * Class used to store 2D control sizes
  11773. */
  11774. var Measure = /** @class */ (function () {
  11775. /**
  11776. * Creates a new measure
  11777. * @param left defines left coordinate
  11778. * @param top defines top coordinate
  11779. * @param width defines width dimension
  11780. * @param height defines height dimension
  11781. */
  11782. function Measure(
  11783. /** defines left coordinate */
  11784. left,
  11785. /** defines top coordinate */
  11786. top,
  11787. /** defines width dimension */
  11788. width,
  11789. /** defines height dimension */
  11790. height) {
  11791. this.left = left;
  11792. this.top = top;
  11793. this.width = width;
  11794. this.height = height;
  11795. }
  11796. /**
  11797. * Copy from another measure
  11798. * @param other defines the other measure to copy from
  11799. */
  11800. Measure.prototype.copyFrom = function (other) {
  11801. this.left = other.left;
  11802. this.top = other.top;
  11803. this.width = other.width;
  11804. this.height = other.height;
  11805. };
  11806. /**
  11807. * Copy from a group of 4 floats
  11808. * @param left defines left coordinate
  11809. * @param top defines top coordinate
  11810. * @param width defines width dimension
  11811. * @param height defines height dimension
  11812. */
  11813. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11814. this.left = left;
  11815. this.top = top;
  11816. this.width = width;
  11817. this.height = height;
  11818. };
  11819. /**
  11820. * Computes the axis aligned bounding box measure for two given measures
  11821. * @param a Input measure
  11822. * @param b Input measure
  11823. * @param result the resulting bounding measure
  11824. */
  11825. Measure.CombineToRef = function (a, b, result) {
  11826. var left = Math.min(a.left, b.left);
  11827. var top = Math.min(a.top, b.top);
  11828. var right = Math.max(a.left + a.width, b.left + b.width);
  11829. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11830. result.left = left;
  11831. result.top = top;
  11832. result.width = right - left;
  11833. result.height = bottom - top;
  11834. };
  11835. /**
  11836. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11837. * @param transform the matrix to transform the measure before computing the AABB
  11838. * @param result the resulting AABB
  11839. */
  11840. Measure.prototype.transformToRef = function (transform, result) {
  11841. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11842. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11843. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11844. for (var i = 0; i < 4; i++) {
  11845. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11846. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11847. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11848. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11849. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11850. }
  11851. result.left = min.x;
  11852. result.top = min.y;
  11853. result.width = max.x - min.x;
  11854. result.height = max.y - min.y;
  11855. };
  11856. /**
  11857. * Check equality between this measure and another one
  11858. * @param other defines the other measures
  11859. * @returns true if both measures are equals
  11860. */
  11861. Measure.prototype.isEqualsTo = function (other) {
  11862. if (this.left !== other.left) {
  11863. return false;
  11864. }
  11865. if (this.top !== other.top) {
  11866. return false;
  11867. }
  11868. if (this.width !== other.width) {
  11869. return false;
  11870. }
  11871. if (this.height !== other.height) {
  11872. return false;
  11873. }
  11874. return true;
  11875. };
  11876. /**
  11877. * Creates an empty measure
  11878. * @returns a new measure
  11879. */
  11880. Measure.Empty = function () {
  11881. return new Measure(0, 0, 0, 0);
  11882. };
  11883. return Measure;
  11884. }());
  11885. /***/ }),
  11886. /***/ "./2D/multiLinePoint.ts":
  11887. /*!******************************!*\
  11888. !*** ./2D/multiLinePoint.ts ***!
  11889. \******************************/
  11890. /*! exports provided: MultiLinePoint */
  11891. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11892. "use strict";
  11893. __webpack_require__.r(__webpack_exports__);
  11894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11895. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11896. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11897. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11898. /**
  11899. * Class used to store a point for a MultiLine object.
  11900. * The point can be pure 2D coordinates, a mesh or a control
  11901. */
  11902. var MultiLinePoint = /** @class */ (function () {
  11903. /**
  11904. * Creates a new MultiLinePoint
  11905. * @param multiLine defines the source MultiLine object
  11906. */
  11907. function MultiLinePoint(multiLine) {
  11908. this._multiLine = multiLine;
  11909. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11910. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11911. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11912. }
  11913. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11914. /** Gets or sets x coordinate */
  11915. get: function () {
  11916. return this._x.toString(this._multiLine._host);
  11917. },
  11918. set: function (value) {
  11919. if (this._x.toString(this._multiLine._host) === value) {
  11920. return;
  11921. }
  11922. if (this._x.fromString(value)) {
  11923. this._multiLine._markAsDirty();
  11924. }
  11925. },
  11926. enumerable: true,
  11927. configurable: true
  11928. });
  11929. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11930. /** Gets or sets y coordinate */
  11931. get: function () {
  11932. return this._y.toString(this._multiLine._host);
  11933. },
  11934. set: function (value) {
  11935. if (this._y.toString(this._multiLine._host) === value) {
  11936. return;
  11937. }
  11938. if (this._y.fromString(value)) {
  11939. this._multiLine._markAsDirty();
  11940. }
  11941. },
  11942. enumerable: true,
  11943. configurable: true
  11944. });
  11945. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11946. /** Gets or sets the control associated with this point */
  11947. get: function () {
  11948. return this._control;
  11949. },
  11950. set: function (value) {
  11951. if (this._control === value) {
  11952. return;
  11953. }
  11954. if (this._control && this._controlObserver) {
  11955. this._control.onDirtyObservable.remove(this._controlObserver);
  11956. this._controlObserver = null;
  11957. }
  11958. this._control = value;
  11959. if (this._control) {
  11960. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11961. }
  11962. this._multiLine._markAsDirty();
  11963. },
  11964. enumerable: true,
  11965. configurable: true
  11966. });
  11967. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11968. /** Gets or sets the mesh associated with this point */
  11969. get: function () {
  11970. return this._mesh;
  11971. },
  11972. set: function (value) {
  11973. if (this._mesh === value) {
  11974. return;
  11975. }
  11976. if (this._mesh && this._meshObserver) {
  11977. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11978. }
  11979. this._mesh = value;
  11980. if (this._mesh) {
  11981. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11982. }
  11983. this._multiLine._markAsDirty();
  11984. },
  11985. enumerable: true,
  11986. configurable: true
  11987. });
  11988. /** Resets links */
  11989. MultiLinePoint.prototype.resetLinks = function () {
  11990. this.control = null;
  11991. this.mesh = null;
  11992. };
  11993. /**
  11994. * Gets a translation vector
  11995. * @returns the translation vector
  11996. */
  11997. MultiLinePoint.prototype.translate = function () {
  11998. this._point = this._translatePoint();
  11999. return this._point;
  12000. };
  12001. MultiLinePoint.prototype._translatePoint = function () {
  12002. if (this._mesh != null) {
  12003. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12004. }
  12005. else if (this._control != null) {
  12006. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12007. }
  12008. else {
  12009. var host = this._multiLine._host;
  12010. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12011. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12012. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12013. }
  12014. };
  12015. /** Release associated resources */
  12016. MultiLinePoint.prototype.dispose = function () {
  12017. this.resetLinks();
  12018. };
  12019. return MultiLinePoint;
  12020. }());
  12021. /***/ }),
  12022. /***/ "./2D/style.ts":
  12023. /*!*********************!*\
  12024. !*** ./2D/style.ts ***!
  12025. \*********************/
  12026. /*! exports provided: Style */
  12027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12028. "use strict";
  12029. __webpack_require__.r(__webpack_exports__);
  12030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12031. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12032. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12033. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12034. /**
  12035. * Define a style used by control to automatically setup properties based on a template.
  12036. * Only support font related properties so far
  12037. */
  12038. var Style = /** @class */ (function () {
  12039. /**
  12040. * Creates a new style object
  12041. * @param host defines the AdvancedDynamicTexture which hosts this style
  12042. */
  12043. function Style(host) {
  12044. this._fontFamily = "Arial";
  12045. this._fontStyle = "";
  12046. this._fontWeight = "";
  12047. /** @hidden */
  12048. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12049. /**
  12050. * Observable raised when the style values are changed
  12051. */
  12052. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12053. this._host = host;
  12054. }
  12055. Object.defineProperty(Style.prototype, "fontSize", {
  12056. /**
  12057. * Gets or sets the font size
  12058. */
  12059. get: function () {
  12060. return this._fontSize.toString(this._host);
  12061. },
  12062. set: function (value) {
  12063. if (this._fontSize.toString(this._host) === value) {
  12064. return;
  12065. }
  12066. if (this._fontSize.fromString(value)) {
  12067. this.onChangedObservable.notifyObservers(this);
  12068. }
  12069. },
  12070. enumerable: true,
  12071. configurable: true
  12072. });
  12073. Object.defineProperty(Style.prototype, "fontFamily", {
  12074. /**
  12075. * Gets or sets the font family
  12076. */
  12077. get: function () {
  12078. return this._fontFamily;
  12079. },
  12080. set: function (value) {
  12081. if (this._fontFamily === value) {
  12082. return;
  12083. }
  12084. this._fontFamily = value;
  12085. this.onChangedObservable.notifyObservers(this);
  12086. },
  12087. enumerable: true,
  12088. configurable: true
  12089. });
  12090. Object.defineProperty(Style.prototype, "fontStyle", {
  12091. /**
  12092. * Gets or sets the font style
  12093. */
  12094. get: function () {
  12095. return this._fontStyle;
  12096. },
  12097. set: function (value) {
  12098. if (this._fontStyle === value) {
  12099. return;
  12100. }
  12101. this._fontStyle = value;
  12102. this.onChangedObservable.notifyObservers(this);
  12103. },
  12104. enumerable: true,
  12105. configurable: true
  12106. });
  12107. Object.defineProperty(Style.prototype, "fontWeight", {
  12108. /** Gets or sets font weight */
  12109. get: function () {
  12110. return this._fontWeight;
  12111. },
  12112. set: function (value) {
  12113. if (this._fontWeight === value) {
  12114. return;
  12115. }
  12116. this._fontWeight = value;
  12117. this.onChangedObservable.notifyObservers(this);
  12118. },
  12119. enumerable: true,
  12120. configurable: true
  12121. });
  12122. /** Dispose all associated resources */
  12123. Style.prototype.dispose = function () {
  12124. this.onChangedObservable.clear();
  12125. };
  12126. return Style;
  12127. }());
  12128. /***/ }),
  12129. /***/ "./2D/valueAndUnit.ts":
  12130. /*!****************************!*\
  12131. !*** ./2D/valueAndUnit.ts ***!
  12132. \****************************/
  12133. /*! exports provided: ValueAndUnit */
  12134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12135. "use strict";
  12136. __webpack_require__.r(__webpack_exports__);
  12137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12138. /**
  12139. * Class used to specific a value and its associated unit
  12140. */
  12141. var ValueAndUnit = /** @class */ (function () {
  12142. /**
  12143. * Creates a new ValueAndUnit
  12144. * @param value defines the value to store
  12145. * @param unit defines the unit to store
  12146. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12147. */
  12148. function ValueAndUnit(value,
  12149. /** defines the unit to store */
  12150. unit,
  12151. /** defines a boolean indicating if the value can be negative */
  12152. negativeValueAllowed) {
  12153. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12154. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12155. this.unit = unit;
  12156. this.negativeValueAllowed = negativeValueAllowed;
  12157. this._value = 1;
  12158. /**
  12159. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12160. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12161. */
  12162. this.ignoreAdaptiveScaling = false;
  12163. this._value = value;
  12164. this._originalUnit = unit;
  12165. }
  12166. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12167. /** Gets a boolean indicating if the value is a percentage */
  12168. get: function () {
  12169. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12170. },
  12171. enumerable: true,
  12172. configurable: true
  12173. });
  12174. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12175. /** Gets a boolean indicating if the value is store as pixel */
  12176. get: function () {
  12177. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12178. },
  12179. enumerable: true,
  12180. configurable: true
  12181. });
  12182. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12183. /** Gets direct internal value */
  12184. get: function () {
  12185. return this._value;
  12186. },
  12187. enumerable: true,
  12188. configurable: true
  12189. });
  12190. /**
  12191. * Gets value as pixel
  12192. * @param host defines the root host
  12193. * @param refValue defines the reference value for percentages
  12194. * @returns the value as pixel
  12195. */
  12196. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12197. if (this.isPixel) {
  12198. return this.getValue(host);
  12199. }
  12200. return this.getValue(host) * refValue;
  12201. };
  12202. /**
  12203. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12204. * @param value defines the value to store
  12205. * @param unit defines the unit to store
  12206. * @returns the current ValueAndUnit
  12207. */
  12208. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12209. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12210. this._value = value;
  12211. this.unit = unit;
  12212. return this;
  12213. };
  12214. /**
  12215. * Gets the value accordingly to its unit
  12216. * @param host defines the root host
  12217. * @returns the value
  12218. */
  12219. ValueAndUnit.prototype.getValue = function (host) {
  12220. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12221. var width = 0;
  12222. var height = 0;
  12223. if (host.idealWidth) {
  12224. width = (this._value * host.getSize().width) / host.idealWidth;
  12225. }
  12226. if (host.idealHeight) {
  12227. height = (this._value * host.getSize().height) / host.idealHeight;
  12228. }
  12229. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12230. return window.innerWidth < window.innerHeight ? width : height;
  12231. }
  12232. if (host.idealWidth) { // horizontal
  12233. return width;
  12234. }
  12235. if (host.idealHeight) { // vertical
  12236. return height;
  12237. }
  12238. }
  12239. return this._value;
  12240. };
  12241. /**
  12242. * Gets a string representation of the value
  12243. * @param host defines the root host
  12244. * @param decimals defines an optional number of decimals to display
  12245. * @returns a string
  12246. */
  12247. ValueAndUnit.prototype.toString = function (host, decimals) {
  12248. switch (this.unit) {
  12249. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12250. var percentage = this.getValue(host) * 100;
  12251. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12252. case ValueAndUnit.UNITMODE_PIXEL:
  12253. var pixels = this.getValue(host);
  12254. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12255. }
  12256. return this.unit.toString();
  12257. };
  12258. /**
  12259. * Store a value parsed from a string
  12260. * @param source defines the source string
  12261. * @returns true if the value was successfully parsed
  12262. */
  12263. ValueAndUnit.prototype.fromString = function (source) {
  12264. var match = ValueAndUnit._Regex.exec(source.toString());
  12265. if (!match || match.length === 0) {
  12266. return false;
  12267. }
  12268. var sourceValue = parseFloat(match[1]);
  12269. var sourceUnit = this._originalUnit;
  12270. if (!this.negativeValueAllowed) {
  12271. if (sourceValue < 0) {
  12272. sourceValue = 0;
  12273. }
  12274. }
  12275. if (match.length === 4) {
  12276. switch (match[3]) {
  12277. case "px":
  12278. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12279. break;
  12280. case "%":
  12281. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12282. sourceValue /= 100.0;
  12283. break;
  12284. }
  12285. }
  12286. if (sourceValue === this._value && sourceUnit === this.unit) {
  12287. return false;
  12288. }
  12289. this._value = sourceValue;
  12290. this.unit = sourceUnit;
  12291. return true;
  12292. };
  12293. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12294. /** UNITMODE_PERCENTAGE */
  12295. get: function () {
  12296. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12297. },
  12298. enumerable: true,
  12299. configurable: true
  12300. });
  12301. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12302. /** UNITMODE_PIXEL */
  12303. get: function () {
  12304. return ValueAndUnit._UNITMODE_PIXEL;
  12305. },
  12306. enumerable: true,
  12307. configurable: true
  12308. });
  12309. // Static
  12310. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12311. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12312. ValueAndUnit._UNITMODE_PIXEL = 1;
  12313. return ValueAndUnit;
  12314. }());
  12315. /***/ }),
  12316. /***/ "./3D/controls/abstractButton3D.ts":
  12317. /*!*****************************************!*\
  12318. !*** ./3D/controls/abstractButton3D.ts ***!
  12319. \*****************************************/
  12320. /*! exports provided: AbstractButton3D */
  12321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12322. "use strict";
  12323. __webpack_require__.r(__webpack_exports__);
  12324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12325. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12326. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12327. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12328. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12329. /**
  12330. * Class used as a root to all buttons
  12331. */
  12332. var AbstractButton3D = /** @class */ (function (_super) {
  12333. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12334. /**
  12335. * Creates a new button
  12336. * @param name defines the control name
  12337. */
  12338. function AbstractButton3D(name) {
  12339. return _super.call(this, name) || this;
  12340. }
  12341. AbstractButton3D.prototype._getTypeName = function () {
  12342. return "AbstractButton3D";
  12343. };
  12344. // Mesh association
  12345. AbstractButton3D.prototype._createNode = function (scene) {
  12346. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12347. };
  12348. return AbstractButton3D;
  12349. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12350. /***/ }),
  12351. /***/ "./3D/controls/button3D.ts":
  12352. /*!*********************************!*\
  12353. !*** ./3D/controls/button3D.ts ***!
  12354. \*********************************/
  12355. /*! exports provided: Button3D */
  12356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12357. "use strict";
  12358. __webpack_require__.r(__webpack_exports__);
  12359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12360. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12361. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  12362. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12363. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12364. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12365. /**
  12366. * Class used to create a button in 3D
  12367. */
  12368. var Button3D = /** @class */ (function (_super) {
  12369. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12370. /**
  12371. * Creates a new button
  12372. * @param name defines the control name
  12373. */
  12374. function Button3D(name) {
  12375. var _this = _super.call(this, name) || this;
  12376. _this._contentResolution = 512;
  12377. _this._contentScaleRatio = 2;
  12378. // Default animations
  12379. _this.pointerEnterAnimation = function () {
  12380. if (!_this.mesh) {
  12381. return;
  12382. }
  12383. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12384. };
  12385. _this.pointerOutAnimation = function () {
  12386. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12387. };
  12388. _this.pointerDownAnimation = function () {
  12389. if (!_this.mesh) {
  12390. return;
  12391. }
  12392. _this.mesh.scaling.scaleInPlace(0.95);
  12393. };
  12394. _this.pointerUpAnimation = function () {
  12395. if (!_this.mesh) {
  12396. return;
  12397. }
  12398. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12399. };
  12400. return _this;
  12401. }
  12402. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12403. /**
  12404. * Gets or sets the texture resolution used to render content (512 by default)
  12405. */
  12406. get: function () {
  12407. return this._contentResolution;
  12408. },
  12409. set: function (value) {
  12410. if (this._contentResolution === value) {
  12411. return;
  12412. }
  12413. this._contentResolution = value;
  12414. this._resetContent();
  12415. },
  12416. enumerable: true,
  12417. configurable: true
  12418. });
  12419. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12420. /**
  12421. * Gets or sets the texture scale ratio used to render content (2 by default)
  12422. */
  12423. get: function () {
  12424. return this._contentScaleRatio;
  12425. },
  12426. set: function (value) {
  12427. if (this._contentScaleRatio === value) {
  12428. return;
  12429. }
  12430. this._contentScaleRatio = value;
  12431. this._resetContent();
  12432. },
  12433. enumerable: true,
  12434. configurable: true
  12435. });
  12436. Button3D.prototype._disposeFacadeTexture = function () {
  12437. if (this._facadeTexture) {
  12438. this._facadeTexture.dispose();
  12439. this._facadeTexture = null;
  12440. }
  12441. };
  12442. Button3D.prototype._resetContent = function () {
  12443. this._disposeFacadeTexture();
  12444. this.content = this._content;
  12445. };
  12446. Object.defineProperty(Button3D.prototype, "content", {
  12447. /**
  12448. * Gets or sets the GUI 2D content used to display the button's facade
  12449. */
  12450. get: function () {
  12451. return this._content;
  12452. },
  12453. set: function (value) {
  12454. this._content = value;
  12455. if (!this._host || !this._host.utilityLayer) {
  12456. return;
  12457. }
  12458. if (!this._facadeTexture) {
  12459. 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);
  12460. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12461. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12462. this._facadeTexture.premulAlpha = true;
  12463. }
  12464. this._facadeTexture.addControl(value);
  12465. this._applyFacade(this._facadeTexture);
  12466. },
  12467. enumerable: true,
  12468. configurable: true
  12469. });
  12470. /**
  12471. * Apply the facade texture (created from the content property).
  12472. * This function can be overloaded by child classes
  12473. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12474. */
  12475. Button3D.prototype._applyFacade = function (facadeTexture) {
  12476. this._currentMaterial.emissiveTexture = facadeTexture;
  12477. };
  12478. Button3D.prototype._getTypeName = function () {
  12479. return "Button3D";
  12480. };
  12481. // Mesh association
  12482. Button3D.prototype._createNode = function (scene) {
  12483. var faceUV = new Array(6);
  12484. for (var i = 0; i < 6; i++) {
  12485. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12486. }
  12487. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12488. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12489. width: 1.0,
  12490. height: 1.0,
  12491. depth: 0.08,
  12492. faceUV: faceUV
  12493. }, scene);
  12494. return mesh;
  12495. };
  12496. Button3D.prototype._affectMaterial = function (mesh) {
  12497. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12498. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12499. mesh.material = material;
  12500. this._currentMaterial = material;
  12501. this._resetContent();
  12502. };
  12503. /**
  12504. * Releases all associated resources
  12505. */
  12506. Button3D.prototype.dispose = function () {
  12507. _super.prototype.dispose.call(this);
  12508. this._disposeFacadeTexture();
  12509. if (this._currentMaterial) {
  12510. this._currentMaterial.dispose();
  12511. }
  12512. };
  12513. return Button3D;
  12514. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12515. /***/ }),
  12516. /***/ "./3D/controls/container3D.ts":
  12517. /*!************************************!*\
  12518. !*** ./3D/controls/container3D.ts ***!
  12519. \************************************/
  12520. /*! exports provided: Container3D */
  12521. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12522. "use strict";
  12523. __webpack_require__.r(__webpack_exports__);
  12524. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12525. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12526. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12527. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12528. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12529. /**
  12530. * Class used to create containers for controls
  12531. */
  12532. var Container3D = /** @class */ (function (_super) {
  12533. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12534. /**
  12535. * Creates a new container
  12536. * @param name defines the container name
  12537. */
  12538. function Container3D(name) {
  12539. var _this = _super.call(this, name) || this;
  12540. _this._blockLayout = false;
  12541. /**
  12542. * Gets the list of child controls
  12543. */
  12544. _this._children = new Array();
  12545. return _this;
  12546. }
  12547. Object.defineProperty(Container3D.prototype, "children", {
  12548. /**
  12549. * Gets the list of child controls
  12550. */
  12551. get: function () {
  12552. return this._children;
  12553. },
  12554. enumerable: true,
  12555. configurable: true
  12556. });
  12557. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12558. /**
  12559. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12560. * This is helpful to optimize layout operation when adding multiple children in a row
  12561. */
  12562. get: function () {
  12563. return this._blockLayout;
  12564. },
  12565. set: function (value) {
  12566. if (this._blockLayout === value) {
  12567. return;
  12568. }
  12569. this._blockLayout = value;
  12570. if (!this._blockLayout) {
  12571. this._arrangeChildren();
  12572. }
  12573. },
  12574. enumerable: true,
  12575. configurable: true
  12576. });
  12577. /**
  12578. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12579. * @returns the current container
  12580. */
  12581. Container3D.prototype.updateLayout = function () {
  12582. this._arrangeChildren();
  12583. return this;
  12584. };
  12585. /**
  12586. * Gets a boolean indicating if the given control is in the children of this control
  12587. * @param control defines the control to check
  12588. * @returns true if the control is in the child list
  12589. */
  12590. Container3D.prototype.containsControl = function (control) {
  12591. return this._children.indexOf(control) !== -1;
  12592. };
  12593. /**
  12594. * Adds a control to the children of this control
  12595. * @param control defines the control to add
  12596. * @returns the current container
  12597. */
  12598. Container3D.prototype.addControl = function (control) {
  12599. var index = this._children.indexOf(control);
  12600. if (index !== -1) {
  12601. return this;
  12602. }
  12603. control.parent = this;
  12604. control._host = this._host;
  12605. this._children.push(control);
  12606. if (this._host.utilityLayer) {
  12607. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12608. if (control.node) {
  12609. control.node.parent = this.node;
  12610. }
  12611. if (!this.blockLayout) {
  12612. this._arrangeChildren();
  12613. }
  12614. }
  12615. return this;
  12616. };
  12617. /**
  12618. * This function will be called everytime a new control is added
  12619. */
  12620. Container3D.prototype._arrangeChildren = function () {
  12621. };
  12622. Container3D.prototype._createNode = function (scene) {
  12623. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12624. };
  12625. /**
  12626. * Removes a control from the children of this control
  12627. * @param control defines the control to remove
  12628. * @returns the current container
  12629. */
  12630. Container3D.prototype.removeControl = function (control) {
  12631. var index = this._children.indexOf(control);
  12632. if (index !== -1) {
  12633. this._children.splice(index, 1);
  12634. control.parent = null;
  12635. control._disposeNode();
  12636. }
  12637. return this;
  12638. };
  12639. Container3D.prototype._getTypeName = function () {
  12640. return "Container3D";
  12641. };
  12642. /**
  12643. * Releases all associated resources
  12644. */
  12645. Container3D.prototype.dispose = function () {
  12646. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12647. var control = _a[_i];
  12648. control.dispose();
  12649. }
  12650. this._children = [];
  12651. _super.prototype.dispose.call(this);
  12652. };
  12653. /** Control rotation will remain unchanged */
  12654. Container3D.UNSET_ORIENTATION = 0;
  12655. /** Control will rotate to make it look at sphere central axis */
  12656. Container3D.FACEORIGIN_ORIENTATION = 1;
  12657. /** Control will rotate to make it look back at sphere central axis */
  12658. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12659. /** Control will rotate to look at z axis (0, 0, 1) */
  12660. Container3D.FACEFORWARD_ORIENTATION = 3;
  12661. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12662. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12663. return Container3D;
  12664. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12665. /***/ }),
  12666. /***/ "./3D/controls/control3D.ts":
  12667. /*!**********************************!*\
  12668. !*** ./3D/controls/control3D.ts ***!
  12669. \**********************************/
  12670. /*! exports provided: Control3D */
  12671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12672. "use strict";
  12673. __webpack_require__.r(__webpack_exports__);
  12674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12675. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12676. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12677. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12678. /**
  12679. * Class used as base class for controls
  12680. */
  12681. var Control3D = /** @class */ (function () {
  12682. /**
  12683. * Creates a new control
  12684. * @param name defines the control name
  12685. */
  12686. function Control3D(
  12687. /** Defines the control name */
  12688. name) {
  12689. this.name = name;
  12690. this._downCount = 0;
  12691. this._enterCount = -1;
  12692. this._downPointerIds = {};
  12693. this._isVisible = true;
  12694. /**
  12695. * An event triggered when the pointer move over the control
  12696. */
  12697. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12698. /**
  12699. * An event triggered when the pointer move out of the control
  12700. */
  12701. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12702. /**
  12703. * An event triggered when the pointer taps the control
  12704. */
  12705. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12706. /**
  12707. * An event triggered when pointer is up
  12708. */
  12709. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12710. /**
  12711. * An event triggered when a control is clicked on (with a mouse)
  12712. */
  12713. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12714. /**
  12715. * An event triggered when pointer enters the control
  12716. */
  12717. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12718. // Behaviors
  12719. this._behaviors = new Array();
  12720. }
  12721. Object.defineProperty(Control3D.prototype, "position", {
  12722. /** Gets or sets the control position in world space */
  12723. get: function () {
  12724. if (!this._node) {
  12725. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12726. }
  12727. return this._node.position;
  12728. },
  12729. set: function (value) {
  12730. if (!this._node) {
  12731. return;
  12732. }
  12733. this._node.position = value;
  12734. },
  12735. enumerable: true,
  12736. configurable: true
  12737. });
  12738. Object.defineProperty(Control3D.prototype, "scaling", {
  12739. /** Gets or sets the control scaling in world space */
  12740. get: function () {
  12741. if (!this._node) {
  12742. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12743. }
  12744. return this._node.scaling;
  12745. },
  12746. set: function (value) {
  12747. if (!this._node) {
  12748. return;
  12749. }
  12750. this._node.scaling = value;
  12751. },
  12752. enumerable: true,
  12753. configurable: true
  12754. });
  12755. Object.defineProperty(Control3D.prototype, "behaviors", {
  12756. /**
  12757. * Gets the list of attached behaviors
  12758. * @see http://doc.babylonjs.com/features/behaviour
  12759. */
  12760. get: function () {
  12761. return this._behaviors;
  12762. },
  12763. enumerable: true,
  12764. configurable: true
  12765. });
  12766. /**
  12767. * Attach a behavior to the control
  12768. * @see http://doc.babylonjs.com/features/behaviour
  12769. * @param behavior defines the behavior to attach
  12770. * @returns the current control
  12771. */
  12772. Control3D.prototype.addBehavior = function (behavior) {
  12773. var _this = this;
  12774. var index = this._behaviors.indexOf(behavior);
  12775. if (index !== -1) {
  12776. return this;
  12777. }
  12778. behavior.init();
  12779. var scene = this._host.scene;
  12780. if (scene.isLoading) {
  12781. // We defer the attach when the scene will be loaded
  12782. scene.onDataLoadedObservable.addOnce(function () {
  12783. behavior.attach(_this);
  12784. });
  12785. }
  12786. else {
  12787. behavior.attach(this);
  12788. }
  12789. this._behaviors.push(behavior);
  12790. return this;
  12791. };
  12792. /**
  12793. * Remove an attached behavior
  12794. * @see http://doc.babylonjs.com/features/behaviour
  12795. * @param behavior defines the behavior to attach
  12796. * @returns the current control
  12797. */
  12798. Control3D.prototype.removeBehavior = function (behavior) {
  12799. var index = this._behaviors.indexOf(behavior);
  12800. if (index === -1) {
  12801. return this;
  12802. }
  12803. this._behaviors[index].detach();
  12804. this._behaviors.splice(index, 1);
  12805. return this;
  12806. };
  12807. /**
  12808. * Gets an attached behavior by name
  12809. * @param name defines the name of the behavior to look for
  12810. * @see http://doc.babylonjs.com/features/behaviour
  12811. * @returns null if behavior was not found else the requested behavior
  12812. */
  12813. Control3D.prototype.getBehaviorByName = function (name) {
  12814. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12815. var behavior = _a[_i];
  12816. if (behavior.name === name) {
  12817. return behavior;
  12818. }
  12819. }
  12820. return null;
  12821. };
  12822. Object.defineProperty(Control3D.prototype, "isVisible", {
  12823. /** Gets or sets a boolean indicating if the control is visible */
  12824. get: function () {
  12825. return this._isVisible;
  12826. },
  12827. set: function (value) {
  12828. if (this._isVisible === value) {
  12829. return;
  12830. }
  12831. this._isVisible = value;
  12832. var mesh = this.mesh;
  12833. if (mesh) {
  12834. mesh.setEnabled(value);
  12835. }
  12836. },
  12837. enumerable: true,
  12838. configurable: true
  12839. });
  12840. Object.defineProperty(Control3D.prototype, "typeName", {
  12841. /**
  12842. * Gets a string representing the class name
  12843. */
  12844. get: function () {
  12845. return this._getTypeName();
  12846. },
  12847. enumerable: true,
  12848. configurable: true
  12849. });
  12850. /**
  12851. * Get the current class name of the control.
  12852. * @returns current class name
  12853. */
  12854. Control3D.prototype.getClassName = function () {
  12855. return this._getTypeName();
  12856. };
  12857. Control3D.prototype._getTypeName = function () {
  12858. return "Control3D";
  12859. };
  12860. Object.defineProperty(Control3D.prototype, "node", {
  12861. /**
  12862. * Gets the transform node used by this control
  12863. */
  12864. get: function () {
  12865. return this._node;
  12866. },
  12867. enumerable: true,
  12868. configurable: true
  12869. });
  12870. Object.defineProperty(Control3D.prototype, "mesh", {
  12871. /**
  12872. * Gets the mesh used to render this control
  12873. */
  12874. get: function () {
  12875. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12876. return this._node;
  12877. }
  12878. return null;
  12879. },
  12880. enumerable: true,
  12881. configurable: true
  12882. });
  12883. /**
  12884. * Link the control as child of the given node
  12885. * @param node defines the node to link to. Use null to unlink the control
  12886. * @returns the current control
  12887. */
  12888. Control3D.prototype.linkToTransformNode = function (node) {
  12889. if (this._node) {
  12890. this._node.parent = node;
  12891. }
  12892. return this;
  12893. };
  12894. /** @hidden **/
  12895. Control3D.prototype._prepareNode = function (scene) {
  12896. if (!this._node) {
  12897. this._node = this._createNode(scene);
  12898. if (!this.node) {
  12899. return;
  12900. }
  12901. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12902. this._node.position = this.position;
  12903. this._node.scaling = this.scaling;
  12904. var mesh = this.mesh;
  12905. if (mesh) {
  12906. mesh.isPickable = true;
  12907. this._affectMaterial(mesh);
  12908. }
  12909. }
  12910. };
  12911. /**
  12912. * Node creation.
  12913. * Can be overriden by children
  12914. * @param scene defines the scene where the node must be attached
  12915. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12916. */
  12917. Control3D.prototype._createNode = function (scene) {
  12918. // Do nothing by default
  12919. return null;
  12920. };
  12921. /**
  12922. * Affect a material to the given mesh
  12923. * @param mesh defines the mesh which will represent the control
  12924. */
  12925. Control3D.prototype._affectMaterial = function (mesh) {
  12926. mesh.material = null;
  12927. };
  12928. // Pointers
  12929. /** @hidden */
  12930. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12931. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12932. };
  12933. /** @hidden */
  12934. Control3D.prototype._onPointerEnter = function (target) {
  12935. if (this._enterCount > 0) {
  12936. return false;
  12937. }
  12938. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12939. this._enterCount = 0;
  12940. }
  12941. this._enterCount++;
  12942. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12943. if (this.pointerEnterAnimation) {
  12944. this.pointerEnterAnimation();
  12945. }
  12946. return true;
  12947. };
  12948. /** @hidden */
  12949. Control3D.prototype._onPointerOut = function (target) {
  12950. this._enterCount = 0;
  12951. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12952. if (this.pointerOutAnimation) {
  12953. this.pointerOutAnimation();
  12954. }
  12955. };
  12956. /** @hidden */
  12957. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12958. if (this._downCount !== 0) {
  12959. this._downCount++;
  12960. return false;
  12961. }
  12962. this._downCount++;
  12963. this._downPointerIds[pointerId] = true;
  12964. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12965. if (this.pointerDownAnimation) {
  12966. this.pointerDownAnimation();
  12967. }
  12968. return true;
  12969. };
  12970. /** @hidden */
  12971. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12972. this._downCount--;
  12973. delete this._downPointerIds[pointerId];
  12974. if (this._downCount < 0) {
  12975. // Handle if forcePointerUp was called prior to this
  12976. this._downCount = 0;
  12977. return;
  12978. }
  12979. if (this._downCount == 0) {
  12980. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12981. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12982. }
  12983. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12984. if (this.pointerUpAnimation) {
  12985. this.pointerUpAnimation();
  12986. }
  12987. }
  12988. };
  12989. /** @hidden */
  12990. Control3D.prototype.forcePointerUp = function (pointerId) {
  12991. if (pointerId === void 0) { pointerId = null; }
  12992. if (pointerId !== null) {
  12993. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12994. }
  12995. else {
  12996. for (var key in this._downPointerIds) {
  12997. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12998. }
  12999. if (this._downCount > 0) {
  13000. this._downCount = 1;
  13001. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13002. }
  13003. }
  13004. };
  13005. /** @hidden */
  13006. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13007. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13008. this._onPointerMove(this, pickedPoint);
  13009. var previousControlOver = this._host._lastControlOver[pointerId];
  13010. if (previousControlOver && previousControlOver !== this) {
  13011. previousControlOver._onPointerOut(this);
  13012. }
  13013. if (previousControlOver !== this) {
  13014. this._onPointerEnter(this);
  13015. }
  13016. this._host._lastControlOver[pointerId] = this;
  13017. return true;
  13018. }
  13019. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13020. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13021. this._host._lastControlDown[pointerId] = this;
  13022. this._host._lastPickedControl = this;
  13023. return true;
  13024. }
  13025. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13026. if (this._host._lastControlDown[pointerId]) {
  13027. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13028. }
  13029. delete this._host._lastControlDown[pointerId];
  13030. return true;
  13031. }
  13032. return false;
  13033. };
  13034. /** @hidden */
  13035. Control3D.prototype._disposeNode = function () {
  13036. if (this._node) {
  13037. this._node.dispose();
  13038. this._node = null;
  13039. }
  13040. };
  13041. /**
  13042. * Releases all associated resources
  13043. */
  13044. Control3D.prototype.dispose = function () {
  13045. this.onPointerDownObservable.clear();
  13046. this.onPointerEnterObservable.clear();
  13047. this.onPointerMoveObservable.clear();
  13048. this.onPointerOutObservable.clear();
  13049. this.onPointerUpObservable.clear();
  13050. this.onPointerClickObservable.clear();
  13051. this._disposeNode();
  13052. // Behaviors
  13053. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13054. var behavior = _a[_i];
  13055. behavior.detach();
  13056. }
  13057. };
  13058. return Control3D;
  13059. }());
  13060. /***/ }),
  13061. /***/ "./3D/controls/cylinderPanel.ts":
  13062. /*!**************************************!*\
  13063. !*** ./3D/controls/cylinderPanel.ts ***!
  13064. \**************************************/
  13065. /*! exports provided: CylinderPanel */
  13066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13067. "use strict";
  13068. __webpack_require__.r(__webpack_exports__);
  13069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13070. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13071. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13072. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13073. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13074. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13075. /**
  13076. * Class used to create a container panel deployed on the surface of a cylinder
  13077. */
  13078. var CylinderPanel = /** @class */ (function (_super) {
  13079. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13080. function CylinderPanel() {
  13081. var _this = _super !== null && _super.apply(this, arguments) || this;
  13082. _this._radius = 5.0;
  13083. return _this;
  13084. }
  13085. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13086. /**
  13087. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13088. */
  13089. get: function () {
  13090. return this._radius;
  13091. },
  13092. set: function (value) {
  13093. var _this = this;
  13094. if (this._radius === value) {
  13095. return;
  13096. }
  13097. this._radius = value;
  13098. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13099. _this._arrangeChildren();
  13100. });
  13101. },
  13102. enumerable: true,
  13103. configurable: true
  13104. });
  13105. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13106. var mesh = control.mesh;
  13107. if (!mesh) {
  13108. return;
  13109. }
  13110. var newPos = this._cylindricalMapping(nodePosition);
  13111. control.position = newPos;
  13112. switch (this.orientation) {
  13113. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13114. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13115. break;
  13116. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13117. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13118. break;
  13119. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13120. break;
  13121. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13122. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13123. break;
  13124. }
  13125. };
  13126. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13127. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13128. var yAngle = (source.x / this._radius);
  13129. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13130. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13131. };
  13132. return CylinderPanel;
  13133. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13134. /***/ }),
  13135. /***/ "./3D/controls/holographicButton.ts":
  13136. /*!******************************************!*\
  13137. !*** ./3D/controls/holographicButton.ts ***!
  13138. \******************************************/
  13139. /*! exports provided: HolographicButton */
  13140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13141. "use strict";
  13142. __webpack_require__.r(__webpack_exports__);
  13143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13144. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13145. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13146. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13147. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13148. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13149. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13150. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13151. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13152. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13153. /**
  13154. * Class used to create a holographic button in 3D
  13155. */
  13156. var HolographicButton = /** @class */ (function (_super) {
  13157. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13158. /**
  13159. * Creates a new button
  13160. * @param name defines the control name
  13161. */
  13162. function HolographicButton(name, shareMaterials) {
  13163. if (shareMaterials === void 0) { shareMaterials = true; }
  13164. var _this = _super.call(this, name) || this;
  13165. _this._shareMaterials = true;
  13166. _this._shareMaterials = shareMaterials;
  13167. // Default animations
  13168. _this.pointerEnterAnimation = function () {
  13169. if (!_this.mesh) {
  13170. return;
  13171. }
  13172. _this._frontPlate.setEnabled(true);
  13173. };
  13174. _this.pointerOutAnimation = function () {
  13175. if (!_this.mesh) {
  13176. return;
  13177. }
  13178. _this._frontPlate.setEnabled(false);
  13179. };
  13180. return _this;
  13181. }
  13182. HolographicButton.prototype._disposeTooltip = function () {
  13183. this._tooltipFade = null;
  13184. if (this._tooltipTextBlock) {
  13185. this._tooltipTextBlock.dispose();
  13186. }
  13187. if (this._tooltipTexture) {
  13188. this._tooltipTexture.dispose();
  13189. }
  13190. if (this._tooltipMesh) {
  13191. this._tooltipMesh.dispose();
  13192. }
  13193. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13194. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13195. };
  13196. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13197. get: function () {
  13198. if (this._tooltipTextBlock) {
  13199. return this._tooltipTextBlock.text;
  13200. }
  13201. return null;
  13202. },
  13203. /**
  13204. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13205. */
  13206. set: function (text) {
  13207. var _this = this;
  13208. if (!text) {
  13209. this._disposeTooltip();
  13210. return;
  13211. }
  13212. if (!this._tooltipFade) {
  13213. // Create tooltip with mesh and text
  13214. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13215. 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);
  13216. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13217. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13218. tooltipBackground.material = mat;
  13219. tooltipBackground.isPickable = false;
  13220. this._tooltipMesh.addChild(tooltipBackground);
  13221. tooltipBackground.position.z = 0.05;
  13222. this._tooltipMesh.scaling.y = 1 / 3;
  13223. this._tooltipMesh.position.y = 0.7;
  13224. this._tooltipMesh.position.z = -0.15;
  13225. this._tooltipMesh.isPickable = false;
  13226. this._tooltipMesh.parent = this._backPlate;
  13227. // Create text texture for the tooltip
  13228. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13229. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13230. this._tooltipTextBlock.scaleY = 3;
  13231. this._tooltipTextBlock.color = "white";
  13232. this._tooltipTextBlock.fontSize = 130;
  13233. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13234. // Add hover action to tooltip
  13235. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13236. this._tooltipFade.delay = 500;
  13237. this._tooltipMesh.addBehavior(this._tooltipFade);
  13238. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13239. if (_this._tooltipFade) {
  13240. _this._tooltipFade.fadeIn(true);
  13241. }
  13242. });
  13243. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13244. if (_this._tooltipFade) {
  13245. _this._tooltipFade.fadeIn(false);
  13246. }
  13247. });
  13248. }
  13249. if (this._tooltipTextBlock) {
  13250. this._tooltipTextBlock.text = text;
  13251. }
  13252. },
  13253. enumerable: true,
  13254. configurable: true
  13255. });
  13256. Object.defineProperty(HolographicButton.prototype, "text", {
  13257. /**
  13258. * Gets or sets text for the button
  13259. */
  13260. get: function () {
  13261. return this._text;
  13262. },
  13263. set: function (value) {
  13264. if (this._text === value) {
  13265. return;
  13266. }
  13267. this._text = value;
  13268. this._rebuildContent();
  13269. },
  13270. enumerable: true,
  13271. configurable: true
  13272. });
  13273. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13274. /**
  13275. * Gets or sets the image url for the button
  13276. */
  13277. get: function () {
  13278. return this._imageUrl;
  13279. },
  13280. set: function (value) {
  13281. if (this._imageUrl === value) {
  13282. return;
  13283. }
  13284. this._imageUrl = value;
  13285. this._rebuildContent();
  13286. },
  13287. enumerable: true,
  13288. configurable: true
  13289. });
  13290. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13291. /**
  13292. * Gets the back material used by this button
  13293. */
  13294. get: function () {
  13295. return this._backMaterial;
  13296. },
  13297. enumerable: true,
  13298. configurable: true
  13299. });
  13300. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13301. /**
  13302. * Gets the front material used by this button
  13303. */
  13304. get: function () {
  13305. return this._frontMaterial;
  13306. },
  13307. enumerable: true,
  13308. configurable: true
  13309. });
  13310. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13311. /**
  13312. * Gets the plate material used by this button
  13313. */
  13314. get: function () {
  13315. return this._plateMaterial;
  13316. },
  13317. enumerable: true,
  13318. configurable: true
  13319. });
  13320. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13321. /**
  13322. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13323. */
  13324. get: function () {
  13325. return this._shareMaterials;
  13326. },
  13327. enumerable: true,
  13328. configurable: true
  13329. });
  13330. HolographicButton.prototype._getTypeName = function () {
  13331. return "HolographicButton";
  13332. };
  13333. HolographicButton.prototype._rebuildContent = function () {
  13334. this._disposeFacadeTexture();
  13335. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13336. panel.isVertical = true;
  13337. if (this._imageUrl) {
  13338. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13339. image.source = this._imageUrl;
  13340. image.paddingTop = "40px";
  13341. image.height = "180px";
  13342. image.width = "100px";
  13343. image.paddingBottom = "40px";
  13344. panel.addControl(image);
  13345. }
  13346. if (this._text) {
  13347. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13348. text.text = this._text;
  13349. text.color = "white";
  13350. text.height = "30px";
  13351. text.fontSize = 24;
  13352. panel.addControl(text);
  13353. }
  13354. if (this._frontPlate) {
  13355. this.content = panel;
  13356. }
  13357. };
  13358. // Mesh association
  13359. HolographicButton.prototype._createNode = function (scene) {
  13360. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13361. width: 1.0,
  13362. height: 1.0,
  13363. depth: 0.08
  13364. }, scene);
  13365. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13366. width: 1.0,
  13367. height: 1.0,
  13368. depth: 0.08
  13369. }, scene);
  13370. this._frontPlate.parent = this._backPlate;
  13371. this._frontPlate.position.z = -0.08;
  13372. this._frontPlate.isPickable = false;
  13373. this._frontPlate.setEnabled(false);
  13374. this._textPlate = _super.prototype._createNode.call(this, scene);
  13375. this._textPlate.parent = this._backPlate;
  13376. this._textPlate.position.z = -0.08;
  13377. this._textPlate.isPickable = false;
  13378. return this._backPlate;
  13379. };
  13380. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13381. this._plateMaterial.emissiveTexture = facadeTexture;
  13382. this._plateMaterial.opacityTexture = facadeTexture;
  13383. };
  13384. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13385. var _this = this;
  13386. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13387. this._backMaterial.renderHoverLight = true;
  13388. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13389. if (pickedPoint) {
  13390. _this._backMaterial.hoverPosition = pickedPoint;
  13391. _this._backMaterial.hoverColor.a = 1.0;
  13392. }
  13393. else {
  13394. _this._backMaterial.hoverColor.a = 0;
  13395. }
  13396. });
  13397. };
  13398. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13399. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13400. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13401. this._frontMaterial.alpha = 0.5; // Additive
  13402. this._frontMaterial.renderBorders = true;
  13403. };
  13404. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13405. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13406. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13407. };
  13408. HolographicButton.prototype._affectMaterial = function (mesh) {
  13409. // Back
  13410. if (this._shareMaterials) {
  13411. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13412. this._createBackMaterial(mesh);
  13413. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13414. }
  13415. else {
  13416. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13417. }
  13418. // Front
  13419. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13420. this._createFrontMaterial(mesh);
  13421. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13422. }
  13423. else {
  13424. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13425. }
  13426. }
  13427. else {
  13428. this._createBackMaterial(mesh);
  13429. this._createFrontMaterial(mesh);
  13430. }
  13431. this._createPlateMaterial(mesh);
  13432. this._backPlate.material = this._backMaterial;
  13433. this._frontPlate.material = this._frontMaterial;
  13434. this._textPlate.material = this._plateMaterial;
  13435. this._rebuildContent();
  13436. };
  13437. /**
  13438. * Releases all associated resources
  13439. */
  13440. HolographicButton.prototype.dispose = function () {
  13441. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13442. this._disposeTooltip();
  13443. if (!this.shareMaterials) {
  13444. this._backMaterial.dispose();
  13445. this._frontMaterial.dispose();
  13446. this._plateMaterial.dispose();
  13447. if (this._pickedPointObserver) {
  13448. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13449. this._pickedPointObserver = null;
  13450. }
  13451. }
  13452. };
  13453. return HolographicButton;
  13454. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13455. /***/ }),
  13456. /***/ "./3D/controls/index.ts":
  13457. /*!******************************!*\
  13458. !*** ./3D/controls/index.ts ***!
  13459. \******************************/
  13460. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13462. "use strict";
  13463. __webpack_require__.r(__webpack_exports__);
  13464. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13466. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13468. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13470. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13472. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13474. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13476. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13478. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13480. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13482. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13484. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13486. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13488. /***/ }),
  13489. /***/ "./3D/controls/meshButton3D.ts":
  13490. /*!*************************************!*\
  13491. !*** ./3D/controls/meshButton3D.ts ***!
  13492. \*************************************/
  13493. /*! exports provided: MeshButton3D */
  13494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13495. "use strict";
  13496. __webpack_require__.r(__webpack_exports__);
  13497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13499. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13500. /**
  13501. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13502. */
  13503. var MeshButton3D = /** @class */ (function (_super) {
  13504. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13505. /**
  13506. * Creates a new 3D button based on a mesh
  13507. * @param mesh mesh to become a 3D button
  13508. * @param name defines the control name
  13509. */
  13510. function MeshButton3D(mesh, name) {
  13511. var _this = _super.call(this, name) || this;
  13512. _this._currentMesh = mesh;
  13513. /**
  13514. * Provides a default behavior on hover/out & up/down
  13515. * Override those function to create your own desired behavior specific to your mesh
  13516. */
  13517. _this.pointerEnterAnimation = function () {
  13518. if (!_this.mesh) {
  13519. return;
  13520. }
  13521. _this.mesh.scaling.scaleInPlace(1.1);
  13522. };
  13523. _this.pointerOutAnimation = function () {
  13524. if (!_this.mesh) {
  13525. return;
  13526. }
  13527. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13528. };
  13529. _this.pointerDownAnimation = function () {
  13530. if (!_this.mesh) {
  13531. return;
  13532. }
  13533. _this.mesh.scaling.scaleInPlace(0.95);
  13534. };
  13535. _this.pointerUpAnimation = function () {
  13536. if (!_this.mesh) {
  13537. return;
  13538. }
  13539. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13540. };
  13541. return _this;
  13542. }
  13543. MeshButton3D.prototype._getTypeName = function () {
  13544. return "MeshButton3D";
  13545. };
  13546. // Mesh association
  13547. MeshButton3D.prototype._createNode = function (scene) {
  13548. var _this = this;
  13549. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13550. mesh.metadata = _this;
  13551. });
  13552. return this._currentMesh;
  13553. };
  13554. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13555. };
  13556. return MeshButton3D;
  13557. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13558. /***/ }),
  13559. /***/ "./3D/controls/planePanel.ts":
  13560. /*!***********************************!*\
  13561. !*** ./3D/controls/planePanel.ts ***!
  13562. \***********************************/
  13563. /*! exports provided: PlanePanel */
  13564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13565. "use strict";
  13566. __webpack_require__.r(__webpack_exports__);
  13567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13568. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13569. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13570. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13571. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13572. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13573. /**
  13574. * Class used to create a container panel deployed on the surface of a plane
  13575. */
  13576. var PlanePanel = /** @class */ (function (_super) {
  13577. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13578. function PlanePanel() {
  13579. return _super !== null && _super.apply(this, arguments) || this;
  13580. }
  13581. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13582. var mesh = control.mesh;
  13583. if (!mesh) {
  13584. return;
  13585. }
  13586. control.position = nodePosition.clone();
  13587. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13588. target.copyFrom(nodePosition);
  13589. switch (this.orientation) {
  13590. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13591. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13592. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13593. mesh.lookAt(target);
  13594. break;
  13595. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13596. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13597. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13598. mesh.lookAt(target);
  13599. break;
  13600. }
  13601. };
  13602. return PlanePanel;
  13603. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13604. /***/ }),
  13605. /***/ "./3D/controls/scatterPanel.ts":
  13606. /*!*************************************!*\
  13607. !*** ./3D/controls/scatterPanel.ts ***!
  13608. \*************************************/
  13609. /*! exports provided: ScatterPanel */
  13610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13611. "use strict";
  13612. __webpack_require__.r(__webpack_exports__);
  13613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13615. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13616. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13617. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13618. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13619. /**
  13620. * Class used to create a container panel where items get randomized planar mapping
  13621. */
  13622. var ScatterPanel = /** @class */ (function (_super) {
  13623. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13624. function ScatterPanel() {
  13625. var _this = _super !== null && _super.apply(this, arguments) || this;
  13626. _this._iteration = 100.0;
  13627. return _this;
  13628. }
  13629. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13630. /**
  13631. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13632. */
  13633. get: function () {
  13634. return this._iteration;
  13635. },
  13636. set: function (value) {
  13637. var _this = this;
  13638. if (this._iteration === value) {
  13639. return;
  13640. }
  13641. this._iteration = value;
  13642. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13643. _this._arrangeChildren();
  13644. });
  13645. },
  13646. enumerable: true,
  13647. configurable: true
  13648. });
  13649. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13650. var mesh = control.mesh;
  13651. var newPos = this._scatterMapping(nodePosition);
  13652. if (!mesh) {
  13653. return;
  13654. }
  13655. switch (this.orientation) {
  13656. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13657. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13658. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13659. break;
  13660. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13661. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13662. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13663. break;
  13664. }
  13665. control.position = newPos;
  13666. };
  13667. ScatterPanel.prototype._scatterMapping = function (source) {
  13668. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13669. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13670. return source;
  13671. };
  13672. ScatterPanel.prototype._finalProcessing = function () {
  13673. var meshes = [];
  13674. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13675. var child = _a[_i];
  13676. if (!child.mesh) {
  13677. continue;
  13678. }
  13679. meshes.push(child.mesh);
  13680. }
  13681. for (var count = 0; count < this._iteration; count++) {
  13682. meshes.sort(function (a, b) {
  13683. var distance1 = a.position.lengthSquared();
  13684. var distance2 = b.position.lengthSquared();
  13685. if (distance1 < distance2) {
  13686. return 1;
  13687. }
  13688. else if (distance1 > distance2) {
  13689. return -1;
  13690. }
  13691. return 0;
  13692. });
  13693. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13694. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13695. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  13696. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13697. for (var i = 0; i < meshes.length - 1; i++) {
  13698. for (var j = i + 1; j < meshes.length; j++) {
  13699. if (i != j) {
  13700. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13701. // Ignore Z axis
  13702. difference2D.x = difference.x;
  13703. difference2D.y = difference.y;
  13704. var combinedRadius = cellSize;
  13705. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13706. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13707. distance -= minSeparation;
  13708. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13709. difference2D.normalize();
  13710. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13711. meshes[j].position.addInPlace(difference);
  13712. meshes[i].position.subtractInPlace(difference);
  13713. }
  13714. }
  13715. }
  13716. }
  13717. }
  13718. };
  13719. return ScatterPanel;
  13720. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13721. /***/ }),
  13722. /***/ "./3D/controls/spherePanel.ts":
  13723. /*!************************************!*\
  13724. !*** ./3D/controls/spherePanel.ts ***!
  13725. \************************************/
  13726. /*! exports provided: SpherePanel */
  13727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13728. "use strict";
  13729. __webpack_require__.r(__webpack_exports__);
  13730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13731. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13732. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13733. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13734. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13735. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13736. /**
  13737. * Class used to create a container panel deployed on the surface of a sphere
  13738. */
  13739. var SpherePanel = /** @class */ (function (_super) {
  13740. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13741. function SpherePanel() {
  13742. var _this = _super !== null && _super.apply(this, arguments) || this;
  13743. _this._radius = 5.0;
  13744. return _this;
  13745. }
  13746. Object.defineProperty(SpherePanel.prototype, "radius", {
  13747. /**
  13748. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13749. */
  13750. get: function () {
  13751. return this._radius;
  13752. },
  13753. set: function (value) {
  13754. var _this = this;
  13755. if (this._radius === value) {
  13756. return;
  13757. }
  13758. this._radius = value;
  13759. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13760. _this._arrangeChildren();
  13761. });
  13762. },
  13763. enumerable: true,
  13764. configurable: true
  13765. });
  13766. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13767. var mesh = control.mesh;
  13768. if (!mesh) {
  13769. return;
  13770. }
  13771. var newPos = this._sphericalMapping(nodePosition);
  13772. control.position = newPos;
  13773. switch (this.orientation) {
  13774. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13775. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13776. break;
  13777. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13778. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13779. break;
  13780. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13781. break;
  13782. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13783. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13784. break;
  13785. }
  13786. };
  13787. SpherePanel.prototype._sphericalMapping = function (source) {
  13788. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13789. var xAngle = (source.y / this._radius);
  13790. var yAngle = -(source.x / this._radius);
  13791. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13792. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13793. };
  13794. return SpherePanel;
  13795. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13796. /***/ }),
  13797. /***/ "./3D/controls/stackPanel3D.ts":
  13798. /*!*************************************!*\
  13799. !*** ./3D/controls/stackPanel3D.ts ***!
  13800. \*************************************/
  13801. /*! exports provided: StackPanel3D */
  13802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13803. "use strict";
  13804. __webpack_require__.r(__webpack_exports__);
  13805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13806. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13807. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13808. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13809. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13810. /**
  13811. * Class used to create a stack panel in 3D on XY plane
  13812. */
  13813. var StackPanel3D = /** @class */ (function (_super) {
  13814. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13815. /**
  13816. * Creates new StackPanel
  13817. * @param isVertical
  13818. */
  13819. function StackPanel3D(isVertical) {
  13820. if (isVertical === void 0) { isVertical = false; }
  13821. var _this = _super.call(this) || this;
  13822. _this._isVertical = false;
  13823. /**
  13824. * Gets or sets the distance between elements
  13825. */
  13826. _this.margin = 0.1;
  13827. _this._isVertical = isVertical;
  13828. return _this;
  13829. }
  13830. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13831. /**
  13832. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13833. */
  13834. get: function () {
  13835. return this._isVertical;
  13836. },
  13837. set: function (value) {
  13838. var _this = this;
  13839. if (this._isVertical === value) {
  13840. return;
  13841. }
  13842. this._isVertical = value;
  13843. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13844. _this._arrangeChildren();
  13845. });
  13846. },
  13847. enumerable: true,
  13848. configurable: true
  13849. });
  13850. StackPanel3D.prototype._arrangeChildren = function () {
  13851. var width = 0;
  13852. var height = 0;
  13853. var controlCount = 0;
  13854. var extendSizes = [];
  13855. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13856. // Measure
  13857. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13858. var child = _a[_i];
  13859. if (!child.mesh) {
  13860. continue;
  13861. }
  13862. controlCount++;
  13863. child.mesh.computeWorldMatrix(true);
  13864. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13865. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13866. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13867. extendSizes.push(extendSize);
  13868. if (this._isVertical) {
  13869. height += extendSize.y;
  13870. }
  13871. else {
  13872. width += extendSize.x;
  13873. }
  13874. }
  13875. if (this._isVertical) {
  13876. height += (controlCount - 1) * this.margin / 2;
  13877. }
  13878. else {
  13879. width += (controlCount - 1) * this.margin / 2;
  13880. }
  13881. // Arrange
  13882. var offset;
  13883. if (this._isVertical) {
  13884. offset = -height;
  13885. }
  13886. else {
  13887. offset = -width;
  13888. }
  13889. var index = 0;
  13890. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13891. var child = _c[_b];
  13892. if (!child.mesh) {
  13893. continue;
  13894. }
  13895. controlCount--;
  13896. var extendSize = extendSizes[index++];
  13897. if (this._isVertical) {
  13898. child.position.y = offset + extendSize.y;
  13899. child.position.x = 0;
  13900. offset += extendSize.y * 2;
  13901. }
  13902. else {
  13903. child.position.x = offset + extendSize.x;
  13904. child.position.y = 0;
  13905. offset += extendSize.x * 2;
  13906. }
  13907. offset += (controlCount > 0 ? this.margin : 0);
  13908. }
  13909. };
  13910. return StackPanel3D;
  13911. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13912. /***/ }),
  13913. /***/ "./3D/controls/volumeBasedPanel.ts":
  13914. /*!*****************************************!*\
  13915. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13916. \*****************************************/
  13917. /*! exports provided: VolumeBasedPanel */
  13918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13919. "use strict";
  13920. __webpack_require__.r(__webpack_exports__);
  13921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13922. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13923. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13924. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13925. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13926. /**
  13927. * Abstract class used to create a container panel deployed on the surface of a volume
  13928. */
  13929. var VolumeBasedPanel = /** @class */ (function (_super) {
  13930. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13931. /**
  13932. * Creates new VolumeBasedPanel
  13933. */
  13934. function VolumeBasedPanel() {
  13935. var _this = _super.call(this) || this;
  13936. _this._columns = 10;
  13937. _this._rows = 0;
  13938. _this._rowThenColum = true;
  13939. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13940. /**
  13941. * Gets or sets the distance between elements
  13942. */
  13943. _this.margin = 0;
  13944. return _this;
  13945. }
  13946. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13947. /**
  13948. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13949. * | Value | Type | Description |
  13950. * | ----- | ----------------------------------- | ----------- |
  13951. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13952. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13953. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13954. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13955. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13956. */
  13957. get: function () {
  13958. return this._orientation;
  13959. },
  13960. set: function (value) {
  13961. var _this = this;
  13962. if (this._orientation === value) {
  13963. return;
  13964. }
  13965. this._orientation = value;
  13966. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13967. _this._arrangeChildren();
  13968. });
  13969. },
  13970. enumerable: true,
  13971. configurable: true
  13972. });
  13973. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13974. /**
  13975. * Gets or sets the number of columns requested (10 by default).
  13976. * The panel will automatically compute the number of rows based on number of child controls.
  13977. */
  13978. get: function () {
  13979. return this._columns;
  13980. },
  13981. set: function (value) {
  13982. var _this = this;
  13983. if (this._columns === value) {
  13984. return;
  13985. }
  13986. this._columns = value;
  13987. this._rowThenColum = true;
  13988. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13989. _this._arrangeChildren();
  13990. });
  13991. },
  13992. enumerable: true,
  13993. configurable: true
  13994. });
  13995. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13996. /**
  13997. * Gets or sets a the number of rows requested.
  13998. * The panel will automatically compute the number of columns based on number of child controls.
  13999. */
  14000. get: function () {
  14001. return this._rows;
  14002. },
  14003. set: function (value) {
  14004. var _this = this;
  14005. if (this._rows === value) {
  14006. return;
  14007. }
  14008. this._rows = value;
  14009. this._rowThenColum = false;
  14010. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14011. _this._arrangeChildren();
  14012. });
  14013. },
  14014. enumerable: true,
  14015. configurable: true
  14016. });
  14017. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14018. this._cellWidth = 0;
  14019. this._cellHeight = 0;
  14020. var rows = 0;
  14021. var columns = 0;
  14022. var controlCount = 0;
  14023. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14024. // Measure
  14025. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14026. var child = _a[_i];
  14027. if (!child.mesh) {
  14028. continue;
  14029. }
  14030. controlCount++;
  14031. child.mesh.computeWorldMatrix(true);
  14032. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14033. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14034. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14035. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14036. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14037. diff.scaleInPlace(0.5);
  14038. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14039. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14040. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14041. }
  14042. this._cellWidth += this.margin * 2;
  14043. this._cellHeight += this.margin * 2;
  14044. // Arrange
  14045. if (this._rowThenColum) {
  14046. columns = this._columns;
  14047. rows = Math.ceil(controlCount / this._columns);
  14048. }
  14049. else {
  14050. rows = this._rows;
  14051. columns = Math.ceil(controlCount / this._rows);
  14052. }
  14053. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14054. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14055. var nodeGrid = [];
  14056. var cellCounter = 0;
  14057. if (this._rowThenColum) {
  14058. for (var r = 0; r < rows; r++) {
  14059. for (var c = 0; c < columns; c++) {
  14060. 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));
  14061. cellCounter++;
  14062. if (cellCounter > controlCount) {
  14063. break;
  14064. }
  14065. }
  14066. }
  14067. }
  14068. else {
  14069. for (var c = 0; c < columns; c++) {
  14070. for (var r = 0; r < rows; r++) {
  14071. 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));
  14072. cellCounter++;
  14073. if (cellCounter > controlCount) {
  14074. break;
  14075. }
  14076. }
  14077. }
  14078. }
  14079. cellCounter = 0;
  14080. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14081. var child = _c[_b];
  14082. if (!child.mesh) {
  14083. continue;
  14084. }
  14085. this._mapGridNode(child, nodeGrid[cellCounter]);
  14086. cellCounter++;
  14087. }
  14088. this._finalProcessing();
  14089. };
  14090. /** Child classes can implement this function to provide additional processing */
  14091. VolumeBasedPanel.prototype._finalProcessing = function () {
  14092. };
  14093. return VolumeBasedPanel;
  14094. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14095. /***/ }),
  14096. /***/ "./3D/gui3DManager.ts":
  14097. /*!****************************!*\
  14098. !*** ./3D/gui3DManager.ts ***!
  14099. \****************************/
  14100. /*! exports provided: GUI3DManager */
  14101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14102. "use strict";
  14103. __webpack_require__.r(__webpack_exports__);
  14104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14105. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  14106. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14107. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14108. /**
  14109. * Class used to manage 3D user interface
  14110. * @see http://doc.babylonjs.com/how_to/gui3d
  14111. */
  14112. var GUI3DManager = /** @class */ (function () {
  14113. /**
  14114. * Creates a new GUI3DManager
  14115. * @param scene
  14116. */
  14117. function GUI3DManager(scene) {
  14118. var _this = this;
  14119. /** @hidden */
  14120. this._lastControlOver = {};
  14121. /** @hidden */
  14122. this._lastControlDown = {};
  14123. /**
  14124. * Observable raised when the point picked by the pointer events changed
  14125. */
  14126. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14127. // Shared resources
  14128. /** @hidden */
  14129. this._sharedMaterials = {};
  14130. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14131. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14132. _this._sceneDisposeObserver = null;
  14133. _this._utilityLayer = null;
  14134. _this.dispose();
  14135. });
  14136. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14137. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14138. this._utilityLayer.pickUtilitySceneFirst = false;
  14139. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14140. return mesh && mesh.metadata && mesh.metadata._node;
  14141. };
  14142. // Root
  14143. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14144. this._rootContainer._host = this;
  14145. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14146. // Events
  14147. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14148. _this._handlePointerOut(pointerId, true);
  14149. });
  14150. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14151. _this._doPicking(pi);
  14152. });
  14153. // Scene
  14154. this._utilityLayer.utilityLayerScene.autoClear = false;
  14155. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14156. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14157. }
  14158. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14159. /** Gets the hosting scene */
  14160. get: function () {
  14161. return this._scene;
  14162. },
  14163. enumerable: true,
  14164. configurable: true
  14165. });
  14166. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14167. /** Gets associated utility layer */
  14168. get: function () {
  14169. return this._utilityLayer;
  14170. },
  14171. enumerable: true,
  14172. configurable: true
  14173. });
  14174. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14175. var previousControlOver = this._lastControlOver[pointerId];
  14176. if (previousControlOver) {
  14177. previousControlOver._onPointerOut(previousControlOver);
  14178. delete this._lastControlOver[pointerId];
  14179. }
  14180. if (isPointerUp) {
  14181. if (this._lastControlDown[pointerId]) {
  14182. this._lastControlDown[pointerId].forcePointerUp();
  14183. delete this._lastControlDown[pointerId];
  14184. }
  14185. }
  14186. this.onPickedPointChangedObservable.notifyObservers(null);
  14187. };
  14188. GUI3DManager.prototype._doPicking = function (pi) {
  14189. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14190. return false;
  14191. }
  14192. var pointerEvent = (pi.event);
  14193. var pointerId = pointerEvent.pointerId || 0;
  14194. var buttonIndex = pointerEvent.button;
  14195. var pickingInfo = pi.pickInfo;
  14196. if (!pickingInfo || !pickingInfo.hit) {
  14197. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14198. return false;
  14199. }
  14200. var control = (pickingInfo.pickedMesh.metadata);
  14201. if (pickingInfo.pickedPoint) {
  14202. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14203. }
  14204. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14205. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14206. if (this._lastControlOver[pointerId]) {
  14207. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14208. }
  14209. delete this._lastControlOver[pointerId];
  14210. }
  14211. }
  14212. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14213. if (this._lastControlDown[pointerEvent.pointerId]) {
  14214. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14215. delete this._lastControlDown[pointerEvent.pointerId];
  14216. }
  14217. if (pointerEvent.pointerType === "touch") {
  14218. this._handlePointerOut(pointerId, false);
  14219. }
  14220. }
  14221. return true;
  14222. };
  14223. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14224. /**
  14225. * Gets the root container
  14226. */
  14227. get: function () {
  14228. return this._rootContainer;
  14229. },
  14230. enumerable: true,
  14231. configurable: true
  14232. });
  14233. /**
  14234. * Gets a boolean indicating if the given control is in the root child list
  14235. * @param control defines the control to check
  14236. * @returns true if the control is in the root child list
  14237. */
  14238. GUI3DManager.prototype.containsControl = function (control) {
  14239. return this._rootContainer.containsControl(control);
  14240. };
  14241. /**
  14242. * Adds a control to the root child list
  14243. * @param control defines the control to add
  14244. * @returns the current manager
  14245. */
  14246. GUI3DManager.prototype.addControl = function (control) {
  14247. this._rootContainer.addControl(control);
  14248. return this;
  14249. };
  14250. /**
  14251. * Removes a control from the root child list
  14252. * @param control defines the control to remove
  14253. * @returns the current container
  14254. */
  14255. GUI3DManager.prototype.removeControl = function (control) {
  14256. this._rootContainer.removeControl(control);
  14257. return this;
  14258. };
  14259. /**
  14260. * Releases all associated resources
  14261. */
  14262. GUI3DManager.prototype.dispose = function () {
  14263. this._rootContainer.dispose();
  14264. for (var materialName in this._sharedMaterials) {
  14265. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14266. continue;
  14267. }
  14268. this._sharedMaterials[materialName].dispose();
  14269. }
  14270. this._sharedMaterials = {};
  14271. if (this._pointerOutObserver && this._utilityLayer) {
  14272. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14273. this._pointerOutObserver = null;
  14274. }
  14275. this.onPickedPointChangedObservable.clear();
  14276. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14277. if (utilityLayerScene) {
  14278. if (this._pointerObserver) {
  14279. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14280. this._pointerObserver = null;
  14281. }
  14282. }
  14283. if (this._scene) {
  14284. if (this._sceneDisposeObserver) {
  14285. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14286. this._sceneDisposeObserver = null;
  14287. }
  14288. }
  14289. if (this._utilityLayer) {
  14290. this._utilityLayer.dispose();
  14291. }
  14292. };
  14293. return GUI3DManager;
  14294. }());
  14295. /***/ }),
  14296. /***/ "./3D/index.ts":
  14297. /*!*********************!*\
  14298. !*** ./3D/index.ts ***!
  14299. \*********************/
  14300. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14302. "use strict";
  14303. __webpack_require__.r(__webpack_exports__);
  14304. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14317. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14320. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14322. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14324. /***/ }),
  14325. /***/ "./3D/materials/fluentMaterial.ts":
  14326. /*!****************************************!*\
  14327. !*** ./3D/materials/fluentMaterial.ts ***!
  14328. \****************************************/
  14329. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14331. "use strict";
  14332. __webpack_require__.r(__webpack_exports__);
  14333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14335. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14336. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  14337. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14338. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14339. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14340. /** @hidden */
  14341. var FluentMaterialDefines = /** @class */ (function (_super) {
  14342. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14343. function FluentMaterialDefines() {
  14344. var _this = _super.call(this) || this;
  14345. _this.INNERGLOW = false;
  14346. _this.BORDER = false;
  14347. _this.HOVERLIGHT = false;
  14348. _this.TEXTURE = false;
  14349. _this.rebuild();
  14350. return _this;
  14351. }
  14352. return FluentMaterialDefines;
  14353. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14354. /**
  14355. * Class used to render controls with fluent desgin
  14356. */
  14357. var FluentMaterial = /** @class */ (function (_super) {
  14358. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14359. /**
  14360. * Creates a new Fluent material
  14361. * @param name defines the name of the material
  14362. * @param scene defines the hosting scene
  14363. */
  14364. function FluentMaterial(name, scene) {
  14365. var _this = _super.call(this, name, scene) || this;
  14366. /**
  14367. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14368. */
  14369. _this.innerGlowColorIntensity = 0.5;
  14370. /**
  14371. * Gets or sets the inner glow color (white by default)
  14372. */
  14373. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14374. /**
  14375. * Gets or sets alpha value (default is 1.0)
  14376. */
  14377. _this.alpha = 1.0;
  14378. /**
  14379. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14380. */
  14381. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14382. /**
  14383. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14384. */
  14385. _this.renderBorders = false;
  14386. /**
  14387. * Gets or sets border width (default is 0.5)
  14388. */
  14389. _this.borderWidth = 0.5;
  14390. /**
  14391. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14392. */
  14393. _this.edgeSmoothingValue = 0.02;
  14394. /**
  14395. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14396. */
  14397. _this.borderMinValue = 0.1;
  14398. /**
  14399. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14400. */
  14401. _this.renderHoverLight = false;
  14402. /**
  14403. * Gets or sets the radius used to render the hover light (default is 1.0)
  14404. */
  14405. _this.hoverRadius = 1.0;
  14406. /**
  14407. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14408. */
  14409. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14410. /**
  14411. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14412. */
  14413. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14414. return _this;
  14415. }
  14416. FluentMaterial.prototype.needAlphaBlending = function () {
  14417. return this.alpha !== 1.0;
  14418. };
  14419. FluentMaterial.prototype.needAlphaTesting = function () {
  14420. return false;
  14421. };
  14422. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14423. return null;
  14424. };
  14425. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14426. if (this.isFrozen) {
  14427. if (this._wasPreviouslyReady && subMesh.effect) {
  14428. return true;
  14429. }
  14430. }
  14431. if (!subMesh._materialDefines) {
  14432. subMesh._materialDefines = new FluentMaterialDefines();
  14433. }
  14434. var scene = this.getScene();
  14435. var defines = subMesh._materialDefines;
  14436. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14437. if (defines._renderId === scene.getRenderId()) {
  14438. return true;
  14439. }
  14440. }
  14441. if (defines._areTexturesDirty) {
  14442. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14443. defines.BORDER = this.renderBorders;
  14444. defines.HOVERLIGHT = this.renderHoverLight;
  14445. if (this._albedoTexture) {
  14446. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14447. return false;
  14448. }
  14449. else {
  14450. defines.TEXTURE = true;
  14451. }
  14452. }
  14453. else {
  14454. defines.TEXTURE = false;
  14455. }
  14456. }
  14457. var engine = scene.getEngine();
  14458. // Get correct effect
  14459. if (defines.isDirty) {
  14460. defines.markAsProcessed();
  14461. scene.resetCachedMaterial();
  14462. //Attributes
  14463. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14464. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14465. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14466. var shaderName = "fluent";
  14467. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14468. "hoverColor", "hoverPosition", "hoverRadius"
  14469. ];
  14470. var samplers = ["albedoSampler"];
  14471. var uniformBuffers = new Array();
  14472. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14473. uniformsNames: uniforms,
  14474. uniformBuffersNames: uniformBuffers,
  14475. samplers: samplers,
  14476. defines: defines,
  14477. maxSimultaneousLights: 4
  14478. });
  14479. var join = defines.toString();
  14480. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14481. attributes: attribs,
  14482. uniformsNames: uniforms,
  14483. uniformBuffersNames: uniformBuffers,
  14484. samplers: samplers,
  14485. defines: join,
  14486. fallbacks: null,
  14487. onCompiled: this.onCompiled,
  14488. onError: this.onError,
  14489. indexParameters: { maxSimultaneousLights: 4 }
  14490. }, engine));
  14491. }
  14492. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14493. return false;
  14494. }
  14495. defines._renderId = scene.getRenderId();
  14496. this._wasPreviouslyReady = true;
  14497. return true;
  14498. };
  14499. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14500. var scene = this.getScene();
  14501. var defines = subMesh._materialDefines;
  14502. if (!defines) {
  14503. return;
  14504. }
  14505. var effect = subMesh.effect;
  14506. if (!effect) {
  14507. return;
  14508. }
  14509. this._activeEffect = effect;
  14510. // Matrices
  14511. this.bindOnlyWorldMatrix(world);
  14512. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14513. if (this._mustRebind(scene, effect)) {
  14514. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14515. if (defines.INNERGLOW) {
  14516. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14517. }
  14518. if (defines.BORDER) {
  14519. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14520. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14521. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14522. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14523. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14524. }
  14525. if (defines.HOVERLIGHT) {
  14526. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14527. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14528. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14529. }
  14530. if (defines.TEXTURE) {
  14531. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14532. }
  14533. }
  14534. this._afterBind(mesh, this._activeEffect);
  14535. };
  14536. FluentMaterial.prototype.getActiveTextures = function () {
  14537. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14538. return activeTextures;
  14539. };
  14540. FluentMaterial.prototype.hasTexture = function (texture) {
  14541. if (_super.prototype.hasTexture.call(this, texture)) {
  14542. return true;
  14543. }
  14544. return false;
  14545. };
  14546. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14547. _super.prototype.dispose.call(this, forceDisposeEffect);
  14548. };
  14549. FluentMaterial.prototype.clone = function (name) {
  14550. var _this = this;
  14551. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14552. };
  14553. FluentMaterial.prototype.serialize = function () {
  14554. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14555. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14556. return serializationObject;
  14557. };
  14558. FluentMaterial.prototype.getClassName = function () {
  14559. return "FluentMaterial";
  14560. };
  14561. // Statics
  14562. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14563. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14564. };
  14565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14566. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14567. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14568. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14570. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14571. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14572. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14573. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14574. ], FluentMaterial.prototype, "alpha", void 0);
  14575. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14576. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14577. ], FluentMaterial.prototype, "albedoColor", void 0);
  14578. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14579. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14580. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14581. ], FluentMaterial.prototype, "renderBorders", void 0);
  14582. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14583. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14584. ], FluentMaterial.prototype, "borderWidth", void 0);
  14585. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14586. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14587. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14588. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14589. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14590. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14591. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14592. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14593. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14594. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14596. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14597. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14599. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14600. ], FluentMaterial.prototype, "hoverColor", void 0);
  14601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14602. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14603. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14605. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14606. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14608. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14609. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14610. return FluentMaterial;
  14611. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14612. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14613. /***/ }),
  14614. /***/ "./3D/materials/index.ts":
  14615. /*!*******************************!*\
  14616. !*** ./3D/materials/index.ts ***!
  14617. \*******************************/
  14618. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14620. "use strict";
  14621. __webpack_require__.r(__webpack_exports__);
  14622. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14625. /***/ }),
  14626. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14627. /*!*************************************************!*\
  14628. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14629. \*************************************************/
  14630. /*! exports provided: fluentPixelShader */
  14631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14632. "use strict";
  14633. __webpack_require__.r(__webpack_exports__);
  14634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14635. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14636. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14637. var name = 'fluentPixelShader';
  14638. 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}";
  14639. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14640. /** @hidden */
  14641. var fluentPixelShader = { name: name, shader: shader };
  14642. /***/ }),
  14643. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14644. /*!***********************************************!*\
  14645. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14646. \***********************************************/
  14647. /*! exports provided: fluentVertexShader */
  14648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14649. "use strict";
  14650. __webpack_require__.r(__webpack_exports__);
  14651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14652. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14653. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14654. var name = 'fluentVertexShader';
  14655. 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";
  14656. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14657. /** @hidden */
  14658. var fluentVertexShader = { name: name, shader: shader };
  14659. /***/ }),
  14660. /***/ "./3D/vector3WithInfo.ts":
  14661. /*!*******************************!*\
  14662. !*** ./3D/vector3WithInfo.ts ***!
  14663. \*******************************/
  14664. /*! exports provided: Vector3WithInfo */
  14665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14666. "use strict";
  14667. __webpack_require__.r(__webpack_exports__);
  14668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14669. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14670. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  14671. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14672. /**
  14673. * Class used to transport Vector3 information for pointer events
  14674. */
  14675. var Vector3WithInfo = /** @class */ (function (_super) {
  14676. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14677. /**
  14678. * Creates a new Vector3WithInfo
  14679. * @param source defines the vector3 data to transport
  14680. * @param buttonIndex defines the current mouse button index
  14681. */
  14682. function Vector3WithInfo(source,
  14683. /** defines the current mouse button index */
  14684. buttonIndex) {
  14685. if (buttonIndex === void 0) { buttonIndex = 0; }
  14686. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14687. _this.buttonIndex = buttonIndex;
  14688. return _this;
  14689. }
  14690. return Vector3WithInfo;
  14691. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14692. /***/ }),
  14693. /***/ "./index.ts":
  14694. /*!******************!*\
  14695. !*** ./index.ts ***!
  14696. \******************/
  14697. /*! 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 */
  14698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14699. "use strict";
  14700. __webpack_require__.r(__webpack_exports__);
  14701. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14741. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14758. /***/ }),
  14759. /***/ "./legacy/legacy.ts":
  14760. /*!**************************!*\
  14761. !*** ./legacy/legacy.ts ***!
  14762. \**************************/
  14763. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14765. "use strict";
  14766. __webpack_require__.r(__webpack_exports__);
  14767. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14823. /**
  14824. * Legacy support, defining window.BABYLON.GUI (global variable).
  14825. *
  14826. * This is the entry point for the UMD module.
  14827. * The entry point for a future ESM package should be index.ts
  14828. */
  14829. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14830. if (typeof globalObject !== "undefined") {
  14831. globalObject.BABYLON = globalObject.BABYLON || {};
  14832. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14833. }
  14834. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14835. /***/ }),
  14836. /***/ "babylonjs/Misc/observable":
  14837. /*!****************************************************************************************************!*\
  14838. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14839. \****************************************************************************************************/
  14840. /*! no static exports found */
  14841. /***/ (function(module, exports) {
  14842. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  14843. /***/ })
  14844. /******/ });
  14845. });
  14846. //# sourceMappingURL=babylon.gui.js.map