babylon.gui.js 672 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542
  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. })(window, 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_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  323. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  324. /**
  325. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  326. */
  327. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  328. /**
  329. * Instantiates a new advanced dynamic texture instrumentation.
  330. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  331. * @param texture Defines the AdvancedDynamicTexture to instrument
  332. */
  333. function AdvancedDynamicTextureInstrumentation(
  334. /**
  335. * Define the instrumented AdvancedDynamicTexture.
  336. */
  337. texture) {
  338. this.texture = texture;
  339. this._captureRenderTime = false;
  340. this._renderTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  341. this._captureLayoutTime = false;
  342. this._layoutTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  343. // Observers
  344. this._onBeginRenderObserver = null;
  345. this._onEndRenderObserver = null;
  346. this._onBeginLayoutObserver = null;
  347. this._onEndLayoutObserver = null;
  348. }
  349. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  350. // Properties
  351. /**
  352. * Gets the perf counter used to capture render time
  353. */
  354. get: function () {
  355. return this._renderTime;
  356. },
  357. enumerable: true,
  358. configurable: true
  359. });
  360. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  361. /**
  362. * Gets the perf counter used to capture layout time
  363. */
  364. get: function () {
  365. return this._layoutTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  371. /**
  372. * Enable or disable the render time capture
  373. */
  374. get: function () {
  375. return this._captureRenderTime;
  376. },
  377. set: function (value) {
  378. var _this = this;
  379. if (value === this._captureRenderTime) {
  380. return;
  381. }
  382. this._captureRenderTime = value;
  383. if (value) {
  384. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  385. _this._renderTime.beginMonitoring();
  386. });
  387. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  388. _this._renderTime.endMonitoring(true);
  389. });
  390. }
  391. else {
  392. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  393. this._onBeginRenderObserver = null;
  394. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  395. this._onEndRenderObserver = null;
  396. }
  397. },
  398. enumerable: true,
  399. configurable: true
  400. });
  401. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  402. /**
  403. * Enable or disable the layout time capture
  404. */
  405. get: function () {
  406. return this._captureLayoutTime;
  407. },
  408. set: function (value) {
  409. var _this = this;
  410. if (value === this._captureLayoutTime) {
  411. return;
  412. }
  413. this._captureLayoutTime = value;
  414. if (value) {
  415. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  416. _this._layoutTime.beginMonitoring();
  417. });
  418. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  419. _this._layoutTime.endMonitoring(true);
  420. });
  421. }
  422. else {
  423. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  424. this._onBeginLayoutObserver = null;
  425. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  426. this._onEndLayoutObserver = null;
  427. }
  428. },
  429. enumerable: true,
  430. configurable: true
  431. });
  432. /**
  433. * Dispose and release associated resources.
  434. */
  435. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  436. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  437. this._onBeginRenderObserver = null;
  438. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  439. this._onEndRenderObserver = null;
  440. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  441. this._onBeginLayoutObserver = null;
  442. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  443. this._onEndLayoutObserver = null;
  444. this.texture = null;
  445. };
  446. return AdvancedDynamicTextureInstrumentation;
  447. }());
  448. /***/ }),
  449. /***/ "./2D/advancedDynamicTexture.ts":
  450. /*!**************************************!*\
  451. !*** ./2D/advancedDynamicTexture.ts ***!
  452. \**************************************/
  453. /*! exports provided: AdvancedDynamicTexture */
  454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  455. "use strict";
  456. __webpack_require__.r(__webpack_exports__);
  457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  459. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/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. /**
  505. * Define type to string to ensure compatibility across browsers
  506. * Safari doesn't support DataTransfer constructor
  507. */
  508. _this._clipboardData = "";
  509. /**
  510. * Observable event triggered each time an clipboard event is received from the rendering canvas
  511. */
  512. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  513. /**
  514. * Observable event triggered each time a pointer down is intercepted by a control
  515. */
  516. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  517. /**
  518. * Observable event triggered before layout is evaluated
  519. */
  520. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  521. /**
  522. * Observable event triggered after the layout was evaluated
  523. */
  524. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  525. /**
  526. * Observable event triggered before the texture is rendered
  527. */
  528. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  529. /**
  530. * Observable event triggered after the texture was rendered
  531. */
  532. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  533. /**
  534. * Gets or sets a boolean defining if alpha is stored as premultiplied
  535. */
  536. _this.premulAlpha = false;
  537. _this._useInvalidateRectOptimization = true;
  538. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  539. _this._invalidatedRectangle = null;
  540. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  541. /** @hidden */
  542. _this.onClipboardCopy = function (rawEvt) {
  543. var evt = rawEvt;
  544. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  545. _this.onClipboardObservable.notifyObservers(ev);
  546. evt.preventDefault();
  547. };
  548. /** @hidden */
  549. _this.onClipboardCut = function (rawEvt) {
  550. var evt = rawEvt;
  551. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  552. _this.onClipboardObservable.notifyObservers(ev);
  553. evt.preventDefault();
  554. };
  555. /** @hidden */
  556. _this.onClipboardPaste = function (rawEvt) {
  557. var evt = rawEvt;
  558. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  559. _this.onClipboardObservable.notifyObservers(ev);
  560. evt.preventDefault();
  561. };
  562. scene = _this.getScene();
  563. if (!scene || !_this._texture) {
  564. return _this;
  565. }
  566. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  567. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  568. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  569. if (!_this._focusedControl) {
  570. return;
  571. }
  572. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  573. _this._focusedControl.processKeyboard(info.event);
  574. }
  575. info.skipOnPointerObservable = true;
  576. });
  577. _this._rootContainer._link(_this);
  578. _this.hasAlpha = true;
  579. if (!width || !height) {
  580. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  581. _this._onResize();
  582. }
  583. _this._texture.isReady = true;
  584. return _this;
  585. }
  586. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  587. /**
  588. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  589. * Useful when you want more antialiasing
  590. */
  591. get: function () {
  592. return this._renderScale;
  593. },
  594. set: function (value) {
  595. if (value === this._renderScale) {
  596. return;
  597. }
  598. this._renderScale = value;
  599. this._onResize();
  600. },
  601. enumerable: true,
  602. configurable: true
  603. });
  604. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  605. /** Gets or sets the background color */
  606. get: function () {
  607. return this._background;
  608. },
  609. set: function (value) {
  610. if (this._background === value) {
  611. return;
  612. }
  613. this._background = value;
  614. this.markAsDirty();
  615. },
  616. enumerable: true,
  617. configurable: true
  618. });
  619. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  620. /**
  621. * Gets or sets the ideal width used to design controls.
  622. * The GUI will then rescale everything accordingly
  623. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  624. */
  625. get: function () {
  626. return this._idealWidth;
  627. },
  628. set: function (value) {
  629. if (this._idealWidth === value) {
  630. return;
  631. }
  632. this._idealWidth = value;
  633. this.markAsDirty();
  634. this._rootContainer._markAllAsDirty();
  635. },
  636. enumerable: true,
  637. configurable: true
  638. });
  639. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  640. /**
  641. * Gets or sets the ideal height used to design controls.
  642. * The GUI will then rescale everything accordingly
  643. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  644. */
  645. get: function () {
  646. return this._idealHeight;
  647. },
  648. set: function (value) {
  649. if (this._idealHeight === value) {
  650. return;
  651. }
  652. this._idealHeight = value;
  653. this.markAsDirty();
  654. this._rootContainer._markAllAsDirty();
  655. },
  656. enumerable: true,
  657. configurable: true
  658. });
  659. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  660. /**
  661. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  662. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  663. */
  664. get: function () {
  665. return this._useSmallestIdeal;
  666. },
  667. set: function (value) {
  668. if (this._useSmallestIdeal === value) {
  669. return;
  670. }
  671. this._useSmallestIdeal = value;
  672. this.markAsDirty();
  673. this._rootContainer._markAllAsDirty();
  674. },
  675. enumerable: true,
  676. configurable: true
  677. });
  678. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  679. /**
  680. * Gets or sets a boolean indicating if adaptive scaling must be used
  681. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  682. */
  683. get: function () {
  684. return this._renderAtIdealSize;
  685. },
  686. set: function (value) {
  687. if (this._renderAtIdealSize === value) {
  688. return;
  689. }
  690. this._renderAtIdealSize = value;
  691. this._onResize();
  692. },
  693. enumerable: true,
  694. configurable: true
  695. });
  696. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  697. /**
  698. * Gets the underlying layer used to render the texture when in fullscreen mode
  699. */
  700. get: function () {
  701. return this._layerToDispose;
  702. },
  703. enumerable: true,
  704. configurable: true
  705. });
  706. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  707. /**
  708. * Gets the root container control
  709. */
  710. get: function () {
  711. return this._rootContainer;
  712. },
  713. enumerable: true,
  714. configurable: true
  715. });
  716. /**
  717. * Returns an array containing the root container.
  718. * This is mostly used to let the Inspector introspects the ADT
  719. * @returns an array containing the rootContainer
  720. */
  721. AdvancedDynamicTexture.prototype.getChildren = function () {
  722. return [this._rootContainer];
  723. };
  724. /**
  725. * Will return all controls that are inside this texture
  726. * @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
  727. * @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
  728. * @return all child controls
  729. */
  730. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  731. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  732. };
  733. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  734. /**
  735. * Gets or sets the current focused control
  736. */
  737. get: function () {
  738. return this._focusedControl;
  739. },
  740. set: function (control) {
  741. if (this._focusedControl == control) {
  742. return;
  743. }
  744. if (this._focusedControl) {
  745. this._focusedControl.onBlur();
  746. }
  747. if (control) {
  748. control.onFocus();
  749. }
  750. this._focusedControl = control;
  751. },
  752. enumerable: true,
  753. configurable: true
  754. });
  755. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  756. /**
  757. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  758. */
  759. get: function () {
  760. if (!this.layer) {
  761. return true;
  762. }
  763. return (!this.layer.isBackground);
  764. },
  765. set: function (value) {
  766. if (!this.layer) {
  767. return;
  768. }
  769. if (this.layer.isBackground === !value) {
  770. return;
  771. }
  772. this.layer.isBackground = !value;
  773. },
  774. enumerable: true,
  775. configurable: true
  776. });
  777. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  778. /**
  779. * Gets or set information about clipboardData
  780. */
  781. get: function () {
  782. return this._clipboardData;
  783. },
  784. set: function (value) {
  785. this._clipboardData = value;
  786. },
  787. enumerable: true,
  788. configurable: true
  789. });
  790. /**
  791. * Get the current class name of the texture useful for serialization or dynamic coding.
  792. * @returns "AdvancedDynamicTexture"
  793. */
  794. AdvancedDynamicTexture.prototype.getClassName = function () {
  795. return "AdvancedDynamicTexture";
  796. };
  797. /**
  798. * Function used to execute a function on all controls
  799. * @param func defines the function to execute
  800. * @param container defines the container where controls belong. If null the root container will be used
  801. */
  802. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  803. if (!container) {
  804. container = this._rootContainer;
  805. }
  806. func(container);
  807. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  808. var child = _a[_i];
  809. if (child.children) {
  810. this.executeOnAllControls(func, child);
  811. continue;
  812. }
  813. func(child);
  814. }
  815. };
  816. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  817. /**
  818. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  819. */
  820. get: function () {
  821. return this._useInvalidateRectOptimization;
  822. },
  823. set: function (value) {
  824. this._useInvalidateRectOptimization = value;
  825. },
  826. enumerable: true,
  827. configurable: true
  828. });
  829. /**
  830. * Invalidates a rectangle area on the gui texture
  831. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  832. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  833. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  834. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  835. */
  836. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  837. if (!this._useInvalidateRectOptimization) {
  838. return;
  839. }
  840. if (!this._invalidatedRectangle) {
  841. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  842. }
  843. else {
  844. // Compute intersection
  845. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  846. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  847. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  848. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  849. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  850. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  851. }
  852. };
  853. /**
  854. * Marks the texture as dirty forcing a complete update
  855. */
  856. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  857. this._isDirty = true;
  858. };
  859. /**
  860. * Helper function used to create a new style
  861. * @returns a new style
  862. * @see http://doc.babylonjs.com/how_to/gui#styles
  863. */
  864. AdvancedDynamicTexture.prototype.createStyle = function () {
  865. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  866. };
  867. /**
  868. * Adds a new control to the root container
  869. * @param control defines the control to add
  870. * @returns the current texture
  871. */
  872. AdvancedDynamicTexture.prototype.addControl = function (control) {
  873. this._rootContainer.addControl(control);
  874. return this;
  875. };
  876. /**
  877. * Removes a control from the root container
  878. * @param control defines the control to remove
  879. * @returns the current texture
  880. */
  881. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  882. this._rootContainer.removeControl(control);
  883. return this;
  884. };
  885. /**
  886. * Release all resources
  887. */
  888. AdvancedDynamicTexture.prototype.dispose = function () {
  889. var scene = this.getScene();
  890. if (!scene) {
  891. return;
  892. }
  893. this._rootCanvas = null;
  894. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  895. if (this._resizeObserver) {
  896. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  897. }
  898. if (this._pointerMoveObserver) {
  899. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  900. }
  901. if (this._pointerObserver) {
  902. scene.onPointerObservable.remove(this._pointerObserver);
  903. }
  904. if (this._preKeyboardObserver) {
  905. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  906. }
  907. if (this._canvasPointerOutObserver) {
  908. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  909. }
  910. if (this._layerToDispose) {
  911. this._layerToDispose.texture = null;
  912. this._layerToDispose.dispose();
  913. this._layerToDispose = null;
  914. }
  915. this._rootContainer.dispose();
  916. this.onClipboardObservable.clear();
  917. this.onControlPickedObservable.clear();
  918. this.onBeginRenderObservable.clear();
  919. this.onEndRenderObservable.clear();
  920. this.onBeginLayoutObservable.clear();
  921. this.onEndLayoutObservable.clear();
  922. _super.prototype.dispose.call(this);
  923. };
  924. AdvancedDynamicTexture.prototype._onResize = function () {
  925. var scene = this.getScene();
  926. if (!scene) {
  927. return;
  928. }
  929. // Check size
  930. var engine = scene.getEngine();
  931. var textureSize = this.getSize();
  932. var renderWidth = engine.getRenderWidth() * this._renderScale;
  933. var renderHeight = engine.getRenderHeight() * this._renderScale;
  934. if (this._renderAtIdealSize) {
  935. if (this._idealWidth) {
  936. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  937. renderWidth = this._idealWidth;
  938. }
  939. else if (this._idealHeight) {
  940. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  941. renderHeight = this._idealHeight;
  942. }
  943. }
  944. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  945. this.scaleTo(renderWidth, renderHeight);
  946. this.markAsDirty();
  947. if (this._idealWidth || this._idealHeight) {
  948. this._rootContainer._markAllAsDirty();
  949. }
  950. }
  951. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  952. };
  953. /** @hidden */
  954. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  955. var engine = scene.getEngine();
  956. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  957. };
  958. /**
  959. * Get screen coordinates for a vector3
  960. * @param position defines the position to project
  961. * @param worldMatrix defines the world matrix to use
  962. * @returns the projected position
  963. */
  964. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  965. var scene = this.getScene();
  966. if (!scene) {
  967. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  968. }
  969. var globalViewport = this._getGlobalViewport(scene);
  970. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  971. projectedPosition.scaleInPlace(this.renderScale);
  972. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  973. };
  974. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  975. if (this._layerToDispose) {
  976. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  977. return;
  978. }
  979. }
  980. if (this._isFullscreen && this._linkedControls.length) {
  981. var scene = this.getScene();
  982. if (!scene) {
  983. return;
  984. }
  985. var globalViewport = this._getGlobalViewport(scene);
  986. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  987. var control = _a[_i];
  988. if (!control.isVisible) {
  989. continue;
  990. }
  991. var mesh = control._linkedMesh;
  992. if (!mesh || mesh.isDisposed()) {
  993. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  994. control.linkWithMesh(null);
  995. });
  996. continue;
  997. }
  998. var position = mesh.getBoundingInfo().boundingSphere.center;
  999. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1000. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1001. control.notRenderable = true;
  1002. continue;
  1003. }
  1004. control.notRenderable = false;
  1005. // Account for RenderScale.
  1006. projectedPosition.scaleInPlace(this.renderScale);
  1007. control._moveToProjectedPosition(projectedPosition);
  1008. }
  1009. }
  1010. if (!this._isDirty && !this._rootContainer.isDirty) {
  1011. return;
  1012. }
  1013. this._isDirty = false;
  1014. this._render();
  1015. this.update(true, this.premulAlpha);
  1016. };
  1017. AdvancedDynamicTexture.prototype._render = function () {
  1018. var textureSize = this.getSize();
  1019. var renderWidth = textureSize.width;
  1020. var renderHeight = textureSize.height;
  1021. var context = this.getContext();
  1022. context.font = "18px Arial";
  1023. context.strokeStyle = "white";
  1024. // Layout
  1025. this.onBeginLayoutObservable.notifyObservers(this);
  1026. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1027. this._rootContainer._layout(measure, context);
  1028. this.onEndLayoutObservable.notifyObservers(this);
  1029. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1030. // Clear
  1031. if (this._invalidatedRectangle) {
  1032. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1033. }
  1034. else {
  1035. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1036. }
  1037. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1038. if (this._background) {
  1039. context.save();
  1040. context.fillStyle = this._background;
  1041. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1042. context.restore();
  1043. }
  1044. // Render
  1045. this.onBeginRenderObservable.notifyObservers(this);
  1046. this._rootContainer._render(context, this._invalidatedRectangle);
  1047. this.onEndRenderObservable.notifyObservers(this);
  1048. this._invalidatedRectangle = null;
  1049. };
  1050. /** @hidden */
  1051. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1052. if (this._rootCanvas) {
  1053. this._rootCanvas.style.cursor = cursor;
  1054. }
  1055. };
  1056. /** @hidden */
  1057. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1058. this._lastControlDown[pointerId] = control;
  1059. this.onControlPickedObservable.notifyObservers(control);
  1060. };
  1061. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1062. var scene = this.getScene();
  1063. if (!scene) {
  1064. return;
  1065. }
  1066. var engine = scene.getEngine();
  1067. var textureSize = this.getSize();
  1068. if (this._isFullscreen) {
  1069. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1070. var viewport = camera.viewport;
  1071. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1072. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1073. }
  1074. if (this._capturingControl[pointerId]) {
  1075. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1076. return;
  1077. }
  1078. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1079. this._changeCursor("");
  1080. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1081. if (this._lastControlOver[pointerId]) {
  1082. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1083. delete this._lastControlOver[pointerId];
  1084. }
  1085. }
  1086. }
  1087. this._manageFocus();
  1088. };
  1089. /** @hidden */
  1090. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1091. for (var pointerId in list) {
  1092. if (!list.hasOwnProperty(pointerId)) {
  1093. continue;
  1094. }
  1095. var lastControlOver = list[pointerId];
  1096. if (lastControlOver === control) {
  1097. delete list[pointerId];
  1098. }
  1099. }
  1100. };
  1101. /** @hidden */
  1102. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1103. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1104. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1105. };
  1106. /** Attach to all scene events required to support pointer events */
  1107. AdvancedDynamicTexture.prototype.attach = function () {
  1108. var _this = this;
  1109. var scene = this.getScene();
  1110. if (!scene) {
  1111. return;
  1112. }
  1113. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1114. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1115. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1116. return;
  1117. }
  1118. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1119. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1120. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1121. return;
  1122. }
  1123. if (!scene) {
  1124. return;
  1125. }
  1126. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1127. var engine = scene.getEngine();
  1128. if (!camera) {
  1129. tempViewport.x = 0;
  1130. tempViewport.y = 0;
  1131. tempViewport.width = engine.getRenderWidth();
  1132. tempViewport.height = engine.getRenderHeight();
  1133. }
  1134. else {
  1135. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1136. }
  1137. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1138. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1139. _this._shouldBlockPointer = false;
  1140. // Do picking modifies _shouldBlockPointer
  1141. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1142. // Avoid overwriting a true skipOnPointerObservable to false
  1143. if (_this._shouldBlockPointer) {
  1144. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1145. }
  1146. });
  1147. this._attachToOnPointerOut(scene);
  1148. };
  1149. /**
  1150. * Register the clipboard Events onto the canvas
  1151. */
  1152. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1153. self.addEventListener("copy", this.onClipboardCopy, false);
  1154. self.addEventListener("cut", this.onClipboardCut, false);
  1155. self.addEventListener("paste", this.onClipboardPaste, false);
  1156. };
  1157. /**
  1158. * Unregister the clipboard Events from the canvas
  1159. */
  1160. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1161. self.removeEventListener("copy", this.onClipboardCopy);
  1162. self.removeEventListener("cut", this.onClipboardCut);
  1163. self.removeEventListener("paste", this.onClipboardPaste);
  1164. };
  1165. /**
  1166. * Connect the texture to a hosting mesh to enable interactions
  1167. * @param mesh defines the mesh to attach to
  1168. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1169. */
  1170. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1171. var _this = this;
  1172. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1173. var scene = this.getScene();
  1174. if (!scene) {
  1175. return;
  1176. }
  1177. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1178. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1179. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1180. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1181. return;
  1182. }
  1183. var pointerId = pi.event.pointerId || 0;
  1184. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1185. var uv = pi.pickInfo.getTextureCoordinates();
  1186. if (uv) {
  1187. var size = _this.getSize();
  1188. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1189. }
  1190. }
  1191. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1192. if (_this._lastControlDown[pointerId]) {
  1193. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1194. }
  1195. delete _this._lastControlDown[pointerId];
  1196. if (_this.focusedControl) {
  1197. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1198. var canMoveFocus = true;
  1199. if (friendlyControls) {
  1200. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1201. var control = friendlyControls_1[_i];
  1202. // Same host, no need to keep the focus
  1203. if (_this === control._host) {
  1204. continue;
  1205. }
  1206. // Different hosts
  1207. var otherHost = control._host;
  1208. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1209. canMoveFocus = false;
  1210. break;
  1211. }
  1212. }
  1213. }
  1214. if (canMoveFocus) {
  1215. _this.focusedControl = null;
  1216. }
  1217. }
  1218. }
  1219. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1220. if (_this._lastControlOver[pointerId]) {
  1221. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId]);
  1222. }
  1223. delete _this._lastControlOver[pointerId];
  1224. }
  1225. });
  1226. mesh.enablePointerMoveEvents = supportPointerMove;
  1227. this._attachToOnPointerOut(scene);
  1228. };
  1229. /**
  1230. * Move the focus to a specific control
  1231. * @param control defines the control which will receive the focus
  1232. */
  1233. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1234. this.focusedControl = control;
  1235. this._lastPickedControl = control;
  1236. this._blockNextFocusCheck = true;
  1237. };
  1238. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1239. if (this._blockNextFocusCheck) {
  1240. this._blockNextFocusCheck = false;
  1241. this._lastPickedControl = this._focusedControl;
  1242. return;
  1243. }
  1244. // Focus management
  1245. if (this._focusedControl) {
  1246. if (this._focusedControl !== this._lastPickedControl) {
  1247. if (this._lastPickedControl.isFocusInvisible) {
  1248. return;
  1249. }
  1250. this.focusedControl = null;
  1251. }
  1252. }
  1253. };
  1254. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1255. var _this = this;
  1256. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1257. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1258. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1259. }
  1260. delete _this._lastControlOver[pointerEvent.pointerId];
  1261. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1262. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1263. delete _this._lastControlDown[pointerEvent.pointerId];
  1264. }
  1265. });
  1266. };
  1267. // Statics
  1268. /**
  1269. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1270. * @param mesh defines the mesh which will receive the texture
  1271. * @param width defines the texture width (1024 by default)
  1272. * @param height defines the texture height (1024 by default)
  1273. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1274. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1275. * @returns a new AdvancedDynamicTexture
  1276. */
  1277. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1278. if (width === void 0) { width = 1024; }
  1279. if (height === void 0) { height = 1024; }
  1280. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1281. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1282. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1283. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1284. material.backFaceCulling = false;
  1285. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1286. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1287. if (onlyAlphaTesting) {
  1288. material.diffuseTexture = result;
  1289. material.emissiveTexture = result;
  1290. result.hasAlpha = true;
  1291. }
  1292. else {
  1293. material.emissiveTexture = result;
  1294. material.opacityTexture = result;
  1295. }
  1296. mesh.material = material;
  1297. result.attachToMesh(mesh, supportPointerMove);
  1298. return result;
  1299. };
  1300. /**
  1301. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1302. * In this mode the texture will rely on a layer for its rendering.
  1303. * This allows it to be treated like any other layer.
  1304. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1305. * LayerMask is set through advancedTexture.layer.layerMask
  1306. * @param name defines name for the texture
  1307. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1308. * @param scene defines the hsoting scene
  1309. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1310. * @returns a new AdvancedDynamicTexture
  1311. */
  1312. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1313. if (foreground === void 0) { foreground = true; }
  1314. if (scene === void 0) { scene = null; }
  1315. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1316. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1317. // Display
  1318. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1319. layer.texture = result;
  1320. result._layerToDispose = layer;
  1321. result._isFullscreen = true;
  1322. // Attach
  1323. result.attach();
  1324. return result;
  1325. };
  1326. return AdvancedDynamicTexture;
  1327. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1328. /***/ }),
  1329. /***/ "./2D/controls/button.ts":
  1330. /*!*******************************!*\
  1331. !*** ./2D/controls/button.ts ***!
  1332. \*******************************/
  1333. /*! exports provided: Button */
  1334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1335. "use strict";
  1336. __webpack_require__.r(__webpack_exports__);
  1337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1338. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1339. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1340. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1341. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1342. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1343. /**
  1344. * Class used to create 2D buttons
  1345. */
  1346. var Button = /** @class */ (function (_super) {
  1347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1348. /**
  1349. * Creates a new Button
  1350. * @param name defines the name of the button
  1351. */
  1352. function Button(name) {
  1353. var _this = _super.call(this, name) || this;
  1354. _this.name = name;
  1355. _this.thickness = 1;
  1356. _this.isPointerBlocker = true;
  1357. var alphaStore = null;
  1358. _this.pointerEnterAnimation = function () {
  1359. alphaStore = _this.alpha;
  1360. _this.alpha -= 0.1;
  1361. };
  1362. _this.pointerOutAnimation = function () {
  1363. if (alphaStore !== null) {
  1364. _this.alpha = alphaStore;
  1365. }
  1366. };
  1367. _this.pointerDownAnimation = function () {
  1368. _this.scaleX -= 0.05;
  1369. _this.scaleY -= 0.05;
  1370. };
  1371. _this.pointerUpAnimation = function () {
  1372. _this.scaleX += 0.05;
  1373. _this.scaleY += 0.05;
  1374. };
  1375. return _this;
  1376. }
  1377. Object.defineProperty(Button.prototype, "image", {
  1378. /**
  1379. * Returns the image part of the button (if any)
  1380. */
  1381. get: function () {
  1382. return this._image;
  1383. },
  1384. enumerable: true,
  1385. configurable: true
  1386. });
  1387. Object.defineProperty(Button.prototype, "textBlock", {
  1388. /**
  1389. * Returns the image part of the button (if any)
  1390. */
  1391. get: function () {
  1392. return this._textBlock;
  1393. },
  1394. enumerable: true,
  1395. configurable: true
  1396. });
  1397. Button.prototype._getTypeName = function () {
  1398. return "Button";
  1399. };
  1400. // While being a container, the button behaves like a control.
  1401. /** @hidden */
  1402. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1403. if (!this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1404. return false;
  1405. }
  1406. if (!_super.prototype.contains.call(this, x, y)) {
  1407. return false;
  1408. }
  1409. this._processObservables(type, x, y, pointerId, buttonIndex);
  1410. return true;
  1411. };
  1412. /** @hidden */
  1413. Button.prototype._onPointerEnter = function (target) {
  1414. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1415. return false;
  1416. }
  1417. if (this.pointerEnterAnimation) {
  1418. this.pointerEnterAnimation();
  1419. }
  1420. return true;
  1421. };
  1422. /** @hidden */
  1423. Button.prototype._onPointerOut = function (target) {
  1424. if (this.pointerOutAnimation) {
  1425. this.pointerOutAnimation();
  1426. }
  1427. _super.prototype._onPointerOut.call(this, target);
  1428. };
  1429. /** @hidden */
  1430. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1431. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1432. return false;
  1433. }
  1434. if (this.pointerDownAnimation) {
  1435. this.pointerDownAnimation();
  1436. }
  1437. return true;
  1438. };
  1439. /** @hidden */
  1440. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1441. if (this.pointerUpAnimation) {
  1442. this.pointerUpAnimation();
  1443. }
  1444. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1445. };
  1446. // Statics
  1447. /**
  1448. * Creates a new button made with an image and a text
  1449. * @param name defines the name of the button
  1450. * @param text defines the text of the button
  1451. * @param imageUrl defines the url of the image
  1452. * @returns a new Button
  1453. */
  1454. Button.CreateImageButton = function (name, text, imageUrl) {
  1455. var result = new Button(name);
  1456. // Adding text
  1457. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1458. textBlock.textWrapping = true;
  1459. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1460. textBlock.paddingLeft = "20%";
  1461. result.addControl(textBlock);
  1462. // Adding image
  1463. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1464. iconImage.width = "20%";
  1465. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1466. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1467. result.addControl(iconImage);
  1468. // Store
  1469. result._image = iconImage;
  1470. result._textBlock = textBlock;
  1471. return result;
  1472. };
  1473. /**
  1474. * Creates a new button made with an image
  1475. * @param name defines the name of the button
  1476. * @param imageUrl defines the url of the image
  1477. * @returns a new Button
  1478. */
  1479. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1480. var result = new Button(name);
  1481. // Adding image
  1482. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1483. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1484. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1485. result.addControl(iconImage);
  1486. // Store
  1487. result._image = iconImage;
  1488. return result;
  1489. };
  1490. /**
  1491. * Creates a new button made with a text
  1492. * @param name defines the name of the button
  1493. * @param text defines the text of the button
  1494. * @returns a new Button
  1495. */
  1496. Button.CreateSimpleButton = function (name, text) {
  1497. var result = new Button(name);
  1498. // Adding text
  1499. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1500. textBlock.textWrapping = true;
  1501. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1502. result.addControl(textBlock);
  1503. // Store
  1504. result._textBlock = textBlock;
  1505. return result;
  1506. };
  1507. /**
  1508. * Creates a new button made with an image and a centered text
  1509. * @param name defines the name of the button
  1510. * @param text defines the text of the button
  1511. * @param imageUrl defines the url of the image
  1512. * @returns a new Button
  1513. */
  1514. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1515. var result = new Button(name);
  1516. // Adding image
  1517. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1518. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1519. result.addControl(iconImage);
  1520. // Adding text
  1521. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1522. textBlock.textWrapping = true;
  1523. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1524. result.addControl(textBlock);
  1525. // Store
  1526. result._image = iconImage;
  1527. result._textBlock = textBlock;
  1528. return result;
  1529. };
  1530. return Button;
  1531. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1532. /***/ }),
  1533. /***/ "./2D/controls/checkbox.ts":
  1534. /*!*********************************!*\
  1535. !*** ./2D/controls/checkbox.ts ***!
  1536. \*********************************/
  1537. /*! exports provided: Checkbox */
  1538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1539. "use strict";
  1540. __webpack_require__.r(__webpack_exports__);
  1541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1542. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1543. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1544. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1545. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1546. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1547. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1548. /**
  1549. * Class used to represent a 2D checkbox
  1550. */
  1551. var Checkbox = /** @class */ (function (_super) {
  1552. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1553. /**
  1554. * Creates a new CheckBox
  1555. * @param name defines the control name
  1556. */
  1557. function Checkbox(name) {
  1558. var _this = _super.call(this, name) || this;
  1559. _this.name = name;
  1560. _this._isChecked = false;
  1561. _this._background = "black";
  1562. _this._checkSizeRatio = 0.8;
  1563. _this._thickness = 1;
  1564. /**
  1565. * Observable raised when isChecked property changes
  1566. */
  1567. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1568. _this.isPointerBlocker = true;
  1569. return _this;
  1570. }
  1571. Object.defineProperty(Checkbox.prototype, "thickness", {
  1572. /** Gets or sets border thickness */
  1573. get: function () {
  1574. return this._thickness;
  1575. },
  1576. set: function (value) {
  1577. if (this._thickness === value) {
  1578. return;
  1579. }
  1580. this._thickness = value;
  1581. this._markAsDirty();
  1582. },
  1583. enumerable: true,
  1584. configurable: true
  1585. });
  1586. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1587. /** Gets or sets a value indicating the ratio between overall size and check size */
  1588. get: function () {
  1589. return this._checkSizeRatio;
  1590. },
  1591. set: function (value) {
  1592. value = Math.max(Math.min(1, value), 0);
  1593. if (this._checkSizeRatio === value) {
  1594. return;
  1595. }
  1596. this._checkSizeRatio = value;
  1597. this._markAsDirty();
  1598. },
  1599. enumerable: true,
  1600. configurable: true
  1601. });
  1602. Object.defineProperty(Checkbox.prototype, "background", {
  1603. /** Gets or sets background color */
  1604. get: function () {
  1605. return this._background;
  1606. },
  1607. set: function (value) {
  1608. if (this._background === value) {
  1609. return;
  1610. }
  1611. this._background = value;
  1612. this._markAsDirty();
  1613. },
  1614. enumerable: true,
  1615. configurable: true
  1616. });
  1617. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1618. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1619. get: function () {
  1620. return this._isChecked;
  1621. },
  1622. set: function (value) {
  1623. if (this._isChecked === value) {
  1624. return;
  1625. }
  1626. this._isChecked = value;
  1627. this._markAsDirty();
  1628. this.onIsCheckedChangedObservable.notifyObservers(value);
  1629. },
  1630. enumerable: true,
  1631. configurable: true
  1632. });
  1633. Checkbox.prototype._getTypeName = function () {
  1634. return "Checkbox";
  1635. };
  1636. /** @hidden */
  1637. Checkbox.prototype._draw = function (context) {
  1638. context.save();
  1639. this._applyStates(context);
  1640. var actualWidth = this._currentMeasure.width - this._thickness;
  1641. var actualHeight = this._currentMeasure.height - this._thickness;
  1642. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1643. context.shadowColor = this.shadowColor;
  1644. context.shadowBlur = this.shadowBlur;
  1645. context.shadowOffsetX = this.shadowOffsetX;
  1646. context.shadowOffsetY = this.shadowOffsetY;
  1647. }
  1648. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1649. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1650. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1651. context.shadowBlur = 0;
  1652. context.shadowOffsetX = 0;
  1653. context.shadowOffsetY = 0;
  1654. }
  1655. if (this._isChecked) {
  1656. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1657. var offsetWidth = actualWidth * this._checkSizeRatio;
  1658. var offseHeight = actualHeight * this._checkSizeRatio;
  1659. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1660. }
  1661. context.strokeStyle = this.color;
  1662. context.lineWidth = this._thickness;
  1663. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1664. context.restore();
  1665. };
  1666. // Events
  1667. /** @hidden */
  1668. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1669. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1670. return false;
  1671. }
  1672. this.isChecked = !this.isChecked;
  1673. return true;
  1674. };
  1675. /**
  1676. * Utility function to easily create a checkbox with a header
  1677. * @param title defines the label to use for the header
  1678. * @param onValueChanged defines the callback to call when value changes
  1679. * @returns a StackPanel containing the checkbox and a textBlock
  1680. */
  1681. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1682. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1683. panel.isVertical = false;
  1684. panel.height = "30px";
  1685. var checkbox = new Checkbox();
  1686. checkbox.width = "20px";
  1687. checkbox.height = "20px";
  1688. checkbox.isChecked = true;
  1689. checkbox.color = "green";
  1690. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1691. panel.addControl(checkbox);
  1692. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1693. header.text = title;
  1694. header.width = "180px";
  1695. header.paddingLeft = "5px";
  1696. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1697. header.color = "white";
  1698. panel.addControl(header);
  1699. return panel;
  1700. };
  1701. return Checkbox;
  1702. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1703. /***/ }),
  1704. /***/ "./2D/controls/colorpicker.ts":
  1705. /*!************************************!*\
  1706. !*** ./2D/controls/colorpicker.ts ***!
  1707. \************************************/
  1708. /*! exports provided: ColorPicker */
  1709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1710. "use strict";
  1711. __webpack_require__.r(__webpack_exports__);
  1712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1714. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1715. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1716. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1717. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1718. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1719. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1720. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1721. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1722. /** Class used to create color pickers */
  1723. var ColorPicker = /** @class */ (function (_super) {
  1724. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1725. /**
  1726. * Creates a new ColorPicker
  1727. * @param name defines the control name
  1728. */
  1729. function ColorPicker(name) {
  1730. var _this = _super.call(this, name) || this;
  1731. _this.name = name;
  1732. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1733. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1734. _this._pointerStartedOnSquare = false;
  1735. _this._pointerStartedOnWheel = false;
  1736. _this._squareLeft = 0;
  1737. _this._squareTop = 0;
  1738. _this._squareSize = 0;
  1739. _this._h = 360;
  1740. _this._s = 1;
  1741. _this._v = 1;
  1742. /**
  1743. * Observable raised when the value changes
  1744. */
  1745. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1746. // Events
  1747. _this._pointerIsDown = false;
  1748. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1749. _this.size = "200px";
  1750. _this.isPointerBlocker = true;
  1751. return _this;
  1752. }
  1753. Object.defineProperty(ColorPicker.prototype, "value", {
  1754. /** Gets or sets the color of the color picker */
  1755. get: function () {
  1756. return this._value;
  1757. },
  1758. set: function (value) {
  1759. if (this._value.equals(value)) {
  1760. return;
  1761. }
  1762. this._value.copyFrom(value);
  1763. this._RGBtoHSV(this._value, this._tmpColor);
  1764. this._h = this._tmpColor.r;
  1765. this._s = Math.max(this._tmpColor.g, 0.00001);
  1766. this._v = Math.max(this._tmpColor.b, 0.00001);
  1767. this._markAsDirty();
  1768. if (this._value.r <= ColorPicker._Epsilon) {
  1769. this._value.r = 0;
  1770. }
  1771. if (this._value.g <= ColorPicker._Epsilon) {
  1772. this._value.g = 0;
  1773. }
  1774. if (this._value.b <= ColorPicker._Epsilon) {
  1775. this._value.b = 0;
  1776. }
  1777. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1778. this._value.r = 1.0;
  1779. }
  1780. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1781. this._value.g = 1.0;
  1782. }
  1783. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1784. this._value.b = 1.0;
  1785. }
  1786. this.onValueChangedObservable.notifyObservers(this._value);
  1787. },
  1788. enumerable: true,
  1789. configurable: true
  1790. });
  1791. Object.defineProperty(ColorPicker.prototype, "width", {
  1792. /**
  1793. * Gets or sets control width
  1794. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1795. */
  1796. get: function () {
  1797. return this._width.toString(this._host);
  1798. },
  1799. set: function (value) {
  1800. if (this._width.toString(this._host) === value) {
  1801. return;
  1802. }
  1803. if (this._width.fromString(value)) {
  1804. this._height.fromString(value);
  1805. this._markAsDirty();
  1806. }
  1807. },
  1808. enumerable: true,
  1809. configurable: true
  1810. });
  1811. Object.defineProperty(ColorPicker.prototype, "height", {
  1812. /**
  1813. * Gets or sets control height
  1814. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1815. */
  1816. get: function () {
  1817. return this._height.toString(this._host);
  1818. },
  1819. /** Gets or sets control height */
  1820. set: function (value) {
  1821. if (this._height.toString(this._host) === value) {
  1822. return;
  1823. }
  1824. if (this._height.fromString(value)) {
  1825. this._width.fromString(value);
  1826. this._markAsDirty();
  1827. }
  1828. },
  1829. enumerable: true,
  1830. configurable: true
  1831. });
  1832. Object.defineProperty(ColorPicker.prototype, "size", {
  1833. /** Gets or sets control size */
  1834. get: function () {
  1835. return this.width;
  1836. },
  1837. set: function (value) {
  1838. this.width = value;
  1839. },
  1840. enumerable: true,
  1841. configurable: true
  1842. });
  1843. ColorPicker.prototype._getTypeName = function () {
  1844. return "ColorPicker";
  1845. };
  1846. /** @hidden */
  1847. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1848. if (parentMeasure.width < parentMeasure.height) {
  1849. this._currentMeasure.height = parentMeasure.width;
  1850. }
  1851. else {
  1852. this._currentMeasure.width = parentMeasure.height;
  1853. }
  1854. };
  1855. ColorPicker.prototype._updateSquareProps = function () {
  1856. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1857. var wheelThickness = radius * .2;
  1858. var innerDiameter = (radius - wheelThickness) * 2;
  1859. var squareSize = innerDiameter / (Math.sqrt(2));
  1860. var offset = radius - squareSize * .5;
  1861. this._squareLeft = this._currentMeasure.left + offset;
  1862. this._squareTop = this._currentMeasure.top + offset;
  1863. this._squareSize = squareSize;
  1864. };
  1865. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1866. var lgh = context.createLinearGradient(left, top, width + left, top);
  1867. lgh.addColorStop(0, '#fff');
  1868. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1869. context.fillStyle = lgh;
  1870. context.fillRect(left, top, width, height);
  1871. var lgv = context.createLinearGradient(left, top, left, height + top);
  1872. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1873. lgv.addColorStop(1, '#000');
  1874. context.fillStyle = lgv;
  1875. context.fillRect(left, top, width, height);
  1876. };
  1877. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1878. context.beginPath();
  1879. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1880. context.lineWidth = 3;
  1881. context.strokeStyle = '#333333';
  1882. context.stroke();
  1883. context.beginPath();
  1884. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1885. context.lineWidth = 3;
  1886. context.strokeStyle = '#ffffff';
  1887. context.stroke();
  1888. };
  1889. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1890. var canvas = document.createElement("canvas");
  1891. canvas.width = radius * 2;
  1892. canvas.height = radius * 2;
  1893. var context = canvas.getContext("2d");
  1894. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1895. var data = image.data;
  1896. var color = this._tmpColor;
  1897. var maxDistSq = radius * radius;
  1898. var innerRadius = radius - thickness;
  1899. var minDistSq = innerRadius * innerRadius;
  1900. for (var x = -radius; x < radius; x++) {
  1901. for (var y = -radius; y < radius; y++) {
  1902. var distSq = x * x + y * y;
  1903. if (distSq > maxDistSq || distSq < minDistSq) {
  1904. continue;
  1905. }
  1906. var dist = Math.sqrt(distSq);
  1907. var ang = Math.atan2(y, x);
  1908. this._HSVtoRGB(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1909. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1910. data[index] = color.r * 255;
  1911. data[index + 1] = color.g * 255;
  1912. data[index + 2] = color.b * 255;
  1913. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1914. //apply less alpha to bigger color pickers
  1915. var alphaAmount = .2;
  1916. var maxAlpha = .2;
  1917. var minAlpha = .04;
  1918. var lowerRadius = 50;
  1919. var upperRadius = 150;
  1920. if (radius < lowerRadius) {
  1921. alphaAmount = maxAlpha;
  1922. }
  1923. else if (radius > upperRadius) {
  1924. alphaAmount = minAlpha;
  1925. }
  1926. else {
  1927. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1928. }
  1929. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1930. if (alphaRatio < alphaAmount) {
  1931. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1932. }
  1933. else if (alphaRatio > 1 - alphaAmount) {
  1934. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1935. }
  1936. else {
  1937. data[index + 3] = 255;
  1938. }
  1939. }
  1940. }
  1941. context.putImageData(image, 0, 0);
  1942. return canvas;
  1943. };
  1944. ColorPicker.prototype._RGBtoHSV = function (color, result) {
  1945. var r = color.r;
  1946. var g = color.g;
  1947. var b = color.b;
  1948. var max = Math.max(r, g, b);
  1949. var min = Math.min(r, g, b);
  1950. var h = 0;
  1951. var s = 0;
  1952. var v = max;
  1953. var dm = max - min;
  1954. if (max !== 0) {
  1955. s = dm / max;
  1956. }
  1957. if (max != min) {
  1958. if (max == r) {
  1959. h = (g - b) / dm;
  1960. if (g < b) {
  1961. h += 6;
  1962. }
  1963. }
  1964. else if (max == g) {
  1965. h = (b - r) / dm + 2;
  1966. }
  1967. else if (max == b) {
  1968. h = (r - g) / dm + 4;
  1969. }
  1970. h *= 60;
  1971. }
  1972. result.r = h;
  1973. result.g = s;
  1974. result.b = v;
  1975. };
  1976. ColorPicker.prototype._HSVtoRGB = function (hue, saturation, value, result) {
  1977. var chroma = value * saturation;
  1978. var h = hue / 60;
  1979. var x = chroma * (1 - Math.abs((h % 2) - 1));
  1980. var r = 0;
  1981. var g = 0;
  1982. var b = 0;
  1983. if (h >= 0 && h <= 1) {
  1984. r = chroma;
  1985. g = x;
  1986. }
  1987. else if (h >= 1 && h <= 2) {
  1988. r = x;
  1989. g = chroma;
  1990. }
  1991. else if (h >= 2 && h <= 3) {
  1992. g = chroma;
  1993. b = x;
  1994. }
  1995. else if (h >= 3 && h <= 4) {
  1996. g = x;
  1997. b = chroma;
  1998. }
  1999. else if (h >= 4 && h <= 5) {
  2000. r = x;
  2001. b = chroma;
  2002. }
  2003. else if (h >= 5 && h <= 6) {
  2004. r = chroma;
  2005. b = x;
  2006. }
  2007. var m = value - chroma;
  2008. result.set((r + m), (g + m), (b + m));
  2009. };
  2010. /** @hidden */
  2011. ColorPicker.prototype._draw = function (context) {
  2012. context.save();
  2013. this._applyStates(context);
  2014. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2015. var wheelThickness = radius * .2;
  2016. var left = this._currentMeasure.left;
  2017. var top = this._currentMeasure.top;
  2018. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2019. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2020. }
  2021. this._updateSquareProps();
  2022. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2023. context.shadowColor = this.shadowColor;
  2024. context.shadowBlur = this.shadowBlur;
  2025. context.shadowOffsetX = this.shadowOffsetX;
  2026. context.shadowOffsetY = this.shadowOffsetY;
  2027. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2028. }
  2029. context.drawImage(this._colorWheelCanvas, left, top);
  2030. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2031. context.shadowBlur = 0;
  2032. context.shadowOffsetX = 0;
  2033. context.shadowOffsetY = 0;
  2034. }
  2035. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2036. var cx = this._squareLeft + this._squareSize * this._s;
  2037. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2038. this._drawCircle(cx, cy, radius * .04, context);
  2039. var dist = radius - wheelThickness * .5;
  2040. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2041. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2042. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2043. context.restore();
  2044. };
  2045. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2046. if (this._pointerStartedOnWheel) {
  2047. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2048. var centerX = radius + this._currentMeasure.left;
  2049. var centerY = radius + this._currentMeasure.top;
  2050. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2051. }
  2052. else if (this._pointerStartedOnSquare) {
  2053. this._updateSquareProps();
  2054. this._s = (x - this._squareLeft) / this._squareSize;
  2055. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2056. this._s = Math.min(this._s, 1);
  2057. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2058. this._v = Math.min(this._v, 1);
  2059. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2060. }
  2061. this._HSVtoRGB(this._h, this._s, this._v, this._tmpColor);
  2062. this.value = this._tmpColor;
  2063. };
  2064. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2065. this._updateSquareProps();
  2066. var left = this._squareLeft;
  2067. var top = this._squareTop;
  2068. var size = this._squareSize;
  2069. if (x >= left && x <= left + size &&
  2070. y >= top && y <= top + size) {
  2071. return true;
  2072. }
  2073. return false;
  2074. };
  2075. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2076. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2077. var centerX = radius + this._currentMeasure.left;
  2078. var centerY = radius + this._currentMeasure.top;
  2079. var wheelThickness = radius * .2;
  2080. var innerRadius = radius - wheelThickness;
  2081. var radiusSq = radius * radius;
  2082. var innerRadiusSq = innerRadius * innerRadius;
  2083. var dx = x - centerX;
  2084. var dy = y - centerY;
  2085. var distSq = dx * dx + dy * dy;
  2086. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2087. return true;
  2088. }
  2089. return false;
  2090. };
  2091. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2092. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2093. return false;
  2094. }
  2095. this._pointerIsDown = true;
  2096. this._pointerStartedOnSquare = false;
  2097. this._pointerStartedOnWheel = false;
  2098. // Invert transform
  2099. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2100. var x = this._transformedPosition.x;
  2101. var y = this._transformedPosition.y;
  2102. if (this._isPointOnSquare(x, y)) {
  2103. this._pointerStartedOnSquare = true;
  2104. }
  2105. else if (this._isPointOnWheel(x, y)) {
  2106. this._pointerStartedOnWheel = true;
  2107. }
  2108. this._updateValueFromPointer(x, y);
  2109. this._host._capturingControl[pointerId] = this;
  2110. return true;
  2111. };
  2112. ColorPicker.prototype._onPointerMove = function (target, coordinates) {
  2113. // Invert transform
  2114. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2115. var x = this._transformedPosition.x;
  2116. var y = this._transformedPosition.y;
  2117. if (this._pointerIsDown) {
  2118. this._updateValueFromPointer(x, y);
  2119. }
  2120. _super.prototype._onPointerMove.call(this, target, coordinates);
  2121. };
  2122. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2123. this._pointerIsDown = false;
  2124. delete this._host._capturingControl[pointerId];
  2125. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2126. };
  2127. /**
  2128. * This function expands the color picker by creating a color picker dialog with manual
  2129. * color value input and the ability to save colors into an array to be used later in
  2130. * subsequent launches of the dialogue.
  2131. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2132. * @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.
  2133. * @returns picked color as a hex string and the saved colors array as hex strings.
  2134. */
  2135. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2136. return new Promise(function (resolve, reject) {
  2137. // Default options
  2138. options.pickerWidth = options.pickerWidth || "640px";
  2139. options.pickerHeight = options.pickerHeight || "400px";
  2140. options.headerHeight = options.headerHeight || "35px";
  2141. options.lastColor = options.lastColor || "#000000";
  2142. options.swatchLimit = options.swatchLimit || 20;
  2143. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2144. // Window size settings
  2145. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2146. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2147. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2148. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2149. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2150. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2151. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2152. // Button Colors
  2153. var buttonColor = "#c0c0c0";
  2154. var buttonBackgroundColor = "#535353";
  2155. var buttonBackgroundHoverColor = "#414141";
  2156. var buttonBackgroundClickColor = "515151";
  2157. var buttonDisabledColor = "#555555";
  2158. var buttonDisabledBackgroundColor = "#454545";
  2159. var currentSwatchesOutlineColor = "#404040";
  2160. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2161. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2162. var iconColorDark = "#aaaaaa";
  2163. var iconColorLight = "#ffffff";
  2164. var closeIconColor;
  2165. // Button settings
  2166. var buttonFontSize;
  2167. var butEdit;
  2168. var buttonWidth;
  2169. var buttonHeight;
  2170. // Input Text Colors
  2171. var inputFieldLabels = ["R", "G", "B"];
  2172. var inputTextBackgroundColor = "#454545";
  2173. var inputTextColor = "#f0f0f0";
  2174. // This is the current color as set by either the picker or by entering a value
  2175. var currentColor;
  2176. // This int is used for naming swatches and serves as the index for calling them from the list
  2177. var swatchNumber;
  2178. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2179. var swatchDrawer;
  2180. var editSwatchMode = false;
  2181. // Color InputText fields that will be updated upon value change
  2182. var picker;
  2183. var rValInt;
  2184. var gValInt;
  2185. var bValInt;
  2186. var rValDec;
  2187. var gValDec;
  2188. var bValDec;
  2189. var hexVal;
  2190. var newSwatch;
  2191. var lastVal;
  2192. var activeField;
  2193. /**
  2194. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2195. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2196. * are will receive no update. This is to prevent the input from the user being overwritten.
  2197. */
  2198. function updateValues(value, inputField) {
  2199. activeField = inputField;
  2200. var pickedColor = value.toHexString();
  2201. newSwatch.background = pickedColor;
  2202. if (rValInt.name != activeField) {
  2203. rValInt.text = Math.floor(value.r * 255).toString();
  2204. }
  2205. if (gValInt.name != activeField) {
  2206. gValInt.text = Math.floor(value.g * 255).toString();
  2207. }
  2208. if (bValInt.name != activeField) {
  2209. bValInt.text = Math.floor(value.b * 255).toString();
  2210. }
  2211. if (rValDec.name != activeField) {
  2212. rValDec.text = value.r.toString();
  2213. }
  2214. if (gValDec.name != activeField) {
  2215. gValDec.text = value.g.toString();
  2216. }
  2217. if (bValDec.name != activeField) {
  2218. bValDec.text = value.b.toString();
  2219. }
  2220. if (hexVal.name != activeField) {
  2221. var minusPound = pickedColor.split("#");
  2222. hexVal.text = minusPound[1];
  2223. }
  2224. if (picker.name != activeField) {
  2225. picker.value = value;
  2226. }
  2227. }
  2228. // 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.
  2229. function updateInt(field, channel) {
  2230. var newValue = field.text;
  2231. var checkVal = /[^0-9]/g.test(newValue);
  2232. if (checkVal) {
  2233. field.text = lastVal;
  2234. return;
  2235. }
  2236. else {
  2237. if (newValue != "") {
  2238. if (Math.floor(parseInt(newValue)) < 0) {
  2239. newValue = "0";
  2240. }
  2241. else if (Math.floor(parseInt(newValue)) > 255) {
  2242. newValue = "255";
  2243. }
  2244. else if (isNaN(parseInt(newValue))) {
  2245. newValue = "0";
  2246. }
  2247. }
  2248. if (activeField == field.name) {
  2249. lastVal = newValue;
  2250. }
  2251. }
  2252. if (newValue != "") {
  2253. newValue = parseInt(newValue).toString();
  2254. field.text = newValue;
  2255. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2256. if (activeField == field.name) {
  2257. if (channel == "r") {
  2258. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2259. }
  2260. else if (channel == "g") {
  2261. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2262. }
  2263. else {
  2264. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2265. }
  2266. }
  2267. }
  2268. }
  2269. // 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.
  2270. function updateFloat(field, channel) {
  2271. var newValue = field.text;
  2272. var checkVal = /[^0-9\.]/g.test(newValue);
  2273. if (checkVal) {
  2274. field.text = lastVal;
  2275. return;
  2276. }
  2277. else {
  2278. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2279. if (parseFloat(newValue) < 0.0) {
  2280. newValue = "0.0";
  2281. }
  2282. else if (parseFloat(newValue) > 1.0) {
  2283. newValue = "1.0";
  2284. }
  2285. else if (isNaN(parseFloat(newValue))) {
  2286. newValue = "0.0";
  2287. }
  2288. }
  2289. if (activeField == field.name) {
  2290. lastVal = newValue;
  2291. }
  2292. }
  2293. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2294. newValue = parseFloat(newValue).toString();
  2295. field.text = newValue;
  2296. }
  2297. else {
  2298. newValue = "0.0";
  2299. }
  2300. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2301. if (activeField == field.name) {
  2302. if (channel == "r") {
  2303. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2304. }
  2305. else if (channel == "g") {
  2306. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2307. }
  2308. else {
  2309. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2310. }
  2311. }
  2312. }
  2313. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2314. function deleteSwatch(index) {
  2315. if (options.savedColors) {
  2316. options.savedColors.splice(index, 1);
  2317. }
  2318. if (options.savedColors && options.savedColors.length == 0) {
  2319. setEditButtonVisibility(false);
  2320. editSwatchMode = false;
  2321. }
  2322. }
  2323. // Creates and styles an individual swatch when updateSwatches is called.
  2324. function createSwatch() {
  2325. if (options.savedColors && options.savedColors[swatchNumber]) {
  2326. if (editSwatchMode) {
  2327. var icon = "b";
  2328. }
  2329. else {
  2330. var icon = "";
  2331. }
  2332. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2333. swatch.fontFamily = "BabylonJSglyphs";
  2334. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2335. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2336. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2337. if (swatchLuminence > luminanceLimit) {
  2338. swatch.color = iconColorDark;
  2339. }
  2340. else {
  2341. swatch.color = iconColorLight;
  2342. }
  2343. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2344. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2345. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2346. swatch.background = options.savedColors[swatchNumber];
  2347. swatch.thickness = 2;
  2348. var metadata_1 = swatchNumber;
  2349. swatch.pointerDownAnimation = function () {
  2350. swatch.thickness = 4;
  2351. };
  2352. swatch.pointerUpAnimation = function () {
  2353. swatch.thickness = 3;
  2354. };
  2355. swatch.pointerEnterAnimation = function () {
  2356. swatch.thickness = 3;
  2357. };
  2358. swatch.pointerOutAnimation = function () {
  2359. swatch.thickness = 2;
  2360. };
  2361. swatch.onPointerClickObservable.add(function () {
  2362. if (!editSwatchMode) {
  2363. if (options.savedColors) {
  2364. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2365. }
  2366. }
  2367. else {
  2368. deleteSwatch(metadata_1);
  2369. updateSwatches("", butSave);
  2370. }
  2371. });
  2372. return swatch;
  2373. }
  2374. else {
  2375. return null;
  2376. }
  2377. }
  2378. // Mode switch to render button text and close symbols on swatch controls
  2379. function editSwatches(mode) {
  2380. if (mode !== undefined) {
  2381. editSwatchMode = mode;
  2382. }
  2383. if (editSwatchMode) {
  2384. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2385. var thisButton = swatchDrawer.children[i];
  2386. thisButton.textBlock.text = "b";
  2387. }
  2388. if (butEdit !== undefined) {
  2389. butEdit.textBlock.text = "Done";
  2390. }
  2391. }
  2392. else {
  2393. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2394. var thisButton = swatchDrawer.children[i];
  2395. thisButton.textBlock.text = "";
  2396. }
  2397. if (butEdit !== undefined) {
  2398. butEdit.textBlock.text = "Edit";
  2399. }
  2400. }
  2401. }
  2402. /**
  2403. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2404. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2405. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2406. * saved colors there are and how many can be stored per row.
  2407. */
  2408. function updateSwatches(color, button) {
  2409. if (options.savedColors) {
  2410. if (color != "") {
  2411. options.savedColors.push(color);
  2412. }
  2413. swatchNumber = 0;
  2414. swatchDrawer.clearControls();
  2415. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2416. if (rowCount == 0) {
  2417. var gutterCount = 0;
  2418. }
  2419. else {
  2420. var gutterCount = rowCount + 1;
  2421. }
  2422. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2423. var currentRows = swatchDrawer.rowCount;
  2424. for (var i = 0; i < currentRows; i++) {
  2425. swatchDrawer.removeRowDefinition(0);
  2426. }
  2427. for (var i = 0; i < rowCount + gutterCount; i++) {
  2428. if (i % 2) {
  2429. swatchDrawer.addRowDefinition(swatchSize, true);
  2430. }
  2431. else {
  2432. swatchDrawer.addRowDefinition(gutterSize, true);
  2433. }
  2434. }
  2435. }
  2436. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2437. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2438. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2439. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2440. var totalButtonsThisRow = options.numSwatchesPerLine;
  2441. }
  2442. else {
  2443. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2444. }
  2445. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2446. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2447. if (x > options.numSwatchesPerLine) {
  2448. continue;
  2449. }
  2450. var swatch = createSwatch();
  2451. if (swatch != null) {
  2452. swatchDrawer.addControl(swatch, y, w);
  2453. w += 2;
  2454. swatchNumber++;
  2455. }
  2456. else {
  2457. continue;
  2458. }
  2459. }
  2460. }
  2461. if (options.savedColors.length >= options.swatchLimit) {
  2462. disableButton(button, true);
  2463. }
  2464. else {
  2465. disableButton(button, false);
  2466. }
  2467. }
  2468. }
  2469. // Shows or hides edit swatches button depending on if there are saved swatches
  2470. function setEditButtonVisibility(enableButton) {
  2471. if (enableButton) {
  2472. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2473. butEdit.width = buttonWidth;
  2474. butEdit.height = buttonHeight;
  2475. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2476. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2477. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2478. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2479. butEdit.thickness = 2;
  2480. butEdit.color = buttonColor;
  2481. butEdit.fontSize = buttonFontSize;
  2482. butEdit.background = buttonBackgroundColor;
  2483. butEdit.onPointerEnterObservable.add(function () {
  2484. butEdit.background = buttonBackgroundHoverColor;
  2485. });
  2486. butEdit.onPointerOutObservable.add(function () {
  2487. butEdit.background = buttonBackgroundColor;
  2488. });
  2489. butEdit.pointerDownAnimation = function () {
  2490. butEdit.background = buttonBackgroundClickColor;
  2491. };
  2492. butEdit.pointerUpAnimation = function () {
  2493. butEdit.background = buttonBackgroundHoverColor;
  2494. };
  2495. butEdit.onPointerClickObservable.add(function () {
  2496. if (editSwatchMode) {
  2497. editSwatchMode = false;
  2498. }
  2499. else {
  2500. editSwatchMode = true;
  2501. }
  2502. editSwatches();
  2503. });
  2504. pickerGrid.addControl(butEdit, 1, 0);
  2505. }
  2506. else {
  2507. pickerGrid.removeControl(butEdit);
  2508. }
  2509. }
  2510. // Called when the user hits the limit of saved colors in the drawer.
  2511. function disableButton(button, disabled) {
  2512. if (disabled) {
  2513. button.color = buttonDisabledColor;
  2514. button.background = buttonDisabledBackgroundColor;
  2515. }
  2516. else {
  2517. button.color = buttonColor;
  2518. button.background = buttonBackgroundColor;
  2519. }
  2520. }
  2521. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2522. function closePicker(color) {
  2523. if (options.savedColors && options.savedColors.length > 0) {
  2524. resolve({
  2525. savedColors: options.savedColors,
  2526. pickedColor: color
  2527. });
  2528. }
  2529. else {
  2530. resolve({
  2531. pickedColor: color
  2532. });
  2533. }
  2534. advancedTexture.removeControl(dialogContainer);
  2535. }
  2536. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2537. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2538. dialogContainer.name = "Dialog Container";
  2539. dialogContainer.width = options.pickerWidth;
  2540. if (options.savedColors) {
  2541. dialogContainer.height = containerSize;
  2542. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2543. dialogContainer.addRowDefinition(topRow, false);
  2544. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2545. }
  2546. else {
  2547. dialogContainer.height = options.pickerHeight;
  2548. dialogContainer.addRowDefinition(1.0, false);
  2549. }
  2550. advancedTexture.addControl(dialogContainer);
  2551. // Swatch drawer which contains all saved color buttons
  2552. if (options.savedColors) {
  2553. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2554. swatchDrawer.name = "Swatch Drawer";
  2555. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2556. swatchDrawer.background = buttonBackgroundColor;
  2557. swatchDrawer.width = options.pickerWidth;
  2558. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2559. if (initialRows == 0) {
  2560. var gutterCount = 0;
  2561. }
  2562. else {
  2563. var gutterCount = initialRows + 1;
  2564. }
  2565. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2566. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2567. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2568. if (i % 2 != 0) {
  2569. swatchDrawer.addRowDefinition(swatchSize, true);
  2570. }
  2571. else {
  2572. swatchDrawer.addRowDefinition(gutterSize, true);
  2573. }
  2574. }
  2575. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2576. if (i % 2 != 0) {
  2577. swatchDrawer.addColumnDefinition(swatchSize, true);
  2578. }
  2579. else {
  2580. swatchDrawer.addColumnDefinition(gutterSize, true);
  2581. }
  2582. }
  2583. dialogContainer.addControl(swatchDrawer, 1, 0);
  2584. }
  2585. // Picker container
  2586. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2587. pickerPanel.name = "Picker Panel";
  2588. pickerPanel.height = options.pickerHeight;
  2589. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2590. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2591. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2592. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2593. dialogContainer.addControl(pickerPanel, 0, 0);
  2594. // Picker container header
  2595. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2596. header.name = "Dialogue Header Bar";
  2597. header.background = "#cccccc";
  2598. header.thickness = 0;
  2599. pickerPanel.addControl(header, 0, 0);
  2600. // Header close button
  2601. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2602. closeButton.fontFamily = "BabylonJSglyphs";
  2603. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2604. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2605. closeButton.color = closeIconColor.toHexString();
  2606. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2607. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2608. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2609. closeButton.height = closeButton.width = options.headerHeight;
  2610. closeButton.background = header.background;
  2611. closeButton.thickness = 0;
  2612. closeButton.pointerDownAnimation = function () {
  2613. };
  2614. closeButton.pointerUpAnimation = function () {
  2615. closeButton.background = header.background;
  2616. };
  2617. closeButton.pointerEnterAnimation = function () {
  2618. closeButton.color = header.background;
  2619. closeButton.background = "red";
  2620. };
  2621. closeButton.pointerOutAnimation = function () {
  2622. closeButton.color = closeIconColor.toHexString();
  2623. closeButton.background = header.background;
  2624. };
  2625. closeButton.onPointerClickObservable.add(function () {
  2626. closePicker(currentSwatch.background);
  2627. });
  2628. pickerPanel.addControl(closeButton, 0, 0);
  2629. // Dialog container body
  2630. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2631. dialogBody.name = "Dialogue Body";
  2632. dialogBody.background = buttonBackgroundColor;
  2633. var dialogBodyCols = [0.4375, 0.5625];
  2634. dialogBody.addRowDefinition(1.0, false);
  2635. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2636. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2637. pickerPanel.addControl(dialogBody, 1, 0);
  2638. // Picker grid
  2639. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2640. pickerGrid.name = "Picker Grid";
  2641. pickerGrid.addRowDefinition(0.85, false);
  2642. pickerGrid.addRowDefinition(0.15, false);
  2643. dialogBody.addControl(pickerGrid, 0, 0);
  2644. // Picker control
  2645. picker = new ColorPicker();
  2646. picker.name = "GUI Color Picker";
  2647. if (options.pickerHeight < options.pickerWidth) {
  2648. picker.width = 0.89;
  2649. }
  2650. else {
  2651. picker.height = 0.89;
  2652. }
  2653. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2654. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2655. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2656. picker.onPointerDownObservable.add(function () {
  2657. activeField = picker.name;
  2658. lastVal = "";
  2659. editSwatches(false);
  2660. });
  2661. picker.onValueChangedObservable.add(function (value) {
  2662. if (activeField == picker.name) {
  2663. updateValues(value, picker.name);
  2664. }
  2665. });
  2666. pickerGrid.addControl(picker, 0, 0);
  2667. // Picker body right quarant
  2668. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2669. pickerBodyRight.name = "Dialogue Right Half";
  2670. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2671. var pickerBodyRightRows = [0.514, 0.486];
  2672. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2673. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2674. dialogBody.addControl(pickerBodyRight, 1, 1);
  2675. // Picker container swatches and buttons
  2676. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2677. pickerSwatchesButtons.name = "Swatches and Buttons";
  2678. var pickerButtonsCol = [0.417, 0.583];
  2679. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2680. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2681. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2682. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2683. // Picker Swatches quadrant
  2684. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2685. pickerSwatches.name = "New and Current Swatches";
  2686. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2687. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2688. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2689. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2690. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2691. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2692. // Active swatches
  2693. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2694. activeSwatches.name = "Active Swatches";
  2695. activeSwatches.width = 0.67;
  2696. activeSwatches.addRowDefinition(0.5, false);
  2697. activeSwatches.addRowDefinition(0.5, false);
  2698. pickerSwatches.addControl(activeSwatches, 2, 0);
  2699. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2700. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2701. if (options.pickerWidth > options.pickerHeight) {
  2702. var labelTextSize = labelHeight;
  2703. }
  2704. else {
  2705. var labelTextSize = labelWidth;
  2706. }
  2707. // New color swatch and previous color button
  2708. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2709. newText.text = "new";
  2710. newText.name = "New Color Label";
  2711. newText.color = buttonColor;
  2712. newText.fontSize = labelTextSize;
  2713. pickerSwatches.addControl(newText, 1, 0);
  2714. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2715. newSwatch.name = "New Color Swatch";
  2716. newSwatch.background = options.lastColor;
  2717. newSwatch.thickness = 0;
  2718. activeSwatches.addControl(newSwatch, 0, 0);
  2719. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2720. currentSwatch.background = options.lastColor;
  2721. currentSwatch.thickness = 0;
  2722. currentSwatch.onPointerClickObservable.add(function () {
  2723. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2724. updateValues(revertColor, currentSwatch.name);
  2725. editSwatches(false);
  2726. });
  2727. currentSwatch.pointerDownAnimation = function () { };
  2728. currentSwatch.pointerUpAnimation = function () { };
  2729. currentSwatch.pointerEnterAnimation = function () { };
  2730. currentSwatch.pointerOutAnimation = function () { };
  2731. activeSwatches.addControl(currentSwatch, 1, 0);
  2732. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2733. swatchOutline.name = "Swatch Outline";
  2734. swatchOutline.width = 0.67;
  2735. swatchOutline.thickness = 2;
  2736. swatchOutline.color = currentSwatchesOutlineColor;
  2737. swatchOutline.isHitTestVisible = false;
  2738. pickerSwatches.addControl(swatchOutline, 2, 0);
  2739. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2740. currentText.name = "Current Color Label";
  2741. currentText.text = "current";
  2742. currentText.color = buttonColor;
  2743. currentText.fontSize = labelTextSize;
  2744. pickerSwatches.addControl(currentText, 3, 0);
  2745. // Buttons grid
  2746. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2747. buttonGrid.name = "Button Grid";
  2748. buttonGrid.height = 0.8;
  2749. var buttonGridRows = 1 / 3;
  2750. buttonGrid.addRowDefinition(buttonGridRows, false);
  2751. buttonGrid.addRowDefinition(buttonGridRows, false);
  2752. buttonGrid.addRowDefinition(buttonGridRows, false);
  2753. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2754. // Determine pixel width and height for all buttons from overall panel dimensions
  2755. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2756. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2757. // Determine button type size
  2758. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2759. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2760. }
  2761. else {
  2762. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2763. }
  2764. // Panel Buttons
  2765. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2766. butOK.width = buttonWidth;
  2767. butOK.height = buttonHeight;
  2768. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2769. butOK.thickness = 2;
  2770. butOK.color = buttonColor;
  2771. butOK.fontSize = buttonFontSize;
  2772. butOK.background = buttonBackgroundColor;
  2773. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2774. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2775. butOK.pointerDownAnimation = function () {
  2776. butOK.background = buttonBackgroundClickColor;
  2777. };
  2778. butOK.pointerUpAnimation = function () {
  2779. butOK.background = buttonBackgroundHoverColor;
  2780. };
  2781. butOK.onPointerClickObservable.add(function () {
  2782. editSwatches(false);
  2783. closePicker(newSwatch.background);
  2784. });
  2785. buttonGrid.addControl(butOK, 0, 0);
  2786. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2787. butCancel.width = buttonWidth;
  2788. butCancel.height = buttonHeight;
  2789. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2790. butCancel.thickness = 2;
  2791. butCancel.color = buttonColor;
  2792. butCancel.fontSize = buttonFontSize;
  2793. butCancel.background = buttonBackgroundColor;
  2794. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2795. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2796. butCancel.pointerDownAnimation = function () {
  2797. butCancel.background = buttonBackgroundClickColor;
  2798. };
  2799. butCancel.pointerUpAnimation = function () {
  2800. butCancel.background = buttonBackgroundHoverColor;
  2801. };
  2802. butCancel.onPointerClickObservable.add(function () {
  2803. editSwatches(false);
  2804. closePicker(currentSwatch.background);
  2805. });
  2806. buttonGrid.addControl(butCancel, 1, 0);
  2807. if (options.savedColors) {
  2808. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2809. butSave.width = buttonWidth;
  2810. butSave.height = buttonHeight;
  2811. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2812. butSave.thickness = 2;
  2813. butSave.fontSize = buttonFontSize;
  2814. if (options.savedColors.length < options.swatchLimit) {
  2815. butSave.color = buttonColor;
  2816. butSave.background = buttonBackgroundColor;
  2817. }
  2818. else {
  2819. disableButton(butSave, true);
  2820. }
  2821. butSave.onPointerEnterObservable.add(function () {
  2822. if (options.savedColors) {
  2823. if (options.savedColors.length < options.swatchLimit) {
  2824. butSave.background = buttonBackgroundHoverColor;
  2825. }
  2826. }
  2827. });
  2828. butSave.onPointerOutObservable.add(function () {
  2829. if (options.savedColors) {
  2830. if (options.savedColors.length < options.swatchLimit) {
  2831. butSave.background = buttonBackgroundColor;
  2832. }
  2833. }
  2834. });
  2835. butSave.pointerDownAnimation = function () {
  2836. if (options.savedColors) {
  2837. if (options.savedColors.length < options.swatchLimit) {
  2838. butSave.background = buttonBackgroundClickColor;
  2839. }
  2840. }
  2841. };
  2842. butSave.pointerUpAnimation = function () {
  2843. if (options.savedColors) {
  2844. if (options.savedColors.length < options.swatchLimit) {
  2845. butSave.background = buttonBackgroundHoverColor;
  2846. }
  2847. }
  2848. };
  2849. butSave.onPointerClickObservable.add(function () {
  2850. if (options.savedColors) {
  2851. if (options.savedColors.length == 0) {
  2852. setEditButtonVisibility(true);
  2853. }
  2854. if (options.savedColors.length < options.swatchLimit) {
  2855. updateSwatches(newSwatch.background, butSave);
  2856. }
  2857. editSwatches(false);
  2858. }
  2859. });
  2860. if (options.savedColors.length > 0) {
  2861. setEditButtonVisibility(true);
  2862. }
  2863. buttonGrid.addControl(butSave, 2, 0);
  2864. }
  2865. // Picker color values input
  2866. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2867. pickerColorValues.name = "Dialog Lower Right";
  2868. pickerColorValues.addRowDefinition(0.02, false);
  2869. pickerColorValues.addRowDefinition(0.63, false);
  2870. pickerColorValues.addRowDefinition(0.21, false);
  2871. pickerColorValues.addRowDefinition(0.14, false);
  2872. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2873. // RGB values text boxes
  2874. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2875. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2876. rgbValuesQuadrant.name = "RGB Values";
  2877. rgbValuesQuadrant.width = 0.82;
  2878. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2879. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2880. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2881. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2882. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2883. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2884. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2885. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2886. for (var i = 0; i < inputFieldLabels.length; i++) {
  2887. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2888. labelText.text = inputFieldLabels[i];
  2889. labelText.color = buttonColor;
  2890. labelText.fontSize = buttonFontSize;
  2891. rgbValuesQuadrant.addControl(labelText, i, 0);
  2892. }
  2893. // Input fields for RGB values
  2894. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2895. rValInt.width = 0.83;
  2896. rValInt.height = 0.72;
  2897. rValInt.name = "rIntField";
  2898. rValInt.fontSize = buttonFontSize;
  2899. rValInt.text = (currentColor.r * 255).toString();
  2900. rValInt.color = inputTextColor;
  2901. rValInt.background = inputTextBackgroundColor;
  2902. rValInt.onFocusObservable.add(function () {
  2903. activeField = rValInt.name;
  2904. lastVal = rValInt.text;
  2905. editSwatches(false);
  2906. });
  2907. rValInt.onBlurObservable.add(function () {
  2908. if (rValInt.text == "") {
  2909. rValInt.text = "0";
  2910. }
  2911. updateInt(rValInt, "r");
  2912. if (activeField == rValInt.name) {
  2913. activeField = "";
  2914. }
  2915. });
  2916. rValInt.onTextChangedObservable.add(function () {
  2917. if (activeField == rValInt.name) {
  2918. updateInt(rValInt, "r");
  2919. }
  2920. });
  2921. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2922. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2923. gValInt.width = 0.83;
  2924. gValInt.height = 0.72;
  2925. gValInt.name = "gIntField";
  2926. gValInt.fontSize = buttonFontSize;
  2927. gValInt.text = (currentColor.g * 255).toString();
  2928. gValInt.color = inputTextColor;
  2929. gValInt.background = inputTextBackgroundColor;
  2930. gValInt.onFocusObservable.add(function () {
  2931. activeField = gValInt.name;
  2932. lastVal = gValInt.text;
  2933. editSwatches(false);
  2934. });
  2935. gValInt.onBlurObservable.add(function () {
  2936. if (gValInt.text == "") {
  2937. gValInt.text = "0";
  2938. }
  2939. updateInt(gValInt, "g");
  2940. if (activeField == gValInt.name) {
  2941. activeField = "";
  2942. }
  2943. });
  2944. gValInt.onTextChangedObservable.add(function () {
  2945. if (activeField == gValInt.name) {
  2946. updateInt(gValInt, "g");
  2947. }
  2948. });
  2949. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2950. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2951. bValInt.width = 0.83;
  2952. bValInt.height = 0.72;
  2953. bValInt.name = "bIntField";
  2954. bValInt.fontSize = buttonFontSize;
  2955. bValInt.text = (currentColor.b * 255).toString();
  2956. bValInt.color = inputTextColor;
  2957. bValInt.background = inputTextBackgroundColor;
  2958. bValInt.onFocusObservable.add(function () {
  2959. activeField = bValInt.name;
  2960. lastVal = bValInt.text;
  2961. editSwatches(false);
  2962. });
  2963. bValInt.onBlurObservable.add(function () {
  2964. if (bValInt.text == "") {
  2965. bValInt.text = "0";
  2966. }
  2967. updateInt(bValInt, "b");
  2968. if (activeField == bValInt.name) {
  2969. activeField = "";
  2970. }
  2971. });
  2972. bValInt.onTextChangedObservable.add(function () {
  2973. if (activeField == bValInt.name) {
  2974. updateInt(bValInt, "b");
  2975. }
  2976. });
  2977. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2978. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2979. rValDec.width = 0.95;
  2980. rValDec.height = 0.72;
  2981. rValDec.name = "rDecField";
  2982. rValDec.fontSize = buttonFontSize;
  2983. rValDec.text = currentColor.r.toString();
  2984. rValDec.color = inputTextColor;
  2985. rValDec.background = inputTextBackgroundColor;
  2986. rValDec.onFocusObservable.add(function () {
  2987. activeField = rValDec.name;
  2988. lastVal = rValDec.text;
  2989. editSwatches(false);
  2990. });
  2991. rValDec.onBlurObservable.add(function () {
  2992. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2993. rValDec.text = "0";
  2994. updateFloat(rValDec, "r");
  2995. }
  2996. if (activeField == rValDec.name) {
  2997. activeField = "";
  2998. }
  2999. });
  3000. rValDec.onTextChangedObservable.add(function () {
  3001. if (activeField == rValDec.name) {
  3002. updateFloat(rValDec, "r");
  3003. }
  3004. });
  3005. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3006. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3007. gValDec.width = 0.95;
  3008. gValDec.height = 0.72;
  3009. gValDec.name = "gDecField";
  3010. gValDec.fontSize = buttonFontSize;
  3011. gValDec.text = currentColor.g.toString();
  3012. gValDec.color = inputTextColor;
  3013. gValDec.background = inputTextBackgroundColor;
  3014. gValDec.onFocusObservable.add(function () {
  3015. activeField = gValDec.name;
  3016. lastVal = gValDec.text;
  3017. editSwatches(false);
  3018. });
  3019. gValDec.onBlurObservable.add(function () {
  3020. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3021. gValDec.text = "0";
  3022. updateFloat(gValDec, "g");
  3023. }
  3024. if (activeField == gValDec.name) {
  3025. activeField = "";
  3026. }
  3027. });
  3028. gValDec.onTextChangedObservable.add(function () {
  3029. if (activeField == gValDec.name) {
  3030. updateFloat(gValDec, "g");
  3031. }
  3032. });
  3033. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3034. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3035. bValDec.width = 0.95;
  3036. bValDec.height = 0.72;
  3037. bValDec.name = "bDecField";
  3038. bValDec.fontSize = buttonFontSize;
  3039. bValDec.text = currentColor.b.toString();
  3040. bValDec.color = inputTextColor;
  3041. bValDec.background = inputTextBackgroundColor;
  3042. bValDec.onFocusObservable.add(function () {
  3043. activeField = bValDec.name;
  3044. lastVal = bValDec.text;
  3045. editSwatches(false);
  3046. });
  3047. bValDec.onBlurObservable.add(function () {
  3048. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3049. bValDec.text = "0";
  3050. updateFloat(bValDec, "b");
  3051. }
  3052. if (activeField == bValDec.name) {
  3053. activeField = "";
  3054. }
  3055. });
  3056. bValDec.onTextChangedObservable.add(function () {
  3057. if (activeField == bValDec.name) {
  3058. updateFloat(bValDec, "b");
  3059. }
  3060. });
  3061. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3062. // Hex value input
  3063. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3064. hexValueQuadrant.name = "Hex Value";
  3065. hexValueQuadrant.width = 0.82;
  3066. hexValueQuadrant.addRowDefinition(1.0, false);
  3067. hexValueQuadrant.addColumnDefinition(0.1, false);
  3068. hexValueQuadrant.addColumnDefinition(0.9, false);
  3069. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3070. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3071. labelText.text = "#";
  3072. labelText.color = buttonColor;
  3073. labelText.fontSize = buttonFontSize;
  3074. hexValueQuadrant.addControl(labelText, 0, 0);
  3075. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3076. hexVal.width = 0.96;
  3077. hexVal.height = 0.72;
  3078. hexVal.name = "hexField";
  3079. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3080. hexVal.fontSize = buttonFontSize;
  3081. var minusPound = options.lastColor.split("#");
  3082. hexVal.text = minusPound[1];
  3083. hexVal.color = inputTextColor;
  3084. hexVal.background = inputTextBackgroundColor;
  3085. hexVal.onFocusObservable.add(function () {
  3086. activeField = hexVal.name;
  3087. lastVal = hexVal.text;
  3088. editSwatches(false);
  3089. });
  3090. hexVal.onBlurObservable.add(function () {
  3091. if (hexVal.text.length == 3) {
  3092. var val = hexVal.text.split("");
  3093. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3094. }
  3095. if (hexVal.text == "") {
  3096. hexVal.text = "000000";
  3097. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3098. }
  3099. if (activeField == hexVal.name) {
  3100. activeField = "";
  3101. }
  3102. });
  3103. hexVal.onTextChangedObservable.add(function () {
  3104. var newHexValue = hexVal.text;
  3105. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3106. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3107. hexVal.text = lastVal;
  3108. }
  3109. else {
  3110. if (hexVal.text.length < 6) {
  3111. var leadingZero = 6 - hexVal.text.length;
  3112. for (var i = 0; i < leadingZero; i++) {
  3113. newHexValue = "0" + newHexValue;
  3114. }
  3115. }
  3116. if (hexVal.text.length == 3) {
  3117. var val = hexVal.text.split("");
  3118. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3119. }
  3120. newHexValue = "#" + newHexValue;
  3121. if (activeField == hexVal.name) {
  3122. lastVal = hexVal.text;
  3123. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3124. }
  3125. }
  3126. });
  3127. hexValueQuadrant.addControl(hexVal, 0, 1);
  3128. if (options.savedColors && options.savedColors.length > 0) {
  3129. updateSwatches("", butSave);
  3130. }
  3131. });
  3132. };
  3133. ColorPicker._Epsilon = 0.000001;
  3134. return ColorPicker;
  3135. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3136. /***/ }),
  3137. /***/ "./2D/controls/container.ts":
  3138. /*!**********************************!*\
  3139. !*** ./2D/controls/container.ts ***!
  3140. \**********************************/
  3141. /*! exports provided: Container */
  3142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3143. "use strict";
  3144. __webpack_require__.r(__webpack_exports__);
  3145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3146. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3147. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3148. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3149. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3150. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3151. /**
  3152. * Root class for 2D containers
  3153. * @see http://doc.babylonjs.com/how_to/gui#containers
  3154. */
  3155. var Container = /** @class */ (function (_super) {
  3156. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3157. /**
  3158. * Creates a new Container
  3159. * @param name defines the name of the container
  3160. */
  3161. function Container(name) {
  3162. var _this = _super.call(this, name) || this;
  3163. _this.name = name;
  3164. /** @hidden */
  3165. _this._children = new Array();
  3166. /** @hidden */
  3167. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3168. /** @hidden */
  3169. _this._background = "";
  3170. /** @hidden */
  3171. _this._adaptWidthToChildren = false;
  3172. /** @hidden */
  3173. _this._adaptHeightToChildren = false;
  3174. return _this;
  3175. }
  3176. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3177. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3178. get: function () {
  3179. return this._adaptHeightToChildren;
  3180. },
  3181. set: function (value) {
  3182. if (this._adaptHeightToChildren === value) {
  3183. return;
  3184. }
  3185. this._adaptHeightToChildren = value;
  3186. if (value) {
  3187. this.height = "100%";
  3188. }
  3189. this._markAsDirty();
  3190. },
  3191. enumerable: true,
  3192. configurable: true
  3193. });
  3194. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3195. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3196. get: function () {
  3197. return this._adaptWidthToChildren;
  3198. },
  3199. set: function (value) {
  3200. if (this._adaptWidthToChildren === value) {
  3201. return;
  3202. }
  3203. this._adaptWidthToChildren = value;
  3204. if (value) {
  3205. this.width = "100%";
  3206. }
  3207. this._markAsDirty();
  3208. },
  3209. enumerable: true,
  3210. configurable: true
  3211. });
  3212. Object.defineProperty(Container.prototype, "background", {
  3213. /** Gets or sets background color */
  3214. get: function () {
  3215. return this._background;
  3216. },
  3217. set: function (value) {
  3218. if (this._background === value) {
  3219. return;
  3220. }
  3221. this._background = value;
  3222. this._markAsDirty();
  3223. },
  3224. enumerable: true,
  3225. configurable: true
  3226. });
  3227. Object.defineProperty(Container.prototype, "children", {
  3228. /** Gets the list of children */
  3229. get: function () {
  3230. return this._children;
  3231. },
  3232. enumerable: true,
  3233. configurable: true
  3234. });
  3235. Container.prototype._getTypeName = function () {
  3236. return "Container";
  3237. };
  3238. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3239. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3240. var child = _a[_i];
  3241. child._markMatrixAsDirty();
  3242. }
  3243. };
  3244. /**
  3245. * Gets a child using its name
  3246. * @param name defines the child name to look for
  3247. * @returns the child control if found
  3248. */
  3249. Container.prototype.getChildByName = function (name) {
  3250. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3251. var child = _a[_i];
  3252. if (child.name === name) {
  3253. return child;
  3254. }
  3255. }
  3256. return null;
  3257. };
  3258. /**
  3259. * Gets a child using its type and its name
  3260. * @param name defines the child name to look for
  3261. * @param type defines the child type to look for
  3262. * @returns the child control if found
  3263. */
  3264. Container.prototype.getChildByType = function (name, type) {
  3265. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3266. var child = _a[_i];
  3267. if (child.typeName === type) {
  3268. return child;
  3269. }
  3270. }
  3271. return null;
  3272. };
  3273. /**
  3274. * Search for a specific control in children
  3275. * @param control defines the control to look for
  3276. * @returns true if the control is in child list
  3277. */
  3278. Container.prototype.containsControl = function (control) {
  3279. return this.children.indexOf(control) !== -1;
  3280. };
  3281. /**
  3282. * Adds a new control to the current container
  3283. * @param control defines the control to add
  3284. * @returns the current container
  3285. */
  3286. Container.prototype.addControl = function (control) {
  3287. if (!control) {
  3288. return this;
  3289. }
  3290. var index = this._children.indexOf(control);
  3291. if (index !== -1) {
  3292. return this;
  3293. }
  3294. control._link(this._host);
  3295. control._markAllAsDirty();
  3296. this._reOrderControl(control);
  3297. this._markAsDirty();
  3298. return this;
  3299. };
  3300. /**
  3301. * Removes all controls from the current container
  3302. * @returns the current container
  3303. */
  3304. Container.prototype.clearControls = function () {
  3305. var children = this.children.slice();
  3306. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3307. var child = children_1[_i];
  3308. this.removeControl(child);
  3309. }
  3310. return this;
  3311. };
  3312. /**
  3313. * Removes a control from the current container
  3314. * @param control defines the control to remove
  3315. * @returns the current container
  3316. */
  3317. Container.prototype.removeControl = function (control) {
  3318. var index = this._children.indexOf(control);
  3319. if (index !== -1) {
  3320. this._children.splice(index, 1);
  3321. control.parent = null;
  3322. }
  3323. control.linkWithMesh(null);
  3324. if (this._host) {
  3325. this._host._cleanControlAfterRemoval(control);
  3326. }
  3327. this._markAsDirty();
  3328. return this;
  3329. };
  3330. /** @hidden */
  3331. Container.prototype._reOrderControl = function (control) {
  3332. this.removeControl(control);
  3333. var wasAdded = false;
  3334. for (var index = 0; index < this._children.length; index++) {
  3335. if (this._children[index].zIndex > control.zIndex) {
  3336. this._children.splice(index, 0, control);
  3337. wasAdded = true;
  3338. break;
  3339. }
  3340. }
  3341. if (!wasAdded) {
  3342. this._children.push(control);
  3343. }
  3344. control.parent = this;
  3345. this._markAsDirty();
  3346. };
  3347. /** @hidden */
  3348. Container.prototype._offsetLeft = function (offset) {
  3349. _super.prototype._offsetLeft.call(this, offset);
  3350. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3351. var child = _a[_i];
  3352. child._offsetLeft(offset);
  3353. }
  3354. };
  3355. /** @hidden */
  3356. Container.prototype._offsetTop = function (offset) {
  3357. _super.prototype._offsetTop.call(this, offset);
  3358. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3359. var child = _a[_i];
  3360. child._offsetTop(offset);
  3361. }
  3362. };
  3363. /** @hidden */
  3364. Container.prototype._markAllAsDirty = function () {
  3365. _super.prototype._markAllAsDirty.call(this);
  3366. for (var index = 0; index < this._children.length; index++) {
  3367. this._children[index]._markAllAsDirty();
  3368. }
  3369. };
  3370. /** @hidden */
  3371. Container.prototype._localDraw = function (context) {
  3372. if (this._background) {
  3373. context.save();
  3374. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3375. context.shadowColor = this.shadowColor;
  3376. context.shadowBlur = this.shadowBlur;
  3377. context.shadowOffsetX = this.shadowOffsetX;
  3378. context.shadowOffsetY = this.shadowOffsetY;
  3379. }
  3380. context.fillStyle = this._background;
  3381. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3382. context.restore();
  3383. }
  3384. };
  3385. /** @hidden */
  3386. Container.prototype._link = function (host) {
  3387. _super.prototype._link.call(this, host);
  3388. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3389. var child = _a[_i];
  3390. child._link(host);
  3391. }
  3392. };
  3393. /** @hidden */
  3394. Container.prototype._beforeLayout = function () {
  3395. // Do nothing
  3396. };
  3397. /** @hidden */
  3398. Container.prototype._processMeasures = function (parentMeasure, context) {
  3399. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3400. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3401. this._evaluateClippingState(parentMeasure);
  3402. }
  3403. };
  3404. /** @hidden */
  3405. Container.prototype._layout = function (parentMeasure, context) {
  3406. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3407. return false;
  3408. }
  3409. if (this._isDirty) {
  3410. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3411. }
  3412. var rebuildCount = 0;
  3413. context.save();
  3414. this._applyStates(context);
  3415. this._beforeLayout();
  3416. do {
  3417. var computedWidth = -1;
  3418. var computedHeight = -1;
  3419. this._rebuildLayout = false;
  3420. this._processMeasures(parentMeasure, context);
  3421. if (!this._isClipped) {
  3422. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3423. var child = _a[_i];
  3424. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3425. if (child._layout(this._measureForChildren, context)) {
  3426. if (this.adaptWidthToChildren && child._width.isPixel) {
  3427. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3428. }
  3429. if (this.adaptHeightToChildren && child._height.isPixel) {
  3430. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3431. }
  3432. }
  3433. }
  3434. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3435. if (this.width !== computedWidth + "px") {
  3436. this.width = computedWidth + "px";
  3437. this._rebuildLayout = true;
  3438. }
  3439. }
  3440. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3441. if (this.height !== computedHeight + "px") {
  3442. this.height = computedHeight + "px";
  3443. this._rebuildLayout = true;
  3444. }
  3445. }
  3446. this._postMeasure();
  3447. }
  3448. rebuildCount++;
  3449. } while (this._rebuildLayout && rebuildCount < 3);
  3450. if (rebuildCount >= 3) {
  3451. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3452. }
  3453. context.restore();
  3454. if (this._isDirty) {
  3455. this.invalidateRect();
  3456. this._isDirty = false;
  3457. }
  3458. return true;
  3459. };
  3460. Container.prototype._postMeasure = function () {
  3461. // Do nothing by default
  3462. };
  3463. /** @hidden */
  3464. Container.prototype._draw = function (context, invalidatedRectangle) {
  3465. this._localDraw(context);
  3466. if (this.clipChildren) {
  3467. this._clipForChildren(context);
  3468. }
  3469. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3470. var child = _a[_i];
  3471. // Only redraw parts of the screen that are invalidated
  3472. if (invalidatedRectangle) {
  3473. if (!child._intersectsRect(invalidatedRectangle)) {
  3474. continue;
  3475. }
  3476. }
  3477. child._render(context, invalidatedRectangle);
  3478. }
  3479. };
  3480. /** @hidden */
  3481. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3482. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3483. if (!this.children) {
  3484. return;
  3485. }
  3486. for (var index = 0; index < this.children.length; index++) {
  3487. var item = this.children[index];
  3488. if (!predicate || predicate(item)) {
  3489. results.push(item);
  3490. }
  3491. if (!directDescendantsOnly) {
  3492. item._getDescendants(results, false, predicate);
  3493. }
  3494. }
  3495. };
  3496. /** @hidden */
  3497. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3498. if (!this.isVisible || this.notRenderable) {
  3499. return false;
  3500. }
  3501. if (!_super.prototype.contains.call(this, x, y)) {
  3502. return false;
  3503. }
  3504. // Checking backwards to pick closest first
  3505. for (var index = this._children.length - 1; index >= 0; index--) {
  3506. var child = this._children[index];
  3507. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3508. if (child.hoverCursor) {
  3509. this._host._changeCursor(child.hoverCursor);
  3510. }
  3511. return true;
  3512. }
  3513. }
  3514. if (!this.isHitTestVisible) {
  3515. return false;
  3516. }
  3517. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3518. };
  3519. /** @hidden */
  3520. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3521. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3522. this._measureForChildren.copyFrom(this._currentMeasure);
  3523. };
  3524. /** Releases associated resources */
  3525. Container.prototype.dispose = function () {
  3526. _super.prototype.dispose.call(this);
  3527. for (var index = this.children.length - 1; index >= 0; index--) {
  3528. this.children[index].dispose();
  3529. }
  3530. };
  3531. return Container;
  3532. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3533. /***/ }),
  3534. /***/ "./2D/controls/control.ts":
  3535. /*!********************************!*\
  3536. !*** ./2D/controls/control.ts ***!
  3537. \********************************/
  3538. /*! exports provided: Control */
  3539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3540. "use strict";
  3541. __webpack_require__.r(__webpack_exports__);
  3542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3543. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3544. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3545. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3546. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3547. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3548. /**
  3549. * Root class used for all 2D controls
  3550. * @see http://doc.babylonjs.com/how_to/gui#controls
  3551. */
  3552. var Control = /** @class */ (function () {
  3553. // Functions
  3554. /**
  3555. * Creates a new control
  3556. * @param name defines the name of the control
  3557. */
  3558. function Control(
  3559. /** defines the name of the control */
  3560. name) {
  3561. this.name = name;
  3562. this._alpha = 1;
  3563. this._alphaSet = false;
  3564. this._zIndex = 0;
  3565. /** @hidden */
  3566. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3567. this._fontFamily = "Arial";
  3568. this._fontStyle = "";
  3569. this._fontWeight = "";
  3570. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3571. /** @hidden */
  3572. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3573. /** @hidden */
  3574. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3575. this._color = "";
  3576. this._style = null;
  3577. /** @hidden */
  3578. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3579. /** @hidden */
  3580. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3581. /** @hidden */
  3582. this._isDirty = true;
  3583. /** @hidden */
  3584. this._wasDirty = false;
  3585. /** @hidden */
  3586. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3587. /** @hidden */
  3588. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3589. /** @hidden */
  3590. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3591. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3592. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3593. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3594. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3595. /** @hidden */
  3596. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3597. /** @hidden */
  3598. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3599. this._scaleX = 1.0;
  3600. this._scaleY = 1.0;
  3601. this._rotation = 0;
  3602. this._transformCenterX = 0.5;
  3603. this._transformCenterY = 0.5;
  3604. /** @hidden */
  3605. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3606. /** @hidden */
  3607. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3608. /** @hidden */
  3609. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3610. this._isMatrixDirty = true;
  3611. this._isVisible = true;
  3612. this._isHighlighted = false;
  3613. this._fontSet = false;
  3614. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3615. this._downCount = 0;
  3616. this._enterCount = -1;
  3617. this._doNotRender = false;
  3618. this._downPointerIds = {};
  3619. this._isEnabled = true;
  3620. this._disabledColor = "#9a9a9a";
  3621. /** @hidden */
  3622. this._rebuildLayout = false;
  3623. /** @hidden */
  3624. this._isClipped = false;
  3625. /**
  3626. * Gets or sets an object used to store user defined information for the node
  3627. */
  3628. this.metadata = null;
  3629. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3630. this.isHitTestVisible = true;
  3631. /** Gets or sets a boolean indicating if the control can block pointer events */
  3632. this.isPointerBlocker = false;
  3633. /** Gets or sets a boolean indicating if the control can be focusable */
  3634. this.isFocusInvisible = false;
  3635. /**
  3636. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3637. * 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
  3638. */
  3639. this.clipChildren = true;
  3640. /**
  3641. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3642. */
  3643. this.useBitmapCache = false;
  3644. this._shadowOffsetX = 0;
  3645. this._shadowOffsetY = 0;
  3646. this._shadowBlur = 0;
  3647. this._shadowColor = 'black';
  3648. /** Gets or sets the cursor to use when the control is hovered */
  3649. this.hoverCursor = "";
  3650. /** @hidden */
  3651. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3652. /** @hidden */
  3653. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3654. /**
  3655. * An event triggered when the pointer move over the control.
  3656. */
  3657. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3658. /**
  3659. * An event triggered when the pointer move out of the control.
  3660. */
  3661. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3662. /**
  3663. * An event triggered when the pointer taps the control
  3664. */
  3665. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3666. /**
  3667. * An event triggered when pointer up
  3668. */
  3669. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3670. /**
  3671. * An event triggered when a control is clicked on
  3672. */
  3673. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3674. /**
  3675. * An event triggered when pointer enters the control
  3676. */
  3677. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3678. /**
  3679. * An event triggered when the control is marked as dirty
  3680. */
  3681. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3682. /**
  3683. * An event triggered before drawing the control
  3684. */
  3685. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3686. /**
  3687. * An event triggered after the control was drawn
  3688. */
  3689. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3690. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3691. }
  3692. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3693. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3694. get: function () {
  3695. return this._shadowOffsetX;
  3696. },
  3697. set: function (value) {
  3698. if (this._shadowOffsetX === value) {
  3699. return;
  3700. }
  3701. this._shadowOffsetX = value;
  3702. this._markAsDirty();
  3703. },
  3704. enumerable: true,
  3705. configurable: true
  3706. });
  3707. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3708. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3709. get: function () {
  3710. return this._shadowOffsetY;
  3711. },
  3712. set: function (value) {
  3713. if (this._shadowOffsetY === value) {
  3714. return;
  3715. }
  3716. this._shadowOffsetY = value;
  3717. this._markAsDirty();
  3718. },
  3719. enumerable: true,
  3720. configurable: true
  3721. });
  3722. Object.defineProperty(Control.prototype, "shadowBlur", {
  3723. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3724. get: function () {
  3725. return this._shadowBlur;
  3726. },
  3727. set: function (value) {
  3728. if (this._shadowBlur === value) {
  3729. return;
  3730. }
  3731. this._shadowBlur = value;
  3732. this._markAsDirty();
  3733. },
  3734. enumerable: true,
  3735. configurable: true
  3736. });
  3737. Object.defineProperty(Control.prototype, "shadowColor", {
  3738. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3739. get: function () {
  3740. return this._shadowColor;
  3741. },
  3742. set: function (value) {
  3743. if (this._shadowColor === value) {
  3744. return;
  3745. }
  3746. this._shadowColor = value;
  3747. this._markAsDirty();
  3748. },
  3749. enumerable: true,
  3750. configurable: true
  3751. });
  3752. Object.defineProperty(Control.prototype, "typeName", {
  3753. // Properties
  3754. /** Gets the control type name */
  3755. get: function () {
  3756. return this._getTypeName();
  3757. },
  3758. enumerable: true,
  3759. configurable: true
  3760. });
  3761. /**
  3762. * Get the current class name of the control.
  3763. * @returns current class name
  3764. */
  3765. Control.prototype.getClassName = function () {
  3766. return this._getTypeName();
  3767. };
  3768. Object.defineProperty(Control.prototype, "host", {
  3769. /**
  3770. * Get the hosting AdvancedDynamicTexture
  3771. */
  3772. get: function () {
  3773. return this._host;
  3774. },
  3775. enumerable: true,
  3776. configurable: true
  3777. });
  3778. Object.defineProperty(Control.prototype, "fontOffset", {
  3779. /** Gets or set information about font offsets (used to render and align text) */
  3780. get: function () {
  3781. return this._fontOffset;
  3782. },
  3783. set: function (offset) {
  3784. this._fontOffset = offset;
  3785. },
  3786. enumerable: true,
  3787. configurable: true
  3788. });
  3789. Object.defineProperty(Control.prototype, "alpha", {
  3790. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3791. get: function () {
  3792. return this._alpha;
  3793. },
  3794. set: function (value) {
  3795. if (this._alpha === value) {
  3796. return;
  3797. }
  3798. this._alphaSet = true;
  3799. this._alpha = value;
  3800. this._markAsDirty();
  3801. },
  3802. enumerable: true,
  3803. configurable: true
  3804. });
  3805. Object.defineProperty(Control.prototype, "isHighlighted", {
  3806. /**
  3807. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3808. */
  3809. get: function () {
  3810. return this._isHighlighted;
  3811. },
  3812. set: function (value) {
  3813. if (this._isHighlighted === value) {
  3814. return;
  3815. }
  3816. this._isHighlighted = value;
  3817. this._markAsDirty();
  3818. },
  3819. enumerable: true,
  3820. configurable: true
  3821. });
  3822. Object.defineProperty(Control.prototype, "scaleX", {
  3823. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3824. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3825. */
  3826. get: function () {
  3827. return this._scaleX;
  3828. },
  3829. set: function (value) {
  3830. if (this._scaleX === value) {
  3831. return;
  3832. }
  3833. this._scaleX = value;
  3834. this._markAsDirty();
  3835. this._markMatrixAsDirty();
  3836. },
  3837. enumerable: true,
  3838. configurable: true
  3839. });
  3840. Object.defineProperty(Control.prototype, "scaleY", {
  3841. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3842. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3843. */
  3844. get: function () {
  3845. return this._scaleY;
  3846. },
  3847. set: function (value) {
  3848. if (this._scaleY === value) {
  3849. return;
  3850. }
  3851. this._scaleY = value;
  3852. this._markAsDirty();
  3853. this._markMatrixAsDirty();
  3854. },
  3855. enumerable: true,
  3856. configurable: true
  3857. });
  3858. Object.defineProperty(Control.prototype, "rotation", {
  3859. /** Gets or sets the rotation angle (0 by default)
  3860. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3861. */
  3862. get: function () {
  3863. return this._rotation;
  3864. },
  3865. set: function (value) {
  3866. if (this._rotation === value) {
  3867. return;
  3868. }
  3869. this._rotation = value;
  3870. this._markAsDirty();
  3871. this._markMatrixAsDirty();
  3872. },
  3873. enumerable: true,
  3874. configurable: true
  3875. });
  3876. Object.defineProperty(Control.prototype, "transformCenterY", {
  3877. /** Gets or sets the transformation center on Y axis (0 by default)
  3878. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3879. */
  3880. get: function () {
  3881. return this._transformCenterY;
  3882. },
  3883. set: function (value) {
  3884. if (this._transformCenterY === value) {
  3885. return;
  3886. }
  3887. this._transformCenterY = value;
  3888. this._markAsDirty();
  3889. this._markMatrixAsDirty();
  3890. },
  3891. enumerable: true,
  3892. configurable: true
  3893. });
  3894. Object.defineProperty(Control.prototype, "transformCenterX", {
  3895. /** Gets or sets the transformation center on X axis (0 by default)
  3896. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3897. */
  3898. get: function () {
  3899. return this._transformCenterX;
  3900. },
  3901. set: function (value) {
  3902. if (this._transformCenterX === value) {
  3903. return;
  3904. }
  3905. this._transformCenterX = value;
  3906. this._markAsDirty();
  3907. this._markMatrixAsDirty();
  3908. },
  3909. enumerable: true,
  3910. configurable: true
  3911. });
  3912. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3913. /**
  3914. * Gets or sets the horizontal alignment
  3915. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3916. */
  3917. get: function () {
  3918. return this._horizontalAlignment;
  3919. },
  3920. set: function (value) {
  3921. if (this._horizontalAlignment === value) {
  3922. return;
  3923. }
  3924. this._horizontalAlignment = value;
  3925. this._markAsDirty();
  3926. },
  3927. enumerable: true,
  3928. configurable: true
  3929. });
  3930. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3931. /**
  3932. * Gets or sets the vertical alignment
  3933. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3934. */
  3935. get: function () {
  3936. return this._verticalAlignment;
  3937. },
  3938. set: function (value) {
  3939. if (this._verticalAlignment === value) {
  3940. return;
  3941. }
  3942. this._verticalAlignment = value;
  3943. this._markAsDirty();
  3944. },
  3945. enumerable: true,
  3946. configurable: true
  3947. });
  3948. Object.defineProperty(Control.prototype, "width", {
  3949. /**
  3950. * Gets or sets control width
  3951. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3952. */
  3953. get: function () {
  3954. return this._width.toString(this._host);
  3955. },
  3956. set: function (value) {
  3957. if (this._width.toString(this._host) === value) {
  3958. return;
  3959. }
  3960. if (this._width.fromString(value)) {
  3961. this._markAsDirty();
  3962. }
  3963. },
  3964. enumerable: true,
  3965. configurable: true
  3966. });
  3967. Object.defineProperty(Control.prototype, "widthInPixels", {
  3968. /**
  3969. * Gets control width in pixel
  3970. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3971. */
  3972. get: function () {
  3973. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3974. },
  3975. enumerable: true,
  3976. configurable: true
  3977. });
  3978. Object.defineProperty(Control.prototype, "height", {
  3979. /**
  3980. * Gets or sets control height
  3981. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3982. */
  3983. get: function () {
  3984. return this._height.toString(this._host);
  3985. },
  3986. set: function (value) {
  3987. if (this._height.toString(this._host) === value) {
  3988. return;
  3989. }
  3990. if (this._height.fromString(value)) {
  3991. this._markAsDirty();
  3992. }
  3993. },
  3994. enumerable: true,
  3995. configurable: true
  3996. });
  3997. Object.defineProperty(Control.prototype, "heightInPixels", {
  3998. /**
  3999. * Gets control height in pixel
  4000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4001. */
  4002. get: function () {
  4003. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4004. },
  4005. enumerable: true,
  4006. configurable: true
  4007. });
  4008. Object.defineProperty(Control.prototype, "fontFamily", {
  4009. /** Gets or set font family */
  4010. get: function () {
  4011. if (!this._fontSet) {
  4012. return "";
  4013. }
  4014. return this._fontFamily;
  4015. },
  4016. set: function (value) {
  4017. if (this._fontFamily === value) {
  4018. return;
  4019. }
  4020. this._fontFamily = value;
  4021. this._resetFontCache();
  4022. },
  4023. enumerable: true,
  4024. configurable: true
  4025. });
  4026. Object.defineProperty(Control.prototype, "fontStyle", {
  4027. /** Gets or sets font style */
  4028. get: function () {
  4029. return this._fontStyle;
  4030. },
  4031. set: function (value) {
  4032. if (this._fontStyle === value) {
  4033. return;
  4034. }
  4035. this._fontStyle = value;
  4036. this._resetFontCache();
  4037. },
  4038. enumerable: true,
  4039. configurable: true
  4040. });
  4041. Object.defineProperty(Control.prototype, "fontWeight", {
  4042. /** Gets or sets font weight */
  4043. get: function () {
  4044. return this._fontWeight;
  4045. },
  4046. set: function (value) {
  4047. if (this._fontWeight === value) {
  4048. return;
  4049. }
  4050. this._fontWeight = value;
  4051. this._resetFontCache();
  4052. },
  4053. enumerable: true,
  4054. configurable: true
  4055. });
  4056. Object.defineProperty(Control.prototype, "style", {
  4057. /**
  4058. * Gets or sets style
  4059. * @see http://doc.babylonjs.com/how_to/gui#styles
  4060. */
  4061. get: function () {
  4062. return this._style;
  4063. },
  4064. set: function (value) {
  4065. var _this = this;
  4066. if (this._style) {
  4067. this._style.onChangedObservable.remove(this._styleObserver);
  4068. this._styleObserver = null;
  4069. }
  4070. this._style = value;
  4071. if (this._style) {
  4072. this._styleObserver = this._style.onChangedObservable.add(function () {
  4073. _this._markAsDirty();
  4074. _this._resetFontCache();
  4075. });
  4076. }
  4077. this._markAsDirty();
  4078. this._resetFontCache();
  4079. },
  4080. enumerable: true,
  4081. configurable: true
  4082. });
  4083. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4084. /** @hidden */
  4085. get: function () {
  4086. return this._fontSize.isPercentage;
  4087. },
  4088. enumerable: true,
  4089. configurable: true
  4090. });
  4091. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4092. /** Gets font size in pixels */
  4093. get: function () {
  4094. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4095. if (fontSizeToUse.isPixel) {
  4096. return fontSizeToUse.getValue(this._host);
  4097. }
  4098. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4099. },
  4100. enumerable: true,
  4101. configurable: true
  4102. });
  4103. Object.defineProperty(Control.prototype, "fontSize", {
  4104. /** Gets or sets font size */
  4105. get: function () {
  4106. return this._fontSize.toString(this._host);
  4107. },
  4108. set: function (value) {
  4109. if (this._fontSize.toString(this._host) === value) {
  4110. return;
  4111. }
  4112. if (this._fontSize.fromString(value)) {
  4113. this._markAsDirty();
  4114. this._resetFontCache();
  4115. }
  4116. },
  4117. enumerable: true,
  4118. configurable: true
  4119. });
  4120. Object.defineProperty(Control.prototype, "color", {
  4121. /** Gets or sets foreground color */
  4122. get: function () {
  4123. return this._color;
  4124. },
  4125. set: function (value) {
  4126. if (this._color === value) {
  4127. return;
  4128. }
  4129. this._color = value;
  4130. this._markAsDirty();
  4131. },
  4132. enumerable: true,
  4133. configurable: true
  4134. });
  4135. Object.defineProperty(Control.prototype, "zIndex", {
  4136. /** Gets or sets z index which is used to reorder controls on the z axis */
  4137. get: function () {
  4138. return this._zIndex;
  4139. },
  4140. set: function (value) {
  4141. if (this.zIndex === value) {
  4142. return;
  4143. }
  4144. this._zIndex = value;
  4145. if (this.parent) {
  4146. this.parent._reOrderControl(this);
  4147. }
  4148. },
  4149. enumerable: true,
  4150. configurable: true
  4151. });
  4152. Object.defineProperty(Control.prototype, "notRenderable", {
  4153. /** Gets or sets a boolean indicating if the control can be rendered */
  4154. get: function () {
  4155. return this._doNotRender;
  4156. },
  4157. set: function (value) {
  4158. if (this._doNotRender === value) {
  4159. return;
  4160. }
  4161. this._doNotRender = value;
  4162. this._markAsDirty();
  4163. },
  4164. enumerable: true,
  4165. configurable: true
  4166. });
  4167. Object.defineProperty(Control.prototype, "isVisible", {
  4168. /** Gets or sets a boolean indicating if the control is visible */
  4169. get: function () {
  4170. return this._isVisible;
  4171. },
  4172. set: function (value) {
  4173. if (this._isVisible === value) {
  4174. return;
  4175. }
  4176. this._isVisible = value;
  4177. this._markAsDirty(true);
  4178. },
  4179. enumerable: true,
  4180. configurable: true
  4181. });
  4182. Object.defineProperty(Control.prototype, "isDirty", {
  4183. /** Gets a boolean indicating that the control needs to update its rendering */
  4184. get: function () {
  4185. return this._isDirty;
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. Object.defineProperty(Control.prototype, "linkedMesh", {
  4191. /**
  4192. * Gets the current linked mesh (or null if none)
  4193. */
  4194. get: function () {
  4195. return this._linkedMesh;
  4196. },
  4197. enumerable: true,
  4198. configurable: true
  4199. });
  4200. Object.defineProperty(Control.prototype, "paddingLeft", {
  4201. /**
  4202. * Gets or sets a value indicating the padding to use on the left of the control
  4203. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4204. */
  4205. get: function () {
  4206. return this._paddingLeft.toString(this._host);
  4207. },
  4208. set: function (value) {
  4209. if (this._paddingLeft.fromString(value)) {
  4210. this._markAsDirty();
  4211. }
  4212. },
  4213. enumerable: true,
  4214. configurable: true
  4215. });
  4216. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4217. /**
  4218. * Gets a value indicating the padding in pixels to use on the left of the control
  4219. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4220. */
  4221. get: function () {
  4222. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4223. },
  4224. enumerable: true,
  4225. configurable: true
  4226. });
  4227. Object.defineProperty(Control.prototype, "paddingRight", {
  4228. /**
  4229. * Gets or sets a value indicating the padding to use on the right of the control
  4230. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4231. */
  4232. get: function () {
  4233. return this._paddingRight.toString(this._host);
  4234. },
  4235. set: function (value) {
  4236. if (this._paddingRight.fromString(value)) {
  4237. this._markAsDirty();
  4238. }
  4239. },
  4240. enumerable: true,
  4241. configurable: true
  4242. });
  4243. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4244. /**
  4245. * Gets a value indicating the padding in pixels to use on the right of the control
  4246. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4247. */
  4248. get: function () {
  4249. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4250. },
  4251. enumerable: true,
  4252. configurable: true
  4253. });
  4254. Object.defineProperty(Control.prototype, "paddingTop", {
  4255. /**
  4256. * Gets or sets a value indicating the padding to use on the top of the control
  4257. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4258. */
  4259. get: function () {
  4260. return this._paddingTop.toString(this._host);
  4261. },
  4262. set: function (value) {
  4263. if (this._paddingTop.fromString(value)) {
  4264. this._markAsDirty();
  4265. }
  4266. },
  4267. enumerable: true,
  4268. configurable: true
  4269. });
  4270. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4271. /**
  4272. * Gets a value indicating the padding in pixels to use on the top of the control
  4273. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4274. */
  4275. get: function () {
  4276. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4277. },
  4278. enumerable: true,
  4279. configurable: true
  4280. });
  4281. Object.defineProperty(Control.prototype, "paddingBottom", {
  4282. /**
  4283. * Gets or sets a value indicating the padding to use on the bottom of the control
  4284. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4285. */
  4286. get: function () {
  4287. return this._paddingBottom.toString(this._host);
  4288. },
  4289. set: function (value) {
  4290. if (this._paddingBottom.fromString(value)) {
  4291. this._markAsDirty();
  4292. }
  4293. },
  4294. enumerable: true,
  4295. configurable: true
  4296. });
  4297. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4298. /**
  4299. * Gets a value indicating the padding in pixels to use on the bottom of the control
  4300. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4301. */
  4302. get: function () {
  4303. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4304. },
  4305. enumerable: true,
  4306. configurable: true
  4307. });
  4308. Object.defineProperty(Control.prototype, "left", {
  4309. /**
  4310. * Gets or sets a value indicating the left coordinate of the control
  4311. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4312. */
  4313. get: function () {
  4314. return this._left.toString(this._host);
  4315. },
  4316. set: function (value) {
  4317. if (this._left.fromString(value)) {
  4318. this._markAsDirty();
  4319. }
  4320. },
  4321. enumerable: true,
  4322. configurable: true
  4323. });
  4324. Object.defineProperty(Control.prototype, "leftInPixels", {
  4325. /**
  4326. * Gets a value indicating the left coordinate in pixels of the control
  4327. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4328. */
  4329. get: function () {
  4330. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  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 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. enumerable: true,
  4360. configurable: true
  4361. });
  4362. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4363. /**
  4364. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4365. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4366. */
  4367. get: function () {
  4368. return this._linkOffsetX.toString(this._host);
  4369. },
  4370. set: function (value) {
  4371. if (this._linkOffsetX.fromString(value)) {
  4372. this._markAsDirty();
  4373. }
  4374. },
  4375. enumerable: true,
  4376. configurable: true
  4377. });
  4378. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4379. /**
  4380. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  4381. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4382. */
  4383. get: function () {
  4384. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4385. },
  4386. enumerable: true,
  4387. configurable: true
  4388. });
  4389. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4390. /**
  4391. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4392. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4393. */
  4394. get: function () {
  4395. return this._linkOffsetY.toString(this._host);
  4396. },
  4397. set: function (value) {
  4398. if (this._linkOffsetY.fromString(value)) {
  4399. this._markAsDirty();
  4400. }
  4401. },
  4402. enumerable: true,
  4403. configurable: true
  4404. });
  4405. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4406. /**
  4407. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  4408. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4409. */
  4410. get: function () {
  4411. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4412. },
  4413. enumerable: true,
  4414. configurable: true
  4415. });
  4416. Object.defineProperty(Control.prototype, "centerX", {
  4417. /** Gets the center coordinate on X axis */
  4418. get: function () {
  4419. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4420. },
  4421. enumerable: true,
  4422. configurable: true
  4423. });
  4424. Object.defineProperty(Control.prototype, "centerY", {
  4425. /** Gets the center coordinate on Y axis */
  4426. get: function () {
  4427. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4428. },
  4429. enumerable: true,
  4430. configurable: true
  4431. });
  4432. Object.defineProperty(Control.prototype, "isEnabled", {
  4433. /** Gets or sets if control is Enabled*/
  4434. get: function () {
  4435. return this._isEnabled;
  4436. },
  4437. set: function (value) {
  4438. if (this._isEnabled === value) {
  4439. return;
  4440. }
  4441. this._isEnabled = value;
  4442. this._markAsDirty();
  4443. },
  4444. enumerable: true,
  4445. configurable: true
  4446. });
  4447. Object.defineProperty(Control.prototype, "disabledColor", {
  4448. /** Gets or sets background color of control if it's disabled*/
  4449. get: function () {
  4450. return this._disabledColor;
  4451. },
  4452. set: function (value) {
  4453. if (this._disabledColor === value) {
  4454. return;
  4455. }
  4456. this._disabledColor = value;
  4457. this._markAsDirty();
  4458. },
  4459. enumerable: true,
  4460. configurable: true
  4461. });
  4462. /** @hidden */
  4463. Control.prototype._getTypeName = function () {
  4464. return "Control";
  4465. };
  4466. /**
  4467. * Gets the first ascendant in the hierarchy of the given type
  4468. * @param className defines the required type
  4469. * @returns the ascendant or null if not found
  4470. */
  4471. Control.prototype.getAscendantOfClass = function (className) {
  4472. if (!this.parent) {
  4473. return null;
  4474. }
  4475. if (this.parent.getClassName() === className) {
  4476. return this.parent;
  4477. }
  4478. return this.parent.getAscendantOfClass(className);
  4479. };
  4480. /** @hidden */
  4481. Control.prototype._resetFontCache = function () {
  4482. this._fontSet = true;
  4483. this._markAsDirty();
  4484. };
  4485. /**
  4486. * Determines if a container is an ascendant of the current control
  4487. * @param container defines the container to look for
  4488. * @returns true if the container is one of the ascendant of the control
  4489. */
  4490. Control.prototype.isAscendant = function (container) {
  4491. if (!this.parent) {
  4492. return false;
  4493. }
  4494. if (this.parent === container) {
  4495. return true;
  4496. }
  4497. return this.parent.isAscendant(container);
  4498. };
  4499. /**
  4500. * Gets coordinates in local control space
  4501. * @param globalCoordinates defines the coordinates to transform
  4502. * @returns the new coordinates in local space
  4503. */
  4504. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4505. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4506. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4507. return result;
  4508. };
  4509. /**
  4510. * Gets coordinates in local control space
  4511. * @param globalCoordinates defines the coordinates to transform
  4512. * @param result defines the target vector2 where to store the result
  4513. * @returns the current control
  4514. */
  4515. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4516. result.x = globalCoordinates.x - this._currentMeasure.left;
  4517. result.y = globalCoordinates.y - this._currentMeasure.top;
  4518. return this;
  4519. };
  4520. /**
  4521. * Gets coordinates in parent local control space
  4522. * @param globalCoordinates defines the coordinates to transform
  4523. * @returns the new coordinates in parent local space
  4524. */
  4525. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4526. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4527. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4528. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4529. return result;
  4530. };
  4531. /**
  4532. * Move the current control to a vector3 position projected onto the screen.
  4533. * @param position defines the target position
  4534. * @param scene defines the hosting scene
  4535. */
  4536. Control.prototype.moveToVector3 = function (position, scene) {
  4537. if (!this._host || this.parent !== this._host._rootContainer) {
  4538. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4539. return;
  4540. }
  4541. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4542. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4543. var globalViewport = this._host._getGlobalViewport(scene);
  4544. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4545. this._moveToProjectedPosition(projectedPosition);
  4546. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4547. this.notRenderable = true;
  4548. return;
  4549. }
  4550. this.notRenderable = false;
  4551. };
  4552. /** @hidden */
  4553. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4554. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4555. // Do nothing by default
  4556. };
  4557. /**
  4558. * Will return all controls that have this control as ascendant
  4559. * @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
  4560. * @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
  4561. * @return all child controls
  4562. */
  4563. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4564. var results = new Array();
  4565. this._getDescendants(results, directDescendantsOnly, predicate);
  4566. return results;
  4567. };
  4568. /**
  4569. * Link current control with a target mesh
  4570. * @param mesh defines the mesh to link with
  4571. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4572. */
  4573. Control.prototype.linkWithMesh = function (mesh) {
  4574. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4575. if (mesh) {
  4576. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4577. }
  4578. return;
  4579. }
  4580. var index = this._host._linkedControls.indexOf(this);
  4581. if (index !== -1) {
  4582. this._linkedMesh = mesh;
  4583. if (!mesh) {
  4584. this._host._linkedControls.splice(index, 1);
  4585. }
  4586. return;
  4587. }
  4588. else if (!mesh) {
  4589. return;
  4590. }
  4591. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4592. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4593. this._linkedMesh = mesh;
  4594. this._host._linkedControls.push(this);
  4595. };
  4596. /** @hidden */
  4597. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4598. var oldLeft = this._left.getValue(this._host);
  4599. var oldTop = this._top.getValue(this._host);
  4600. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4601. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4602. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4603. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4604. newLeft = oldLeft;
  4605. }
  4606. if (Math.abs(newTop - oldTop) < 0.5) {
  4607. newTop = oldTop;
  4608. }
  4609. }
  4610. this.left = newLeft + "px";
  4611. this.top = newTop + "px";
  4612. this._left.ignoreAdaptiveScaling = true;
  4613. this._top.ignoreAdaptiveScaling = true;
  4614. this._markAsDirty();
  4615. };
  4616. /** @hidden */
  4617. Control.prototype._offsetLeft = function (offset) {
  4618. this._isDirty = true;
  4619. this._currentMeasure.left += offset;
  4620. };
  4621. /** @hidden */
  4622. Control.prototype._offsetTop = function (offset) {
  4623. this._isDirty = true;
  4624. this._currentMeasure.top += offset;
  4625. };
  4626. /** @hidden */
  4627. Control.prototype._markMatrixAsDirty = function () {
  4628. this._isMatrixDirty = true;
  4629. this._flagDescendantsAsMatrixDirty();
  4630. };
  4631. /** @hidden */
  4632. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4633. // No child
  4634. };
  4635. /** @hidden */
  4636. Control.prototype._intersectsRect = function (rect) {
  4637. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4638. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4639. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4640. return false;
  4641. }
  4642. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4643. return false;
  4644. }
  4645. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4646. return false;
  4647. }
  4648. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4649. return false;
  4650. }
  4651. return true;
  4652. };
  4653. /** @hidden */
  4654. Control.prototype.invalidateRect = function () {
  4655. this._transform();
  4656. if (this.host && this.host.useInvalidateRectOptimization) {
  4657. // Rotate by transform to get the measure transformed to global space
  4658. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4659. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4660. // the previous measure is used to properly clear a control that is scaled down
  4661. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4662. 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));
  4663. }
  4664. };
  4665. /** @hidden */
  4666. Control.prototype._markAsDirty = function (force) {
  4667. if (force === void 0) { force = false; }
  4668. if (!this._isVisible && !force) {
  4669. return;
  4670. }
  4671. this._isDirty = true;
  4672. // Redraw only this rectangle
  4673. if (this._host) {
  4674. this._host.markAsDirty();
  4675. }
  4676. };
  4677. /** @hidden */
  4678. Control.prototype._markAllAsDirty = function () {
  4679. this._markAsDirty();
  4680. if (this._font) {
  4681. this._prepareFont();
  4682. }
  4683. };
  4684. /** @hidden */
  4685. Control.prototype._link = function (host) {
  4686. this._host = host;
  4687. if (this._host) {
  4688. this.uniqueId = this._host.getScene().getUniqueId();
  4689. }
  4690. };
  4691. /** @hidden */
  4692. Control.prototype._transform = function (context) {
  4693. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4694. return;
  4695. }
  4696. // postTranslate
  4697. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4698. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4699. if (context) {
  4700. context.translate(offsetX, offsetY);
  4701. // rotate
  4702. context.rotate(this._rotation);
  4703. // scale
  4704. context.scale(this._scaleX, this._scaleY);
  4705. // preTranslate
  4706. context.translate(-offsetX, -offsetY);
  4707. }
  4708. // Need to update matrices?
  4709. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4710. this._cachedOffsetX = offsetX;
  4711. this._cachedOffsetY = offsetY;
  4712. this._isMatrixDirty = false;
  4713. this._flagDescendantsAsMatrixDirty();
  4714. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4715. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4716. }
  4717. };
  4718. /** @hidden */
  4719. Control.prototype._renderHighlight = function (context) {
  4720. if (!this.isHighlighted) {
  4721. return;
  4722. }
  4723. context.save();
  4724. context.strokeStyle = "#4affff";
  4725. context.lineWidth = 2;
  4726. this._renderHighlightSpecific(context);
  4727. context.restore();
  4728. };
  4729. /** @hidden */
  4730. Control.prototype._renderHighlightSpecific = function (context) {
  4731. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4732. };
  4733. /** @hidden */
  4734. Control.prototype._applyStates = function (context) {
  4735. if (this._isFontSizeInPercentage) {
  4736. this._fontSet = true;
  4737. }
  4738. if (this._fontSet) {
  4739. this._prepareFont();
  4740. this._fontSet = false;
  4741. }
  4742. if (this._font) {
  4743. context.font = this._font;
  4744. }
  4745. if (this._color) {
  4746. context.fillStyle = this._color;
  4747. }
  4748. if (Control.AllowAlphaInheritance) {
  4749. context.globalAlpha *= this._alpha;
  4750. }
  4751. else if (this._alphaSet) {
  4752. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4753. }
  4754. };
  4755. /** @hidden */
  4756. Control.prototype._layout = function (parentMeasure, context) {
  4757. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4758. return false;
  4759. }
  4760. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4761. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4762. context.save();
  4763. this._applyStates(context);
  4764. var rebuildCount = 0;
  4765. do {
  4766. this._rebuildLayout = false;
  4767. this._processMeasures(parentMeasure, context);
  4768. rebuildCount++;
  4769. } while (this._rebuildLayout && rebuildCount < 3);
  4770. if (rebuildCount >= 3) {
  4771. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4772. }
  4773. context.restore();
  4774. this.invalidateRect();
  4775. this._evaluateClippingState(parentMeasure);
  4776. }
  4777. this._wasDirty = this._isDirty;
  4778. this._isDirty = false;
  4779. return true;
  4780. };
  4781. /** @hidden */
  4782. Control.prototype._processMeasures = function (parentMeasure, context) {
  4783. this._currentMeasure.copyFrom(parentMeasure);
  4784. // Let children take some pre-measurement actions
  4785. this._preMeasure(parentMeasure, context);
  4786. this._measure();
  4787. this._computeAlignment(parentMeasure, context);
  4788. // Convert to int values
  4789. this._currentMeasure.left = this._currentMeasure.left | 0;
  4790. this._currentMeasure.top = this._currentMeasure.top | 0;
  4791. this._currentMeasure.width = this._currentMeasure.width | 0;
  4792. this._currentMeasure.height = this._currentMeasure.height | 0;
  4793. // Let children add more features
  4794. this._additionalProcessing(parentMeasure, context);
  4795. this._cachedParentMeasure.copyFrom(parentMeasure);
  4796. if (this.onDirtyObservable.hasObservers()) {
  4797. this.onDirtyObservable.notifyObservers(this);
  4798. }
  4799. };
  4800. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4801. if (this.parent && this.parent.clipChildren) {
  4802. // Early clip
  4803. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4804. this._isClipped = true;
  4805. return;
  4806. }
  4807. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4808. this._isClipped = true;
  4809. return;
  4810. }
  4811. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4812. this._isClipped = true;
  4813. return;
  4814. }
  4815. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4816. this._isClipped = true;
  4817. return;
  4818. }
  4819. }
  4820. this._isClipped = false;
  4821. };
  4822. /** @hidden */
  4823. Control.prototype._measure = function () {
  4824. // Width / Height
  4825. if (this._width.isPixel) {
  4826. this._currentMeasure.width = this._width.getValue(this._host);
  4827. }
  4828. else {
  4829. this._currentMeasure.width *= this._width.getValue(this._host);
  4830. }
  4831. if (this._height.isPixel) {
  4832. this._currentMeasure.height = this._height.getValue(this._host);
  4833. }
  4834. else {
  4835. this._currentMeasure.height *= this._height.getValue(this._host);
  4836. }
  4837. };
  4838. /** @hidden */
  4839. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4840. var width = this._currentMeasure.width;
  4841. var height = this._currentMeasure.height;
  4842. var parentWidth = parentMeasure.width;
  4843. var parentHeight = parentMeasure.height;
  4844. // Left / top
  4845. var x = 0;
  4846. var y = 0;
  4847. switch (this.horizontalAlignment) {
  4848. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4849. x = 0;
  4850. break;
  4851. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4852. x = parentWidth - width;
  4853. break;
  4854. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4855. x = (parentWidth - width) / 2;
  4856. break;
  4857. }
  4858. switch (this.verticalAlignment) {
  4859. case Control.VERTICAL_ALIGNMENT_TOP:
  4860. y = 0;
  4861. break;
  4862. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4863. y = parentHeight - height;
  4864. break;
  4865. case Control.VERTICAL_ALIGNMENT_CENTER:
  4866. y = (parentHeight - height) / 2;
  4867. break;
  4868. }
  4869. if (this._paddingLeft.isPixel) {
  4870. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4871. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4872. }
  4873. else {
  4874. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4875. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4876. }
  4877. if (this._paddingRight.isPixel) {
  4878. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4879. }
  4880. else {
  4881. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4882. }
  4883. if (this._paddingTop.isPixel) {
  4884. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4885. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4886. }
  4887. else {
  4888. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4889. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4890. }
  4891. if (this._paddingBottom.isPixel) {
  4892. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4893. }
  4894. else {
  4895. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4896. }
  4897. if (this._left.isPixel) {
  4898. this._currentMeasure.left += this._left.getValue(this._host);
  4899. }
  4900. else {
  4901. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4902. }
  4903. if (this._top.isPixel) {
  4904. this._currentMeasure.top += this._top.getValue(this._host);
  4905. }
  4906. else {
  4907. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4908. }
  4909. this._currentMeasure.left += x;
  4910. this._currentMeasure.top += y;
  4911. };
  4912. /** @hidden */
  4913. Control.prototype._preMeasure = function (parentMeasure, context) {
  4914. // Do nothing
  4915. };
  4916. /** @hidden */
  4917. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4918. // Do nothing
  4919. };
  4920. /** @hidden */
  4921. Control.prototype._clipForChildren = function (context) {
  4922. // DO nothing
  4923. };
  4924. Control.prototype._clip = function (context, invalidatedRectangle) {
  4925. context.beginPath();
  4926. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4927. if (invalidatedRectangle) {
  4928. // Rotate the invalidated rect into the control's space
  4929. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4930. // Get the intersection of the rect in context space and the current context
  4931. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4932. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4933. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4934. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4935. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4936. Control._ClipMeasure.copyFrom(intersection);
  4937. }
  4938. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4939. var shadowOffsetX = this.shadowOffsetX;
  4940. var shadowOffsetY = this.shadowOffsetY;
  4941. var shadowBlur = this.shadowBlur;
  4942. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4943. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4944. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4945. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4946. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  4947. }
  4948. else {
  4949. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  4950. }
  4951. context.clip();
  4952. };
  4953. /** @hidden */
  4954. Control.prototype._render = function (context, invalidatedRectangle) {
  4955. if (!this.isVisible || this.notRenderable || this._isClipped) {
  4956. this._isDirty = false;
  4957. return false;
  4958. }
  4959. context.save();
  4960. this._applyStates(context);
  4961. // Transform
  4962. this._transform(context);
  4963. // Clip
  4964. if (this.clipChildren) {
  4965. this._clip(context, invalidatedRectangle);
  4966. }
  4967. if (this.onBeforeDrawObservable.hasObservers()) {
  4968. this.onBeforeDrawObservable.notifyObservers(this);
  4969. }
  4970. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  4971. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  4972. }
  4973. else {
  4974. this._draw(context, invalidatedRectangle);
  4975. }
  4976. if (this.useBitmapCache && this._wasDirty) {
  4977. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4978. }
  4979. this._renderHighlight(context);
  4980. if (this.onAfterDrawObservable.hasObservers()) {
  4981. this.onAfterDrawObservable.notifyObservers(this);
  4982. }
  4983. context.restore();
  4984. return true;
  4985. };
  4986. /** @hidden */
  4987. Control.prototype._draw = function (context, invalidatedRectangle) {
  4988. // Do nothing
  4989. };
  4990. /**
  4991. * Tests if a given coordinates belong to the current control
  4992. * @param x defines x coordinate to test
  4993. * @param y defines y coordinate to test
  4994. * @returns true if the coordinates are inside the control
  4995. */
  4996. Control.prototype.contains = function (x, y) {
  4997. // Invert transform
  4998. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  4999. x = this._transformedPosition.x;
  5000. y = this._transformedPosition.y;
  5001. // Check
  5002. if (x < this._currentMeasure.left) {
  5003. return false;
  5004. }
  5005. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5006. return false;
  5007. }
  5008. if (y < this._currentMeasure.top) {
  5009. return false;
  5010. }
  5011. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5012. return false;
  5013. }
  5014. if (this.isPointerBlocker) {
  5015. this._host._shouldBlockPointer = true;
  5016. }
  5017. return true;
  5018. };
  5019. /** @hidden */
  5020. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5021. if (!this._isEnabled) {
  5022. return false;
  5023. }
  5024. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5025. return false;
  5026. }
  5027. if (!this.contains(x, y)) {
  5028. return false;
  5029. }
  5030. this._processObservables(type, x, y, pointerId, buttonIndex);
  5031. return true;
  5032. };
  5033. /** @hidden */
  5034. Control.prototype._onPointerMove = function (target, coordinates) {
  5035. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5036. if (canNotify && this.parent != null) {
  5037. this.parent._onPointerMove(target, coordinates);
  5038. }
  5039. };
  5040. /** @hidden */
  5041. Control.prototype._onPointerEnter = function (target) {
  5042. if (!this._isEnabled) {
  5043. return false;
  5044. }
  5045. if (this._enterCount > 0) {
  5046. return false;
  5047. }
  5048. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5049. this._enterCount = 0;
  5050. }
  5051. this._enterCount++;
  5052. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5053. if (canNotify && this.parent != null) {
  5054. this.parent._onPointerEnter(target);
  5055. }
  5056. return true;
  5057. };
  5058. /** @hidden */
  5059. Control.prototype._onPointerOut = function (target) {
  5060. if (!this._isEnabled || target === this) {
  5061. return;
  5062. }
  5063. this._enterCount = 0;
  5064. var canNotify = true;
  5065. if (!target.isAscendant(this)) {
  5066. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5067. }
  5068. if (canNotify && this.parent != null) {
  5069. this.parent._onPointerOut(target);
  5070. }
  5071. };
  5072. /** @hidden */
  5073. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5074. // Prevent pointerout to lose control context.
  5075. // Event redundancy is checked inside the function.
  5076. this._onPointerEnter(this);
  5077. if (this._downCount !== 0) {
  5078. return false;
  5079. }
  5080. this._downCount++;
  5081. this._downPointerIds[pointerId] = true;
  5082. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5083. if (canNotify && this.parent != null) {
  5084. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5085. }
  5086. return true;
  5087. };
  5088. /** @hidden */
  5089. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5090. if (!this._isEnabled) {
  5091. return;
  5092. }
  5093. this._downCount = 0;
  5094. delete this._downPointerIds[pointerId];
  5095. var canNotifyClick = notifyClick;
  5096. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5097. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5098. }
  5099. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5100. if (canNotify && this.parent != null) {
  5101. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5102. }
  5103. };
  5104. /** @hidden */
  5105. Control.prototype._forcePointerUp = function (pointerId) {
  5106. if (pointerId === void 0) { pointerId = null; }
  5107. if (pointerId !== null) {
  5108. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5109. }
  5110. else {
  5111. for (var key in this._downPointerIds) {
  5112. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5113. }
  5114. }
  5115. };
  5116. /** @hidden */
  5117. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5118. if (!this._isEnabled) {
  5119. return false;
  5120. }
  5121. this._dummyVector2.copyFromFloats(x, y);
  5122. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5123. this._onPointerMove(this, this._dummyVector2);
  5124. var previousControlOver = this._host._lastControlOver[pointerId];
  5125. if (previousControlOver && previousControlOver !== this) {
  5126. previousControlOver._onPointerOut(this);
  5127. }
  5128. if (previousControlOver !== this) {
  5129. this._onPointerEnter(this);
  5130. }
  5131. this._host._lastControlOver[pointerId] = this;
  5132. return true;
  5133. }
  5134. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5135. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5136. this._host._registerLastControlDown(this, pointerId);
  5137. this._host._lastPickedControl = this;
  5138. return true;
  5139. }
  5140. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5141. if (this._host._lastControlDown[pointerId]) {
  5142. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5143. }
  5144. delete this._host._lastControlDown[pointerId];
  5145. return true;
  5146. }
  5147. return false;
  5148. };
  5149. Control.prototype._prepareFont = function () {
  5150. if (!this._font && !this._fontSet) {
  5151. return;
  5152. }
  5153. if (this._style) {
  5154. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5155. }
  5156. else {
  5157. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5158. }
  5159. this._fontOffset = Control._GetFontOffset(this._font);
  5160. };
  5161. /** Releases associated resources */
  5162. Control.prototype.dispose = function () {
  5163. this.onDirtyObservable.clear();
  5164. this.onBeforeDrawObservable.clear();
  5165. this.onAfterDrawObservable.clear();
  5166. this.onPointerDownObservable.clear();
  5167. this.onPointerEnterObservable.clear();
  5168. this.onPointerMoveObservable.clear();
  5169. this.onPointerOutObservable.clear();
  5170. this.onPointerUpObservable.clear();
  5171. this.onPointerClickObservable.clear();
  5172. if (this._styleObserver && this._style) {
  5173. this._style.onChangedObservable.remove(this._styleObserver);
  5174. this._styleObserver = null;
  5175. }
  5176. if (this.parent) {
  5177. this.parent.removeControl(this);
  5178. this.parent = null;
  5179. }
  5180. if (this._host) {
  5181. var index = this._host._linkedControls.indexOf(this);
  5182. if (index > -1) {
  5183. this.linkWithMesh(null);
  5184. }
  5185. }
  5186. };
  5187. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5188. /** HORIZONTAL_ALIGNMENT_LEFT */
  5189. get: function () {
  5190. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5191. },
  5192. enumerable: true,
  5193. configurable: true
  5194. });
  5195. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5196. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5197. get: function () {
  5198. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5199. },
  5200. enumerable: true,
  5201. configurable: true
  5202. });
  5203. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5204. /** HORIZONTAL_ALIGNMENT_CENTER */
  5205. get: function () {
  5206. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5207. },
  5208. enumerable: true,
  5209. configurable: true
  5210. });
  5211. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5212. /** VERTICAL_ALIGNMENT_TOP */
  5213. get: function () {
  5214. return Control._VERTICAL_ALIGNMENT_TOP;
  5215. },
  5216. enumerable: true,
  5217. configurable: true
  5218. });
  5219. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5220. /** VERTICAL_ALIGNMENT_BOTTOM */
  5221. get: function () {
  5222. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5223. },
  5224. enumerable: true,
  5225. configurable: true
  5226. });
  5227. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5228. /** VERTICAL_ALIGNMENT_CENTER */
  5229. get: function () {
  5230. return Control._VERTICAL_ALIGNMENT_CENTER;
  5231. },
  5232. enumerable: true,
  5233. configurable: true
  5234. });
  5235. /** @hidden */
  5236. Control._GetFontOffset = function (font) {
  5237. if (Control._FontHeightSizes[font]) {
  5238. return Control._FontHeightSizes[font];
  5239. }
  5240. var text = document.createElement("span");
  5241. text.innerHTML = "Hg";
  5242. text.style.font = font;
  5243. var block = document.createElement("div");
  5244. block.style.display = "inline-block";
  5245. block.style.width = "1px";
  5246. block.style.height = "0px";
  5247. block.style.verticalAlign = "bottom";
  5248. var div = document.createElement("div");
  5249. div.appendChild(text);
  5250. div.appendChild(block);
  5251. document.body.appendChild(div);
  5252. var fontAscent = 0;
  5253. var fontHeight = 0;
  5254. try {
  5255. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5256. block.style.verticalAlign = "baseline";
  5257. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5258. }
  5259. finally {
  5260. document.body.removeChild(div);
  5261. }
  5262. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5263. Control._FontHeightSizes[font] = result;
  5264. return result;
  5265. };
  5266. /** @hidden */
  5267. Control.drawEllipse = function (x, y, width, height, context) {
  5268. context.translate(x, y);
  5269. context.scale(width, height);
  5270. context.beginPath();
  5271. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5272. context.closePath();
  5273. context.scale(1 / width, 1 / height);
  5274. context.translate(-x, -y);
  5275. };
  5276. /**
  5277. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5278. */
  5279. Control.AllowAlphaInheritance = false;
  5280. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5281. // Statics
  5282. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5283. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5284. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5285. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5286. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5287. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5288. Control._FontHeightSizes = {};
  5289. /**
  5290. * Creates a stack panel that can be used to render headers
  5291. * @param control defines the control to associate with the header
  5292. * @param text defines the text of the header
  5293. * @param size defines the size of the header
  5294. * @param options defines options used to configure the header
  5295. * @returns a new StackPanel
  5296. * @ignore
  5297. * @hidden
  5298. */
  5299. Control.AddHeader = function () { };
  5300. return Control;
  5301. }());
  5302. /***/ }),
  5303. /***/ "./2D/controls/displayGrid.ts":
  5304. /*!************************************!*\
  5305. !*** ./2D/controls/displayGrid.ts ***!
  5306. \************************************/
  5307. /*! exports provided: DisplayGrid */
  5308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5309. "use strict";
  5310. __webpack_require__.r(__webpack_exports__);
  5311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5312. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5313. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5314. /** Class used to render a grid */
  5315. var DisplayGrid = /** @class */ (function (_super) {
  5316. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5317. /**
  5318. * Creates a new GridDisplayRectangle
  5319. * @param name defines the control name
  5320. */
  5321. function DisplayGrid(name) {
  5322. var _this = _super.call(this, name) || this;
  5323. _this.name = name;
  5324. _this._cellWidth = 20;
  5325. _this._cellHeight = 20;
  5326. _this._minorLineTickness = 1;
  5327. _this._minorLineColor = "DarkGray";
  5328. _this._majorLineTickness = 2;
  5329. _this._majorLineColor = "White";
  5330. _this._majorLineFrequency = 5;
  5331. _this._background = "Black";
  5332. _this._displayMajorLines = true;
  5333. _this._displayMinorLines = true;
  5334. return _this;
  5335. }
  5336. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5337. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5338. get: function () {
  5339. return this._displayMinorLines;
  5340. },
  5341. set: function (value) {
  5342. if (this._displayMinorLines === value) {
  5343. return;
  5344. }
  5345. this._displayMinorLines = value;
  5346. this._markAsDirty();
  5347. },
  5348. enumerable: true,
  5349. configurable: true
  5350. });
  5351. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5352. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5353. get: function () {
  5354. return this._displayMajorLines;
  5355. },
  5356. set: function (value) {
  5357. if (this._displayMajorLines === value) {
  5358. return;
  5359. }
  5360. this._displayMajorLines = value;
  5361. this._markAsDirty();
  5362. },
  5363. enumerable: true,
  5364. configurable: true
  5365. });
  5366. Object.defineProperty(DisplayGrid.prototype, "background", {
  5367. /** Gets or sets background color (Black by default) */
  5368. get: function () {
  5369. return this._background;
  5370. },
  5371. set: function (value) {
  5372. if (this._background === value) {
  5373. return;
  5374. }
  5375. this._background = value;
  5376. this._markAsDirty();
  5377. },
  5378. enumerable: true,
  5379. configurable: true
  5380. });
  5381. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5382. /** Gets or sets the width of each cell (20 by default) */
  5383. get: function () {
  5384. return this._cellWidth;
  5385. },
  5386. set: function (value) {
  5387. this._cellWidth = value;
  5388. this._markAsDirty();
  5389. },
  5390. enumerable: true,
  5391. configurable: true
  5392. });
  5393. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5394. /** Gets or sets the height of each cell (20 by default) */
  5395. get: function () {
  5396. return this._cellHeight;
  5397. },
  5398. set: function (value) {
  5399. this._cellHeight = value;
  5400. this._markAsDirty();
  5401. },
  5402. enumerable: true,
  5403. configurable: true
  5404. });
  5405. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5406. /** Gets or sets the tickness of minor lines (1 by default) */
  5407. get: function () {
  5408. return this._minorLineTickness;
  5409. },
  5410. set: function (value) {
  5411. this._minorLineTickness = value;
  5412. this._markAsDirty();
  5413. },
  5414. enumerable: true,
  5415. configurable: true
  5416. });
  5417. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5418. /** Gets or sets the color of minor lines (DarkGray by default) */
  5419. get: function () {
  5420. return this._minorLineColor;
  5421. },
  5422. set: function (value) {
  5423. this._minorLineColor = value;
  5424. this._markAsDirty();
  5425. },
  5426. enumerable: true,
  5427. configurable: true
  5428. });
  5429. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5430. /** Gets or sets the tickness of major lines (2 by default) */
  5431. get: function () {
  5432. return this._majorLineTickness;
  5433. },
  5434. set: function (value) {
  5435. this._majorLineTickness = value;
  5436. this._markAsDirty();
  5437. },
  5438. enumerable: true,
  5439. configurable: true
  5440. });
  5441. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5442. /** Gets or sets the color of major lines (White by default) */
  5443. get: function () {
  5444. return this._majorLineColor;
  5445. },
  5446. set: function (value) {
  5447. this._majorLineColor = value;
  5448. this._markAsDirty();
  5449. },
  5450. enumerable: true,
  5451. configurable: true
  5452. });
  5453. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5454. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5455. get: function () {
  5456. return this._majorLineFrequency;
  5457. },
  5458. set: function (value) {
  5459. this._majorLineFrequency = value;
  5460. this._markAsDirty();
  5461. },
  5462. enumerable: true,
  5463. configurable: true
  5464. });
  5465. DisplayGrid.prototype._draw = function (context) {
  5466. context.save();
  5467. this._applyStates(context);
  5468. if (this._isEnabled) {
  5469. if (this._background) {
  5470. context.fillStyle = this._background;
  5471. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5472. }
  5473. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5474. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5475. // Minor lines
  5476. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5477. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5478. if (this._displayMinorLines) {
  5479. context.strokeStyle = this._minorLineColor;
  5480. context.lineWidth = this._minorLineTickness;
  5481. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5482. var cellX = left + x * this.cellWidth;
  5483. context.beginPath();
  5484. context.moveTo(cellX, this._currentMeasure.top);
  5485. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5486. context.stroke();
  5487. }
  5488. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5489. var cellY = top_1 + y * this.cellHeight;
  5490. context.beginPath();
  5491. context.moveTo(this._currentMeasure.left, cellY);
  5492. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5493. context.stroke();
  5494. }
  5495. }
  5496. // Major lines
  5497. if (this._displayMajorLines) {
  5498. context.strokeStyle = this._majorLineColor;
  5499. context.lineWidth = this._majorLineTickness;
  5500. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5501. var cellX = left + x * this.cellWidth;
  5502. context.beginPath();
  5503. context.moveTo(cellX, this._currentMeasure.top);
  5504. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5505. context.stroke();
  5506. }
  5507. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5508. var cellY = top_1 + y * this.cellHeight;
  5509. context.moveTo(this._currentMeasure.left, cellY);
  5510. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5511. context.closePath();
  5512. context.stroke();
  5513. }
  5514. }
  5515. }
  5516. context.restore();
  5517. };
  5518. DisplayGrid.prototype._getTypeName = function () {
  5519. return "DisplayGrid";
  5520. };
  5521. return DisplayGrid;
  5522. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5523. /***/ }),
  5524. /***/ "./2D/controls/ellipse.ts":
  5525. /*!********************************!*\
  5526. !*** ./2D/controls/ellipse.ts ***!
  5527. \********************************/
  5528. /*! exports provided: Ellipse */
  5529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5530. "use strict";
  5531. __webpack_require__.r(__webpack_exports__);
  5532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5533. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5534. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5535. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5536. /** Class used to create 2D ellipse containers */
  5537. var Ellipse = /** @class */ (function (_super) {
  5538. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5539. /**
  5540. * Creates a new Ellipse
  5541. * @param name defines the control name
  5542. */
  5543. function Ellipse(name) {
  5544. var _this = _super.call(this, name) || this;
  5545. _this.name = name;
  5546. _this._thickness = 1;
  5547. return _this;
  5548. }
  5549. Object.defineProperty(Ellipse.prototype, "thickness", {
  5550. /** Gets or sets border thickness */
  5551. get: function () {
  5552. return this._thickness;
  5553. },
  5554. set: function (value) {
  5555. if (this._thickness === value) {
  5556. return;
  5557. }
  5558. this._thickness = value;
  5559. this._markAsDirty();
  5560. },
  5561. enumerable: true,
  5562. configurable: true
  5563. });
  5564. Ellipse.prototype._getTypeName = function () {
  5565. return "Ellipse";
  5566. };
  5567. Ellipse.prototype._localDraw = function (context) {
  5568. context.save();
  5569. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5570. context.shadowColor = this.shadowColor;
  5571. context.shadowBlur = this.shadowBlur;
  5572. context.shadowOffsetX = this.shadowOffsetX;
  5573. context.shadowOffsetY = this.shadowOffsetY;
  5574. }
  5575. _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);
  5576. if (this._background) {
  5577. context.fillStyle = this._background;
  5578. context.fill();
  5579. }
  5580. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5581. context.shadowBlur = 0;
  5582. context.shadowOffsetX = 0;
  5583. context.shadowOffsetY = 0;
  5584. }
  5585. if (this._thickness) {
  5586. if (this.color) {
  5587. context.strokeStyle = this.color;
  5588. }
  5589. context.lineWidth = this._thickness;
  5590. context.stroke();
  5591. }
  5592. context.restore();
  5593. };
  5594. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5595. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5596. this._measureForChildren.width -= 2 * this._thickness;
  5597. this._measureForChildren.height -= 2 * this._thickness;
  5598. this._measureForChildren.left += this._thickness;
  5599. this._measureForChildren.top += this._thickness;
  5600. };
  5601. Ellipse.prototype._clipForChildren = function (context) {
  5602. _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);
  5603. context.clip();
  5604. };
  5605. return Ellipse;
  5606. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5607. /***/ }),
  5608. /***/ "./2D/controls/grid.ts":
  5609. /*!*****************************!*\
  5610. !*** ./2D/controls/grid.ts ***!
  5611. \*****************************/
  5612. /*! exports provided: Grid */
  5613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5614. "use strict";
  5615. __webpack_require__.r(__webpack_exports__);
  5616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5617. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5618. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5619. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5620. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5621. /**
  5622. * Class used to create a 2D grid container
  5623. */
  5624. var Grid = /** @class */ (function (_super) {
  5625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5626. /**
  5627. * Creates a new Grid
  5628. * @param name defines control name
  5629. */
  5630. function Grid(name) {
  5631. var _this = _super.call(this, name) || this;
  5632. _this.name = name;
  5633. _this._rowDefinitions = new Array();
  5634. _this._columnDefinitions = new Array();
  5635. _this._cells = {};
  5636. _this._childControls = new Array();
  5637. return _this;
  5638. }
  5639. Object.defineProperty(Grid.prototype, "columnCount", {
  5640. /**
  5641. * Gets the number of columns
  5642. */
  5643. get: function () {
  5644. return this._columnDefinitions.length;
  5645. },
  5646. enumerable: true,
  5647. configurable: true
  5648. });
  5649. Object.defineProperty(Grid.prototype, "rowCount", {
  5650. /**
  5651. * Gets the number of rows
  5652. */
  5653. get: function () {
  5654. return this._rowDefinitions.length;
  5655. },
  5656. enumerable: true,
  5657. configurable: true
  5658. });
  5659. Object.defineProperty(Grid.prototype, "children", {
  5660. /** Gets the list of children */
  5661. get: function () {
  5662. return this._childControls;
  5663. },
  5664. enumerable: true,
  5665. configurable: true
  5666. });
  5667. /**
  5668. * Gets the definition of a specific row
  5669. * @param index defines the index of the row
  5670. * @returns the row definition
  5671. */
  5672. Grid.prototype.getRowDefinition = function (index) {
  5673. if (index < 0 || index >= this._rowDefinitions.length) {
  5674. return null;
  5675. }
  5676. return this._rowDefinitions[index];
  5677. };
  5678. /**
  5679. * Gets the definition of a specific column
  5680. * @param index defines the index of the column
  5681. * @returns the column definition
  5682. */
  5683. Grid.prototype.getColumnDefinition = function (index) {
  5684. if (index < 0 || index >= this._columnDefinitions.length) {
  5685. return null;
  5686. }
  5687. return this._columnDefinitions[index];
  5688. };
  5689. /**
  5690. * Adds a new row to the grid
  5691. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5692. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5693. * @returns the current grid
  5694. */
  5695. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5696. if (isPixel === void 0) { isPixel = false; }
  5697. 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));
  5698. this._markAsDirty();
  5699. return this;
  5700. };
  5701. /**
  5702. * Adds a new column to the grid
  5703. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5704. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5705. * @returns the current grid
  5706. */
  5707. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5708. if (isPixel === void 0) { isPixel = false; }
  5709. 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));
  5710. this._markAsDirty();
  5711. return this;
  5712. };
  5713. /**
  5714. * Update a row definition
  5715. * @param index defines the index of the row to update
  5716. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5717. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5718. * @returns the current grid
  5719. */
  5720. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5721. if (isPixel === void 0) { isPixel = false; }
  5722. if (index < 0 || index >= this._rowDefinitions.length) {
  5723. return this;
  5724. }
  5725. var current = this._rowDefinitions[index];
  5726. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5727. return this;
  5728. }
  5729. 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);
  5730. this._markAsDirty();
  5731. return this;
  5732. };
  5733. /**
  5734. * Update a column definition
  5735. * @param index defines the index of the column to update
  5736. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5737. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5738. * @returns the current grid
  5739. */
  5740. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5741. if (isPixel === void 0) { isPixel = false; }
  5742. if (index < 0 || index >= this._columnDefinitions.length) {
  5743. return this;
  5744. }
  5745. var current = this._columnDefinitions[index];
  5746. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5747. return this;
  5748. }
  5749. 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);
  5750. this._markAsDirty();
  5751. return this;
  5752. };
  5753. /**
  5754. * Gets the list of children stored in a specific cell
  5755. * @param row defines the row to check
  5756. * @param column defines the column to check
  5757. * @returns the list of controls
  5758. */
  5759. Grid.prototype.getChildrenAt = function (row, column) {
  5760. var cell = this._cells[row + ":" + column];
  5761. if (!cell) {
  5762. return null;
  5763. }
  5764. return cell.children;
  5765. };
  5766. /**
  5767. * Gets a string representing the child cell info (row x column)
  5768. * @param child defines the control to get info from
  5769. * @returns a string containing the child cell info (row x column)
  5770. */
  5771. Grid.prototype.getChildCellInfo = function (child) {
  5772. return child._tag;
  5773. };
  5774. Grid.prototype._removeCell = function (cell, key) {
  5775. if (!cell) {
  5776. return;
  5777. }
  5778. _super.prototype.removeControl.call(this, cell);
  5779. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5780. var control = _a[_i];
  5781. var childIndex = this._childControls.indexOf(control);
  5782. if (childIndex !== -1) {
  5783. this._childControls.splice(childIndex, 1);
  5784. }
  5785. }
  5786. delete this._cells[key];
  5787. };
  5788. Grid.prototype._offsetCell = function (previousKey, key) {
  5789. if (!this._cells[key]) {
  5790. return;
  5791. }
  5792. this._cells[previousKey] = this._cells[key];
  5793. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5794. var control = _a[_i];
  5795. control._tag = previousKey;
  5796. }
  5797. delete this._cells[key];
  5798. };
  5799. /**
  5800. * Remove a column definition at specified index
  5801. * @param index defines the index of the column to remove
  5802. * @returns the current grid
  5803. */
  5804. Grid.prototype.removeColumnDefinition = function (index) {
  5805. if (index < 0 || index >= this._columnDefinitions.length) {
  5806. return this;
  5807. }
  5808. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5809. var key = x + ":" + index;
  5810. var cell = this._cells[key];
  5811. this._removeCell(cell, key);
  5812. }
  5813. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5814. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5815. var previousKey = x + ":" + (y - 1);
  5816. var key = x + ":" + y;
  5817. this._offsetCell(previousKey, key);
  5818. }
  5819. }
  5820. this._columnDefinitions.splice(index, 1);
  5821. this._markAsDirty();
  5822. return this;
  5823. };
  5824. /**
  5825. * Remove a row definition at specified index
  5826. * @param index defines the index of the row to remove
  5827. * @returns the current grid
  5828. */
  5829. Grid.prototype.removeRowDefinition = function (index) {
  5830. if (index < 0 || index >= this._rowDefinitions.length) {
  5831. return this;
  5832. }
  5833. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5834. var key = index + ":" + y;
  5835. var cell = this._cells[key];
  5836. this._removeCell(cell, key);
  5837. }
  5838. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5839. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5840. var previousKey = x - 1 + ":" + y;
  5841. var key = x + ":" + y;
  5842. this._offsetCell(previousKey, key);
  5843. }
  5844. }
  5845. this._rowDefinitions.splice(index, 1);
  5846. this._markAsDirty();
  5847. return this;
  5848. };
  5849. /**
  5850. * Adds a new control to the current grid
  5851. * @param control defines the control to add
  5852. * @param row defines the row where to add the control (0 by default)
  5853. * @param column defines the column where to add the control (0 by default)
  5854. * @returns the current grid
  5855. */
  5856. Grid.prototype.addControl = function (control, row, column) {
  5857. if (row === void 0) { row = 0; }
  5858. if (column === void 0) { column = 0; }
  5859. if (this._rowDefinitions.length === 0) {
  5860. // Add default row definition
  5861. this.addRowDefinition(1, false);
  5862. }
  5863. if (this._columnDefinitions.length === 0) {
  5864. // Add default column definition
  5865. this.addColumnDefinition(1, false);
  5866. }
  5867. var x = Math.min(row, this._rowDefinitions.length - 1);
  5868. var y = Math.min(column, this._columnDefinitions.length - 1);
  5869. var key = x + ":" + y;
  5870. var goodContainer = this._cells[key];
  5871. if (!goodContainer) {
  5872. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5873. this._cells[key] = goodContainer;
  5874. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5875. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5876. _super.prototype.addControl.call(this, goodContainer);
  5877. }
  5878. goodContainer.addControl(control);
  5879. this._childControls.push(control);
  5880. control._tag = key;
  5881. control.parent = this;
  5882. this._markAsDirty();
  5883. return this;
  5884. };
  5885. /**
  5886. * Removes a control from the current container
  5887. * @param control defines the control to remove
  5888. * @returns the current container
  5889. */
  5890. Grid.prototype.removeControl = function (control) {
  5891. var index = this._childControls.indexOf(control);
  5892. if (index !== -1) {
  5893. this._childControls.splice(index, 1);
  5894. }
  5895. var cell = this._cells[control._tag];
  5896. if (cell) {
  5897. cell.removeControl(control);
  5898. }
  5899. this._markAsDirty();
  5900. return this;
  5901. };
  5902. Grid.prototype._getTypeName = function () {
  5903. return "Grid";
  5904. };
  5905. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5906. var widths = [];
  5907. var heights = [];
  5908. var lefts = [];
  5909. var tops = [];
  5910. var availableWidth = this._currentMeasure.width;
  5911. var globalWidthPercentage = 0;
  5912. var availableHeight = this._currentMeasure.height;
  5913. var globalHeightPercentage = 0;
  5914. // Heights
  5915. var index = 0;
  5916. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5917. var value = _a[_i];
  5918. if (value.isPixel) {
  5919. var height = value.getValue(this._host);
  5920. availableHeight -= height;
  5921. heights[index] = height;
  5922. }
  5923. else {
  5924. globalHeightPercentage += value.internalValue;
  5925. }
  5926. index++;
  5927. }
  5928. var top = 0;
  5929. index = 0;
  5930. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  5931. var value = _c[_b];
  5932. tops.push(top);
  5933. if (!value.isPixel) {
  5934. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  5935. top += height;
  5936. heights[index] = height;
  5937. }
  5938. else {
  5939. top += value.getValue(this._host);
  5940. }
  5941. index++;
  5942. }
  5943. // Widths
  5944. index = 0;
  5945. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  5946. var value = _e[_d];
  5947. if (value.isPixel) {
  5948. var width = value.getValue(this._host);
  5949. availableWidth -= width;
  5950. widths[index] = width;
  5951. }
  5952. else {
  5953. globalWidthPercentage += value.internalValue;
  5954. }
  5955. index++;
  5956. }
  5957. var left = 0;
  5958. index = 0;
  5959. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  5960. var value = _g[_f];
  5961. lefts.push(left);
  5962. if (!value.isPixel) {
  5963. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  5964. left += width;
  5965. widths[index] = width;
  5966. }
  5967. else {
  5968. left += value.getValue(this._host);
  5969. }
  5970. index++;
  5971. }
  5972. definitionCallback(lefts, tops, widths, heights);
  5973. };
  5974. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  5975. var _this = this;
  5976. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  5977. // Setting child sizes
  5978. for (var key in _this._cells) {
  5979. if (!_this._cells.hasOwnProperty(key)) {
  5980. continue;
  5981. }
  5982. var split = key.split(":");
  5983. var x = parseInt(split[0]);
  5984. var y = parseInt(split[1]);
  5985. var cell = _this._cells[key];
  5986. cell.left = lefts[y] + "px";
  5987. cell.top = tops[x] + "px";
  5988. cell.width = widths[y] + "px";
  5989. cell.height = heights[x] + "px";
  5990. }
  5991. });
  5992. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5993. };
  5994. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  5995. for (var key in this._cells) {
  5996. if (!this._cells.hasOwnProperty(key)) {
  5997. continue;
  5998. }
  5999. var child = this._cells[key];
  6000. child._markMatrixAsDirty();
  6001. }
  6002. };
  6003. Grid.prototype._renderHighlightSpecific = function (context) {
  6004. var _this = this;
  6005. _super.prototype._renderHighlightSpecific.call(this, context);
  6006. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6007. // Columns
  6008. for (var index = 0; index < lefts.length; index++) {
  6009. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6010. context.beginPath();
  6011. context.moveTo(left, _this._currentMeasure.top);
  6012. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6013. context.stroke();
  6014. }
  6015. // Rows
  6016. for (var index = 0; index < tops.length; index++) {
  6017. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6018. context.beginPath();
  6019. context.moveTo(_this._currentMeasure.left, top_1);
  6020. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6021. context.stroke();
  6022. }
  6023. });
  6024. context.restore();
  6025. };
  6026. /** Releases associated resources */
  6027. Grid.prototype.dispose = function () {
  6028. _super.prototype.dispose.call(this);
  6029. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6030. var control = _a[_i];
  6031. control.dispose();
  6032. }
  6033. this._childControls = [];
  6034. };
  6035. return Grid;
  6036. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6037. /***/ }),
  6038. /***/ "./2D/controls/image.ts":
  6039. /*!******************************!*\
  6040. !*** ./2D/controls/image.ts ***!
  6041. \******************************/
  6042. /*! exports provided: Image */
  6043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6044. "use strict";
  6045. __webpack_require__.r(__webpack_exports__);
  6046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6047. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6048. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6049. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6050. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6051. /**
  6052. * Class used to create 2D images
  6053. */
  6054. var Image = /** @class */ (function (_super) {
  6055. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6056. /**
  6057. * Creates a new Image
  6058. * @param name defines the control name
  6059. * @param url defines the image url
  6060. */
  6061. function Image(name, url) {
  6062. if (url === void 0) { url = null; }
  6063. var _this = _super.call(this, name) || this;
  6064. _this.name = name;
  6065. _this._loaded = false;
  6066. _this._stretch = Image.STRETCH_FILL;
  6067. _this._autoScale = false;
  6068. _this._sourceLeft = 0;
  6069. _this._sourceTop = 0;
  6070. _this._sourceWidth = 0;
  6071. _this._sourceHeight = 0;
  6072. _this._cellWidth = 0;
  6073. _this._cellHeight = 0;
  6074. _this._cellId = -1;
  6075. _this._populateNinePatchSlicesFromImage = false;
  6076. /**
  6077. * Observable notified when the content is loaded
  6078. */
  6079. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6080. _this.source = url;
  6081. return _this;
  6082. }
  6083. Object.defineProperty(Image.prototype, "isLoaded", {
  6084. /**
  6085. * Gets a boolean indicating that the content is loaded
  6086. */
  6087. get: function () {
  6088. return this._loaded;
  6089. },
  6090. enumerable: true,
  6091. configurable: true
  6092. });
  6093. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6094. /**
  6095. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6096. */
  6097. get: function () {
  6098. return this._populateNinePatchSlicesFromImage;
  6099. },
  6100. set: function (value) {
  6101. if (this._populateNinePatchSlicesFromImage === value) {
  6102. return;
  6103. }
  6104. this._populateNinePatchSlicesFromImage = value;
  6105. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6106. this._extractNinePatchSliceDataFromImage();
  6107. }
  6108. },
  6109. enumerable: true,
  6110. configurable: true
  6111. });
  6112. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6113. /**
  6114. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6115. * Beware using this as this will comsume more memory as the image has to be stored twice
  6116. */
  6117. get: function () {
  6118. return this._detectPointerOnOpaqueOnly;
  6119. },
  6120. set: function (value) {
  6121. if (this._detectPointerOnOpaqueOnly === value) {
  6122. return;
  6123. }
  6124. this._detectPointerOnOpaqueOnly = value;
  6125. },
  6126. enumerable: true,
  6127. configurable: true
  6128. });
  6129. Object.defineProperty(Image.prototype, "sliceLeft", {
  6130. /**
  6131. * Gets or sets the left value for slicing (9-patch)
  6132. */
  6133. get: function () {
  6134. return this._sliceLeft;
  6135. },
  6136. set: function (value) {
  6137. if (this._sliceLeft === value) {
  6138. return;
  6139. }
  6140. this._sliceLeft = value;
  6141. this._markAsDirty();
  6142. },
  6143. enumerable: true,
  6144. configurable: true
  6145. });
  6146. Object.defineProperty(Image.prototype, "sliceRight", {
  6147. /**
  6148. * Gets or sets the right value for slicing (9-patch)
  6149. */
  6150. get: function () {
  6151. return this._sliceRight;
  6152. },
  6153. set: function (value) {
  6154. if (this._sliceRight === value) {
  6155. return;
  6156. }
  6157. this._sliceRight = value;
  6158. this._markAsDirty();
  6159. },
  6160. enumerable: true,
  6161. configurable: true
  6162. });
  6163. Object.defineProperty(Image.prototype, "sliceTop", {
  6164. /**
  6165. * Gets or sets the top value for slicing (9-patch)
  6166. */
  6167. get: function () {
  6168. return this._sliceTop;
  6169. },
  6170. set: function (value) {
  6171. if (this._sliceTop === value) {
  6172. return;
  6173. }
  6174. this._sliceTop = value;
  6175. this._markAsDirty();
  6176. },
  6177. enumerable: true,
  6178. configurable: true
  6179. });
  6180. Object.defineProperty(Image.prototype, "sliceBottom", {
  6181. /**
  6182. * Gets or sets the bottom value for slicing (9-patch)
  6183. */
  6184. get: function () {
  6185. return this._sliceBottom;
  6186. },
  6187. set: function (value) {
  6188. if (this._sliceBottom === value) {
  6189. return;
  6190. }
  6191. this._sliceBottom = value;
  6192. this._markAsDirty();
  6193. },
  6194. enumerable: true,
  6195. configurable: true
  6196. });
  6197. Object.defineProperty(Image.prototype, "sourceLeft", {
  6198. /**
  6199. * Gets or sets the left coordinate in the source image
  6200. */
  6201. get: function () {
  6202. return this._sourceLeft;
  6203. },
  6204. set: function (value) {
  6205. if (this._sourceLeft === value) {
  6206. return;
  6207. }
  6208. this._sourceLeft = value;
  6209. this._markAsDirty();
  6210. },
  6211. enumerable: true,
  6212. configurable: true
  6213. });
  6214. Object.defineProperty(Image.prototype, "sourceTop", {
  6215. /**
  6216. * Gets or sets the top coordinate in the source image
  6217. */
  6218. get: function () {
  6219. return this._sourceTop;
  6220. },
  6221. set: function (value) {
  6222. if (this._sourceTop === value) {
  6223. return;
  6224. }
  6225. this._sourceTop = value;
  6226. this._markAsDirty();
  6227. },
  6228. enumerable: true,
  6229. configurable: true
  6230. });
  6231. Object.defineProperty(Image.prototype, "sourceWidth", {
  6232. /**
  6233. * Gets or sets the width to capture in the source image
  6234. */
  6235. get: function () {
  6236. return this._sourceWidth;
  6237. },
  6238. set: function (value) {
  6239. if (this._sourceWidth === value) {
  6240. return;
  6241. }
  6242. this._sourceWidth = value;
  6243. this._markAsDirty();
  6244. },
  6245. enumerable: true,
  6246. configurable: true
  6247. });
  6248. Object.defineProperty(Image.prototype, "sourceHeight", {
  6249. /**
  6250. * Gets or sets the height to capture in the source image
  6251. */
  6252. get: function () {
  6253. return this._sourceHeight;
  6254. },
  6255. set: function (value) {
  6256. if (this._sourceHeight === value) {
  6257. return;
  6258. }
  6259. this._sourceHeight = value;
  6260. this._markAsDirty();
  6261. },
  6262. enumerable: true,
  6263. configurable: true
  6264. });
  6265. Object.defineProperty(Image.prototype, "autoScale", {
  6266. /**
  6267. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6268. * @see http://doc.babylonjs.com/how_to/gui#image
  6269. */
  6270. get: function () {
  6271. return this._autoScale;
  6272. },
  6273. set: function (value) {
  6274. if (this._autoScale === value) {
  6275. return;
  6276. }
  6277. this._autoScale = value;
  6278. if (value && this._loaded) {
  6279. this.synchronizeSizeWithContent();
  6280. }
  6281. },
  6282. enumerable: true,
  6283. configurable: true
  6284. });
  6285. Object.defineProperty(Image.prototype, "stretch", {
  6286. /** Gets or sets the streching mode used by the image */
  6287. get: function () {
  6288. return this._stretch;
  6289. },
  6290. set: function (value) {
  6291. if (this._stretch === value) {
  6292. return;
  6293. }
  6294. this._stretch = value;
  6295. this._markAsDirty();
  6296. },
  6297. enumerable: true,
  6298. configurable: true
  6299. });
  6300. Object.defineProperty(Image.prototype, "domImage", {
  6301. get: function () {
  6302. return this._domImage;
  6303. },
  6304. /**
  6305. * Gets or sets the internal DOM image used to render the control
  6306. */
  6307. set: function (value) {
  6308. var _this = this;
  6309. this._domImage = value;
  6310. this._loaded = false;
  6311. if (this._domImage.width) {
  6312. this._onImageLoaded();
  6313. }
  6314. else {
  6315. this._domImage.onload = function () {
  6316. _this._onImageLoaded();
  6317. };
  6318. }
  6319. },
  6320. enumerable: true,
  6321. configurable: true
  6322. });
  6323. Image.prototype._onImageLoaded = function () {
  6324. this._imageWidth = this._domImage.width;
  6325. this._imageHeight = this._domImage.height;
  6326. this._loaded = true;
  6327. if (this._populateNinePatchSlicesFromImage) {
  6328. this._extractNinePatchSliceDataFromImage();
  6329. }
  6330. if (this._autoScale) {
  6331. this.synchronizeSizeWithContent();
  6332. }
  6333. this.onImageLoadedObservable.notifyObservers(this);
  6334. this._markAsDirty();
  6335. };
  6336. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6337. if (!Image._WorkingCanvas) {
  6338. Image._WorkingCanvas = document.createElement('canvas');
  6339. }
  6340. var canvas = Image._WorkingCanvas;
  6341. var context = canvas.getContext('2d');
  6342. var width = this._domImage.width;
  6343. var height = this._domImage.height;
  6344. canvas.width = width;
  6345. canvas.height = height;
  6346. context.drawImage(this._domImage, 0, 0, width, height);
  6347. var imageData = context.getImageData(0, 0, width, height);
  6348. // Left and right
  6349. this._sliceLeft = -1;
  6350. this._sliceRight = -1;
  6351. for (var x = 0; x < width; x++) {
  6352. var alpha = imageData.data[x * 4 + 3];
  6353. if (alpha > 127 && this._sliceLeft === -1) {
  6354. this._sliceLeft = x;
  6355. continue;
  6356. }
  6357. if (alpha < 127 && this._sliceLeft > -1) {
  6358. this._sliceRight = x;
  6359. break;
  6360. }
  6361. }
  6362. // top and bottom
  6363. this._sliceTop = -1;
  6364. this._sliceBottom = -1;
  6365. for (var y = 0; y < height; y++) {
  6366. var alpha = imageData.data[y * width * 4 + 3];
  6367. if (alpha > 127 && this._sliceTop === -1) {
  6368. this._sliceTop = y;
  6369. continue;
  6370. }
  6371. if (alpha < 127 && this._sliceTop > -1) {
  6372. this._sliceBottom = y;
  6373. break;
  6374. }
  6375. }
  6376. };
  6377. Object.defineProperty(Image.prototype, "source", {
  6378. /**
  6379. * Gets or sets image source url
  6380. */
  6381. set: function (value) {
  6382. var _this = this;
  6383. if (this._source === value) {
  6384. return;
  6385. }
  6386. this._loaded = false;
  6387. this._source = value;
  6388. this._domImage = document.createElement("img");
  6389. this._domImage.onload = function () {
  6390. _this._onImageLoaded();
  6391. };
  6392. if (value) {
  6393. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6394. this._domImage.src = value;
  6395. }
  6396. },
  6397. enumerable: true,
  6398. configurable: true
  6399. });
  6400. Object.defineProperty(Image.prototype, "cellWidth", {
  6401. /**
  6402. * Gets or sets the cell width to use when animation sheet is enabled
  6403. * @see http://doc.babylonjs.com/how_to/gui#image
  6404. */
  6405. get: function () {
  6406. return this._cellWidth;
  6407. },
  6408. set: function (value) {
  6409. if (this._cellWidth === value) {
  6410. return;
  6411. }
  6412. this._cellWidth = value;
  6413. this._markAsDirty();
  6414. },
  6415. enumerable: true,
  6416. configurable: true
  6417. });
  6418. Object.defineProperty(Image.prototype, "cellHeight", {
  6419. /**
  6420. * Gets or sets the cell height to use when animation sheet is enabled
  6421. * @see http://doc.babylonjs.com/how_to/gui#image
  6422. */
  6423. get: function () {
  6424. return this._cellHeight;
  6425. },
  6426. set: function (value) {
  6427. if (this._cellHeight === value) {
  6428. return;
  6429. }
  6430. this._cellHeight = value;
  6431. this._markAsDirty();
  6432. },
  6433. enumerable: true,
  6434. configurable: true
  6435. });
  6436. Object.defineProperty(Image.prototype, "cellId", {
  6437. /**
  6438. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6439. * @see http://doc.babylonjs.com/how_to/gui#image
  6440. */
  6441. get: function () {
  6442. return this._cellId;
  6443. },
  6444. set: function (value) {
  6445. if (this._cellId === value) {
  6446. return;
  6447. }
  6448. this._cellId = value;
  6449. this._markAsDirty();
  6450. },
  6451. enumerable: true,
  6452. configurable: true
  6453. });
  6454. /**
  6455. * Tests if a given coordinates belong to the current control
  6456. * @param x defines x coordinate to test
  6457. * @param y defines y coordinate to test
  6458. * @returns true if the coordinates are inside the control
  6459. */
  6460. Image.prototype.contains = function (x, y) {
  6461. if (!_super.prototype.contains.call(this, x, y)) {
  6462. return false;
  6463. }
  6464. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6465. return true;
  6466. }
  6467. var canvas = Image._WorkingCanvas;
  6468. var context = canvas.getContext("2d");
  6469. var width = this._currentMeasure.width | 0;
  6470. var height = this._currentMeasure.height | 0;
  6471. var imageData = context.getImageData(0, 0, width, height).data;
  6472. x = (x - this._currentMeasure.left) | 0;
  6473. y = (y - this._currentMeasure.top) | 0;
  6474. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6475. return pickedPixel > 0;
  6476. };
  6477. Image.prototype._getTypeName = function () {
  6478. return "Image";
  6479. };
  6480. /** Force the control to synchronize with its content */
  6481. Image.prototype.synchronizeSizeWithContent = function () {
  6482. if (!this._loaded) {
  6483. return;
  6484. }
  6485. this.width = this._domImage.width + "px";
  6486. this.height = this._domImage.height + "px";
  6487. };
  6488. Image.prototype._processMeasures = function (parentMeasure, context) {
  6489. if (this._loaded) {
  6490. switch (this._stretch) {
  6491. case Image.STRETCH_NONE:
  6492. break;
  6493. case Image.STRETCH_FILL:
  6494. break;
  6495. case Image.STRETCH_UNIFORM:
  6496. break;
  6497. case Image.STRETCH_NINE_PATCH:
  6498. break;
  6499. case Image.STRETCH_EXTEND:
  6500. if (this._autoScale) {
  6501. this.synchronizeSizeWithContent();
  6502. }
  6503. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6504. this.parent.adaptWidthToChildren = true;
  6505. this.parent.adaptHeightToChildren = true;
  6506. }
  6507. break;
  6508. }
  6509. }
  6510. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6511. };
  6512. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6513. if (!this._detectPointerOnOpaqueOnly) {
  6514. return;
  6515. }
  6516. if (!Image._WorkingCanvas) {
  6517. Image._WorkingCanvas = document.createElement('canvas');
  6518. }
  6519. var canvas = Image._WorkingCanvas;
  6520. var width = this._currentMeasure.width;
  6521. var height = this._currentMeasure.height;
  6522. var context = canvas.getContext("2d");
  6523. canvas.width = width;
  6524. canvas.height = height;
  6525. context.clearRect(0, 0, width, height);
  6526. };
  6527. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6528. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6529. if (!this._detectPointerOnOpaqueOnly) {
  6530. return;
  6531. }
  6532. var canvas = Image._WorkingCanvas;
  6533. context = canvas.getContext("2d");
  6534. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6535. };
  6536. Image.prototype._draw = function (context) {
  6537. context.save();
  6538. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6539. context.shadowColor = this.shadowColor;
  6540. context.shadowBlur = this.shadowBlur;
  6541. context.shadowOffsetX = this.shadowOffsetX;
  6542. context.shadowOffsetY = this.shadowOffsetY;
  6543. }
  6544. var x, y, width, height;
  6545. if (this.cellId == -1) {
  6546. x = this._sourceLeft;
  6547. y = this._sourceTop;
  6548. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6549. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6550. }
  6551. else {
  6552. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6553. var column = (this.cellId / rowCount) >> 0;
  6554. var row = this.cellId % rowCount;
  6555. x = this.cellWidth * row;
  6556. y = this.cellHeight * column;
  6557. width = this.cellWidth;
  6558. height = this.cellHeight;
  6559. }
  6560. this._prepareWorkingCanvasForOpaqueDetection();
  6561. this._applyStates(context);
  6562. if (this._loaded) {
  6563. switch (this._stretch) {
  6564. case Image.STRETCH_NONE:
  6565. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6566. break;
  6567. case Image.STRETCH_FILL:
  6568. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6569. break;
  6570. case Image.STRETCH_UNIFORM:
  6571. var hRatio = this._currentMeasure.width / width;
  6572. var vRatio = this._currentMeasure.height / height;
  6573. var ratio = Math.min(hRatio, vRatio);
  6574. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6575. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6576. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6577. break;
  6578. case Image.STRETCH_EXTEND:
  6579. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6580. break;
  6581. case Image.STRETCH_NINE_PATCH:
  6582. this._renderNinePatch(context);
  6583. break;
  6584. }
  6585. }
  6586. context.restore();
  6587. };
  6588. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6589. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6590. };
  6591. Image.prototype._renderNinePatch = function (context) {
  6592. var height = this._imageHeight;
  6593. var leftWidth = this._sliceLeft;
  6594. var topHeight = this._sliceTop;
  6595. var bottomHeight = this._imageHeight - this._sliceBottom;
  6596. var rightWidth = this._imageWidth - this._sliceRight;
  6597. var left = 0;
  6598. var top = 0;
  6599. if (this._populateNinePatchSlicesFromImage) {
  6600. left = 1;
  6601. top = 1;
  6602. height -= 2;
  6603. leftWidth -= 1;
  6604. topHeight -= 1;
  6605. bottomHeight -= 1;
  6606. rightWidth -= 1;
  6607. }
  6608. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6609. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6610. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6611. // Corners
  6612. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6613. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6614. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6615. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6616. // Center
  6617. 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);
  6618. // Borders
  6619. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6620. 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);
  6621. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6622. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6623. };
  6624. Image.prototype.dispose = function () {
  6625. _super.prototype.dispose.call(this);
  6626. this.onImageLoadedObservable.clear();
  6627. };
  6628. Image._WorkingCanvas = null;
  6629. // Static
  6630. /** STRETCH_NONE */
  6631. Image.STRETCH_NONE = 0;
  6632. /** STRETCH_FILL */
  6633. Image.STRETCH_FILL = 1;
  6634. /** STRETCH_UNIFORM */
  6635. Image.STRETCH_UNIFORM = 2;
  6636. /** STRETCH_EXTEND */
  6637. Image.STRETCH_EXTEND = 3;
  6638. /** NINE_PATCH */
  6639. Image.STRETCH_NINE_PATCH = 4;
  6640. return Image;
  6641. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6642. /***/ }),
  6643. /***/ "./2D/controls/index.ts":
  6644. /*!******************************!*\
  6645. !*** ./2D/controls/index.ts ***!
  6646. \******************************/
  6647. /*! 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, name */
  6648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6649. "use strict";
  6650. __webpack_require__.r(__webpack_exports__);
  6651. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6653. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6655. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6657. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6659. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6661. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6663. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6665. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6667. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6669. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6671. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6673. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6675. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6677. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6679. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6685. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6687. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6690. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6693. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6695. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6697. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6699. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6701. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6703. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_23__["name"]; });
  6705. /***/ }),
  6706. /***/ "./2D/controls/inputPassword.ts":
  6707. /*!**************************************!*\
  6708. !*** ./2D/controls/inputPassword.ts ***!
  6709. \**************************************/
  6710. /*! exports provided: InputPassword */
  6711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6712. "use strict";
  6713. __webpack_require__.r(__webpack_exports__);
  6714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6715. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6716. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6717. /**
  6718. * Class used to create a password control
  6719. */
  6720. var InputPassword = /** @class */ (function (_super) {
  6721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6722. function InputPassword() {
  6723. return _super !== null && _super.apply(this, arguments) || this;
  6724. }
  6725. InputPassword.prototype._beforeRenderText = function (text) {
  6726. var txt = "";
  6727. for (var i = 0; i < text.length; i++) {
  6728. txt += "\u2022";
  6729. }
  6730. return txt;
  6731. };
  6732. return InputPassword;
  6733. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6734. /***/ }),
  6735. /***/ "./2D/controls/inputText.ts":
  6736. /*!**********************************!*\
  6737. !*** ./2D/controls/inputText.ts ***!
  6738. \**********************************/
  6739. /*! exports provided: InputText */
  6740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6741. "use strict";
  6742. __webpack_require__.r(__webpack_exports__);
  6743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6744. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6745. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6746. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6747. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6748. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6749. /**
  6750. * Class used to create input text control
  6751. */
  6752. var InputText = /** @class */ (function (_super) {
  6753. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6754. /**
  6755. * Creates a new InputText
  6756. * @param name defines the control name
  6757. * @param text defines the text of the control
  6758. */
  6759. function InputText(name, text) {
  6760. if (text === void 0) { text = ""; }
  6761. var _this = _super.call(this, name) || this;
  6762. _this.name = name;
  6763. _this._text = "";
  6764. _this._placeholderText = "";
  6765. _this._background = "#222222";
  6766. _this._focusedBackground = "#000000";
  6767. _this._focusedColor = "white";
  6768. _this._placeholderColor = "gray";
  6769. _this._thickness = 1;
  6770. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6771. _this._autoStretchWidth = true;
  6772. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6773. _this._isFocused = false;
  6774. _this._blinkIsEven = false;
  6775. _this._cursorOffset = 0;
  6776. _this._deadKey = false;
  6777. _this._addKey = true;
  6778. _this._currentKey = "";
  6779. _this._isTextHighlightOn = false;
  6780. _this._textHighlightColor = "#d5e0ff";
  6781. _this._highligherOpacity = 0.4;
  6782. _this._highlightedText = "";
  6783. _this._startHighlightIndex = 0;
  6784. _this._endHighlightIndex = 0;
  6785. _this._cursorIndex = -1;
  6786. _this._onFocusSelectAll = false;
  6787. _this._isPointerDown = false;
  6788. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6789. _this.promptMessage = "Please enter text:";
  6790. /** Observable raised when the text changes */
  6791. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6792. /** Observable raised just before an entered character is to be added */
  6793. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6794. /** Observable raised when the control gets the focus */
  6795. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6796. /** Observable raised when the control loses the focus */
  6797. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6798. /**Observable raised when the text is highlighted */
  6799. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6800. /**Observable raised when copy event is triggered */
  6801. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6802. /** Observable raised when cut event is triggered */
  6803. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6804. /** Observable raised when paste event is triggered */
  6805. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6806. /** Observable raised when a key event was processed */
  6807. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6808. _this.text = text;
  6809. _this.isPointerBlocker = true;
  6810. return _this;
  6811. }
  6812. Object.defineProperty(InputText.prototype, "maxWidth", {
  6813. /** Gets or sets the maximum width allowed by the control */
  6814. get: function () {
  6815. return this._maxWidth.toString(this._host);
  6816. },
  6817. set: function (value) {
  6818. if (this._maxWidth.toString(this._host) === value) {
  6819. return;
  6820. }
  6821. if (this._maxWidth.fromString(value)) {
  6822. this._markAsDirty();
  6823. }
  6824. },
  6825. enumerable: true,
  6826. configurable: true
  6827. });
  6828. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6829. /** Gets the maximum width allowed by the control in pixels */
  6830. get: function () {
  6831. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6832. },
  6833. enumerable: true,
  6834. configurable: true
  6835. });
  6836. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6837. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6838. get: function () {
  6839. return this._highligherOpacity;
  6840. },
  6841. set: function (value) {
  6842. if (this._highligherOpacity === value) {
  6843. return;
  6844. }
  6845. this._highligherOpacity = value;
  6846. this._markAsDirty();
  6847. },
  6848. enumerable: true,
  6849. configurable: true
  6850. });
  6851. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6852. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6853. get: function () {
  6854. return this._onFocusSelectAll;
  6855. },
  6856. set: function (value) {
  6857. if (this._onFocusSelectAll === value) {
  6858. return;
  6859. }
  6860. this._onFocusSelectAll = value;
  6861. this._markAsDirty();
  6862. },
  6863. enumerable: true,
  6864. configurable: true
  6865. });
  6866. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6867. /** Gets or sets the text hightlight color */
  6868. get: function () {
  6869. return this._textHighlightColor;
  6870. },
  6871. set: function (value) {
  6872. if (this._textHighlightColor === value) {
  6873. return;
  6874. }
  6875. this._textHighlightColor = value;
  6876. this._markAsDirty();
  6877. },
  6878. enumerable: true,
  6879. configurable: true
  6880. });
  6881. Object.defineProperty(InputText.prototype, "margin", {
  6882. /** Gets or sets control margin */
  6883. get: function () {
  6884. return this._margin.toString(this._host);
  6885. },
  6886. set: function (value) {
  6887. if (this._margin.toString(this._host) === value) {
  6888. return;
  6889. }
  6890. if (this._margin.fromString(value)) {
  6891. this._markAsDirty();
  6892. }
  6893. },
  6894. enumerable: true,
  6895. configurable: true
  6896. });
  6897. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6898. /** Gets control margin in pixels */
  6899. get: function () {
  6900. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6901. },
  6902. enumerable: true,
  6903. configurable: true
  6904. });
  6905. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6906. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6907. get: function () {
  6908. return this._autoStretchWidth;
  6909. },
  6910. set: function (value) {
  6911. if (this._autoStretchWidth === value) {
  6912. return;
  6913. }
  6914. this._autoStretchWidth = value;
  6915. this._markAsDirty();
  6916. },
  6917. enumerable: true,
  6918. configurable: true
  6919. });
  6920. Object.defineProperty(InputText.prototype, "thickness", {
  6921. /** Gets or sets border thickness */
  6922. get: function () {
  6923. return this._thickness;
  6924. },
  6925. set: function (value) {
  6926. if (this._thickness === value) {
  6927. return;
  6928. }
  6929. this._thickness = value;
  6930. this._markAsDirty();
  6931. },
  6932. enumerable: true,
  6933. configurable: true
  6934. });
  6935. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6936. /** Gets or sets the background color when focused */
  6937. get: function () {
  6938. return this._focusedBackground;
  6939. },
  6940. set: function (value) {
  6941. if (this._focusedBackground === value) {
  6942. return;
  6943. }
  6944. this._focusedBackground = value;
  6945. this._markAsDirty();
  6946. },
  6947. enumerable: true,
  6948. configurable: true
  6949. });
  6950. Object.defineProperty(InputText.prototype, "focusedColor", {
  6951. /** Gets or sets the background color when focused */
  6952. get: function () {
  6953. return this._focusedColor;
  6954. },
  6955. set: function (value) {
  6956. if (this._focusedColor === value) {
  6957. return;
  6958. }
  6959. this._focusedColor = value;
  6960. this._markAsDirty();
  6961. },
  6962. enumerable: true,
  6963. configurable: true
  6964. });
  6965. Object.defineProperty(InputText.prototype, "background", {
  6966. /** Gets or sets the background color */
  6967. get: function () {
  6968. return this._background;
  6969. },
  6970. set: function (value) {
  6971. if (this._background === value) {
  6972. return;
  6973. }
  6974. this._background = value;
  6975. this._markAsDirty();
  6976. },
  6977. enumerable: true,
  6978. configurable: true
  6979. });
  6980. Object.defineProperty(InputText.prototype, "placeholderColor", {
  6981. /** Gets or sets the placeholder color */
  6982. get: function () {
  6983. return this._placeholderColor;
  6984. },
  6985. set: function (value) {
  6986. if (this._placeholderColor === value) {
  6987. return;
  6988. }
  6989. this._placeholderColor = value;
  6990. this._markAsDirty();
  6991. },
  6992. enumerable: true,
  6993. configurable: true
  6994. });
  6995. Object.defineProperty(InputText.prototype, "placeholderText", {
  6996. /** Gets or sets the text displayed when the control is empty */
  6997. get: function () {
  6998. return this._placeholderText;
  6999. },
  7000. set: function (value) {
  7001. if (this._placeholderText === value) {
  7002. return;
  7003. }
  7004. this._placeholderText = value;
  7005. this._markAsDirty();
  7006. },
  7007. enumerable: true,
  7008. configurable: true
  7009. });
  7010. Object.defineProperty(InputText.prototype, "deadKey", {
  7011. /** Gets or sets the dead key flag */
  7012. get: function () {
  7013. return this._deadKey;
  7014. },
  7015. set: function (flag) {
  7016. this._deadKey = flag;
  7017. },
  7018. enumerable: true,
  7019. configurable: true
  7020. });
  7021. Object.defineProperty(InputText.prototype, "highlightedText", {
  7022. /** Gets or sets the highlight text */
  7023. get: function () {
  7024. return this._highlightedText;
  7025. },
  7026. set: function (text) {
  7027. if (this._highlightedText === text) {
  7028. return;
  7029. }
  7030. this._highlightedText = text;
  7031. this._markAsDirty();
  7032. },
  7033. enumerable: true,
  7034. configurable: true
  7035. });
  7036. Object.defineProperty(InputText.prototype, "addKey", {
  7037. /** Gets or sets if the current key should be added */
  7038. get: function () {
  7039. return this._addKey;
  7040. },
  7041. set: function (flag) {
  7042. this._addKey = flag;
  7043. },
  7044. enumerable: true,
  7045. configurable: true
  7046. });
  7047. Object.defineProperty(InputText.prototype, "currentKey", {
  7048. /** Gets or sets the value of the current key being entered */
  7049. get: function () {
  7050. return this._currentKey;
  7051. },
  7052. set: function (key) {
  7053. this._currentKey = key;
  7054. },
  7055. enumerable: true,
  7056. configurable: true
  7057. });
  7058. Object.defineProperty(InputText.prototype, "text", {
  7059. /** Gets or sets the text displayed in the control */
  7060. get: function () {
  7061. return this._text;
  7062. },
  7063. set: function (value) {
  7064. var valueAsString = value.toString(); // Forcing convertion
  7065. if (this._text === valueAsString) {
  7066. return;
  7067. }
  7068. this._text = valueAsString;
  7069. this._markAsDirty();
  7070. this.onTextChangedObservable.notifyObservers(this);
  7071. },
  7072. enumerable: true,
  7073. configurable: true
  7074. });
  7075. Object.defineProperty(InputText.prototype, "width", {
  7076. /** Gets or sets control width */
  7077. get: function () {
  7078. return this._width.toString(this._host);
  7079. },
  7080. set: function (value) {
  7081. if (this._width.toString(this._host) === value) {
  7082. return;
  7083. }
  7084. if (this._width.fromString(value)) {
  7085. this._markAsDirty();
  7086. }
  7087. this.autoStretchWidth = false;
  7088. },
  7089. enumerable: true,
  7090. configurable: true
  7091. });
  7092. /** @hidden */
  7093. InputText.prototype.onBlur = function () {
  7094. this._isFocused = false;
  7095. this._scrollLeft = null;
  7096. this._cursorOffset = 0;
  7097. clearTimeout(this._blinkTimeout);
  7098. this._markAsDirty();
  7099. this.onBlurObservable.notifyObservers(this);
  7100. this._host.unRegisterClipboardEvents();
  7101. if (this._onClipboardObserver) {
  7102. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7103. }
  7104. var scene = this._host.getScene();
  7105. if (this._onPointerDblTapObserver && scene) {
  7106. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7107. }
  7108. };
  7109. /** @hidden */
  7110. InputText.prototype.onFocus = function () {
  7111. var _this = this;
  7112. if (!this._isEnabled) {
  7113. return;
  7114. }
  7115. this._scrollLeft = null;
  7116. this._isFocused = true;
  7117. this._blinkIsEven = false;
  7118. this._cursorOffset = 0;
  7119. this._markAsDirty();
  7120. this.onFocusObservable.notifyObservers(this);
  7121. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7122. var value = prompt(this.promptMessage);
  7123. if (value !== null) {
  7124. this.text = value;
  7125. }
  7126. this._host.focusedControl = null;
  7127. return;
  7128. }
  7129. this._host.registerClipboardEvents();
  7130. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7131. // process clipboard event, can be configured.
  7132. switch (clipboardInfo.type) {
  7133. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7134. _this._onCopyText(clipboardInfo.event);
  7135. _this.onTextCopyObservable.notifyObservers(_this);
  7136. break;
  7137. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7138. _this._onCutText(clipboardInfo.event);
  7139. _this.onTextCutObservable.notifyObservers(_this);
  7140. break;
  7141. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7142. _this._onPasteText(clipboardInfo.event);
  7143. _this.onTextPasteObservable.notifyObservers(_this);
  7144. break;
  7145. default: return;
  7146. }
  7147. });
  7148. var scene = this._host.getScene();
  7149. if (scene) {
  7150. //register the pointer double tap event
  7151. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7152. if (!_this._isFocused) {
  7153. return;
  7154. }
  7155. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7156. _this._processDblClick(pointerInfo);
  7157. }
  7158. });
  7159. }
  7160. if (this._onFocusSelectAll) {
  7161. this._selectAllText();
  7162. }
  7163. };
  7164. InputText.prototype._getTypeName = function () {
  7165. return "InputText";
  7166. };
  7167. /**
  7168. * Function called to get the list of controls that should not steal the focus from this control
  7169. * @returns an array of controls
  7170. */
  7171. InputText.prototype.keepsFocusWith = function () {
  7172. if (!this._connectedVirtualKeyboard) {
  7173. return null;
  7174. }
  7175. return [this._connectedVirtualKeyboard];
  7176. };
  7177. /** @hidden */
  7178. InputText.prototype.processKey = function (keyCode, key, evt) {
  7179. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7180. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7181. return;
  7182. }
  7183. //select all
  7184. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7185. this._selectAllText();
  7186. evt.preventDefault();
  7187. return;
  7188. }
  7189. // Specific cases
  7190. switch (keyCode) {
  7191. case 32: //SPACE
  7192. key = " "; //ie11 key for space is "Spacebar"
  7193. break;
  7194. case 191: //SLASH
  7195. if (evt) {
  7196. evt.preventDefault();
  7197. }
  7198. break;
  7199. case 8: // BACKSPACE
  7200. if (this._text && this._text.length > 0) {
  7201. //delete the highlighted text
  7202. if (this._isTextHighlightOn) {
  7203. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7204. this._isTextHighlightOn = false;
  7205. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7206. this._blinkIsEven = false;
  7207. if (evt) {
  7208. evt.preventDefault();
  7209. }
  7210. return;
  7211. }
  7212. //delete single character
  7213. if (this._cursorOffset === 0) {
  7214. this.text = this._text.substr(0, this._text.length - 1);
  7215. }
  7216. else {
  7217. var deletePosition = this._text.length - this._cursorOffset;
  7218. if (deletePosition > 0) {
  7219. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7220. }
  7221. }
  7222. }
  7223. if (evt) {
  7224. evt.preventDefault();
  7225. }
  7226. return;
  7227. case 46: // DELETE
  7228. if (this._isTextHighlightOn) {
  7229. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7230. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7231. while (decrementor > 0 && this._cursorOffset > 0) {
  7232. this._cursorOffset--;
  7233. }
  7234. this._isTextHighlightOn = false;
  7235. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7236. if (evt) {
  7237. evt.preventDefault();
  7238. }
  7239. return;
  7240. }
  7241. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7242. var deletePosition = this._text.length - this._cursorOffset;
  7243. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7244. this._cursorOffset--;
  7245. }
  7246. if (evt) {
  7247. evt.preventDefault();
  7248. }
  7249. return;
  7250. case 13: // RETURN
  7251. this._host.focusedControl = null;
  7252. this._isTextHighlightOn = false;
  7253. return;
  7254. case 35: // END
  7255. this._cursorOffset = 0;
  7256. this._blinkIsEven = false;
  7257. this._isTextHighlightOn = false;
  7258. this._markAsDirty();
  7259. return;
  7260. case 36: // HOME
  7261. this._cursorOffset = this._text.length;
  7262. this._blinkIsEven = false;
  7263. this._isTextHighlightOn = false;
  7264. this._markAsDirty();
  7265. return;
  7266. case 37: // LEFT
  7267. this._cursorOffset++;
  7268. if (this._cursorOffset > this._text.length) {
  7269. this._cursorOffset = this._text.length;
  7270. }
  7271. if (evt && evt.shiftKey) {
  7272. // update the cursor
  7273. this._blinkIsEven = false;
  7274. // shift + ctrl/cmd + <-
  7275. if (evt.ctrlKey || evt.metaKey) {
  7276. if (!this._isTextHighlightOn) {
  7277. if (this._text.length === this._cursorOffset) {
  7278. return;
  7279. }
  7280. else {
  7281. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7282. }
  7283. }
  7284. this._startHighlightIndex = 0;
  7285. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7286. this._cursorOffset = this._text.length;
  7287. this._isTextHighlightOn = true;
  7288. this._markAsDirty();
  7289. return;
  7290. }
  7291. //store the starting point
  7292. if (!this._isTextHighlightOn) {
  7293. this._isTextHighlightOn = true;
  7294. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7295. }
  7296. //if text is already highlighted
  7297. else if (this._cursorIndex === -1) {
  7298. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7299. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7300. }
  7301. //set the highlight indexes
  7302. if (this._cursorIndex < this._cursorOffset) {
  7303. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7304. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7305. }
  7306. else if (this._cursorIndex > this._cursorOffset) {
  7307. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7308. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7309. }
  7310. else {
  7311. this._isTextHighlightOn = false;
  7312. }
  7313. this._markAsDirty();
  7314. return;
  7315. }
  7316. if (this._isTextHighlightOn) {
  7317. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7318. this._isTextHighlightOn = false;
  7319. }
  7320. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7321. this._cursorOffset = this.text.length;
  7322. evt.preventDefault();
  7323. }
  7324. this._blinkIsEven = false;
  7325. this._isTextHighlightOn = false;
  7326. this._cursorIndex = -1;
  7327. this._markAsDirty();
  7328. return;
  7329. case 39: // RIGHT
  7330. this._cursorOffset--;
  7331. if (this._cursorOffset < 0) {
  7332. this._cursorOffset = 0;
  7333. }
  7334. if (evt && evt.shiftKey) {
  7335. //update the cursor
  7336. this._blinkIsEven = false;
  7337. //shift + ctrl/cmd + ->
  7338. if (evt.ctrlKey || evt.metaKey) {
  7339. if (!this._isTextHighlightOn) {
  7340. if (this._cursorOffset === 0) {
  7341. return;
  7342. }
  7343. else {
  7344. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7345. }
  7346. }
  7347. this._endHighlightIndex = this._text.length;
  7348. this._isTextHighlightOn = true;
  7349. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7350. this._cursorOffset = 0;
  7351. this._markAsDirty();
  7352. return;
  7353. }
  7354. if (!this._isTextHighlightOn) {
  7355. this._isTextHighlightOn = true;
  7356. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7357. }
  7358. //if text is already highlighted
  7359. else if (this._cursorIndex === -1) {
  7360. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7361. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7362. }
  7363. //set the highlight indexes
  7364. if (this._cursorIndex < this._cursorOffset) {
  7365. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7366. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7367. }
  7368. else if (this._cursorIndex > this._cursorOffset) {
  7369. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7370. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7371. }
  7372. else {
  7373. this._isTextHighlightOn = false;
  7374. }
  7375. this._markAsDirty();
  7376. return;
  7377. }
  7378. if (this._isTextHighlightOn) {
  7379. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7380. this._isTextHighlightOn = false;
  7381. }
  7382. //ctr + ->
  7383. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7384. this._cursorOffset = 0;
  7385. evt.preventDefault();
  7386. }
  7387. this._blinkIsEven = false;
  7388. this._isTextHighlightOn = false;
  7389. this._cursorIndex = -1;
  7390. this._markAsDirty();
  7391. return;
  7392. case 222: // Dead
  7393. if (evt) {
  7394. evt.preventDefault();
  7395. }
  7396. this._cursorIndex = -1;
  7397. this.deadKey = true;
  7398. break;
  7399. }
  7400. // Printable characters
  7401. if (key &&
  7402. ((keyCode === -1) || // Direct access
  7403. (keyCode === 32) || // Space
  7404. (keyCode > 47 && keyCode < 64) || // Numbers
  7405. (keyCode > 64 && keyCode < 91) || // Letters
  7406. (keyCode > 159 && keyCode < 193) || // Special characters
  7407. (keyCode > 218 && keyCode < 223) || // Special characters
  7408. (keyCode > 95 && keyCode < 112))) { // Numpad
  7409. this._currentKey = key;
  7410. this.onBeforeKeyAddObservable.notifyObservers(this);
  7411. key = this._currentKey;
  7412. if (this._addKey) {
  7413. if (this._isTextHighlightOn) {
  7414. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7415. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7416. this._isTextHighlightOn = false;
  7417. this._blinkIsEven = false;
  7418. this._markAsDirty();
  7419. }
  7420. else if (this._cursorOffset === 0) {
  7421. this.text += key;
  7422. }
  7423. else {
  7424. var insertPosition = this._text.length - this._cursorOffset;
  7425. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7426. }
  7427. }
  7428. }
  7429. };
  7430. /** @hidden */
  7431. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7432. //update the cursor
  7433. this._blinkIsEven = false;
  7434. if (this._cursorIndex === -1) {
  7435. this._cursorIndex = offset;
  7436. }
  7437. else {
  7438. if (this._cursorIndex < this._cursorOffset) {
  7439. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7440. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7441. }
  7442. else if (this._cursorIndex > this._cursorOffset) {
  7443. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7444. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7445. }
  7446. else {
  7447. this._isTextHighlightOn = false;
  7448. this._markAsDirty();
  7449. return;
  7450. }
  7451. }
  7452. this._isTextHighlightOn = true;
  7453. this._markAsDirty();
  7454. };
  7455. /** @hidden */
  7456. InputText.prototype._processDblClick = function (evt) {
  7457. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7458. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7459. this._endHighlightIndex = this._startHighlightIndex;
  7460. var rWord = /\w+/g, moveLeft, moveRight;
  7461. do {
  7462. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7463. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7464. } while (moveLeft || moveRight);
  7465. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7466. this.onTextHighlightObservable.notifyObservers(this);
  7467. this._isTextHighlightOn = true;
  7468. this._clickedCoordinate = null;
  7469. this._blinkIsEven = true;
  7470. this._cursorIndex = -1;
  7471. this._markAsDirty();
  7472. };
  7473. /** @hidden */
  7474. InputText.prototype._selectAllText = function () {
  7475. this._blinkIsEven = true;
  7476. this._isTextHighlightOn = true;
  7477. this._startHighlightIndex = 0;
  7478. this._endHighlightIndex = this._text.length;
  7479. this._cursorOffset = this._text.length;
  7480. this._cursorIndex = -1;
  7481. this._markAsDirty();
  7482. };
  7483. /**
  7484. * Handles the keyboard event
  7485. * @param evt Defines the KeyboardEvent
  7486. */
  7487. InputText.prototype.processKeyboard = function (evt) {
  7488. // process pressed key
  7489. this.processKey(evt.keyCode, evt.key, evt);
  7490. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7491. };
  7492. /** @hidden */
  7493. InputText.prototype._onCopyText = function (ev) {
  7494. this._isTextHighlightOn = false;
  7495. //when write permission to clipbaord data is denied
  7496. try {
  7497. ev.clipboardData.setData("text/plain", this._highlightedText);
  7498. }
  7499. catch (_a) { } //pass
  7500. this._host.clipboardData = this._highlightedText;
  7501. };
  7502. /** @hidden */
  7503. InputText.prototype._onCutText = function (ev) {
  7504. if (!this._highlightedText) {
  7505. return;
  7506. }
  7507. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7508. this._isTextHighlightOn = false;
  7509. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7510. //when write permission to clipbaord data is denied
  7511. try {
  7512. ev.clipboardData.setData("text/plain", this._highlightedText);
  7513. }
  7514. catch (_a) { } //pass
  7515. this._host.clipboardData = this._highlightedText;
  7516. this._highlightedText = "";
  7517. };
  7518. /** @hidden */
  7519. InputText.prototype._onPasteText = function (ev) {
  7520. var data = "";
  7521. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7522. data = ev.clipboardData.getData("text/plain");
  7523. }
  7524. else {
  7525. //get the cached data; returns blank string by default
  7526. data = this._host.clipboardData;
  7527. }
  7528. var insertPosition = this._text.length - this._cursorOffset;
  7529. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7530. };
  7531. InputText.prototype._draw = function (context) {
  7532. var _this = this;
  7533. context.save();
  7534. this._applyStates(context);
  7535. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7536. context.shadowColor = this.shadowColor;
  7537. context.shadowBlur = this.shadowBlur;
  7538. context.shadowOffsetX = this.shadowOffsetX;
  7539. context.shadowOffsetY = this.shadowOffsetY;
  7540. }
  7541. // Background
  7542. if (this._isFocused) {
  7543. if (this._focusedBackground) {
  7544. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7545. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7546. }
  7547. }
  7548. else if (this._background) {
  7549. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7550. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7551. }
  7552. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7553. context.shadowBlur = 0;
  7554. context.shadowOffsetX = 0;
  7555. context.shadowOffsetY = 0;
  7556. }
  7557. if (!this._fontOffset) {
  7558. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7559. }
  7560. // Text
  7561. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7562. if (this.color) {
  7563. context.fillStyle = this.color;
  7564. }
  7565. var text = this._beforeRenderText(this._text);
  7566. if (!this._isFocused && !this._text && this._placeholderText) {
  7567. text = this._placeholderText;
  7568. if (this._placeholderColor) {
  7569. context.fillStyle = this._placeholderColor;
  7570. }
  7571. }
  7572. this._textWidth = context.measureText(text).width;
  7573. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7574. if (this._autoStretchWidth) {
  7575. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7576. }
  7577. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7578. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7579. context.save();
  7580. context.beginPath();
  7581. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7582. context.clip();
  7583. if (this._isFocused && this._textWidth > availableWidth) {
  7584. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7585. if (!this._scrollLeft) {
  7586. this._scrollLeft = textLeft;
  7587. }
  7588. }
  7589. else {
  7590. this._scrollLeft = clipTextLeft;
  7591. }
  7592. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7593. // Cursor
  7594. if (this._isFocused) {
  7595. // Need to move cursor
  7596. if (this._clickedCoordinate) {
  7597. var rightPosition = this._scrollLeft + this._textWidth;
  7598. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7599. var currentSize = 0;
  7600. this._cursorOffset = 0;
  7601. var previousDist = 0;
  7602. do {
  7603. if (this._cursorOffset) {
  7604. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7605. }
  7606. this._cursorOffset++;
  7607. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7608. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7609. // Find closest move
  7610. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7611. this._cursorOffset--;
  7612. }
  7613. this._blinkIsEven = false;
  7614. this._clickedCoordinate = null;
  7615. }
  7616. // Render cursor
  7617. if (!this._blinkIsEven) {
  7618. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7619. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7620. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7621. if (cursorLeft < clipTextLeft) {
  7622. this._scrollLeft += (clipTextLeft - cursorLeft);
  7623. cursorLeft = clipTextLeft;
  7624. this._markAsDirty();
  7625. }
  7626. else if (cursorLeft > clipTextLeft + availableWidth) {
  7627. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7628. cursorLeft = clipTextLeft + availableWidth;
  7629. this._markAsDirty();
  7630. }
  7631. if (!this._isTextHighlightOn) {
  7632. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7633. }
  7634. }
  7635. clearTimeout(this._blinkTimeout);
  7636. this._blinkTimeout = setTimeout(function () {
  7637. _this._blinkIsEven = !_this._blinkIsEven;
  7638. _this._markAsDirty();
  7639. }, 500);
  7640. //show the highlighted text
  7641. if (this._isTextHighlightOn) {
  7642. clearTimeout(this._blinkTimeout);
  7643. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7644. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7645. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7646. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7647. if (highlightCursorLeft < clipTextLeft) {
  7648. width = width - (clipTextLeft - highlightCursorLeft);
  7649. if (!width) {
  7650. // when using left arrow on text.length > availableWidth;
  7651. // assigns the width of the first letter after clipTextLeft
  7652. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7653. }
  7654. highlightCursorLeft = clipTextLeft;
  7655. }
  7656. //for transparancy
  7657. context.globalAlpha = this._highligherOpacity;
  7658. context.fillStyle = this._textHighlightColor;
  7659. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7660. context.globalAlpha = 1.0;
  7661. }
  7662. }
  7663. context.restore();
  7664. // Border
  7665. if (this._thickness) {
  7666. if (this._isFocused) {
  7667. if (this.focusedColor) {
  7668. context.strokeStyle = this.focusedColor;
  7669. }
  7670. }
  7671. else {
  7672. if (this.color) {
  7673. context.strokeStyle = this.color;
  7674. }
  7675. }
  7676. context.lineWidth = this._thickness;
  7677. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7678. }
  7679. context.restore();
  7680. };
  7681. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7682. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7683. return false;
  7684. }
  7685. this._clickedCoordinate = coordinates.x;
  7686. this._isTextHighlightOn = false;
  7687. this._highlightedText = "";
  7688. this._cursorIndex = -1;
  7689. this._isPointerDown = true;
  7690. this._host._capturingControl[pointerId] = this;
  7691. if (this._host.focusedControl === this) {
  7692. // Move cursor
  7693. clearTimeout(this._blinkTimeout);
  7694. this._markAsDirty();
  7695. return true;
  7696. }
  7697. if (!this._isEnabled) {
  7698. return false;
  7699. }
  7700. this._host.focusedControl = this;
  7701. return true;
  7702. };
  7703. InputText.prototype._onPointerMove = function (target, coordinates) {
  7704. if (this._host.focusedControl === this && this._isPointerDown) {
  7705. this._clickedCoordinate = coordinates.x;
  7706. this._markAsDirty();
  7707. this._updateValueFromCursorIndex(this._cursorOffset);
  7708. }
  7709. _super.prototype._onPointerMove.call(this, target, coordinates);
  7710. };
  7711. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7712. this._isPointerDown = false;
  7713. delete this._host._capturingControl[pointerId];
  7714. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7715. };
  7716. InputText.prototype._beforeRenderText = function (text) {
  7717. return text;
  7718. };
  7719. InputText.prototype.dispose = function () {
  7720. _super.prototype.dispose.call(this);
  7721. this.onBlurObservable.clear();
  7722. this.onFocusObservable.clear();
  7723. this.onTextChangedObservable.clear();
  7724. this.onTextCopyObservable.clear();
  7725. this.onTextCutObservable.clear();
  7726. this.onTextPasteObservable.clear();
  7727. this.onTextHighlightObservable.clear();
  7728. this.onKeyboardEventProcessedObservable.clear();
  7729. };
  7730. return InputText;
  7731. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7732. /***/ }),
  7733. /***/ "./2D/controls/line.ts":
  7734. /*!*****************************!*\
  7735. !*** ./2D/controls/line.ts ***!
  7736. \*****************************/
  7737. /*! exports provided: Line */
  7738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7739. "use strict";
  7740. __webpack_require__.r(__webpack_exports__);
  7741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7742. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7743. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  7744. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7745. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7746. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7747. /** Class used to render 2D lines */
  7748. var Line = /** @class */ (function (_super) {
  7749. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7750. /**
  7751. * Creates a new Line
  7752. * @param name defines the control name
  7753. */
  7754. function Line(name) {
  7755. var _this = _super.call(this, name) || this;
  7756. _this.name = name;
  7757. _this._lineWidth = 1;
  7758. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7759. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7760. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7761. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7762. _this._dash = new Array();
  7763. _this.isHitTestVisible = false;
  7764. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7765. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7766. return _this;
  7767. }
  7768. Object.defineProperty(Line.prototype, "dash", {
  7769. /** Gets or sets the dash pattern */
  7770. get: function () {
  7771. return this._dash;
  7772. },
  7773. set: function (value) {
  7774. if (this._dash === value) {
  7775. return;
  7776. }
  7777. this._dash = value;
  7778. this._markAsDirty();
  7779. },
  7780. enumerable: true,
  7781. configurable: true
  7782. });
  7783. Object.defineProperty(Line.prototype, "connectedControl", {
  7784. /** Gets or sets the control connected with the line end */
  7785. get: function () {
  7786. return this._connectedControl;
  7787. },
  7788. set: function (value) {
  7789. var _this = this;
  7790. if (this._connectedControl === value) {
  7791. return;
  7792. }
  7793. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7794. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7795. this._connectedControlDirtyObserver = null;
  7796. }
  7797. if (value) {
  7798. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7799. }
  7800. this._connectedControl = value;
  7801. this._markAsDirty();
  7802. },
  7803. enumerable: true,
  7804. configurable: true
  7805. });
  7806. Object.defineProperty(Line.prototype, "x1", {
  7807. /** Gets or sets start coordinates on X axis */
  7808. get: function () {
  7809. return this._x1.toString(this._host);
  7810. },
  7811. set: function (value) {
  7812. if (this._x1.toString(this._host) === value) {
  7813. return;
  7814. }
  7815. if (this._x1.fromString(value)) {
  7816. this._markAsDirty();
  7817. }
  7818. },
  7819. enumerable: true,
  7820. configurable: true
  7821. });
  7822. Object.defineProperty(Line.prototype, "y1", {
  7823. /** Gets or sets start coordinates on Y axis */
  7824. get: function () {
  7825. return this._y1.toString(this._host);
  7826. },
  7827. set: function (value) {
  7828. if (this._y1.toString(this._host) === value) {
  7829. return;
  7830. }
  7831. if (this._y1.fromString(value)) {
  7832. this._markAsDirty();
  7833. }
  7834. },
  7835. enumerable: true,
  7836. configurable: true
  7837. });
  7838. Object.defineProperty(Line.prototype, "x2", {
  7839. /** Gets or sets end coordinates on X axis */
  7840. get: function () {
  7841. return this._x2.toString(this._host);
  7842. },
  7843. set: function (value) {
  7844. if (this._x2.toString(this._host) === value) {
  7845. return;
  7846. }
  7847. if (this._x2.fromString(value)) {
  7848. this._markAsDirty();
  7849. }
  7850. },
  7851. enumerable: true,
  7852. configurable: true
  7853. });
  7854. Object.defineProperty(Line.prototype, "y2", {
  7855. /** Gets or sets end coordinates on Y axis */
  7856. get: function () {
  7857. return this._y2.toString(this._host);
  7858. },
  7859. set: function (value) {
  7860. if (this._y2.toString(this._host) === value) {
  7861. return;
  7862. }
  7863. if (this._y2.fromString(value)) {
  7864. this._markAsDirty();
  7865. }
  7866. },
  7867. enumerable: true,
  7868. configurable: true
  7869. });
  7870. Object.defineProperty(Line.prototype, "lineWidth", {
  7871. /** Gets or sets line width */
  7872. get: function () {
  7873. return this._lineWidth;
  7874. },
  7875. set: function (value) {
  7876. if (this._lineWidth === value) {
  7877. return;
  7878. }
  7879. this._lineWidth = value;
  7880. this._markAsDirty();
  7881. },
  7882. enumerable: true,
  7883. configurable: true
  7884. });
  7885. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7886. /** Gets or sets horizontal alignment */
  7887. set: function (value) {
  7888. return;
  7889. },
  7890. enumerable: true,
  7891. configurable: true
  7892. });
  7893. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7894. /** Gets or sets vertical alignment */
  7895. set: function (value) {
  7896. return;
  7897. },
  7898. enumerable: true,
  7899. configurable: true
  7900. });
  7901. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7902. get: function () {
  7903. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7904. },
  7905. enumerable: true,
  7906. configurable: true
  7907. });
  7908. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7909. get: function () {
  7910. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7911. },
  7912. enumerable: true,
  7913. configurable: true
  7914. });
  7915. Line.prototype._getTypeName = function () {
  7916. return "Line";
  7917. };
  7918. Line.prototype._draw = function (context) {
  7919. context.save();
  7920. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7921. context.shadowColor = this.shadowColor;
  7922. context.shadowBlur = this.shadowBlur;
  7923. context.shadowOffsetX = this.shadowOffsetX;
  7924. context.shadowOffsetY = this.shadowOffsetY;
  7925. }
  7926. this._applyStates(context);
  7927. context.strokeStyle = this.color;
  7928. context.lineWidth = this._lineWidth;
  7929. context.setLineDash(this._dash);
  7930. context.beginPath();
  7931. context.moveTo(this._x1.getValue(this._host), this._y1.getValue(this._host));
  7932. context.lineTo(this._effectiveX2, this._effectiveY2);
  7933. context.stroke();
  7934. context.restore();
  7935. };
  7936. Line.prototype._measure = function () {
  7937. // Width / Height
  7938. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7939. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7940. };
  7941. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7942. this._currentMeasure.left = Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7943. this._currentMeasure.top = Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7944. };
  7945. /**
  7946. * Move one end of the line given 3D cartesian coordinates.
  7947. * @param position Targeted world position
  7948. * @param scene Scene
  7949. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7950. */
  7951. Line.prototype.moveToVector3 = function (position, scene, end) {
  7952. if (end === void 0) { end = false; }
  7953. if (!this._host || this.parent !== this._host._rootContainer) {
  7954. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  7955. return;
  7956. }
  7957. var globalViewport = this._host._getGlobalViewport(scene);
  7958. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  7959. this._moveToProjectedPosition(projectedPosition, end);
  7960. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  7961. this.notRenderable = true;
  7962. return;
  7963. }
  7964. this.notRenderable = false;
  7965. };
  7966. /**
  7967. * Move one end of the line to a position in screen absolute space.
  7968. * @param projectedPosition Position in screen absolute space (X, Y)
  7969. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7970. */
  7971. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  7972. if (end === void 0) { end = false; }
  7973. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  7974. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  7975. if (end) {
  7976. this.x2 = x;
  7977. this.y2 = y;
  7978. this._x2.ignoreAdaptiveScaling = true;
  7979. this._y2.ignoreAdaptiveScaling = true;
  7980. }
  7981. else {
  7982. this.x1 = x;
  7983. this.y1 = y;
  7984. this._x1.ignoreAdaptiveScaling = true;
  7985. this._y1.ignoreAdaptiveScaling = true;
  7986. }
  7987. };
  7988. return Line;
  7989. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7990. /***/ }),
  7991. /***/ "./2D/controls/multiLine.ts":
  7992. /*!**********************************!*\
  7993. !*** ./2D/controls/multiLine.ts ***!
  7994. \**********************************/
  7995. /*! exports provided: MultiLine */
  7996. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7997. "use strict";
  7998. __webpack_require__.r(__webpack_exports__);
  7999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8000. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8001. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  8002. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8003. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8004. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8005. /**
  8006. * Class used to create multi line control
  8007. */
  8008. var MultiLine = /** @class */ (function (_super) {
  8009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8010. /**
  8011. * Creates a new MultiLine
  8012. * @param name defines the control name
  8013. */
  8014. function MultiLine(name) {
  8015. var _this = _super.call(this, name) || this;
  8016. _this.name = name;
  8017. _this._lineWidth = 1;
  8018. /** Function called when a point is updated */
  8019. _this.onPointUpdate = function () {
  8020. _this._markAsDirty();
  8021. };
  8022. _this.isHitTestVisible = false;
  8023. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8024. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8025. _this._dash = [];
  8026. _this._points = [];
  8027. return _this;
  8028. }
  8029. Object.defineProperty(MultiLine.prototype, "dash", {
  8030. /** Gets or sets dash pattern */
  8031. get: function () {
  8032. return this._dash;
  8033. },
  8034. set: function (value) {
  8035. if (this._dash === value) {
  8036. return;
  8037. }
  8038. this._dash = value;
  8039. this._markAsDirty();
  8040. },
  8041. enumerable: true,
  8042. configurable: true
  8043. });
  8044. /**
  8045. * Gets point stored at specified index
  8046. * @param index defines the index to look for
  8047. * @returns the requested point if found
  8048. */
  8049. MultiLine.prototype.getAt = function (index) {
  8050. if (!this._points[index]) {
  8051. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8052. }
  8053. return this._points[index];
  8054. };
  8055. /**
  8056. * Adds new points to the point collection
  8057. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8058. * @returns the list of created MultiLinePoint
  8059. */
  8060. MultiLine.prototype.add = function () {
  8061. var _this = this;
  8062. var items = [];
  8063. for (var _i = 0; _i < arguments.length; _i++) {
  8064. items[_i] = arguments[_i];
  8065. }
  8066. return items.map(function (item) { return _this.push(item); });
  8067. };
  8068. /**
  8069. * Adds a new point to the point collection
  8070. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8071. * @returns the created MultiLinePoint
  8072. */
  8073. MultiLine.prototype.push = function (item) {
  8074. var point = this.getAt(this._points.length);
  8075. if (item == null) {
  8076. return point;
  8077. }
  8078. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8079. point.mesh = item;
  8080. }
  8081. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8082. point.control = item;
  8083. }
  8084. else if (item.x != null && item.y != null) {
  8085. point.x = item.x;
  8086. point.y = item.y;
  8087. }
  8088. return point;
  8089. };
  8090. /**
  8091. * Remove a specific value or point from the active point collection
  8092. * @param value defines the value or point to remove
  8093. */
  8094. MultiLine.prototype.remove = function (value) {
  8095. var index;
  8096. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8097. index = this._points.indexOf(value);
  8098. if (index === -1) {
  8099. return;
  8100. }
  8101. }
  8102. else {
  8103. index = value;
  8104. }
  8105. var point = this._points[index];
  8106. if (!point) {
  8107. return;
  8108. }
  8109. point.dispose();
  8110. this._points.splice(index, 1);
  8111. };
  8112. /**
  8113. * Resets this object to initial state (no point)
  8114. */
  8115. MultiLine.prototype.reset = function () {
  8116. while (this._points.length > 0) {
  8117. this.remove(this._points.length - 1);
  8118. }
  8119. };
  8120. /**
  8121. * Resets all links
  8122. */
  8123. MultiLine.prototype.resetLinks = function () {
  8124. this._points.forEach(function (point) {
  8125. if (point != null) {
  8126. point.resetLinks();
  8127. }
  8128. });
  8129. };
  8130. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8131. /** Gets or sets line width */
  8132. get: function () {
  8133. return this._lineWidth;
  8134. },
  8135. set: function (value) {
  8136. if (this._lineWidth === value) {
  8137. return;
  8138. }
  8139. this._lineWidth = value;
  8140. this._markAsDirty();
  8141. },
  8142. enumerable: true,
  8143. configurable: true
  8144. });
  8145. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8146. set: function (value) {
  8147. return;
  8148. },
  8149. enumerable: true,
  8150. configurable: true
  8151. });
  8152. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8153. set: function (value) {
  8154. return;
  8155. },
  8156. enumerable: true,
  8157. configurable: true
  8158. });
  8159. MultiLine.prototype._getTypeName = function () {
  8160. return "MultiLine";
  8161. };
  8162. MultiLine.prototype._draw = function (context) {
  8163. context.save();
  8164. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8165. context.shadowColor = this.shadowColor;
  8166. context.shadowBlur = this.shadowBlur;
  8167. context.shadowOffsetX = this.shadowOffsetX;
  8168. context.shadowOffsetY = this.shadowOffsetY;
  8169. }
  8170. this._applyStates(context);
  8171. context.strokeStyle = this.color;
  8172. context.lineWidth = this._lineWidth;
  8173. context.setLineDash(this._dash);
  8174. context.beginPath();
  8175. var first = true; //first index is not necessarily 0
  8176. this._points.forEach(function (point) {
  8177. if (!point) {
  8178. return;
  8179. }
  8180. if (first) {
  8181. context.moveTo(point._point.x, point._point.y);
  8182. first = false;
  8183. }
  8184. else {
  8185. context.lineTo(point._point.x, point._point.y);
  8186. }
  8187. });
  8188. context.stroke();
  8189. context.restore();
  8190. };
  8191. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8192. var _this = this;
  8193. this._minX = null;
  8194. this._minY = null;
  8195. this._maxX = null;
  8196. this._maxY = null;
  8197. this._points.forEach(function (point, index) {
  8198. if (!point) {
  8199. return;
  8200. }
  8201. point.translate();
  8202. if (_this._minX == null || point._point.x < _this._minX) {
  8203. _this._minX = point._point.x;
  8204. }
  8205. if (_this._minY == null || point._point.y < _this._minY) {
  8206. _this._minY = point._point.y;
  8207. }
  8208. if (_this._maxX == null || point._point.x > _this._maxX) {
  8209. _this._maxX = point._point.x;
  8210. }
  8211. if (_this._maxY == null || point._point.y > _this._maxY) {
  8212. _this._maxY = point._point.y;
  8213. }
  8214. });
  8215. if (this._minX == null) {
  8216. this._minX = 0;
  8217. }
  8218. if (this._minY == null) {
  8219. this._minY = 0;
  8220. }
  8221. if (this._maxX == null) {
  8222. this._maxX = 0;
  8223. }
  8224. if (this._maxY == null) {
  8225. this._maxY = 0;
  8226. }
  8227. };
  8228. MultiLine.prototype._measure = function () {
  8229. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8230. return;
  8231. }
  8232. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8233. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8234. };
  8235. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8236. if (this._minX == null || this._minY == null) {
  8237. return;
  8238. }
  8239. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8240. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8241. };
  8242. MultiLine.prototype.dispose = function () {
  8243. this.reset();
  8244. _super.prototype.dispose.call(this);
  8245. };
  8246. return MultiLine;
  8247. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8248. /***/ }),
  8249. /***/ "./2D/controls/radioButton.ts":
  8250. /*!************************************!*\
  8251. !*** ./2D/controls/radioButton.ts ***!
  8252. \************************************/
  8253. /*! exports provided: RadioButton */
  8254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8255. "use strict";
  8256. __webpack_require__.r(__webpack_exports__);
  8257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8258. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8259. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8260. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8261. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8262. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8263. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8264. /**
  8265. * Class used to create radio button controls
  8266. */
  8267. var RadioButton = /** @class */ (function (_super) {
  8268. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8269. /**
  8270. * Creates a new RadioButton
  8271. * @param name defines the control name
  8272. */
  8273. function RadioButton(name) {
  8274. var _this = _super.call(this, name) || this;
  8275. _this.name = name;
  8276. _this._isChecked = false;
  8277. _this._background = "black";
  8278. _this._checkSizeRatio = 0.8;
  8279. _this._thickness = 1;
  8280. /** Gets or sets group name */
  8281. _this.group = "";
  8282. /** Observable raised when isChecked is changed */
  8283. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8284. _this.isPointerBlocker = true;
  8285. return _this;
  8286. }
  8287. Object.defineProperty(RadioButton.prototype, "thickness", {
  8288. /** Gets or sets border thickness */
  8289. get: function () {
  8290. return this._thickness;
  8291. },
  8292. set: function (value) {
  8293. if (this._thickness === value) {
  8294. return;
  8295. }
  8296. this._thickness = value;
  8297. this._markAsDirty();
  8298. },
  8299. enumerable: true,
  8300. configurable: true
  8301. });
  8302. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8303. /** Gets or sets a value indicating the ratio between overall size and check size */
  8304. get: function () {
  8305. return this._checkSizeRatio;
  8306. },
  8307. set: function (value) {
  8308. value = Math.max(Math.min(1, value), 0);
  8309. if (this._checkSizeRatio === value) {
  8310. return;
  8311. }
  8312. this._checkSizeRatio = value;
  8313. this._markAsDirty();
  8314. },
  8315. enumerable: true,
  8316. configurable: true
  8317. });
  8318. Object.defineProperty(RadioButton.prototype, "background", {
  8319. /** Gets or sets background color */
  8320. get: function () {
  8321. return this._background;
  8322. },
  8323. set: function (value) {
  8324. if (this._background === value) {
  8325. return;
  8326. }
  8327. this._background = value;
  8328. this._markAsDirty();
  8329. },
  8330. enumerable: true,
  8331. configurable: true
  8332. });
  8333. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8334. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8335. get: function () {
  8336. return this._isChecked;
  8337. },
  8338. set: function (value) {
  8339. var _this = this;
  8340. if (this._isChecked === value) {
  8341. return;
  8342. }
  8343. this._isChecked = value;
  8344. this._markAsDirty();
  8345. this.onIsCheckedChangedObservable.notifyObservers(value);
  8346. if (this._isChecked && this._host) {
  8347. // Update all controls from same group
  8348. this._host.executeOnAllControls(function (control) {
  8349. if (control === _this) {
  8350. return;
  8351. }
  8352. if (control.group === undefined) {
  8353. return;
  8354. }
  8355. var childRadio = control;
  8356. if (childRadio.group === _this.group) {
  8357. childRadio.isChecked = false;
  8358. }
  8359. });
  8360. }
  8361. },
  8362. enumerable: true,
  8363. configurable: true
  8364. });
  8365. RadioButton.prototype._getTypeName = function () {
  8366. return "RadioButton";
  8367. };
  8368. RadioButton.prototype._draw = function (context) {
  8369. context.save();
  8370. this._applyStates(context);
  8371. var actualWidth = this._currentMeasure.width - this._thickness;
  8372. var actualHeight = this._currentMeasure.height - this._thickness;
  8373. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8374. context.shadowColor = this.shadowColor;
  8375. context.shadowBlur = this.shadowBlur;
  8376. context.shadowOffsetX = this.shadowOffsetX;
  8377. context.shadowOffsetY = this.shadowOffsetY;
  8378. }
  8379. // Outer
  8380. _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);
  8381. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8382. context.fill();
  8383. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8384. context.shadowBlur = 0;
  8385. context.shadowOffsetX = 0;
  8386. context.shadowOffsetY = 0;
  8387. }
  8388. context.strokeStyle = this.color;
  8389. context.lineWidth = this._thickness;
  8390. context.stroke();
  8391. // Inner
  8392. if (this._isChecked) {
  8393. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8394. var offsetWidth = actualWidth * this._checkSizeRatio;
  8395. var offseHeight = actualHeight * this._checkSizeRatio;
  8396. _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);
  8397. context.fill();
  8398. }
  8399. context.restore();
  8400. };
  8401. // Events
  8402. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8403. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8404. return false;
  8405. }
  8406. if (!this.isChecked) {
  8407. this.isChecked = true;
  8408. }
  8409. return true;
  8410. };
  8411. /**
  8412. * Utility function to easily create a radio button with a header
  8413. * @param title defines the label to use for the header
  8414. * @param group defines the group to use for the radio button
  8415. * @param isChecked defines the initial state of the radio button
  8416. * @param onValueChanged defines the callback to call when value changes
  8417. * @returns a StackPanel containing the radio button and a textBlock
  8418. */
  8419. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8420. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8421. panel.isVertical = false;
  8422. panel.height = "30px";
  8423. var radio = new RadioButton();
  8424. radio.width = "20px";
  8425. radio.height = "20px";
  8426. radio.isChecked = isChecked;
  8427. radio.color = "green";
  8428. radio.group = group;
  8429. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8430. panel.addControl(radio);
  8431. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8432. header.text = title;
  8433. header.width = "180px";
  8434. header.paddingLeft = "5px";
  8435. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8436. header.color = "white";
  8437. panel.addControl(header);
  8438. return panel;
  8439. };
  8440. return RadioButton;
  8441. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8442. /***/ }),
  8443. /***/ "./2D/controls/rectangle.ts":
  8444. /*!**********************************!*\
  8445. !*** ./2D/controls/rectangle.ts ***!
  8446. \**********************************/
  8447. /*! exports provided: Rectangle */
  8448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8449. "use strict";
  8450. __webpack_require__.r(__webpack_exports__);
  8451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8452. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8453. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8454. /** Class used to create rectangle container */
  8455. var Rectangle = /** @class */ (function (_super) {
  8456. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8457. /**
  8458. * Creates a new Rectangle
  8459. * @param name defines the control name
  8460. */
  8461. function Rectangle(name) {
  8462. var _this = _super.call(this, name) || this;
  8463. _this.name = name;
  8464. _this._thickness = 1;
  8465. _this._cornerRadius = 0;
  8466. return _this;
  8467. }
  8468. Object.defineProperty(Rectangle.prototype, "thickness", {
  8469. /** Gets or sets border thickness */
  8470. get: function () {
  8471. return this._thickness;
  8472. },
  8473. set: function (value) {
  8474. if (this._thickness === value) {
  8475. return;
  8476. }
  8477. this._thickness = value;
  8478. this._markAsDirty();
  8479. },
  8480. enumerable: true,
  8481. configurable: true
  8482. });
  8483. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8484. /** Gets or sets the corner radius angle */
  8485. get: function () {
  8486. return this._cornerRadius;
  8487. },
  8488. set: function (value) {
  8489. if (value < 0) {
  8490. value = 0;
  8491. }
  8492. if (this._cornerRadius === value) {
  8493. return;
  8494. }
  8495. this._cornerRadius = value;
  8496. this._markAsDirty();
  8497. },
  8498. enumerable: true,
  8499. configurable: true
  8500. });
  8501. Rectangle.prototype._getTypeName = function () {
  8502. return "Rectangle";
  8503. };
  8504. Rectangle.prototype._localDraw = function (context) {
  8505. context.save();
  8506. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8507. context.shadowColor = this.shadowColor;
  8508. context.shadowBlur = this.shadowBlur;
  8509. context.shadowOffsetX = this.shadowOffsetX;
  8510. context.shadowOffsetY = this.shadowOffsetY;
  8511. }
  8512. if (this._background) {
  8513. context.fillStyle = this._background;
  8514. if (this._cornerRadius) {
  8515. this._drawRoundedRect(context, this._thickness / 2);
  8516. context.fill();
  8517. }
  8518. else {
  8519. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8520. }
  8521. }
  8522. if (this._thickness) {
  8523. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8524. context.shadowBlur = 0;
  8525. context.shadowOffsetX = 0;
  8526. context.shadowOffsetY = 0;
  8527. }
  8528. if (this.color) {
  8529. context.strokeStyle = this.color;
  8530. }
  8531. context.lineWidth = this._thickness;
  8532. if (this._cornerRadius) {
  8533. this._drawRoundedRect(context, this._thickness / 2);
  8534. context.stroke();
  8535. }
  8536. else {
  8537. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8538. }
  8539. }
  8540. context.restore();
  8541. };
  8542. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8543. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8544. this._measureForChildren.width -= 2 * this._thickness;
  8545. this._measureForChildren.height -= 2 * this._thickness;
  8546. this._measureForChildren.left += this._thickness;
  8547. this._measureForChildren.top += this._thickness;
  8548. };
  8549. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8550. if (offset === void 0) { offset = 0; }
  8551. var x = this._currentMeasure.left + offset;
  8552. var y = this._currentMeasure.top + offset;
  8553. var width = this._currentMeasure.width - offset * 2;
  8554. var height = this._currentMeasure.height - offset * 2;
  8555. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8556. context.beginPath();
  8557. context.moveTo(x + radius, y);
  8558. context.lineTo(x + width - radius, y);
  8559. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8560. context.lineTo(x + width, y + height - radius);
  8561. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8562. context.lineTo(x + radius, y + height);
  8563. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8564. context.lineTo(x, y + radius);
  8565. context.quadraticCurveTo(x, y, x + radius, y);
  8566. context.closePath();
  8567. };
  8568. Rectangle.prototype._clipForChildren = function (context) {
  8569. if (this._cornerRadius) {
  8570. this._drawRoundedRect(context, this._thickness);
  8571. context.clip();
  8572. }
  8573. };
  8574. return Rectangle;
  8575. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8576. /***/ }),
  8577. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8578. /*!***************************************************!*\
  8579. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8580. \***************************************************/
  8581. /*! exports provided: ScrollViewer */
  8582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8583. "use strict";
  8584. __webpack_require__.r(__webpack_exports__);
  8585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8586. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8587. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/observable");
  8588. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8589. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8590. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8591. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8592. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8593. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8594. /**
  8595. * Class used to hold a viewer window and sliders in a grid
  8596. */
  8597. var ScrollViewer = /** @class */ (function (_super) {
  8598. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8599. /**
  8600. * Creates a new ScrollViewer
  8601. * @param name of ScrollViewer
  8602. */
  8603. function ScrollViewer(name) {
  8604. var _this = _super.call(this, name) || this;
  8605. _this._barSize = 20;
  8606. _this._pointerIsOver = false;
  8607. _this._wheelPrecision = 0.05;
  8608. _this.onDirtyObservable.add(function () {
  8609. _this._horizontalBarSpace.color = _this.color;
  8610. _this._verticalBarSpace.color = _this.color;
  8611. _this._dragSpace.color = _this.color;
  8612. });
  8613. _this.onPointerEnterObservable.add(function () {
  8614. _this._pointerIsOver = true;
  8615. });
  8616. _this.onPointerOutObservable.add(function () {
  8617. _this._pointerIsOver = false;
  8618. });
  8619. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8620. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8621. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8622. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8623. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8624. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8625. _this._grid.addColumnDefinition(1);
  8626. _this._grid.addColumnDefinition(0, true);
  8627. _this._grid.addRowDefinition(1);
  8628. _this._grid.addRowDefinition(0, true);
  8629. _super.prototype.addControl.call(_this, _this._grid);
  8630. _this._grid.addControl(_this._window, 0, 0);
  8631. _this._verticalBar.paddingLeft = 0;
  8632. _this._verticalBar.width = "100%";
  8633. _this._verticalBar.height = "100%";
  8634. _this._verticalBar.barOffset = 0;
  8635. _this._verticalBar.value = 0;
  8636. _this._verticalBar.maximum = 1;
  8637. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8638. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8639. _this._verticalBar.isVertical = true;
  8640. _this._verticalBar.rotation = Math.PI;
  8641. _this._verticalBar.isVisible = false;
  8642. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8643. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8644. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8645. _this._verticalBarSpace.thickness = 1;
  8646. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8647. _this._verticalBarSpace.addControl(_this._verticalBar);
  8648. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8649. _this._window.top = value * _this._endTop + "px";
  8650. });
  8651. _this._horizontalBar.paddingLeft = 0;
  8652. _this._horizontalBar.width = "100%";
  8653. _this._horizontalBar.height = "100%";
  8654. _this._horizontalBar.barOffset = 0;
  8655. _this._horizontalBar.value = 0;
  8656. _this._horizontalBar.maximum = 1;
  8657. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8658. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8659. _this._horizontalBar.isVisible = false;
  8660. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8661. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8662. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8663. _this._horizontalBarSpace.thickness = 1;
  8664. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8665. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8666. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8667. _this._window.left = value * _this._endLeft + "px";
  8668. });
  8669. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8670. _this._dragSpace.thickness = 1;
  8671. _this._grid.addControl(_this._dragSpace, 1, 1);
  8672. // Colors
  8673. _this.barColor = "grey";
  8674. _this.barBackground = "transparent";
  8675. return _this;
  8676. }
  8677. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8678. /**
  8679. * Gets the horizontal scrollbar
  8680. */
  8681. get: function () {
  8682. return this._horizontalBar;
  8683. },
  8684. enumerable: true,
  8685. configurable: true
  8686. });
  8687. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8688. /**
  8689. * Gets the vertical scrollbar
  8690. */
  8691. get: function () {
  8692. return this._verticalBar;
  8693. },
  8694. enumerable: true,
  8695. configurable: true
  8696. });
  8697. /**
  8698. * Adds a new control to the current container
  8699. * @param control defines the control to add
  8700. * @returns the current container
  8701. */
  8702. ScrollViewer.prototype.addControl = function (control) {
  8703. if (!control) {
  8704. return this;
  8705. }
  8706. this._window.addControl(control);
  8707. return this;
  8708. };
  8709. /**
  8710. * Removes a control from the current container
  8711. * @param control defines the control to remove
  8712. * @returns the current container
  8713. */
  8714. ScrollViewer.prototype.removeControl = function (control) {
  8715. this._window.removeControl(control);
  8716. return this;
  8717. };
  8718. Object.defineProperty(ScrollViewer.prototype, "children", {
  8719. /** Gets the list of children */
  8720. get: function () {
  8721. return this._window.children;
  8722. },
  8723. enumerable: true,
  8724. configurable: true
  8725. });
  8726. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8727. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8728. var child = _a[_i];
  8729. child._markMatrixAsDirty();
  8730. }
  8731. };
  8732. /** Reset the scroll viewer window to initial size */
  8733. ScrollViewer.prototype.resetWindow = function () {
  8734. this._window.width = "100%";
  8735. this._window.height = "100%";
  8736. };
  8737. ScrollViewer.prototype._getTypeName = function () {
  8738. return "ScrollViewer";
  8739. };
  8740. ScrollViewer.prototype._buildClientSizes = function () {
  8741. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8742. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8743. this._clientWidth = this._window.parentClientWidth;
  8744. this._clientHeight = this._window.parentClientHeight;
  8745. };
  8746. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8747. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8748. this._buildClientSizes();
  8749. };
  8750. ScrollViewer.prototype._postMeasure = function () {
  8751. _super.prototype._postMeasure.call(this);
  8752. this._updateScroller();
  8753. };
  8754. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8755. /**
  8756. * Gets or sets the mouse wheel precision
  8757. * from 0 to 1 with a default value of 0.05
  8758. * */
  8759. get: function () {
  8760. return this._wheelPrecision;
  8761. },
  8762. set: function (value) {
  8763. if (this._wheelPrecision === value) {
  8764. return;
  8765. }
  8766. if (value < 0) {
  8767. value = 0;
  8768. }
  8769. if (value > 1) {
  8770. value = 1;
  8771. }
  8772. this._wheelPrecision = value;
  8773. },
  8774. enumerable: true,
  8775. configurable: true
  8776. });
  8777. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8778. /** Gets or sets the bar color */
  8779. get: function () {
  8780. return this._barColor;
  8781. },
  8782. set: function (color) {
  8783. if (this._barColor === color) {
  8784. return;
  8785. }
  8786. this._barColor = color;
  8787. this._horizontalBar.color = color;
  8788. this._verticalBar.color = color;
  8789. },
  8790. enumerable: true,
  8791. configurable: true
  8792. });
  8793. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8794. /** Gets or sets the size of the bar */
  8795. get: function () {
  8796. return this._barSize;
  8797. },
  8798. set: function (value) {
  8799. if (this._barSize === value) {
  8800. return;
  8801. }
  8802. this._barSize = value;
  8803. this._markAsDirty();
  8804. if (this._horizontalBar.isVisible) {
  8805. this._grid.setRowDefinition(1, this._barSize, true);
  8806. }
  8807. if (this._verticalBar.isVisible) {
  8808. this._grid.setColumnDefinition(1, this._barSize, true);
  8809. }
  8810. },
  8811. enumerable: true,
  8812. configurable: true
  8813. });
  8814. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8815. /** Gets or sets the bar background */
  8816. get: function () {
  8817. return this._barBackground;
  8818. },
  8819. set: function (color) {
  8820. if (this._barBackground === color) {
  8821. return;
  8822. }
  8823. this._barBackground = color;
  8824. this._horizontalBar.background = color;
  8825. this._verticalBar.background = color;
  8826. this._dragSpace.background = color;
  8827. },
  8828. enumerable: true,
  8829. configurable: true
  8830. });
  8831. /** @hidden */
  8832. ScrollViewer.prototype._updateScroller = function () {
  8833. var windowContentsWidth = this._window._currentMeasure.width;
  8834. var windowContentsHeight = this._window._currentMeasure.height;
  8835. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8836. this._grid.setRowDefinition(1, 0, true);
  8837. this._horizontalBar.isVisible = false;
  8838. this._horizontalBar.value = 0;
  8839. this._rebuildLayout = true;
  8840. }
  8841. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8842. this._grid.setRowDefinition(1, this._barSize, true);
  8843. this._horizontalBar.isVisible = true;
  8844. this._rebuildLayout = true;
  8845. }
  8846. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8847. this._grid.setColumnDefinition(1, 0, true);
  8848. this._verticalBar.isVisible = false;
  8849. this._verticalBar.value = 0;
  8850. this._rebuildLayout = true;
  8851. }
  8852. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8853. this._grid.setColumnDefinition(1, this._barSize, true);
  8854. this._verticalBar.isVisible = true;
  8855. this._rebuildLayout = true;
  8856. }
  8857. this._buildClientSizes();
  8858. this._endLeft = this._clientWidth - windowContentsWidth;
  8859. this._endTop = this._clientHeight - windowContentsHeight;
  8860. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8861. var newTop = this._verticalBar.value * this._endTop + "px";
  8862. if (newLeft !== this._window.left) {
  8863. this._window.left = newLeft;
  8864. this._rebuildLayout = true;
  8865. }
  8866. if (newTop !== this._window.top) {
  8867. this._window.top = newTop;
  8868. this._rebuildLayout = true;
  8869. }
  8870. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8871. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8872. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8873. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8874. };
  8875. ScrollViewer.prototype._link = function (host) {
  8876. _super.prototype._link.call(this, host);
  8877. this._attachWheel();
  8878. };
  8879. /** @hidden */
  8880. ScrollViewer.prototype._attachWheel = function () {
  8881. var _this = this;
  8882. if (this._onPointerObserver) {
  8883. return;
  8884. }
  8885. var scene = this._host.getScene();
  8886. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8887. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8888. return;
  8889. }
  8890. if (_this._verticalBar.isVisible == true) {
  8891. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8892. _this._verticalBar.value -= _this._wheelPrecision;
  8893. }
  8894. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8895. _this._verticalBar.value += _this._wheelPrecision;
  8896. }
  8897. }
  8898. if (_this._horizontalBar.isVisible == true) {
  8899. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8900. _this._horizontalBar.value += _this._wheelPrecision;
  8901. }
  8902. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8903. _this._horizontalBar.value -= _this._wheelPrecision;
  8904. }
  8905. }
  8906. });
  8907. };
  8908. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8909. if (!this.isHighlighted) {
  8910. return;
  8911. }
  8912. _super.prototype._renderHighlightSpecific.call(this, context);
  8913. this._grid._renderHighlightSpecific(context);
  8914. context.restore();
  8915. };
  8916. /** Releases associated resources */
  8917. ScrollViewer.prototype.dispose = function () {
  8918. var scene = this._host.getScene();
  8919. if (scene && this._onPointerObserver) {
  8920. scene.onPointerObservable.remove(this._onPointerObserver);
  8921. this._onPointerObserver = null;
  8922. }
  8923. _super.prototype.dispose.call(this);
  8924. };
  8925. return ScrollViewer;
  8926. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8927. /***/ }),
  8928. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8929. /*!*********************************************************!*\
  8930. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8931. \*********************************************************/
  8932. /*! exports provided: _ScrollViewerWindow */
  8933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8934. "use strict";
  8935. __webpack_require__.r(__webpack_exports__);
  8936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8937. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8938. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8939. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8940. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8941. /**
  8942. * Class used to hold a the container for ScrollViewer
  8943. * @hidden
  8944. */
  8945. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8946. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  8947. /**
  8948. * Creates a new ScrollViewerWindow
  8949. * @param name of ScrollViewerWindow
  8950. */
  8951. function _ScrollViewerWindow(name) {
  8952. return _super.call(this, name) || this;
  8953. }
  8954. _ScrollViewerWindow.prototype._getTypeName = function () {
  8955. return "ScrollViewerWindow";
  8956. };
  8957. /** @hidden */
  8958. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  8959. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8960. this._measureForChildren.left = this._currentMeasure.left;
  8961. this._measureForChildren.top = this._currentMeasure.top;
  8962. this._measureForChildren.width = parentMeasure.width;
  8963. this._measureForChildren.height = parentMeasure.height;
  8964. };
  8965. _ScrollViewerWindow.prototype._postMeasure = function () {
  8966. var maxWidth = this.parentClientWidth;
  8967. var maxHeight = this.parentClientHeight;
  8968. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  8969. var child = _a[_i];
  8970. if (!child.isVisible || child.notRenderable) {
  8971. continue;
  8972. }
  8973. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  8974. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  8975. }
  8976. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  8977. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  8978. }
  8979. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  8980. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  8981. }
  8982. if (this._currentMeasure.width !== maxWidth) {
  8983. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8984. this._currentMeasure.width = maxWidth;
  8985. this._rebuildLayout = true;
  8986. this._isDirty = true;
  8987. }
  8988. if (this._currentMeasure.height !== maxHeight) {
  8989. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8990. this._currentMeasure.height = maxHeight;
  8991. this._rebuildLayout = true;
  8992. this._isDirty = true;
  8993. }
  8994. _super.prototype._postMeasure.call(this);
  8995. };
  8996. return _ScrollViewerWindow;
  8997. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8998. /***/ }),
  8999. /***/ "./2D/controls/selector.ts":
  9000. /*!*********************************!*\
  9001. !*** ./2D/controls/selector.ts ***!
  9002. \*********************************/
  9003. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9005. "use strict";
  9006. __webpack_require__.r(__webpack_exports__);
  9007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9012. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9013. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9014. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9015. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9016. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9017. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9018. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9019. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9020. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9021. /** Class used to create a RadioGroup
  9022. * which contains groups of radio buttons
  9023. */
  9024. var SelectorGroup = /** @class */ (function () {
  9025. /**
  9026. * Creates a new SelectorGroup
  9027. * @param name of group, used as a group heading
  9028. */
  9029. function SelectorGroup(
  9030. /** name of SelectorGroup */
  9031. name) {
  9032. this.name = name;
  9033. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9034. this._selectors = new Array();
  9035. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9036. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9037. this._groupHeader = this._addGroupHeader(name);
  9038. }
  9039. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9040. /** Gets the groupPanel of the SelectorGroup */
  9041. get: function () {
  9042. return this._groupPanel;
  9043. },
  9044. enumerable: true,
  9045. configurable: true
  9046. });
  9047. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9048. /** Gets the selectors array */
  9049. get: function () {
  9050. return this._selectors;
  9051. },
  9052. enumerable: true,
  9053. configurable: true
  9054. });
  9055. Object.defineProperty(SelectorGroup.prototype, "header", {
  9056. /** Gets and sets the group header */
  9057. get: function () {
  9058. return this._groupHeader.text;
  9059. },
  9060. set: function (label) {
  9061. if (this._groupHeader.text === "label") {
  9062. return;
  9063. }
  9064. this._groupHeader.text = label;
  9065. },
  9066. enumerable: true,
  9067. configurable: true
  9068. });
  9069. /** @hidden */
  9070. SelectorGroup.prototype._addGroupHeader = function (text) {
  9071. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9072. groupHeading.width = 0.9;
  9073. groupHeading.height = "30px";
  9074. groupHeading.textWrapping = true;
  9075. groupHeading.color = "black";
  9076. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9077. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9078. groupHeading.left = "2px";
  9079. this._groupPanel.addControl(groupHeading);
  9080. return groupHeading;
  9081. };
  9082. /** @hidden*/
  9083. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9084. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9085. return;
  9086. }
  9087. return this._selectors[selectorNb];
  9088. };
  9089. /** Removes the selector at the given position
  9090. * @param selectorNb the position of the selector within the group
  9091. */
  9092. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9093. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9094. return;
  9095. }
  9096. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9097. this._selectors.splice(selectorNb, 1);
  9098. };
  9099. return SelectorGroup;
  9100. }());
  9101. /** Class used to create a CheckboxGroup
  9102. * which contains groups of checkbox buttons
  9103. */
  9104. var CheckboxGroup = /** @class */ (function (_super) {
  9105. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9106. function CheckboxGroup() {
  9107. return _super !== null && _super.apply(this, arguments) || this;
  9108. }
  9109. /** Adds a checkbox as a control
  9110. * @param text is the label for the selector
  9111. * @param func is the function called when the Selector is checked
  9112. * @param checked is true when Selector is checked
  9113. */
  9114. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9115. if (func === void 0) { func = function (s) { }; }
  9116. if (checked === void 0) { checked = false; }
  9117. var checked = checked || false;
  9118. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9119. button.width = "20px";
  9120. button.height = "20px";
  9121. button.color = "#364249";
  9122. button.background = "#CCCCCC";
  9123. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9124. button.onIsCheckedChangedObservable.add(function (state) {
  9125. func(state);
  9126. });
  9127. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9128. _selector.height = "30px";
  9129. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9130. _selector.left = "4px";
  9131. this.groupPanel.addControl(_selector);
  9132. this.selectors.push(_selector);
  9133. button.isChecked = checked;
  9134. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9135. button.color = this.groupPanel.parent.parent.buttonColor;
  9136. button.background = this.groupPanel.parent.parent.buttonBackground;
  9137. }
  9138. };
  9139. /** @hidden */
  9140. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9141. this.selectors[selectorNb].children[1].text = label;
  9142. };
  9143. /** @hidden */
  9144. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9145. this.selectors[selectorNb].children[1].color = color;
  9146. };
  9147. /** @hidden */
  9148. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9149. this.selectors[selectorNb].children[0].color = color;
  9150. };
  9151. /** @hidden */
  9152. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9153. this.selectors[selectorNb].children[0].background = color;
  9154. };
  9155. return CheckboxGroup;
  9156. }(SelectorGroup));
  9157. /** Class used to create a RadioGroup
  9158. * which contains groups of radio buttons
  9159. */
  9160. var RadioGroup = /** @class */ (function (_super) {
  9161. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9162. function RadioGroup() {
  9163. var _this = _super !== null && _super.apply(this, arguments) || this;
  9164. _this._selectNb = 0;
  9165. return _this;
  9166. }
  9167. /** Adds a radio button as a control
  9168. * @param label is the label for the selector
  9169. * @param func is the function called when the Selector is checked
  9170. * @param checked is true when Selector is checked
  9171. */
  9172. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9173. if (func === void 0) { func = function (n) { }; }
  9174. if (checked === void 0) { checked = false; }
  9175. var nb = this._selectNb++;
  9176. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9177. button.name = label;
  9178. button.width = "20px";
  9179. button.height = "20px";
  9180. button.color = "#364249";
  9181. button.background = "#CCCCCC";
  9182. button.group = this.name;
  9183. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9184. button.onIsCheckedChangedObservable.add(function (state) {
  9185. if (state) {
  9186. func(nb);
  9187. }
  9188. });
  9189. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9190. _selector.height = "30px";
  9191. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9192. _selector.left = "4px";
  9193. this.groupPanel.addControl(_selector);
  9194. this.selectors.push(_selector);
  9195. button.isChecked = checked;
  9196. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9197. button.color = this.groupPanel.parent.parent.buttonColor;
  9198. button.background = this.groupPanel.parent.parent.buttonBackground;
  9199. }
  9200. };
  9201. /** @hidden */
  9202. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9203. this.selectors[selectorNb].children[1].text = label;
  9204. };
  9205. /** @hidden */
  9206. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9207. this.selectors[selectorNb].children[1].color = color;
  9208. };
  9209. /** @hidden */
  9210. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9211. this.selectors[selectorNb].children[0].color = color;
  9212. };
  9213. /** @hidden */
  9214. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9215. this.selectors[selectorNb].children[0].background = color;
  9216. };
  9217. return RadioGroup;
  9218. }(SelectorGroup));
  9219. /** Class used to create a SliderGroup
  9220. * which contains groups of slider buttons
  9221. */
  9222. var SliderGroup = /** @class */ (function (_super) {
  9223. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9224. function SliderGroup() {
  9225. return _super !== null && _super.apply(this, arguments) || this;
  9226. }
  9227. /**
  9228. * Adds a slider to the SelectorGroup
  9229. * @param label is the label for the SliderBar
  9230. * @param func is the function called when the Slider moves
  9231. * @param unit is a string describing the units used, eg degrees or metres
  9232. * @param min is the minimum value for the Slider
  9233. * @param max is the maximum value for the Slider
  9234. * @param value is the start value for the Slider between min and max
  9235. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9236. */
  9237. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9238. if (func === void 0) { func = function (v) { }; }
  9239. if (unit === void 0) { unit = "Units"; }
  9240. if (min === void 0) { min = 0; }
  9241. if (max === void 0) { max = 0; }
  9242. if (value === void 0) { value = 0; }
  9243. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9244. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9245. button.name = unit;
  9246. button.value = value;
  9247. button.minimum = min;
  9248. button.maximum = max;
  9249. button.width = 0.9;
  9250. button.height = "20px";
  9251. button.color = "#364249";
  9252. button.background = "#CCCCCC";
  9253. button.borderColor = "black";
  9254. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9255. button.left = "4px";
  9256. button.paddingBottom = "4px";
  9257. button.onValueChangedObservable.add(function (value) {
  9258. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9259. func(value);
  9260. });
  9261. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9262. _selector.height = "60px";
  9263. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9264. _selector.left = "4px";
  9265. _selector.children[0].name = label;
  9266. this.groupPanel.addControl(_selector);
  9267. this.selectors.push(_selector);
  9268. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9269. button.color = this.groupPanel.parent.parent.buttonColor;
  9270. button.background = this.groupPanel.parent.parent.buttonBackground;
  9271. }
  9272. };
  9273. /** @hidden */
  9274. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9275. this.selectors[selectorNb].children[0].name = label;
  9276. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9277. };
  9278. /** @hidden */
  9279. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9280. this.selectors[selectorNb].children[0].color = color;
  9281. };
  9282. /** @hidden */
  9283. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9284. this.selectors[selectorNb].children[1].color = color;
  9285. };
  9286. /** @hidden */
  9287. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9288. this.selectors[selectorNb].children[1].background = color;
  9289. };
  9290. return SliderGroup;
  9291. }(SelectorGroup));
  9292. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9293. * @see http://doc.babylonjs.com/how_to/selector
  9294. */
  9295. var SelectionPanel = /** @class */ (function (_super) {
  9296. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9297. /**
  9298. * Creates a new SelectionPanel
  9299. * @param name of SelectionPanel
  9300. * @param groups is an array of SelectionGroups
  9301. */
  9302. function SelectionPanel(
  9303. /** name of SelectionPanel */
  9304. name,
  9305. /** an array of SelectionGroups */
  9306. groups) {
  9307. if (groups === void 0) { groups = []; }
  9308. var _this = _super.call(this, name) || this;
  9309. _this.name = name;
  9310. _this.groups = groups;
  9311. _this._buttonColor = "#364249";
  9312. _this._buttonBackground = "#CCCCCC";
  9313. _this._headerColor = "black";
  9314. _this._barColor = "white";
  9315. _this._barHeight = "2px";
  9316. _this._spacerHeight = "20px";
  9317. _this._bars = new Array();
  9318. _this._groups = groups;
  9319. _this.thickness = 2;
  9320. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9321. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9322. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9323. _this._panel.top = 5;
  9324. _this._panel.left = 5;
  9325. _this._panel.width = 0.95;
  9326. if (groups.length > 0) {
  9327. for (var i = 0; i < groups.length - 1; i++) {
  9328. _this._panel.addControl(groups[i].groupPanel);
  9329. _this._addSpacer();
  9330. }
  9331. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9332. }
  9333. _this.addControl(_this._panel);
  9334. return _this;
  9335. }
  9336. SelectionPanel.prototype._getTypeName = function () {
  9337. return "SelectionPanel";
  9338. };
  9339. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9340. /** Gets or sets the headerColor */
  9341. get: function () {
  9342. return this._headerColor;
  9343. },
  9344. set: function (color) {
  9345. if (this._headerColor === color) {
  9346. return;
  9347. }
  9348. this._headerColor = color;
  9349. this._setHeaderColor();
  9350. },
  9351. enumerable: true,
  9352. configurable: true
  9353. });
  9354. SelectionPanel.prototype._setHeaderColor = function () {
  9355. for (var i = 0; i < this._groups.length; i++) {
  9356. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9357. }
  9358. };
  9359. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9360. /** Gets or sets the button color */
  9361. get: function () {
  9362. return this._buttonColor;
  9363. },
  9364. set: function (color) {
  9365. if (this._buttonColor === color) {
  9366. return;
  9367. }
  9368. this._buttonColor = color;
  9369. this._setbuttonColor();
  9370. },
  9371. enumerable: true,
  9372. configurable: true
  9373. });
  9374. SelectionPanel.prototype._setbuttonColor = function () {
  9375. for (var i = 0; i < this._groups.length; i++) {
  9376. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9377. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9378. }
  9379. }
  9380. };
  9381. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9382. /** Gets or sets the label color */
  9383. get: function () {
  9384. return this._labelColor;
  9385. },
  9386. set: function (color) {
  9387. if (this._labelColor === color) {
  9388. return;
  9389. }
  9390. this._labelColor = color;
  9391. this._setLabelColor();
  9392. },
  9393. enumerable: true,
  9394. configurable: true
  9395. });
  9396. SelectionPanel.prototype._setLabelColor = function () {
  9397. for (var i = 0; i < this._groups.length; i++) {
  9398. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9399. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9400. }
  9401. }
  9402. };
  9403. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9404. /** Gets or sets the button background */
  9405. get: function () {
  9406. return this._buttonBackground;
  9407. },
  9408. set: function (color) {
  9409. if (this._buttonBackground === color) {
  9410. return;
  9411. }
  9412. this._buttonBackground = color;
  9413. this._setButtonBackground();
  9414. },
  9415. enumerable: true,
  9416. configurable: true
  9417. });
  9418. SelectionPanel.prototype._setButtonBackground = function () {
  9419. for (var i = 0; i < this._groups.length; i++) {
  9420. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9421. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9422. }
  9423. }
  9424. };
  9425. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9426. /** Gets or sets the color of separator bar */
  9427. get: function () {
  9428. return this._barColor;
  9429. },
  9430. set: function (color) {
  9431. if (this._barColor === color) {
  9432. return;
  9433. }
  9434. this._barColor = color;
  9435. this._setBarColor();
  9436. },
  9437. enumerable: true,
  9438. configurable: true
  9439. });
  9440. SelectionPanel.prototype._setBarColor = function () {
  9441. for (var i = 0; i < this._bars.length; i++) {
  9442. this._bars[i].children[0].background = this._barColor;
  9443. }
  9444. };
  9445. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9446. /** Gets or sets the height of separator bar */
  9447. get: function () {
  9448. return this._barHeight;
  9449. },
  9450. set: function (value) {
  9451. if (this._barHeight === value) {
  9452. return;
  9453. }
  9454. this._barHeight = value;
  9455. this._setBarHeight();
  9456. },
  9457. enumerable: true,
  9458. configurable: true
  9459. });
  9460. SelectionPanel.prototype._setBarHeight = function () {
  9461. for (var i = 0; i < this._bars.length; i++) {
  9462. this._bars[i].children[0].height = this._barHeight;
  9463. }
  9464. };
  9465. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9466. /** Gets or sets the height of spacers*/
  9467. get: function () {
  9468. return this._spacerHeight;
  9469. },
  9470. set: function (value) {
  9471. if (this._spacerHeight === value) {
  9472. return;
  9473. }
  9474. this._spacerHeight = value;
  9475. this._setSpacerHeight();
  9476. },
  9477. enumerable: true,
  9478. configurable: true
  9479. });
  9480. SelectionPanel.prototype._setSpacerHeight = function () {
  9481. for (var i = 0; i < this._bars.length; i++) {
  9482. this._bars[i].height = this._spacerHeight;
  9483. }
  9484. };
  9485. /** Adds a bar between groups */
  9486. SelectionPanel.prototype._addSpacer = function () {
  9487. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9488. separator.width = 1;
  9489. separator.height = this._spacerHeight;
  9490. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9491. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9492. bar.width = 1;
  9493. bar.height = this._barHeight;
  9494. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9495. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9496. bar.background = this._barColor;
  9497. bar.color = "transparent";
  9498. separator.addControl(bar);
  9499. this._panel.addControl(separator);
  9500. this._bars.push(separator);
  9501. };
  9502. /** Add a group to the selection panel
  9503. * @param group is the selector group to add
  9504. */
  9505. SelectionPanel.prototype.addGroup = function (group) {
  9506. if (this._groups.length > 0) {
  9507. this._addSpacer();
  9508. }
  9509. this._panel.addControl(group.groupPanel);
  9510. this._groups.push(group);
  9511. group.groupPanel.children[0].color = this._headerColor;
  9512. for (var j = 0; j < group.selectors.length; j++) {
  9513. group._setSelectorButtonColor(j, this._buttonColor);
  9514. group._setSelectorButtonBackground(j, this._buttonBackground);
  9515. }
  9516. };
  9517. /** Remove the group from the given position
  9518. * @param groupNb is the position of the group in the list
  9519. */
  9520. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9521. if (groupNb < 0 || groupNb >= this._groups.length) {
  9522. return;
  9523. }
  9524. var group = this._groups[groupNb];
  9525. this._panel.removeControl(group.groupPanel);
  9526. this._groups.splice(groupNb, 1);
  9527. if (groupNb < this._bars.length) {
  9528. this._panel.removeControl(this._bars[groupNb]);
  9529. this._bars.splice(groupNb, 1);
  9530. }
  9531. };
  9532. /** Change a group header label
  9533. * @param label is the new group header label
  9534. * @param groupNb is the number of the group to relabel
  9535. * */
  9536. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9537. if (groupNb < 0 || groupNb >= this._groups.length) {
  9538. return;
  9539. }
  9540. var group = this._groups[groupNb];
  9541. group.groupPanel.children[0].text = label;
  9542. };
  9543. /** Change selector label to the one given
  9544. * @param label is the new selector label
  9545. * @param groupNb is the number of the groupcontaining the selector
  9546. * @param selectorNb is the number of the selector within a group to relabel
  9547. * */
  9548. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9549. if (groupNb < 0 || groupNb >= this._groups.length) {
  9550. return;
  9551. }
  9552. var group = this._groups[groupNb];
  9553. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9554. return;
  9555. }
  9556. group._setSelectorLabel(selectorNb, label);
  9557. };
  9558. /** For a given group position remove the selector at the given position
  9559. * @param groupNb is the number of the group to remove the selector from
  9560. * @param selectorNb is the number of the selector within the group
  9561. */
  9562. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9563. if (groupNb < 0 || groupNb >= this._groups.length) {
  9564. return;
  9565. }
  9566. var group = this._groups[groupNb];
  9567. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9568. return;
  9569. }
  9570. group.removeSelector(selectorNb);
  9571. };
  9572. /** For a given group position of correct type add a checkbox button
  9573. * @param groupNb is the number of the group to remove the selector from
  9574. * @param label is the label for the selector
  9575. * @param func is the function called when the Selector is checked
  9576. * @param checked is true when Selector is checked
  9577. */
  9578. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9579. if (func === void 0) { func = function () { }; }
  9580. if (checked === void 0) { checked = false; }
  9581. if (groupNb < 0 || groupNb >= this._groups.length) {
  9582. return;
  9583. }
  9584. var group = this._groups[groupNb];
  9585. group.addCheckbox(label, func, checked);
  9586. };
  9587. /** For a given group position of correct type add a radio button
  9588. * @param groupNb is the number of the group to remove the selector from
  9589. * @param label is the label for the selector
  9590. * @param func is the function called when the Selector is checked
  9591. * @param checked is true when Selector is checked
  9592. */
  9593. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9594. if (func === void 0) { func = function () { }; }
  9595. if (checked === void 0) { checked = false; }
  9596. if (groupNb < 0 || groupNb >= this._groups.length) {
  9597. return;
  9598. }
  9599. var group = this._groups[groupNb];
  9600. group.addRadio(label, func, checked);
  9601. };
  9602. /**
  9603. * For a given slider group add a slider
  9604. * @param groupNb is the number of the group to add the slider to
  9605. * @param label is the label for the Slider
  9606. * @param func is the function called when the Slider moves
  9607. * @param unit is a string describing the units used, eg degrees or metres
  9608. * @param min is the minimum value for the Slider
  9609. * @param max is the maximum value for the Slider
  9610. * @param value is the start value for the Slider between min and max
  9611. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9612. */
  9613. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9614. if (func === void 0) { func = function () { }; }
  9615. if (unit === void 0) { unit = "Units"; }
  9616. if (min === void 0) { min = 0; }
  9617. if (max === void 0) { max = 0; }
  9618. if (value === void 0) { value = 0; }
  9619. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9620. if (groupNb < 0 || groupNb >= this._groups.length) {
  9621. return;
  9622. }
  9623. var group = this._groups[groupNb];
  9624. group.addSlider(label, func, unit, min, max, value, onVal);
  9625. };
  9626. return SelectionPanel;
  9627. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9628. /***/ }),
  9629. /***/ "./2D/controls/sliders/baseSlider.ts":
  9630. /*!*******************************************!*\
  9631. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9632. \*******************************************/
  9633. /*! exports provided: BaseSlider */
  9634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9635. "use strict";
  9636. __webpack_require__.r(__webpack_exports__);
  9637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9638. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9639. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  9640. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9641. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9642. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9643. /**
  9644. * Class used to create slider controls
  9645. */
  9646. var BaseSlider = /** @class */ (function (_super) {
  9647. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9648. /**
  9649. * Creates a new BaseSlider
  9650. * @param name defines the control name
  9651. */
  9652. function BaseSlider(name) {
  9653. var _this = _super.call(this, name) || this;
  9654. _this.name = name;
  9655. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9656. _this._minimum = 0;
  9657. _this._maximum = 100;
  9658. _this._value = 50;
  9659. _this._isVertical = false;
  9660. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9661. _this._isThumbClamped = false;
  9662. _this._displayThumb = true;
  9663. // Shared rendering info
  9664. _this._effectiveBarOffset = 0;
  9665. /** Observable raised when the sldier value changes */
  9666. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9667. // Events
  9668. _this._pointerIsDown = false;
  9669. _this.isPointerBlocker = true;
  9670. return _this;
  9671. }
  9672. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9673. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9674. get: function () {
  9675. return this._displayThumb;
  9676. },
  9677. set: function (value) {
  9678. if (this._displayThumb === value) {
  9679. return;
  9680. }
  9681. this._displayThumb = value;
  9682. this._markAsDirty();
  9683. },
  9684. enumerable: true,
  9685. configurable: true
  9686. });
  9687. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9688. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9689. get: function () {
  9690. return this._barOffset.toString(this._host);
  9691. },
  9692. set: function (value) {
  9693. if (this._barOffset.toString(this._host) === value) {
  9694. return;
  9695. }
  9696. if (this._barOffset.fromString(value)) {
  9697. this._markAsDirty();
  9698. }
  9699. },
  9700. enumerable: true,
  9701. configurable: true
  9702. });
  9703. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9704. /** Gets main bar offset in pixels*/
  9705. get: function () {
  9706. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9707. },
  9708. enumerable: true,
  9709. configurable: true
  9710. });
  9711. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9712. /** Gets or sets thumb width */
  9713. get: function () {
  9714. return this._thumbWidth.toString(this._host);
  9715. },
  9716. set: function (value) {
  9717. if (this._thumbWidth.toString(this._host) === value) {
  9718. return;
  9719. }
  9720. if (this._thumbWidth.fromString(value)) {
  9721. this._markAsDirty();
  9722. }
  9723. },
  9724. enumerable: true,
  9725. configurable: true
  9726. });
  9727. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9728. /** Gets thumb width in pixels */
  9729. get: function () {
  9730. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9731. },
  9732. enumerable: true,
  9733. configurable: true
  9734. });
  9735. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9736. /** Gets or sets minimum value */
  9737. get: function () {
  9738. return this._minimum;
  9739. },
  9740. set: function (value) {
  9741. if (this._minimum === value) {
  9742. return;
  9743. }
  9744. this._minimum = value;
  9745. this._markAsDirty();
  9746. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9747. },
  9748. enumerable: true,
  9749. configurable: true
  9750. });
  9751. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9752. /** Gets or sets maximum value */
  9753. get: function () {
  9754. return this._maximum;
  9755. },
  9756. set: function (value) {
  9757. if (this._maximum === value) {
  9758. return;
  9759. }
  9760. this._maximum = value;
  9761. this._markAsDirty();
  9762. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9763. },
  9764. enumerable: true,
  9765. configurable: true
  9766. });
  9767. Object.defineProperty(BaseSlider.prototype, "value", {
  9768. /** Gets or sets current value */
  9769. get: function () {
  9770. return this._value;
  9771. },
  9772. set: function (value) {
  9773. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9774. if (this._value === value) {
  9775. return;
  9776. }
  9777. this._value = value;
  9778. this._markAsDirty();
  9779. this.onValueChangedObservable.notifyObservers(this._value);
  9780. },
  9781. enumerable: true,
  9782. configurable: true
  9783. });
  9784. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9785. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9786. get: function () {
  9787. return this._isVertical;
  9788. },
  9789. set: function (value) {
  9790. if (this._isVertical === value) {
  9791. return;
  9792. }
  9793. this._isVertical = value;
  9794. this._markAsDirty();
  9795. },
  9796. enumerable: true,
  9797. configurable: true
  9798. });
  9799. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9800. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9801. get: function () {
  9802. return this._isThumbClamped;
  9803. },
  9804. set: function (value) {
  9805. if (this._isThumbClamped === value) {
  9806. return;
  9807. }
  9808. this._isThumbClamped = value;
  9809. this._markAsDirty();
  9810. },
  9811. enumerable: true,
  9812. configurable: true
  9813. });
  9814. BaseSlider.prototype._getTypeName = function () {
  9815. return "BaseSlider";
  9816. };
  9817. BaseSlider.prototype._getThumbPosition = function () {
  9818. if (this.isVertical) {
  9819. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9820. }
  9821. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9822. };
  9823. BaseSlider.prototype._getThumbThickness = function (type) {
  9824. var thumbThickness = 0;
  9825. switch (type) {
  9826. case "circle":
  9827. if (this._thumbWidth.isPixel) {
  9828. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9829. }
  9830. else {
  9831. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9832. }
  9833. break;
  9834. case "rectangle":
  9835. if (this._thumbWidth.isPixel) {
  9836. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9837. }
  9838. else {
  9839. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9840. }
  9841. }
  9842. return thumbThickness;
  9843. };
  9844. BaseSlider.prototype._prepareRenderingData = function (type) {
  9845. // Main bar
  9846. this._effectiveBarOffset = 0;
  9847. this._renderLeft = this._currentMeasure.left;
  9848. this._renderTop = this._currentMeasure.top;
  9849. this._renderWidth = this._currentMeasure.width;
  9850. this._renderHeight = this._currentMeasure.height;
  9851. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9852. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9853. this._effectiveThumbThickness = this._getThumbThickness(type);
  9854. if (this.displayThumb) {
  9855. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9856. }
  9857. //throw error when height is less than width for vertical slider
  9858. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9859. console.error("Height should be greater than width");
  9860. return;
  9861. }
  9862. if (this._barOffset.isPixel) {
  9863. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9864. }
  9865. else {
  9866. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9867. }
  9868. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9869. if (this.isVertical) {
  9870. this._renderLeft += this._effectiveBarOffset;
  9871. if (!this.isThumbClamped && this.displayThumb) {
  9872. this._renderTop += (this._effectiveThumbThickness / 2);
  9873. }
  9874. this._renderHeight = this._backgroundBoxLength;
  9875. this._renderWidth = this._backgroundBoxThickness;
  9876. }
  9877. else {
  9878. this._renderTop += this._effectiveBarOffset;
  9879. if (!this.isThumbClamped && this.displayThumb) {
  9880. this._renderLeft += (this._effectiveThumbThickness / 2);
  9881. }
  9882. this._renderHeight = this._backgroundBoxThickness;
  9883. this._renderWidth = this._backgroundBoxLength;
  9884. }
  9885. };
  9886. /** @hidden */
  9887. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9888. if (this.rotation != 0) {
  9889. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9890. x = this._transformedPosition.x;
  9891. y = this._transformedPosition.y;
  9892. }
  9893. if (this._isVertical) {
  9894. this.value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9895. }
  9896. else {
  9897. this.value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9898. }
  9899. };
  9900. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9901. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9902. return false;
  9903. }
  9904. this._pointerIsDown = true;
  9905. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9906. this._host._capturingControl[pointerId] = this;
  9907. return true;
  9908. };
  9909. BaseSlider.prototype._onPointerMove = function (target, coordinates) {
  9910. if (this._pointerIsDown) {
  9911. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9912. }
  9913. _super.prototype._onPointerMove.call(this, target, coordinates);
  9914. };
  9915. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9916. this._pointerIsDown = false;
  9917. delete this._host._capturingControl[pointerId];
  9918. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9919. };
  9920. return BaseSlider;
  9921. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9922. /***/ }),
  9923. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  9924. /*!*************************************************!*\
  9925. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  9926. \*************************************************/
  9927. /*! exports provided: ImageBasedSlider */
  9928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9929. "use strict";
  9930. __webpack_require__.r(__webpack_exports__);
  9931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  9932. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9933. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  9934. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9935. /**
  9936. * Class used to create slider controls based on images
  9937. */
  9938. var ImageBasedSlider = /** @class */ (function (_super) {
  9939. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  9940. /**
  9941. * Creates a new ImageBasedSlider
  9942. * @param name defines the control name
  9943. */
  9944. function ImageBasedSlider(name) {
  9945. var _this = _super.call(this, name) || this;
  9946. _this.name = name;
  9947. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  9948. return _this;
  9949. }
  9950. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  9951. get: function () {
  9952. return this._displayThumb && this.thumbImage != null;
  9953. },
  9954. set: function (value) {
  9955. if (this._displayThumb === value) {
  9956. return;
  9957. }
  9958. this._displayThumb = value;
  9959. this._markAsDirty();
  9960. },
  9961. enumerable: true,
  9962. configurable: true
  9963. });
  9964. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  9965. /**
  9966. * Gets or sets the image used to render the background
  9967. */
  9968. get: function () {
  9969. return this._backgroundImage;
  9970. },
  9971. set: function (value) {
  9972. var _this = this;
  9973. if (this._backgroundImage === value) {
  9974. return;
  9975. }
  9976. this._backgroundImage = value;
  9977. if (value && !value.isLoaded) {
  9978. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  9979. }
  9980. this._markAsDirty();
  9981. },
  9982. enumerable: true,
  9983. configurable: true
  9984. });
  9985. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  9986. /**
  9987. * Gets or sets the image used to render the value bar
  9988. */
  9989. get: function () {
  9990. return this._valueBarImage;
  9991. },
  9992. set: function (value) {
  9993. var _this = this;
  9994. if (this._valueBarImage === value) {
  9995. return;
  9996. }
  9997. this._valueBarImage = value;
  9998. if (value && !value.isLoaded) {
  9999. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10000. }
  10001. this._markAsDirty();
  10002. },
  10003. enumerable: true,
  10004. configurable: true
  10005. });
  10006. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10007. /**
  10008. * Gets or sets the image used to render the thumb
  10009. */
  10010. get: function () {
  10011. return this._thumbImage;
  10012. },
  10013. set: function (value) {
  10014. var _this = this;
  10015. if (this._thumbImage === value) {
  10016. return;
  10017. }
  10018. this._thumbImage = value;
  10019. if (value && !value.isLoaded) {
  10020. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10021. }
  10022. this._markAsDirty();
  10023. },
  10024. enumerable: true,
  10025. configurable: true
  10026. });
  10027. ImageBasedSlider.prototype._getTypeName = function () {
  10028. return "ImageBasedSlider";
  10029. };
  10030. ImageBasedSlider.prototype._draw = function (context) {
  10031. context.save();
  10032. this._applyStates(context);
  10033. this._prepareRenderingData("rectangle");
  10034. var thumbPosition = this._getThumbPosition();
  10035. var left = this._renderLeft;
  10036. var top = this._renderTop;
  10037. var width = this._renderWidth;
  10038. var height = this._renderHeight;
  10039. // Background
  10040. if (this._backgroundImage) {
  10041. this._tempMeasure.copyFromFloats(left, top, width, height);
  10042. if (this.isThumbClamped && this.displayThumb) {
  10043. if (this.isVertical) {
  10044. this._tempMeasure.height += this._effectiveThumbThickness;
  10045. }
  10046. else {
  10047. this._tempMeasure.width += this._effectiveThumbThickness;
  10048. }
  10049. }
  10050. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10051. this._backgroundImage._draw(context);
  10052. }
  10053. // Bar
  10054. if (this._valueBarImage) {
  10055. if (this.isVertical) {
  10056. if (this.isThumbClamped && this.displayThumb) {
  10057. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10058. }
  10059. else {
  10060. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10061. }
  10062. }
  10063. else {
  10064. if (this.isThumbClamped && this.displayThumb) {
  10065. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10066. }
  10067. else {
  10068. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10069. }
  10070. }
  10071. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10072. this._valueBarImage._draw(context);
  10073. }
  10074. // Thumb
  10075. if (this.displayThumb) {
  10076. if (this.isVertical) {
  10077. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10078. }
  10079. else {
  10080. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10081. }
  10082. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10083. this._thumbImage._draw(context);
  10084. }
  10085. context.restore();
  10086. };
  10087. return ImageBasedSlider;
  10088. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10089. /***/ }),
  10090. /***/ "./2D/controls/sliders/scrollBar.ts":
  10091. /*!******************************************!*\
  10092. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10093. \******************************************/
  10094. /*! exports provided: ScrollBar */
  10095. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10096. "use strict";
  10097. __webpack_require__.r(__webpack_exports__);
  10098. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10099. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10100. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10101. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10102. /**
  10103. * Class used to create slider controls
  10104. */
  10105. var ScrollBar = /** @class */ (function (_super) {
  10106. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10107. /**
  10108. * Creates a new Slider
  10109. * @param name defines the control name
  10110. */
  10111. function ScrollBar(name) {
  10112. var _this = _super.call(this, name) || this;
  10113. _this.name = name;
  10114. _this._background = "black";
  10115. _this._borderColor = "white";
  10116. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10117. return _this;
  10118. }
  10119. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10120. /** Gets or sets border color */
  10121. get: function () {
  10122. return this._borderColor;
  10123. },
  10124. set: function (value) {
  10125. if (this._borderColor === value) {
  10126. return;
  10127. }
  10128. this._borderColor = value;
  10129. this._markAsDirty();
  10130. },
  10131. enumerable: true,
  10132. configurable: true
  10133. });
  10134. Object.defineProperty(ScrollBar.prototype, "background", {
  10135. /** Gets or sets background color */
  10136. get: function () {
  10137. return this._background;
  10138. },
  10139. set: function (value) {
  10140. if (this._background === value) {
  10141. return;
  10142. }
  10143. this._background = value;
  10144. this._markAsDirty();
  10145. },
  10146. enumerable: true,
  10147. configurable: true
  10148. });
  10149. ScrollBar.prototype._getTypeName = function () {
  10150. return "Scrollbar";
  10151. };
  10152. ScrollBar.prototype._getThumbThickness = function () {
  10153. var thumbThickness = 0;
  10154. if (this._thumbWidth.isPixel) {
  10155. thumbThickness = this._thumbWidth.getValue(this._host);
  10156. }
  10157. else {
  10158. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10159. }
  10160. return thumbThickness;
  10161. };
  10162. ScrollBar.prototype._draw = function (context) {
  10163. context.save();
  10164. this._applyStates(context);
  10165. this._prepareRenderingData("rectangle");
  10166. var left = this._renderLeft;
  10167. var thumbPosition = this._getThumbPosition();
  10168. context.fillStyle = this._background;
  10169. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10170. // Value bar
  10171. context.fillStyle = this.color;
  10172. // Thumb
  10173. if (this.isVertical) {
  10174. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10175. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10176. this._thumbMeasure.width = this._currentMeasure.width;
  10177. this._thumbMeasure.height = this._effectiveThumbThickness;
  10178. }
  10179. else {
  10180. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10181. this._thumbMeasure.top = this._currentMeasure.top;
  10182. this._thumbMeasure.width = this._effectiveThumbThickness;
  10183. this._thumbMeasure.height = this._currentMeasure.height;
  10184. }
  10185. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10186. context.restore();
  10187. };
  10188. /** @hidden */
  10189. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10190. if (this.rotation != 0) {
  10191. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10192. x = this._transformedPosition.x;
  10193. y = this._transformedPosition.y;
  10194. }
  10195. if (this._first) {
  10196. this._first = false;
  10197. this._originX = x;
  10198. this._originY = y;
  10199. // Check if move is required
  10200. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10201. if (this.isVertical) {
  10202. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10203. }
  10204. else {
  10205. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10206. }
  10207. }
  10208. }
  10209. // Delta mode
  10210. var delta = 0;
  10211. if (this.isVertical) {
  10212. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10213. }
  10214. else {
  10215. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10216. }
  10217. this.value += delta * (this.maximum - this.minimum);
  10218. this._originX = x;
  10219. this._originY = y;
  10220. };
  10221. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10222. this._first = true;
  10223. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10224. };
  10225. return ScrollBar;
  10226. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10227. /***/ }),
  10228. /***/ "./2D/controls/sliders/slider.ts":
  10229. /*!***************************************!*\
  10230. !*** ./2D/controls/sliders/slider.ts ***!
  10231. \***************************************/
  10232. /*! exports provided: Slider */
  10233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10234. "use strict";
  10235. __webpack_require__.r(__webpack_exports__);
  10236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10237. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10238. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10239. /**
  10240. * Class used to create slider controls
  10241. */
  10242. var Slider = /** @class */ (function (_super) {
  10243. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10244. /**
  10245. * Creates a new Slider
  10246. * @param name defines the control name
  10247. */
  10248. function Slider(name) {
  10249. var _this = _super.call(this, name) || this;
  10250. _this.name = name;
  10251. _this._background = "black";
  10252. _this._borderColor = "white";
  10253. _this._isThumbCircle = false;
  10254. _this._displayValueBar = true;
  10255. return _this;
  10256. }
  10257. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10258. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10259. get: function () {
  10260. return this._displayValueBar;
  10261. },
  10262. set: function (value) {
  10263. if (this._displayValueBar === value) {
  10264. return;
  10265. }
  10266. this._displayValueBar = value;
  10267. this._markAsDirty();
  10268. },
  10269. enumerable: true,
  10270. configurable: true
  10271. });
  10272. Object.defineProperty(Slider.prototype, "borderColor", {
  10273. /** Gets or sets border color */
  10274. get: function () {
  10275. return this._borderColor;
  10276. },
  10277. set: function (value) {
  10278. if (this._borderColor === value) {
  10279. return;
  10280. }
  10281. this._borderColor = value;
  10282. this._markAsDirty();
  10283. },
  10284. enumerable: true,
  10285. configurable: true
  10286. });
  10287. Object.defineProperty(Slider.prototype, "background", {
  10288. /** Gets or sets background color */
  10289. get: function () {
  10290. return this._background;
  10291. },
  10292. set: function (value) {
  10293. if (this._background === value) {
  10294. return;
  10295. }
  10296. this._background = value;
  10297. this._markAsDirty();
  10298. },
  10299. enumerable: true,
  10300. configurable: true
  10301. });
  10302. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10303. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10304. get: function () {
  10305. return this._isThumbCircle;
  10306. },
  10307. set: function (value) {
  10308. if (this._isThumbCircle === value) {
  10309. return;
  10310. }
  10311. this._isThumbCircle = value;
  10312. this._markAsDirty();
  10313. },
  10314. enumerable: true,
  10315. configurable: true
  10316. });
  10317. Slider.prototype._getTypeName = function () {
  10318. return "Slider";
  10319. };
  10320. Slider.prototype._draw = function (context) {
  10321. context.save();
  10322. this._applyStates(context);
  10323. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10324. var left = this._renderLeft;
  10325. var top = this._renderTop;
  10326. var width = this._renderWidth;
  10327. var height = this._renderHeight;
  10328. var radius = 0;
  10329. if (this.isThumbClamped && this.isThumbCircle) {
  10330. if (this.isVertical) {
  10331. top += (this._effectiveThumbThickness / 2);
  10332. }
  10333. else {
  10334. left += (this._effectiveThumbThickness / 2);
  10335. }
  10336. radius = this._backgroundBoxThickness / 2;
  10337. }
  10338. else {
  10339. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10340. }
  10341. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10342. context.shadowColor = this.shadowColor;
  10343. context.shadowBlur = this.shadowBlur;
  10344. context.shadowOffsetX = this.shadowOffsetX;
  10345. context.shadowOffsetY = this.shadowOffsetY;
  10346. }
  10347. var thumbPosition = this._getThumbPosition();
  10348. context.fillStyle = this._background;
  10349. if (this.isVertical) {
  10350. if (this.isThumbClamped) {
  10351. if (this.isThumbCircle) {
  10352. context.beginPath();
  10353. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10354. context.fill();
  10355. context.fillRect(left, top, width, height);
  10356. }
  10357. else {
  10358. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10359. }
  10360. }
  10361. else {
  10362. context.fillRect(left, top, width, height);
  10363. }
  10364. }
  10365. else {
  10366. if (this.isThumbClamped) {
  10367. if (this.isThumbCircle) {
  10368. context.beginPath();
  10369. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10370. context.fill();
  10371. context.fillRect(left, top, width, height);
  10372. }
  10373. else {
  10374. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10375. }
  10376. }
  10377. else {
  10378. context.fillRect(left, top, width, height);
  10379. }
  10380. }
  10381. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10382. context.shadowBlur = 0;
  10383. context.shadowOffsetX = 0;
  10384. context.shadowOffsetY = 0;
  10385. }
  10386. // Value bar
  10387. context.fillStyle = this.color;
  10388. if (this._displayValueBar) {
  10389. if (this.isVertical) {
  10390. if (this.isThumbClamped) {
  10391. if (this.isThumbCircle) {
  10392. context.beginPath();
  10393. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10394. context.fill();
  10395. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10396. }
  10397. else {
  10398. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10399. }
  10400. }
  10401. else {
  10402. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10403. }
  10404. }
  10405. else {
  10406. if (this.isThumbClamped) {
  10407. if (this.isThumbCircle) {
  10408. context.beginPath();
  10409. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10410. context.fill();
  10411. context.fillRect(left, top, thumbPosition, height);
  10412. }
  10413. else {
  10414. context.fillRect(left, top, thumbPosition, height);
  10415. }
  10416. }
  10417. else {
  10418. context.fillRect(left, top, thumbPosition, height);
  10419. }
  10420. }
  10421. }
  10422. // Thumb
  10423. if (this.displayThumb) {
  10424. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10425. context.shadowColor = this.shadowColor;
  10426. context.shadowBlur = this.shadowBlur;
  10427. context.shadowOffsetX = this.shadowOffsetX;
  10428. context.shadowOffsetY = this.shadowOffsetY;
  10429. }
  10430. if (this._isThumbCircle) {
  10431. context.beginPath();
  10432. if (this.isVertical) {
  10433. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10434. }
  10435. else {
  10436. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10437. }
  10438. context.fill();
  10439. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10440. context.shadowBlur = 0;
  10441. context.shadowOffsetX = 0;
  10442. context.shadowOffsetY = 0;
  10443. }
  10444. context.strokeStyle = this._borderColor;
  10445. context.stroke();
  10446. }
  10447. else {
  10448. if (this.isVertical) {
  10449. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10450. }
  10451. else {
  10452. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10453. }
  10454. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10455. context.shadowBlur = 0;
  10456. context.shadowOffsetX = 0;
  10457. context.shadowOffsetY = 0;
  10458. }
  10459. context.strokeStyle = this._borderColor;
  10460. if (this.isVertical) {
  10461. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10462. }
  10463. else {
  10464. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10465. }
  10466. }
  10467. }
  10468. context.restore();
  10469. };
  10470. return Slider;
  10471. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10472. /***/ }),
  10473. /***/ "./2D/controls/stackPanel.ts":
  10474. /*!***********************************!*\
  10475. !*** ./2D/controls/stackPanel.ts ***!
  10476. \***********************************/
  10477. /*! exports provided: StackPanel */
  10478. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10479. "use strict";
  10480. __webpack_require__.r(__webpack_exports__);
  10481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10482. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10483. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  10484. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10485. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10486. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10487. /**
  10488. * Class used to create a 2D stack panel container
  10489. */
  10490. var StackPanel = /** @class */ (function (_super) {
  10491. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10492. /**
  10493. * Creates a new StackPanel
  10494. * @param name defines control name
  10495. */
  10496. function StackPanel(name) {
  10497. var _this = _super.call(this, name) || this;
  10498. _this.name = name;
  10499. _this._isVertical = true;
  10500. _this._manualWidth = false;
  10501. _this._manualHeight = false;
  10502. _this._doNotTrackManualChanges = false;
  10503. return _this;
  10504. }
  10505. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10506. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10507. get: function () {
  10508. return this._isVertical;
  10509. },
  10510. set: function (value) {
  10511. if (this._isVertical === value) {
  10512. return;
  10513. }
  10514. this._isVertical = value;
  10515. this._markAsDirty();
  10516. },
  10517. enumerable: true,
  10518. configurable: true
  10519. });
  10520. Object.defineProperty(StackPanel.prototype, "width", {
  10521. get: function () {
  10522. return this._width.toString(this._host);
  10523. },
  10524. /**
  10525. * Gets or sets panel width.
  10526. * This value should not be set when in horizontal mode as it will be computed automatically
  10527. */
  10528. set: function (value) {
  10529. if (!this._doNotTrackManualChanges) {
  10530. this._manualWidth = true;
  10531. }
  10532. if (this._width.toString(this._host) === value) {
  10533. return;
  10534. }
  10535. if (this._width.fromString(value)) {
  10536. this._markAsDirty();
  10537. }
  10538. },
  10539. enumerable: true,
  10540. configurable: true
  10541. });
  10542. Object.defineProperty(StackPanel.prototype, "height", {
  10543. get: function () {
  10544. return this._height.toString(this._host);
  10545. },
  10546. /**
  10547. * Gets or sets panel height.
  10548. * This value should not be set when in vertical mode as it will be computed automatically
  10549. */
  10550. set: function (value) {
  10551. if (!this._doNotTrackManualChanges) {
  10552. this._manualHeight = true;
  10553. }
  10554. if (this._height.toString(this._host) === value) {
  10555. return;
  10556. }
  10557. if (this._height.fromString(value)) {
  10558. this._markAsDirty();
  10559. }
  10560. },
  10561. enumerable: true,
  10562. configurable: true
  10563. });
  10564. StackPanel.prototype._getTypeName = function () {
  10565. return "StackPanel";
  10566. };
  10567. /** @hidden */
  10568. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10569. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10570. var child = _a[_i];
  10571. if (this._isVertical) {
  10572. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10573. }
  10574. else {
  10575. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10576. }
  10577. }
  10578. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10579. };
  10580. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10581. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10582. this._measureForChildren.copyFrom(parentMeasure);
  10583. this._measureForChildren.left = this._currentMeasure.left;
  10584. this._measureForChildren.top = this._currentMeasure.top;
  10585. if (!this.isVertical || this._manualWidth) {
  10586. this._measureForChildren.width = this._currentMeasure.width;
  10587. }
  10588. if (this.isVertical || this._manualHeight) {
  10589. this._measureForChildren.height = this._currentMeasure.height;
  10590. }
  10591. };
  10592. StackPanel.prototype._postMeasure = function () {
  10593. var stackWidth = 0;
  10594. var stackHeight = 0;
  10595. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10596. var child = _a[_i];
  10597. if (!child.isVisible || child.notRenderable) {
  10598. continue;
  10599. }
  10600. if (this._isVertical) {
  10601. if (child.top !== stackHeight + "px") {
  10602. child.top = stackHeight + "px";
  10603. this._rebuildLayout = true;
  10604. child._top.ignoreAdaptiveScaling = true;
  10605. }
  10606. if (child._height.isPercentage) {
  10607. 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");
  10608. }
  10609. else {
  10610. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10611. }
  10612. }
  10613. else {
  10614. if (child.left !== stackWidth + "px") {
  10615. child.left = stackWidth + "px";
  10616. this._rebuildLayout = true;
  10617. child._left.ignoreAdaptiveScaling = true;
  10618. }
  10619. if (child._width.isPercentage) {
  10620. 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");
  10621. }
  10622. else {
  10623. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10624. }
  10625. }
  10626. }
  10627. this._doNotTrackManualChanges = true;
  10628. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10629. // User can now define their own height and width for stack panel.
  10630. var panelWidthChanged = false;
  10631. var panelHeightChanged = false;
  10632. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10633. var previousHeight = this.height;
  10634. this.height = stackHeight + "px";
  10635. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10636. }
  10637. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10638. var previousWidth = this.width;
  10639. this.width = stackWidth + "px";
  10640. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10641. }
  10642. if (panelHeightChanged) {
  10643. this._height.ignoreAdaptiveScaling = true;
  10644. }
  10645. if (panelWidthChanged) {
  10646. this._width.ignoreAdaptiveScaling = true;
  10647. }
  10648. this._doNotTrackManualChanges = false;
  10649. if (panelWidthChanged || panelHeightChanged) {
  10650. this._rebuildLayout = true;
  10651. }
  10652. _super.prototype._postMeasure.call(this);
  10653. };
  10654. return StackPanel;
  10655. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10656. /***/ }),
  10657. /***/ "./2D/controls/statics.ts":
  10658. /*!********************************!*\
  10659. !*** ./2D/controls/statics.ts ***!
  10660. \********************************/
  10661. /*! exports provided: name */
  10662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10663. "use strict";
  10664. __webpack_require__.r(__webpack_exports__);
  10665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10666. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10667. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10668. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10669. /**
  10670. * Forcing an export so that this code will execute
  10671. * @hidden
  10672. */
  10673. var name = "Statics";
  10674. /**
  10675. * Creates a stack panel that can be used to render headers
  10676. * @param control defines the control to associate with the header
  10677. * @param text defines the text of the header
  10678. * @param size defines the size of the header
  10679. * @param options defines options used to configure the header
  10680. * @returns a new StackPanel
  10681. */
  10682. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10683. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10684. var isHorizontal = options ? options.isHorizontal : true;
  10685. var controlFirst = options ? options.controlFirst : true;
  10686. panel.isVertical = !isHorizontal;
  10687. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10688. header.text = text;
  10689. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10690. if (isHorizontal) {
  10691. header.width = size;
  10692. }
  10693. else {
  10694. header.height = size;
  10695. }
  10696. if (controlFirst) {
  10697. panel.addControl(control);
  10698. panel.addControl(header);
  10699. header.paddingLeft = "5px";
  10700. }
  10701. else {
  10702. panel.addControl(header);
  10703. panel.addControl(control);
  10704. header.paddingRight = "5px";
  10705. }
  10706. header.shadowBlur = control.shadowBlur;
  10707. header.shadowColor = control.shadowColor;
  10708. header.shadowOffsetX = control.shadowOffsetX;
  10709. header.shadowOffsetY = control.shadowOffsetY;
  10710. return panel;
  10711. };
  10712. /***/ }),
  10713. /***/ "./2D/controls/textBlock.ts":
  10714. /*!**********************************!*\
  10715. !*** ./2D/controls/textBlock.ts ***!
  10716. \**********************************/
  10717. /*! exports provided: TextWrapping, TextBlock */
  10718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10719. "use strict";
  10720. __webpack_require__.r(__webpack_exports__);
  10721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10724. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10725. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10726. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10727. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10728. /**
  10729. * Enum that determines the text-wrapping mode to use.
  10730. */
  10731. var TextWrapping;
  10732. (function (TextWrapping) {
  10733. /**
  10734. * Clip the text when it's larger than Control.width; this is the default mode.
  10735. */
  10736. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10737. /**
  10738. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10739. */
  10740. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10741. /**
  10742. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10743. */
  10744. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10745. })(TextWrapping || (TextWrapping = {}));
  10746. /**
  10747. * Class used to create text block control
  10748. */
  10749. var TextBlock = /** @class */ (function (_super) {
  10750. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10751. /**
  10752. * Creates a new TextBlock object
  10753. * @param name defines the name of the control
  10754. * @param text defines the text to display (emptry string by default)
  10755. */
  10756. function TextBlock(
  10757. /**
  10758. * Defines the name of the control
  10759. */
  10760. name, text) {
  10761. if (text === void 0) { text = ""; }
  10762. var _this = _super.call(this, name) || this;
  10763. _this.name = name;
  10764. _this._text = "";
  10765. _this._textWrapping = TextWrapping.Clip;
  10766. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10767. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10768. _this._resizeToFit = false;
  10769. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10770. _this._outlineWidth = 0;
  10771. _this._outlineColor = "white";
  10772. /**
  10773. * An event triggered after the text is changed
  10774. */
  10775. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10776. /**
  10777. * An event triggered after the text was broken up into lines
  10778. */
  10779. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10780. _this.text = text;
  10781. return _this;
  10782. }
  10783. Object.defineProperty(TextBlock.prototype, "lines", {
  10784. /**
  10785. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10786. */
  10787. get: function () {
  10788. return this._lines;
  10789. },
  10790. enumerable: true,
  10791. configurable: true
  10792. });
  10793. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10794. /**
  10795. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10796. */
  10797. get: function () {
  10798. return this._resizeToFit;
  10799. },
  10800. /**
  10801. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10802. */
  10803. set: function (value) {
  10804. if (this._resizeToFit === value) {
  10805. return;
  10806. }
  10807. this._resizeToFit = value;
  10808. if (this._resizeToFit) {
  10809. this._width.ignoreAdaptiveScaling = true;
  10810. this._height.ignoreAdaptiveScaling = true;
  10811. }
  10812. this._markAsDirty();
  10813. },
  10814. enumerable: true,
  10815. configurable: true
  10816. });
  10817. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10818. /**
  10819. * Gets or sets a boolean indicating if text must be wrapped
  10820. */
  10821. get: function () {
  10822. return this._textWrapping;
  10823. },
  10824. /**
  10825. * Gets or sets a boolean indicating if text must be wrapped
  10826. */
  10827. set: function (value) {
  10828. if (this._textWrapping === value) {
  10829. return;
  10830. }
  10831. this._textWrapping = +value;
  10832. this._markAsDirty();
  10833. },
  10834. enumerable: true,
  10835. configurable: true
  10836. });
  10837. Object.defineProperty(TextBlock.prototype, "text", {
  10838. /**
  10839. * Gets or sets text to display
  10840. */
  10841. get: function () {
  10842. return this._text;
  10843. },
  10844. /**
  10845. * Gets or sets text to display
  10846. */
  10847. set: function (value) {
  10848. if (this._text === value) {
  10849. return;
  10850. }
  10851. this._text = value;
  10852. this._markAsDirty();
  10853. this.onTextChangedObservable.notifyObservers(this);
  10854. },
  10855. enumerable: true,
  10856. configurable: true
  10857. });
  10858. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10859. /**
  10860. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10861. */
  10862. get: function () {
  10863. return this._textHorizontalAlignment;
  10864. },
  10865. /**
  10866. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10867. */
  10868. set: function (value) {
  10869. if (this._textHorizontalAlignment === value) {
  10870. return;
  10871. }
  10872. this._textHorizontalAlignment = value;
  10873. this._markAsDirty();
  10874. },
  10875. enumerable: true,
  10876. configurable: true
  10877. });
  10878. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10879. /**
  10880. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10881. */
  10882. get: function () {
  10883. return this._textVerticalAlignment;
  10884. },
  10885. /**
  10886. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10887. */
  10888. set: function (value) {
  10889. if (this._textVerticalAlignment === value) {
  10890. return;
  10891. }
  10892. this._textVerticalAlignment = value;
  10893. this._markAsDirty();
  10894. },
  10895. enumerable: true,
  10896. configurable: true
  10897. });
  10898. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10899. /**
  10900. * Gets or sets line spacing value
  10901. */
  10902. get: function () {
  10903. return this._lineSpacing.toString(this._host);
  10904. },
  10905. /**
  10906. * Gets or sets line spacing value
  10907. */
  10908. set: function (value) {
  10909. if (this._lineSpacing.fromString(value)) {
  10910. this._markAsDirty();
  10911. }
  10912. },
  10913. enumerable: true,
  10914. configurable: true
  10915. });
  10916. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10917. /**
  10918. * Gets or sets outlineWidth of the text to display
  10919. */
  10920. get: function () {
  10921. return this._outlineWidth;
  10922. },
  10923. /**
  10924. * Gets or sets outlineWidth of the text to display
  10925. */
  10926. set: function (value) {
  10927. if (this._outlineWidth === value) {
  10928. return;
  10929. }
  10930. this._outlineWidth = value;
  10931. this._markAsDirty();
  10932. },
  10933. enumerable: true,
  10934. configurable: true
  10935. });
  10936. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  10937. /**
  10938. * Gets or sets outlineColor of the text to display
  10939. */
  10940. get: function () {
  10941. return this._outlineColor;
  10942. },
  10943. /**
  10944. * Gets or sets outlineColor of the text to display
  10945. */
  10946. set: function (value) {
  10947. if (this._outlineColor === value) {
  10948. return;
  10949. }
  10950. this._outlineColor = value;
  10951. this._markAsDirty();
  10952. },
  10953. enumerable: true,
  10954. configurable: true
  10955. });
  10956. TextBlock.prototype._getTypeName = function () {
  10957. return "TextBlock";
  10958. };
  10959. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  10960. if (!this._fontOffset) {
  10961. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  10962. }
  10963. _super.prototype._processMeasures.call(this, parentMeasure, context);
  10964. // Prepare lines
  10965. this._lines = this._breakLines(this._currentMeasure.width, context);
  10966. this.onLinesReadyObservable.notifyObservers(this);
  10967. var maxLineWidth = 0;
  10968. for (var i = 0; i < this._lines.length; i++) {
  10969. var line = this._lines[i];
  10970. if (line.width > maxLineWidth) {
  10971. maxLineWidth = line.width;
  10972. }
  10973. }
  10974. if (this._resizeToFit) {
  10975. if (this._textWrapping === TextWrapping.Clip) {
  10976. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  10977. if (newWidth !== this._width.internalValue) {
  10978. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10979. this._rebuildLayout = true;
  10980. }
  10981. }
  10982. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  10983. if (newHeight !== this._height.internalValue) {
  10984. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10985. this._rebuildLayout = true;
  10986. }
  10987. }
  10988. };
  10989. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  10990. var width = this._currentMeasure.width;
  10991. var x = 0;
  10992. switch (this._textHorizontalAlignment) {
  10993. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  10994. x = 0;
  10995. break;
  10996. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  10997. x = width - textWidth;
  10998. break;
  10999. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11000. x = (width - textWidth) / 2;
  11001. break;
  11002. }
  11003. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11004. context.shadowColor = this.shadowColor;
  11005. context.shadowBlur = this.shadowBlur;
  11006. context.shadowOffsetX = this.shadowOffsetX;
  11007. context.shadowOffsetY = this.shadowOffsetY;
  11008. }
  11009. if (this.outlineWidth) {
  11010. context.strokeText(text, this._currentMeasure.left + x, y);
  11011. }
  11012. context.fillText(text, this._currentMeasure.left + x, y);
  11013. };
  11014. /** @hidden */
  11015. TextBlock.prototype._draw = function (context) {
  11016. context.save();
  11017. this._applyStates(context);
  11018. // Render lines
  11019. this._renderLines(context);
  11020. context.restore();
  11021. };
  11022. TextBlock.prototype._applyStates = function (context) {
  11023. _super.prototype._applyStates.call(this, context);
  11024. if (this.outlineWidth) {
  11025. context.lineWidth = this.outlineWidth;
  11026. context.strokeStyle = this.outlineColor;
  11027. }
  11028. };
  11029. TextBlock.prototype._breakLines = function (refWidth, context) {
  11030. var lines = [];
  11031. var _lines = this.text.split("\n");
  11032. if (this._textWrapping === TextWrapping.Ellipsis) {
  11033. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11034. var _line = _lines_1[_i];
  11035. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11036. }
  11037. }
  11038. else if (this._textWrapping === TextWrapping.WordWrap) {
  11039. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11040. var _line = _lines_2[_a];
  11041. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11042. }
  11043. }
  11044. else {
  11045. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11046. var _line = _lines_3[_b];
  11047. lines.push(this._parseLine(_line, context));
  11048. }
  11049. }
  11050. return lines;
  11051. };
  11052. TextBlock.prototype._parseLine = function (line, context) {
  11053. if (line === void 0) { line = ''; }
  11054. return { text: line, width: context.measureText(line).width };
  11055. };
  11056. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11057. if (line === void 0) { line = ''; }
  11058. var lineWidth = context.measureText(line).width;
  11059. if (lineWidth > width) {
  11060. line += '…';
  11061. }
  11062. while (line.length > 2 && lineWidth > width) {
  11063. line = line.slice(0, -2) + '…';
  11064. lineWidth = context.measureText(line).width;
  11065. }
  11066. return { text: line, width: lineWidth };
  11067. };
  11068. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11069. if (line === void 0) { line = ''; }
  11070. var lines = [];
  11071. var words = line.split(' ');
  11072. var lineWidth = 0;
  11073. for (var n = 0; n < words.length; n++) {
  11074. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11075. var metrics = context.measureText(testLine);
  11076. var testWidth = metrics.width;
  11077. if (testWidth > width && n > 0) {
  11078. lines.push({ text: line, width: lineWidth });
  11079. line = words[n];
  11080. lineWidth = context.measureText(line).width;
  11081. }
  11082. else {
  11083. lineWidth = testWidth;
  11084. line = testLine;
  11085. }
  11086. }
  11087. lines.push({ text: line, width: lineWidth });
  11088. return lines;
  11089. };
  11090. TextBlock.prototype._renderLines = function (context) {
  11091. var height = this._currentMeasure.height;
  11092. var rootY = 0;
  11093. switch (this._textVerticalAlignment) {
  11094. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11095. rootY = this._fontOffset.ascent;
  11096. break;
  11097. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11098. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11099. break;
  11100. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11101. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11102. break;
  11103. }
  11104. rootY += this._currentMeasure.top;
  11105. for (var i = 0; i < this._lines.length; i++) {
  11106. var line = this._lines[i];
  11107. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11108. if (this._lineSpacing.isPixel) {
  11109. rootY += this._lineSpacing.getValue(this._host);
  11110. }
  11111. else {
  11112. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11113. }
  11114. }
  11115. this._drawText(line.text, line.width, rootY, context);
  11116. rootY += this._fontOffset.height;
  11117. }
  11118. };
  11119. /**
  11120. * Given a width constraint applied on the text block, find the expected height
  11121. * @returns expected height
  11122. */
  11123. TextBlock.prototype.computeExpectedHeight = function () {
  11124. if (this.text && this.widthInPixels) {
  11125. var context_1 = document.createElement('canvas').getContext('2d');
  11126. if (context_1) {
  11127. this._applyStates(context_1);
  11128. if (!this._fontOffset) {
  11129. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11130. }
  11131. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11132. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11133. }
  11134. }
  11135. return 0;
  11136. };
  11137. TextBlock.prototype.dispose = function () {
  11138. _super.prototype.dispose.call(this);
  11139. this.onTextChangedObservable.clear();
  11140. };
  11141. return TextBlock;
  11142. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11143. /***/ }),
  11144. /***/ "./2D/controls/virtualKeyboard.ts":
  11145. /*!****************************************!*\
  11146. !*** ./2D/controls/virtualKeyboard.ts ***!
  11147. \****************************************/
  11148. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11150. "use strict";
  11151. __webpack_require__.r(__webpack_exports__);
  11152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11153. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11154. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11155. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11156. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11157. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11158. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11159. /**
  11160. * Class used to store key control properties
  11161. */
  11162. var KeyPropertySet = /** @class */ (function () {
  11163. function KeyPropertySet() {
  11164. }
  11165. return KeyPropertySet;
  11166. }());
  11167. /**
  11168. * Class used to create virtual keyboard
  11169. */
  11170. var VirtualKeyboard = /** @class */ (function (_super) {
  11171. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11172. function VirtualKeyboard() {
  11173. var _this = _super !== null && _super.apply(this, arguments) || this;
  11174. /** Observable raised when a key is pressed */
  11175. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11176. /** Gets or sets default key button width */
  11177. _this.defaultButtonWidth = "40px";
  11178. /** Gets or sets default key button height */
  11179. _this.defaultButtonHeight = "40px";
  11180. /** Gets or sets default key button left padding */
  11181. _this.defaultButtonPaddingLeft = "2px";
  11182. /** Gets or sets default key button right padding */
  11183. _this.defaultButtonPaddingRight = "2px";
  11184. /** Gets or sets default key button top padding */
  11185. _this.defaultButtonPaddingTop = "2px";
  11186. /** Gets or sets default key button bottom padding */
  11187. _this.defaultButtonPaddingBottom = "2px";
  11188. /** Gets or sets default key button foreground color */
  11189. _this.defaultButtonColor = "#DDD";
  11190. /** Gets or sets default key button background color */
  11191. _this.defaultButtonBackground = "#070707";
  11192. /** Gets or sets shift button foreground color */
  11193. _this.shiftButtonColor = "#7799FF";
  11194. /** Gets or sets shift button thickness*/
  11195. _this.selectedShiftThickness = 1;
  11196. /** Gets shift key state */
  11197. _this.shiftState = 0;
  11198. _this._currentlyConnectedInputText = null;
  11199. _this._connectedInputTexts = [];
  11200. _this._onKeyPressObserver = null;
  11201. return _this;
  11202. }
  11203. VirtualKeyboard.prototype._getTypeName = function () {
  11204. return "VirtualKeyboard";
  11205. };
  11206. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11207. var _this = this;
  11208. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11209. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11210. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11211. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11212. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11213. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11214. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11215. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11216. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11217. button.thickness = 0;
  11218. button.isFocusInvisible = true;
  11219. button.shadowColor = this.shadowColor;
  11220. button.shadowBlur = this.shadowBlur;
  11221. button.shadowOffsetX = this.shadowOffsetX;
  11222. button.shadowOffsetY = this.shadowOffsetY;
  11223. button.onPointerUpObservable.add(function () {
  11224. _this.onKeyPressObservable.notifyObservers(key);
  11225. });
  11226. return button;
  11227. };
  11228. /**
  11229. * Adds a new row of keys
  11230. * @param keys defines the list of keys to add
  11231. * @param propertySets defines the associated property sets
  11232. */
  11233. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11234. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11235. panel.isVertical = false;
  11236. panel.isFocusInvisible = true;
  11237. for (var i = 0; i < keys.length; i++) {
  11238. var properties = null;
  11239. if (propertySets && propertySets.length === keys.length) {
  11240. properties = propertySets[i];
  11241. }
  11242. panel.addControl(this._createKey(keys[i], properties));
  11243. }
  11244. this.addControl(panel);
  11245. };
  11246. /**
  11247. * Set the shift key to a specific state
  11248. * @param shiftState defines the new shift state
  11249. */
  11250. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11251. if (!this.children) {
  11252. return;
  11253. }
  11254. for (var i = 0; i < this.children.length; i++) {
  11255. var row = this.children[i];
  11256. if (!row || !row.children) {
  11257. continue;
  11258. }
  11259. var rowContainer = row;
  11260. for (var j = 0; j < rowContainer.children.length; j++) {
  11261. var button = rowContainer.children[j];
  11262. if (!button || !button.children[0]) {
  11263. continue;
  11264. }
  11265. var button_tblock = button.children[0];
  11266. if (button_tblock.text === "\u21E7") {
  11267. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11268. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11269. }
  11270. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11271. }
  11272. }
  11273. };
  11274. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11275. /** Gets the input text control currently attached to the keyboard */
  11276. get: function () {
  11277. return this._currentlyConnectedInputText;
  11278. },
  11279. enumerable: true,
  11280. configurable: true
  11281. });
  11282. /**
  11283. * Connects the keyboard with an input text control
  11284. *
  11285. * @param input defines the target control
  11286. */
  11287. VirtualKeyboard.prototype.connect = function (input) {
  11288. var _this = this;
  11289. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11290. if (inputTextAlreadyConnected) {
  11291. return;
  11292. }
  11293. if (this._onKeyPressObserver === null) {
  11294. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11295. if (!_this._currentlyConnectedInputText) {
  11296. return;
  11297. }
  11298. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11299. switch (key) {
  11300. case "\u21E7":
  11301. _this.shiftState++;
  11302. if (_this.shiftState > 2) {
  11303. _this.shiftState = 0;
  11304. }
  11305. _this.applyShiftState(_this.shiftState);
  11306. return;
  11307. case "\u2190":
  11308. _this._currentlyConnectedInputText.processKey(8);
  11309. return;
  11310. case "\u21B5":
  11311. _this._currentlyConnectedInputText.processKey(13);
  11312. return;
  11313. }
  11314. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11315. if (_this.shiftState === 1) {
  11316. _this.shiftState = 0;
  11317. _this.applyShiftState(_this.shiftState);
  11318. }
  11319. });
  11320. }
  11321. this.isVisible = false;
  11322. this._currentlyConnectedInputText = input;
  11323. input._connectedVirtualKeyboard = this;
  11324. // Events hooking
  11325. var onFocusObserver = input.onFocusObservable.add(function () {
  11326. _this._currentlyConnectedInputText = input;
  11327. input._connectedVirtualKeyboard = _this;
  11328. _this.isVisible = true;
  11329. });
  11330. var onBlurObserver = input.onBlurObservable.add(function () {
  11331. input._connectedVirtualKeyboard = null;
  11332. _this._currentlyConnectedInputText = null;
  11333. _this.isVisible = false;
  11334. });
  11335. this._connectedInputTexts.push({
  11336. input: input,
  11337. onBlurObserver: onBlurObserver,
  11338. onFocusObserver: onFocusObserver
  11339. });
  11340. };
  11341. /**
  11342. * Disconnects the keyboard from connected InputText controls
  11343. *
  11344. * @param input optionally defines a target control, otherwise all are disconnected
  11345. */
  11346. VirtualKeyboard.prototype.disconnect = function (input) {
  11347. var _this = this;
  11348. if (input) {
  11349. // .find not available on IE
  11350. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11351. if (filtered.length === 1) {
  11352. this._removeConnectedInputObservables(filtered[0]);
  11353. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11354. if (this._currentlyConnectedInputText === input) {
  11355. this._currentlyConnectedInputText = null;
  11356. }
  11357. }
  11358. }
  11359. else {
  11360. this._connectedInputTexts.forEach(function (connectedInputText) {
  11361. _this._removeConnectedInputObservables(connectedInputText);
  11362. });
  11363. this._connectedInputTexts = [];
  11364. }
  11365. if (this._connectedInputTexts.length === 0) {
  11366. this._currentlyConnectedInputText = null;
  11367. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11368. this._onKeyPressObserver = null;
  11369. }
  11370. };
  11371. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11372. connectedInputText.input._connectedVirtualKeyboard = null;
  11373. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11374. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11375. };
  11376. /**
  11377. * Release all resources
  11378. */
  11379. VirtualKeyboard.prototype.dispose = function () {
  11380. _super.prototype.dispose.call(this);
  11381. this.disconnect();
  11382. };
  11383. // Statics
  11384. /**
  11385. * Creates a new keyboard using a default layout
  11386. *
  11387. * @param name defines control name
  11388. * @returns a new VirtualKeyboard
  11389. */
  11390. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11391. var returnValue = new VirtualKeyboard(name);
  11392. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11393. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11394. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11395. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11396. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11397. return returnValue;
  11398. };
  11399. return VirtualKeyboard;
  11400. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11401. /***/ }),
  11402. /***/ "./2D/index.ts":
  11403. /*!*********************!*\
  11404. !*** ./2D/index.ts ***!
  11405. \*********************/
  11406. /*! 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, name */
  11407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11408. "use strict";
  11409. __webpack_require__.r(__webpack_exports__);
  11410. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11441. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11443. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11445. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11448. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11450. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11452. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11454. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11456. /***/ }),
  11457. /***/ "./2D/math2D.ts":
  11458. /*!**********************!*\
  11459. !*** ./2D/math2D.ts ***!
  11460. \**********************/
  11461. /*! exports provided: Vector2WithInfo, Matrix2D */
  11462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11463. "use strict";
  11464. __webpack_require__.r(__webpack_exports__);
  11465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11467. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11468. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11469. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11470. /**
  11471. * Class used to transport Vector2 information for pointer events
  11472. */
  11473. var Vector2WithInfo = /** @class */ (function (_super) {
  11474. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11475. /**
  11476. * Creates a new Vector2WithInfo
  11477. * @param source defines the vector2 data to transport
  11478. * @param buttonIndex defines the current mouse button index
  11479. */
  11480. function Vector2WithInfo(source,
  11481. /** defines the current mouse button index */
  11482. buttonIndex) {
  11483. if (buttonIndex === void 0) { buttonIndex = 0; }
  11484. var _this = _super.call(this, source.x, source.y) || this;
  11485. _this.buttonIndex = buttonIndex;
  11486. return _this;
  11487. }
  11488. return Vector2WithInfo;
  11489. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11490. /** Class used to provide 2D matrix features */
  11491. var Matrix2D = /** @class */ (function () {
  11492. /**
  11493. * Creates a new matrix
  11494. * @param m00 defines value for (0, 0)
  11495. * @param m01 defines value for (0, 1)
  11496. * @param m10 defines value for (1, 0)
  11497. * @param m11 defines value for (1, 1)
  11498. * @param m20 defines value for (2, 0)
  11499. * @param m21 defines value for (2, 1)
  11500. */
  11501. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11502. /** Gets the internal array of 6 floats used to store matrix data */
  11503. this.m = new Float32Array(6);
  11504. this.fromValues(m00, m01, m10, m11, m20, m21);
  11505. }
  11506. /**
  11507. * Fills the matrix from direct values
  11508. * @param m00 defines value for (0, 0)
  11509. * @param m01 defines value for (0, 1)
  11510. * @param m10 defines value for (1, 0)
  11511. * @param m11 defines value for (1, 1)
  11512. * @param m20 defines value for (2, 0)
  11513. * @param m21 defines value for (2, 1)
  11514. * @returns the current modified matrix
  11515. */
  11516. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11517. this.m[0] = m00;
  11518. this.m[1] = m01;
  11519. this.m[2] = m10;
  11520. this.m[3] = m11;
  11521. this.m[4] = m20;
  11522. this.m[5] = m21;
  11523. return this;
  11524. };
  11525. /**
  11526. * Gets matrix determinant
  11527. * @returns the determinant
  11528. */
  11529. Matrix2D.prototype.determinant = function () {
  11530. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11531. };
  11532. /**
  11533. * Inverses the matrix and stores it in a target matrix
  11534. * @param result defines the target matrix
  11535. * @returns the current matrix
  11536. */
  11537. Matrix2D.prototype.invertToRef = function (result) {
  11538. var l0 = this.m[0];
  11539. var l1 = this.m[1];
  11540. var l2 = this.m[2];
  11541. var l3 = this.m[3];
  11542. var l4 = this.m[4];
  11543. var l5 = this.m[5];
  11544. var det = this.determinant();
  11545. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11546. result.m[0] = 0;
  11547. result.m[1] = 0;
  11548. result.m[2] = 0;
  11549. result.m[3] = 0;
  11550. result.m[4] = 0;
  11551. result.m[5] = 0;
  11552. return this;
  11553. }
  11554. var detDiv = 1 / det;
  11555. var det4 = l2 * l5 - l3 * l4;
  11556. var det5 = l1 * l4 - l0 * l5;
  11557. result.m[0] = l3 * detDiv;
  11558. result.m[1] = -l1 * detDiv;
  11559. result.m[2] = -l2 * detDiv;
  11560. result.m[3] = l0 * detDiv;
  11561. result.m[4] = det4 * detDiv;
  11562. result.m[5] = det5 * detDiv;
  11563. return this;
  11564. };
  11565. /**
  11566. * Multiplies the current matrix with another one
  11567. * @param other defines the second operand
  11568. * @param result defines the target matrix
  11569. * @returns the current matrix
  11570. */
  11571. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11572. var l0 = this.m[0];
  11573. var l1 = this.m[1];
  11574. var l2 = this.m[2];
  11575. var l3 = this.m[3];
  11576. var l4 = this.m[4];
  11577. var l5 = this.m[5];
  11578. var r0 = other.m[0];
  11579. var r1 = other.m[1];
  11580. var r2 = other.m[2];
  11581. var r3 = other.m[3];
  11582. var r4 = other.m[4];
  11583. var r5 = other.m[5];
  11584. result.m[0] = l0 * r0 + l1 * r2;
  11585. result.m[1] = l0 * r1 + l1 * r3;
  11586. result.m[2] = l2 * r0 + l3 * r2;
  11587. result.m[3] = l2 * r1 + l3 * r3;
  11588. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11589. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11590. return this;
  11591. };
  11592. /**
  11593. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11594. * @param x defines the x coordinate to transform
  11595. * @param y defines the x coordinate to transform
  11596. * @param result defines the target vector2
  11597. * @returns the current matrix
  11598. */
  11599. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11600. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11601. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11602. return this;
  11603. };
  11604. // Statics
  11605. /**
  11606. * Creates an identity matrix
  11607. * @returns a new matrix
  11608. */
  11609. Matrix2D.Identity = function () {
  11610. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11611. };
  11612. /**
  11613. * Creates a translation matrix and stores it in a target matrix
  11614. * @param x defines the x coordinate of the translation
  11615. * @param y defines the y coordinate of the translation
  11616. * @param result defines the target matrix
  11617. */
  11618. Matrix2D.TranslationToRef = function (x, y, result) {
  11619. result.fromValues(1, 0, 0, 1, x, y);
  11620. };
  11621. /**
  11622. * Creates a scaling matrix and stores it in a target matrix
  11623. * @param x defines the x coordinate of the scaling
  11624. * @param y defines the y coordinate of the scaling
  11625. * @param result defines the target matrix
  11626. */
  11627. Matrix2D.ScalingToRef = function (x, y, result) {
  11628. result.fromValues(x, 0, 0, y, 0, 0);
  11629. };
  11630. /**
  11631. * Creates a rotation matrix and stores it in a target matrix
  11632. * @param angle defines the rotation angle
  11633. * @param result defines the target matrix
  11634. */
  11635. Matrix2D.RotationToRef = function (angle, result) {
  11636. var s = Math.sin(angle);
  11637. var c = Math.cos(angle);
  11638. result.fromValues(c, s, -s, c, 0, 0);
  11639. };
  11640. /**
  11641. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11642. * @param tx defines the x coordinate of the translation
  11643. * @param ty defines the y coordinate of the translation
  11644. * @param angle defines the rotation angle
  11645. * @param scaleX defines the x coordinate of the scaling
  11646. * @param scaleY defines the y coordinate of the scaling
  11647. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11648. * @param result defines the target matrix
  11649. */
  11650. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11651. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11652. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11653. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11654. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11655. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11656. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11657. if (parentMatrix) {
  11658. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11659. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11660. }
  11661. else {
  11662. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11663. }
  11664. };
  11665. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11666. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11667. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11668. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11669. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11670. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11671. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11672. return Matrix2D;
  11673. }());
  11674. /***/ }),
  11675. /***/ "./2D/measure.ts":
  11676. /*!***********************!*\
  11677. !*** ./2D/measure.ts ***!
  11678. \***********************/
  11679. /*! exports provided: Measure */
  11680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11681. "use strict";
  11682. __webpack_require__.r(__webpack_exports__);
  11683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11684. /* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs */ "babylonjs/Misc/observable");
  11685. /* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs__WEBPACK_IMPORTED_MODULE_0__);
  11686. /**
  11687. * Class used to store 2D control sizes
  11688. */
  11689. var Measure = /** @class */ (function () {
  11690. /**
  11691. * Creates a new measure
  11692. * @param left defines left coordinate
  11693. * @param top defines top coordinate
  11694. * @param width defines width dimension
  11695. * @param height defines height dimension
  11696. */
  11697. function Measure(
  11698. /** defines left coordinate */
  11699. left,
  11700. /** defines top coordinate */
  11701. top,
  11702. /** defines width dimension */
  11703. width,
  11704. /** defines height dimension */
  11705. height) {
  11706. this.left = left;
  11707. this.top = top;
  11708. this.width = width;
  11709. this.height = height;
  11710. }
  11711. /**
  11712. * Copy from another measure
  11713. * @param other defines the other measure to copy from
  11714. */
  11715. Measure.prototype.copyFrom = function (other) {
  11716. this.left = other.left;
  11717. this.top = other.top;
  11718. this.width = other.width;
  11719. this.height = other.height;
  11720. };
  11721. /**
  11722. * Copy from a group of 4 floats
  11723. * @param left defines left coordinate
  11724. * @param top defines top coordinate
  11725. * @param width defines width dimension
  11726. * @param height defines height dimension
  11727. */
  11728. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11729. this.left = left;
  11730. this.top = top;
  11731. this.width = width;
  11732. this.height = height;
  11733. };
  11734. /**
  11735. * Computes the axis aligned bounding box measure for two given measures
  11736. * @param a Input measure
  11737. * @param b Input measure
  11738. * @param result the resulting bounding measure
  11739. */
  11740. Measure.CombineToRef = function (a, b, result) {
  11741. var left = Math.min(a.left, b.left);
  11742. var top = Math.min(a.top, b.top);
  11743. var right = Math.max(a.left + a.width, b.left + b.width);
  11744. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11745. result.left = left;
  11746. result.top = top;
  11747. result.width = right - left;
  11748. result.height = bottom - top;
  11749. };
  11750. /**
  11751. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11752. * @param transform the matrix to transform the measure before computing the AABB
  11753. * @param result the resulting AABB
  11754. */
  11755. Measure.prototype.transformToRef = function (transform, result) {
  11756. var rectanglePoints = babylonjs__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11757. var min = new babylonjs__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11758. var max = new babylonjs__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11759. for (var i = 0; i < 4; i++) {
  11760. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11761. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11762. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11763. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11764. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11765. }
  11766. result.left = min.x;
  11767. result.top = min.y;
  11768. result.width = max.x - min.x;
  11769. result.height = max.y - min.y;
  11770. };
  11771. /**
  11772. * Check equality between this measure and another one
  11773. * @param other defines the other measures
  11774. * @returns true if both measures are equals
  11775. */
  11776. Measure.prototype.isEqualsTo = function (other) {
  11777. if (this.left !== other.left) {
  11778. return false;
  11779. }
  11780. if (this.top !== other.top) {
  11781. return false;
  11782. }
  11783. if (this.width !== other.width) {
  11784. return false;
  11785. }
  11786. if (this.height !== other.height) {
  11787. return false;
  11788. }
  11789. return true;
  11790. };
  11791. /**
  11792. * Creates an empty measure
  11793. * @returns a new measure
  11794. */
  11795. Measure.Empty = function () {
  11796. return new Measure(0, 0, 0, 0);
  11797. };
  11798. return Measure;
  11799. }());
  11800. /***/ }),
  11801. /***/ "./2D/multiLinePoint.ts":
  11802. /*!******************************!*\
  11803. !*** ./2D/multiLinePoint.ts ***!
  11804. \******************************/
  11805. /*! exports provided: MultiLinePoint */
  11806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11807. "use strict";
  11808. __webpack_require__.r(__webpack_exports__);
  11809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11810. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11811. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11812. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11813. /**
  11814. * Class used to store a point for a MultiLine object.
  11815. * The point can be pure 2D coordinates, a mesh or a control
  11816. */
  11817. var MultiLinePoint = /** @class */ (function () {
  11818. /**
  11819. * Creates a new MultiLinePoint
  11820. * @param multiLine defines the source MultiLine object
  11821. */
  11822. function MultiLinePoint(multiLine) {
  11823. this._multiLine = multiLine;
  11824. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11825. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11826. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11827. }
  11828. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11829. /** Gets or sets x coordinate */
  11830. get: function () {
  11831. return this._x.toString(this._multiLine._host);
  11832. },
  11833. set: function (value) {
  11834. if (this._x.toString(this._multiLine._host) === value) {
  11835. return;
  11836. }
  11837. if (this._x.fromString(value)) {
  11838. this._multiLine._markAsDirty();
  11839. }
  11840. },
  11841. enumerable: true,
  11842. configurable: true
  11843. });
  11844. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11845. /** Gets or sets y coordinate */
  11846. get: function () {
  11847. return this._y.toString(this._multiLine._host);
  11848. },
  11849. set: function (value) {
  11850. if (this._y.toString(this._multiLine._host) === value) {
  11851. return;
  11852. }
  11853. if (this._y.fromString(value)) {
  11854. this._multiLine._markAsDirty();
  11855. }
  11856. },
  11857. enumerable: true,
  11858. configurable: true
  11859. });
  11860. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11861. /** Gets or sets the control associated with this point */
  11862. get: function () {
  11863. return this._control;
  11864. },
  11865. set: function (value) {
  11866. if (this._control === value) {
  11867. return;
  11868. }
  11869. if (this._control && this._controlObserver) {
  11870. this._control.onDirtyObservable.remove(this._controlObserver);
  11871. this._controlObserver = null;
  11872. }
  11873. this._control = value;
  11874. if (this._control) {
  11875. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11876. }
  11877. this._multiLine._markAsDirty();
  11878. },
  11879. enumerable: true,
  11880. configurable: true
  11881. });
  11882. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11883. /** Gets or sets the mesh associated with this point */
  11884. get: function () {
  11885. return this._mesh;
  11886. },
  11887. set: function (value) {
  11888. if (this._mesh === value) {
  11889. return;
  11890. }
  11891. if (this._mesh && this._meshObserver) {
  11892. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11893. }
  11894. this._mesh = value;
  11895. if (this._mesh) {
  11896. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11897. }
  11898. this._multiLine._markAsDirty();
  11899. },
  11900. enumerable: true,
  11901. configurable: true
  11902. });
  11903. /** Resets links */
  11904. MultiLinePoint.prototype.resetLinks = function () {
  11905. this.control = null;
  11906. this.mesh = null;
  11907. };
  11908. /**
  11909. * Gets a translation vector
  11910. * @returns the translation vector
  11911. */
  11912. MultiLinePoint.prototype.translate = function () {
  11913. this._point = this._translatePoint();
  11914. return this._point;
  11915. };
  11916. MultiLinePoint.prototype._translatePoint = function () {
  11917. if (this._mesh != null) {
  11918. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  11919. }
  11920. else if (this._control != null) {
  11921. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  11922. }
  11923. else {
  11924. var host = this._multiLine._host;
  11925. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  11926. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  11927. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  11928. }
  11929. };
  11930. /** Release associated resources */
  11931. MultiLinePoint.prototype.dispose = function () {
  11932. this.resetLinks();
  11933. };
  11934. return MultiLinePoint;
  11935. }());
  11936. /***/ }),
  11937. /***/ "./2D/style.ts":
  11938. /*!*********************!*\
  11939. !*** ./2D/style.ts ***!
  11940. \*********************/
  11941. /*! exports provided: Style */
  11942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11943. "use strict";
  11944. __webpack_require__.r(__webpack_exports__);
  11945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  11946. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11947. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  11948. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11949. /**
  11950. * Define a style used by control to automatically setup properties based on a template.
  11951. * Only support font related properties so far
  11952. */
  11953. var Style = /** @class */ (function () {
  11954. /**
  11955. * Creates a new style object
  11956. * @param host defines the AdvancedDynamicTexture which hosts this style
  11957. */
  11958. function Style(host) {
  11959. this._fontFamily = "Arial";
  11960. this._fontStyle = "";
  11961. this._fontWeight = "";
  11962. /** @hidden */
  11963. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11964. /**
  11965. * Observable raised when the style values are changed
  11966. */
  11967. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  11968. this._host = host;
  11969. }
  11970. Object.defineProperty(Style.prototype, "fontSize", {
  11971. /**
  11972. * Gets or sets the font size
  11973. */
  11974. get: function () {
  11975. return this._fontSize.toString(this._host);
  11976. },
  11977. set: function (value) {
  11978. if (this._fontSize.toString(this._host) === value) {
  11979. return;
  11980. }
  11981. if (this._fontSize.fromString(value)) {
  11982. this.onChangedObservable.notifyObservers(this);
  11983. }
  11984. },
  11985. enumerable: true,
  11986. configurable: true
  11987. });
  11988. Object.defineProperty(Style.prototype, "fontFamily", {
  11989. /**
  11990. * Gets or sets the font family
  11991. */
  11992. get: function () {
  11993. return this._fontFamily;
  11994. },
  11995. set: function (value) {
  11996. if (this._fontFamily === value) {
  11997. return;
  11998. }
  11999. this._fontFamily = value;
  12000. this.onChangedObservable.notifyObservers(this);
  12001. },
  12002. enumerable: true,
  12003. configurable: true
  12004. });
  12005. Object.defineProperty(Style.prototype, "fontStyle", {
  12006. /**
  12007. * Gets or sets the font style
  12008. */
  12009. get: function () {
  12010. return this._fontStyle;
  12011. },
  12012. set: function (value) {
  12013. if (this._fontStyle === value) {
  12014. return;
  12015. }
  12016. this._fontStyle = value;
  12017. this.onChangedObservable.notifyObservers(this);
  12018. },
  12019. enumerable: true,
  12020. configurable: true
  12021. });
  12022. Object.defineProperty(Style.prototype, "fontWeight", {
  12023. /** Gets or sets font weight */
  12024. get: function () {
  12025. return this._fontWeight;
  12026. },
  12027. set: function (value) {
  12028. if (this._fontWeight === value) {
  12029. return;
  12030. }
  12031. this._fontWeight = value;
  12032. this.onChangedObservable.notifyObservers(this);
  12033. },
  12034. enumerable: true,
  12035. configurable: true
  12036. });
  12037. /** Dispose all associated resources */
  12038. Style.prototype.dispose = function () {
  12039. this.onChangedObservable.clear();
  12040. };
  12041. return Style;
  12042. }());
  12043. /***/ }),
  12044. /***/ "./2D/valueAndUnit.ts":
  12045. /*!****************************!*\
  12046. !*** ./2D/valueAndUnit.ts ***!
  12047. \****************************/
  12048. /*! exports provided: ValueAndUnit */
  12049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12050. "use strict";
  12051. __webpack_require__.r(__webpack_exports__);
  12052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12053. /**
  12054. * Class used to specific a value and its associated unit
  12055. */
  12056. var ValueAndUnit = /** @class */ (function () {
  12057. /**
  12058. * Creates a new ValueAndUnit
  12059. * @param value defines the value to store
  12060. * @param unit defines the unit to store
  12061. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12062. */
  12063. function ValueAndUnit(value,
  12064. /** defines the unit to store */
  12065. unit,
  12066. /** defines a boolean indicating if the value can be negative */
  12067. negativeValueAllowed) {
  12068. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12069. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12070. this.unit = unit;
  12071. this.negativeValueAllowed = negativeValueAllowed;
  12072. this._value = 1;
  12073. /**
  12074. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12075. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12076. */
  12077. this.ignoreAdaptiveScaling = false;
  12078. this._value = value;
  12079. this._originalUnit = unit;
  12080. }
  12081. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12082. /** Gets a boolean indicating if the value is a percentage */
  12083. get: function () {
  12084. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12085. },
  12086. enumerable: true,
  12087. configurable: true
  12088. });
  12089. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12090. /** Gets a boolean indicating if the value is store as pixel */
  12091. get: function () {
  12092. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12093. },
  12094. enumerable: true,
  12095. configurable: true
  12096. });
  12097. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12098. /** Gets direct internal value */
  12099. get: function () {
  12100. return this._value;
  12101. },
  12102. enumerable: true,
  12103. configurable: true
  12104. });
  12105. /**
  12106. * Gets value as pixel
  12107. * @param host defines the root host
  12108. * @param refValue defines the reference value for percentages
  12109. * @returns the value as pixel
  12110. */
  12111. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12112. if (this.isPixel) {
  12113. return this.getValue(host);
  12114. }
  12115. return this.getValue(host) * refValue;
  12116. };
  12117. /**
  12118. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12119. * @param value defines the value to store
  12120. * @param unit defines the unit to store
  12121. * @returns the current ValueAndUnit
  12122. */
  12123. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12124. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12125. this._value = value;
  12126. this.unit = unit;
  12127. return this;
  12128. };
  12129. /**
  12130. * Gets the value accordingly to its unit
  12131. * @param host defines the root host
  12132. * @returns the value
  12133. */
  12134. ValueAndUnit.prototype.getValue = function (host) {
  12135. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12136. var width = 0;
  12137. var height = 0;
  12138. if (host.idealWidth) {
  12139. width = (this._value * host.getSize().width) / host.idealWidth;
  12140. }
  12141. if (host.idealHeight) {
  12142. height = (this._value * host.getSize().height) / host.idealHeight;
  12143. }
  12144. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12145. return window.innerWidth < window.innerHeight ? width : height;
  12146. }
  12147. if (host.idealWidth) { // horizontal
  12148. return width;
  12149. }
  12150. if (host.idealHeight) { // vertical
  12151. return height;
  12152. }
  12153. }
  12154. return this._value;
  12155. };
  12156. /**
  12157. * Gets a string representation of the value
  12158. * @param host defines the root host
  12159. * @returns a string
  12160. */
  12161. ValueAndUnit.prototype.toString = function (host) {
  12162. switch (this.unit) {
  12163. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12164. return (this.getValue(host) * 100) + "%";
  12165. case ValueAndUnit.UNITMODE_PIXEL:
  12166. return this.getValue(host) + "px";
  12167. }
  12168. return this.unit.toString();
  12169. };
  12170. /**
  12171. * Store a value parsed from a string
  12172. * @param source defines the source string
  12173. * @returns true if the value was successfully parsed
  12174. */
  12175. ValueAndUnit.prototype.fromString = function (source) {
  12176. var match = ValueAndUnit._Regex.exec(source.toString());
  12177. if (!match || match.length === 0) {
  12178. return false;
  12179. }
  12180. var sourceValue = parseFloat(match[1]);
  12181. var sourceUnit = this._originalUnit;
  12182. if (!this.negativeValueAllowed) {
  12183. if (sourceValue < 0) {
  12184. sourceValue = 0;
  12185. }
  12186. }
  12187. if (match.length === 4) {
  12188. switch (match[3]) {
  12189. case "px":
  12190. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12191. break;
  12192. case "%":
  12193. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12194. sourceValue /= 100.0;
  12195. break;
  12196. }
  12197. }
  12198. if (sourceValue === this._value && sourceUnit === this.unit) {
  12199. return false;
  12200. }
  12201. this._value = sourceValue;
  12202. this.unit = sourceUnit;
  12203. return true;
  12204. };
  12205. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12206. /** UNITMODE_PERCENTAGE */
  12207. get: function () {
  12208. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12209. },
  12210. enumerable: true,
  12211. configurable: true
  12212. });
  12213. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12214. /** UNITMODE_PIXEL */
  12215. get: function () {
  12216. return ValueAndUnit._UNITMODE_PIXEL;
  12217. },
  12218. enumerable: true,
  12219. configurable: true
  12220. });
  12221. // Static
  12222. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12223. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12224. ValueAndUnit._UNITMODE_PIXEL = 1;
  12225. return ValueAndUnit;
  12226. }());
  12227. /***/ }),
  12228. /***/ "./3D/controls/abstractButton3D.ts":
  12229. /*!*****************************************!*\
  12230. !*** ./3D/controls/abstractButton3D.ts ***!
  12231. \*****************************************/
  12232. /*! exports provided: AbstractButton3D */
  12233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12234. "use strict";
  12235. __webpack_require__.r(__webpack_exports__);
  12236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12237. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12238. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12239. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12240. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12241. /**
  12242. * Class used as a root to all buttons
  12243. */
  12244. var AbstractButton3D = /** @class */ (function (_super) {
  12245. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12246. /**
  12247. * Creates a new button
  12248. * @param name defines the control name
  12249. */
  12250. function AbstractButton3D(name) {
  12251. return _super.call(this, name) || this;
  12252. }
  12253. AbstractButton3D.prototype._getTypeName = function () {
  12254. return "AbstractButton3D";
  12255. };
  12256. // Mesh association
  12257. AbstractButton3D.prototype._createNode = function (scene) {
  12258. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12259. };
  12260. return AbstractButton3D;
  12261. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12262. /***/ }),
  12263. /***/ "./3D/controls/button3D.ts":
  12264. /*!*********************************!*\
  12265. !*** ./3D/controls/button3D.ts ***!
  12266. \*********************************/
  12267. /*! exports provided: Button3D */
  12268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12269. "use strict";
  12270. __webpack_require__.r(__webpack_exports__);
  12271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12272. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12273. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  12274. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12275. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12276. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12277. /**
  12278. * Class used to create a button in 3D
  12279. */
  12280. var Button3D = /** @class */ (function (_super) {
  12281. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12282. /**
  12283. * Creates a new button
  12284. * @param name defines the control name
  12285. */
  12286. function Button3D(name) {
  12287. var _this = _super.call(this, name) || this;
  12288. _this._contentResolution = 512;
  12289. _this._contentScaleRatio = 2;
  12290. // Default animations
  12291. _this.pointerEnterAnimation = function () {
  12292. if (!_this.mesh) {
  12293. return;
  12294. }
  12295. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12296. };
  12297. _this.pointerOutAnimation = function () {
  12298. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12299. };
  12300. _this.pointerDownAnimation = function () {
  12301. if (!_this.mesh) {
  12302. return;
  12303. }
  12304. _this.mesh.scaling.scaleInPlace(0.95);
  12305. };
  12306. _this.pointerUpAnimation = function () {
  12307. if (!_this.mesh) {
  12308. return;
  12309. }
  12310. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12311. };
  12312. return _this;
  12313. }
  12314. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12315. /**
  12316. * Gets or sets the texture resolution used to render content (512 by default)
  12317. */
  12318. get: function () {
  12319. return this._contentResolution;
  12320. },
  12321. set: function (value) {
  12322. if (this._contentResolution === value) {
  12323. return;
  12324. }
  12325. this._contentResolution = value;
  12326. this._resetContent();
  12327. },
  12328. enumerable: true,
  12329. configurable: true
  12330. });
  12331. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12332. /**
  12333. * Gets or sets the texture scale ratio used to render content (2 by default)
  12334. */
  12335. get: function () {
  12336. return this._contentScaleRatio;
  12337. },
  12338. set: function (value) {
  12339. if (this._contentScaleRatio === value) {
  12340. return;
  12341. }
  12342. this._contentScaleRatio = value;
  12343. this._resetContent();
  12344. },
  12345. enumerable: true,
  12346. configurable: true
  12347. });
  12348. Button3D.prototype._disposeFacadeTexture = function () {
  12349. if (this._facadeTexture) {
  12350. this._facadeTexture.dispose();
  12351. this._facadeTexture = null;
  12352. }
  12353. };
  12354. Button3D.prototype._resetContent = function () {
  12355. this._disposeFacadeTexture();
  12356. this.content = this._content;
  12357. };
  12358. Object.defineProperty(Button3D.prototype, "content", {
  12359. /**
  12360. * Gets or sets the GUI 2D content used to display the button's facade
  12361. */
  12362. get: function () {
  12363. return this._content;
  12364. },
  12365. set: function (value) {
  12366. this._content = value;
  12367. if (!this._host || !this._host.utilityLayer) {
  12368. return;
  12369. }
  12370. if (!this._facadeTexture) {
  12371. 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);
  12372. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12373. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12374. this._facadeTexture.premulAlpha = true;
  12375. }
  12376. this._facadeTexture.addControl(value);
  12377. this._applyFacade(this._facadeTexture);
  12378. },
  12379. enumerable: true,
  12380. configurable: true
  12381. });
  12382. /**
  12383. * Apply the facade texture (created from the content property).
  12384. * This function can be overloaded by child classes
  12385. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12386. */
  12387. Button3D.prototype._applyFacade = function (facadeTexture) {
  12388. this._currentMaterial.emissiveTexture = facadeTexture;
  12389. };
  12390. Button3D.prototype._getTypeName = function () {
  12391. return "Button3D";
  12392. };
  12393. // Mesh association
  12394. Button3D.prototype._createNode = function (scene) {
  12395. var faceUV = new Array(6);
  12396. for (var i = 0; i < 6; i++) {
  12397. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12398. }
  12399. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12400. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateBox(this.name + "_rootMesh", {
  12401. width: 1.0,
  12402. height: 1.0,
  12403. depth: 0.08,
  12404. faceUV: faceUV
  12405. }, scene);
  12406. return mesh;
  12407. };
  12408. Button3D.prototype._affectMaterial = function (mesh) {
  12409. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12410. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12411. mesh.material = material;
  12412. this._currentMaterial = material;
  12413. this._resetContent();
  12414. };
  12415. /**
  12416. * Releases all associated resources
  12417. */
  12418. Button3D.prototype.dispose = function () {
  12419. _super.prototype.dispose.call(this);
  12420. this._disposeFacadeTexture();
  12421. if (this._currentMaterial) {
  12422. this._currentMaterial.dispose();
  12423. }
  12424. };
  12425. return Button3D;
  12426. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12427. /***/ }),
  12428. /***/ "./3D/controls/container3D.ts":
  12429. /*!************************************!*\
  12430. !*** ./3D/controls/container3D.ts ***!
  12431. \************************************/
  12432. /*! exports provided: Container3D */
  12433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12434. "use strict";
  12435. __webpack_require__.r(__webpack_exports__);
  12436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12437. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12438. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12439. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12440. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12441. /**
  12442. * Class used to create containers for controls
  12443. */
  12444. var Container3D = /** @class */ (function (_super) {
  12445. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12446. /**
  12447. * Creates a new container
  12448. * @param name defines the container name
  12449. */
  12450. function Container3D(name) {
  12451. var _this = _super.call(this, name) || this;
  12452. _this._blockLayout = false;
  12453. /**
  12454. * Gets the list of child controls
  12455. */
  12456. _this._children = new Array();
  12457. return _this;
  12458. }
  12459. Object.defineProperty(Container3D.prototype, "children", {
  12460. /**
  12461. * Gets the list of child controls
  12462. */
  12463. get: function () {
  12464. return this._children;
  12465. },
  12466. enumerable: true,
  12467. configurable: true
  12468. });
  12469. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12470. /**
  12471. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12472. * This is helpful to optimize layout operation when adding multiple children in a row
  12473. */
  12474. get: function () {
  12475. return this._blockLayout;
  12476. },
  12477. set: function (value) {
  12478. if (this._blockLayout === value) {
  12479. return;
  12480. }
  12481. this._blockLayout = value;
  12482. if (!this._blockLayout) {
  12483. this._arrangeChildren();
  12484. }
  12485. },
  12486. enumerable: true,
  12487. configurable: true
  12488. });
  12489. /**
  12490. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12491. * @returns the current container
  12492. */
  12493. Container3D.prototype.updateLayout = function () {
  12494. this._arrangeChildren();
  12495. return this;
  12496. };
  12497. /**
  12498. * Gets a boolean indicating if the given control is in the children of this control
  12499. * @param control defines the control to check
  12500. * @returns true if the control is in the child list
  12501. */
  12502. Container3D.prototype.containsControl = function (control) {
  12503. return this._children.indexOf(control) !== -1;
  12504. };
  12505. /**
  12506. * Adds a control to the children of this control
  12507. * @param control defines the control to add
  12508. * @returns the current container
  12509. */
  12510. Container3D.prototype.addControl = function (control) {
  12511. var index = this._children.indexOf(control);
  12512. if (index !== -1) {
  12513. return this;
  12514. }
  12515. control.parent = this;
  12516. control._host = this._host;
  12517. this._children.push(control);
  12518. if (this._host.utilityLayer) {
  12519. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12520. if (control.node) {
  12521. control.node.parent = this.node;
  12522. }
  12523. if (!this.blockLayout) {
  12524. this._arrangeChildren();
  12525. }
  12526. }
  12527. return this;
  12528. };
  12529. /**
  12530. * This function will be called everytime a new control is added
  12531. */
  12532. Container3D.prototype._arrangeChildren = function () {
  12533. };
  12534. Container3D.prototype._createNode = function (scene) {
  12535. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12536. };
  12537. /**
  12538. * Removes a control from the children of this control
  12539. * @param control defines the control to remove
  12540. * @returns the current container
  12541. */
  12542. Container3D.prototype.removeControl = function (control) {
  12543. var index = this._children.indexOf(control);
  12544. if (index !== -1) {
  12545. this._children.splice(index, 1);
  12546. control.parent = null;
  12547. control._disposeNode();
  12548. }
  12549. return this;
  12550. };
  12551. Container3D.prototype._getTypeName = function () {
  12552. return "Container3D";
  12553. };
  12554. /**
  12555. * Releases all associated resources
  12556. */
  12557. Container3D.prototype.dispose = function () {
  12558. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12559. var control = _a[_i];
  12560. control.dispose();
  12561. }
  12562. this._children = [];
  12563. _super.prototype.dispose.call(this);
  12564. };
  12565. /** Control rotation will remain unchanged */
  12566. Container3D.UNSET_ORIENTATION = 0;
  12567. /** Control will rotate to make it look at sphere central axis */
  12568. Container3D.FACEORIGIN_ORIENTATION = 1;
  12569. /** Control will rotate to make it look back at sphere central axis */
  12570. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12571. /** Control will rotate to look at z axis (0, 0, 1) */
  12572. Container3D.FACEFORWARD_ORIENTATION = 3;
  12573. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12574. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12575. return Container3D;
  12576. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12577. /***/ }),
  12578. /***/ "./3D/controls/control3D.ts":
  12579. /*!**********************************!*\
  12580. !*** ./3D/controls/control3D.ts ***!
  12581. \**********************************/
  12582. /*! exports provided: Control3D */
  12583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12584. "use strict";
  12585. __webpack_require__.r(__webpack_exports__);
  12586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12587. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12588. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12589. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12590. /**
  12591. * Class used as base class for controls
  12592. */
  12593. var Control3D = /** @class */ (function () {
  12594. /**
  12595. * Creates a new control
  12596. * @param name defines the control name
  12597. */
  12598. function Control3D(
  12599. /** Defines the control name */
  12600. name) {
  12601. this.name = name;
  12602. this._downCount = 0;
  12603. this._enterCount = -1;
  12604. this._downPointerIds = {};
  12605. this._isVisible = true;
  12606. /**
  12607. * An event triggered when the pointer move over the control
  12608. */
  12609. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12610. /**
  12611. * An event triggered when the pointer move out of the control
  12612. */
  12613. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12614. /**
  12615. * An event triggered when the pointer taps the control
  12616. */
  12617. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12618. /**
  12619. * An event triggered when pointer is up
  12620. */
  12621. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12622. /**
  12623. * An event triggered when a control is clicked on (with a mouse)
  12624. */
  12625. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12626. /**
  12627. * An event triggered when pointer enters the control
  12628. */
  12629. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12630. // Behaviors
  12631. this._behaviors = new Array();
  12632. }
  12633. Object.defineProperty(Control3D.prototype, "position", {
  12634. /** Gets or sets the control position in world space */
  12635. get: function () {
  12636. if (!this._node) {
  12637. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12638. }
  12639. return this._node.position;
  12640. },
  12641. set: function (value) {
  12642. if (!this._node) {
  12643. return;
  12644. }
  12645. this._node.position = value;
  12646. },
  12647. enumerable: true,
  12648. configurable: true
  12649. });
  12650. Object.defineProperty(Control3D.prototype, "scaling", {
  12651. /** Gets or sets the control scaling in world space */
  12652. get: function () {
  12653. if (!this._node) {
  12654. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12655. }
  12656. return this._node.scaling;
  12657. },
  12658. set: function (value) {
  12659. if (!this._node) {
  12660. return;
  12661. }
  12662. this._node.scaling = value;
  12663. },
  12664. enumerable: true,
  12665. configurable: true
  12666. });
  12667. Object.defineProperty(Control3D.prototype, "behaviors", {
  12668. /**
  12669. * Gets the list of attached behaviors
  12670. * @see http://doc.babylonjs.com/features/behaviour
  12671. */
  12672. get: function () {
  12673. return this._behaviors;
  12674. },
  12675. enumerable: true,
  12676. configurable: true
  12677. });
  12678. /**
  12679. * Attach a behavior to the control
  12680. * @see http://doc.babylonjs.com/features/behaviour
  12681. * @param behavior defines the behavior to attach
  12682. * @returns the current control
  12683. */
  12684. Control3D.prototype.addBehavior = function (behavior) {
  12685. var _this = this;
  12686. var index = this._behaviors.indexOf(behavior);
  12687. if (index !== -1) {
  12688. return this;
  12689. }
  12690. behavior.init();
  12691. var scene = this._host.scene;
  12692. if (scene.isLoading) {
  12693. // We defer the attach when the scene will be loaded
  12694. scene.onDataLoadedObservable.addOnce(function () {
  12695. behavior.attach(_this);
  12696. });
  12697. }
  12698. else {
  12699. behavior.attach(this);
  12700. }
  12701. this._behaviors.push(behavior);
  12702. return this;
  12703. };
  12704. /**
  12705. * Remove an attached behavior
  12706. * @see http://doc.babylonjs.com/features/behaviour
  12707. * @param behavior defines the behavior to attach
  12708. * @returns the current control
  12709. */
  12710. Control3D.prototype.removeBehavior = function (behavior) {
  12711. var index = this._behaviors.indexOf(behavior);
  12712. if (index === -1) {
  12713. return this;
  12714. }
  12715. this._behaviors[index].detach();
  12716. this._behaviors.splice(index, 1);
  12717. return this;
  12718. };
  12719. /**
  12720. * Gets an attached behavior by name
  12721. * @param name defines the name of the behavior to look for
  12722. * @see http://doc.babylonjs.com/features/behaviour
  12723. * @returns null if behavior was not found else the requested behavior
  12724. */
  12725. Control3D.prototype.getBehaviorByName = function (name) {
  12726. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12727. var behavior = _a[_i];
  12728. if (behavior.name === name) {
  12729. return behavior;
  12730. }
  12731. }
  12732. return null;
  12733. };
  12734. Object.defineProperty(Control3D.prototype, "isVisible", {
  12735. /** Gets or sets a boolean indicating if the control is visible */
  12736. get: function () {
  12737. return this._isVisible;
  12738. },
  12739. set: function (value) {
  12740. if (this._isVisible === value) {
  12741. return;
  12742. }
  12743. this._isVisible = value;
  12744. var mesh = this.mesh;
  12745. if (mesh) {
  12746. mesh.setEnabled(value);
  12747. }
  12748. },
  12749. enumerable: true,
  12750. configurable: true
  12751. });
  12752. Object.defineProperty(Control3D.prototype, "typeName", {
  12753. /**
  12754. * Gets a string representing the class name
  12755. */
  12756. get: function () {
  12757. return this._getTypeName();
  12758. },
  12759. enumerable: true,
  12760. configurable: true
  12761. });
  12762. /**
  12763. * Get the current class name of the control.
  12764. * @returns current class name
  12765. */
  12766. Control3D.prototype.getClassName = function () {
  12767. return this._getTypeName();
  12768. };
  12769. Control3D.prototype._getTypeName = function () {
  12770. return "Control3D";
  12771. };
  12772. Object.defineProperty(Control3D.prototype, "node", {
  12773. /**
  12774. * Gets the transform node used by this control
  12775. */
  12776. get: function () {
  12777. return this._node;
  12778. },
  12779. enumerable: true,
  12780. configurable: true
  12781. });
  12782. Object.defineProperty(Control3D.prototype, "mesh", {
  12783. /**
  12784. * Gets the mesh used to render this control
  12785. */
  12786. get: function () {
  12787. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12788. return this._node;
  12789. }
  12790. return null;
  12791. },
  12792. enumerable: true,
  12793. configurable: true
  12794. });
  12795. /**
  12796. * Link the control as child of the given node
  12797. * @param node defines the node to link to. Use null to unlink the control
  12798. * @returns the current control
  12799. */
  12800. Control3D.prototype.linkToTransformNode = function (node) {
  12801. if (this._node) {
  12802. this._node.parent = node;
  12803. }
  12804. return this;
  12805. };
  12806. /** @hidden **/
  12807. Control3D.prototype._prepareNode = function (scene) {
  12808. if (!this._node) {
  12809. this._node = this._createNode(scene);
  12810. if (!this.node) {
  12811. return;
  12812. }
  12813. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12814. this._node.position = this.position;
  12815. this._node.scaling = this.scaling;
  12816. var mesh = this.mesh;
  12817. if (mesh) {
  12818. mesh.isPickable = true;
  12819. this._affectMaterial(mesh);
  12820. }
  12821. }
  12822. };
  12823. /**
  12824. * Node creation.
  12825. * Can be overriden by children
  12826. * @param scene defines the scene where the node must be attached
  12827. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12828. */
  12829. Control3D.prototype._createNode = function (scene) {
  12830. // Do nothing by default
  12831. return null;
  12832. };
  12833. /**
  12834. * Affect a material to the given mesh
  12835. * @param mesh defines the mesh which will represent the control
  12836. */
  12837. Control3D.prototype._affectMaterial = function (mesh) {
  12838. mesh.material = null;
  12839. };
  12840. // Pointers
  12841. /** @hidden */
  12842. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12843. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12844. };
  12845. /** @hidden */
  12846. Control3D.prototype._onPointerEnter = function (target) {
  12847. if (this._enterCount > 0) {
  12848. return false;
  12849. }
  12850. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12851. this._enterCount = 0;
  12852. }
  12853. this._enterCount++;
  12854. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12855. if (this.pointerEnterAnimation) {
  12856. this.pointerEnterAnimation();
  12857. }
  12858. return true;
  12859. };
  12860. /** @hidden */
  12861. Control3D.prototype._onPointerOut = function (target) {
  12862. this._enterCount = 0;
  12863. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12864. if (this.pointerOutAnimation) {
  12865. this.pointerOutAnimation();
  12866. }
  12867. };
  12868. /** @hidden */
  12869. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12870. if (this._downCount !== 0) {
  12871. return false;
  12872. }
  12873. this._downCount++;
  12874. this._downPointerIds[pointerId] = true;
  12875. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12876. if (this.pointerDownAnimation) {
  12877. this.pointerDownAnimation();
  12878. }
  12879. return true;
  12880. };
  12881. /** @hidden */
  12882. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12883. this._downCount = 0;
  12884. delete this._downPointerIds[pointerId];
  12885. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12886. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12887. }
  12888. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12889. if (this.pointerUpAnimation) {
  12890. this.pointerUpAnimation();
  12891. }
  12892. };
  12893. /** @hidden */
  12894. Control3D.prototype.forcePointerUp = function (pointerId) {
  12895. if (pointerId === void 0) { pointerId = null; }
  12896. if (pointerId !== null) {
  12897. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12898. }
  12899. else {
  12900. for (var key in this._downPointerIds) {
  12901. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12902. }
  12903. }
  12904. };
  12905. /** @hidden */
  12906. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  12907. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  12908. this._onPointerMove(this, pickedPoint);
  12909. var previousControlOver = this._host._lastControlOver[pointerId];
  12910. if (previousControlOver && previousControlOver !== this) {
  12911. previousControlOver._onPointerOut(this);
  12912. }
  12913. if (previousControlOver !== this) {
  12914. this._onPointerEnter(this);
  12915. }
  12916. this._host._lastControlOver[pointerId] = this;
  12917. return true;
  12918. }
  12919. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  12920. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  12921. this._host._lastControlDown[pointerId] = this;
  12922. this._host._lastPickedControl = this;
  12923. return true;
  12924. }
  12925. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  12926. if (this._host._lastControlDown[pointerId]) {
  12927. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  12928. }
  12929. delete this._host._lastControlDown[pointerId];
  12930. return true;
  12931. }
  12932. return false;
  12933. };
  12934. /** @hidden */
  12935. Control3D.prototype._disposeNode = function () {
  12936. if (this._node) {
  12937. this._node.dispose();
  12938. this._node = null;
  12939. }
  12940. };
  12941. /**
  12942. * Releases all associated resources
  12943. */
  12944. Control3D.prototype.dispose = function () {
  12945. this.onPointerDownObservable.clear();
  12946. this.onPointerEnterObservable.clear();
  12947. this.onPointerMoveObservable.clear();
  12948. this.onPointerOutObservable.clear();
  12949. this.onPointerUpObservable.clear();
  12950. this.onPointerClickObservable.clear();
  12951. this._disposeNode();
  12952. // Behaviors
  12953. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12954. var behavior = _a[_i];
  12955. behavior.detach();
  12956. }
  12957. };
  12958. return Control3D;
  12959. }());
  12960. /***/ }),
  12961. /***/ "./3D/controls/cylinderPanel.ts":
  12962. /*!**************************************!*\
  12963. !*** ./3D/controls/cylinderPanel.ts ***!
  12964. \**************************************/
  12965. /*! exports provided: CylinderPanel */
  12966. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12967. "use strict";
  12968. __webpack_require__.r(__webpack_exports__);
  12969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  12970. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12971. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  12972. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12973. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  12974. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  12975. /**
  12976. * Class used to create a container panel deployed on the surface of a cylinder
  12977. */
  12978. var CylinderPanel = /** @class */ (function (_super) {
  12979. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  12980. function CylinderPanel() {
  12981. var _this = _super !== null && _super.apply(this, arguments) || this;
  12982. _this._radius = 5.0;
  12983. return _this;
  12984. }
  12985. Object.defineProperty(CylinderPanel.prototype, "radius", {
  12986. /**
  12987. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  12988. */
  12989. get: function () {
  12990. return this._radius;
  12991. },
  12992. set: function (value) {
  12993. var _this = this;
  12994. if (this._radius === value) {
  12995. return;
  12996. }
  12997. this._radius = value;
  12998. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  12999. _this._arrangeChildren();
  13000. });
  13001. },
  13002. enumerable: true,
  13003. configurable: true
  13004. });
  13005. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13006. var mesh = control.mesh;
  13007. if (!mesh) {
  13008. return;
  13009. }
  13010. var newPos = this._cylindricalMapping(nodePosition);
  13011. control.position = newPos;
  13012. switch (this.orientation) {
  13013. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13014. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13015. break;
  13016. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13017. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13018. break;
  13019. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13020. break;
  13021. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13022. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13023. break;
  13024. }
  13025. };
  13026. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13027. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13028. var yAngle = (source.x / this._radius);
  13029. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13030. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13031. };
  13032. return CylinderPanel;
  13033. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13034. /***/ }),
  13035. /***/ "./3D/controls/holographicButton.ts":
  13036. /*!******************************************!*\
  13037. !*** ./3D/controls/holographicButton.ts ***!
  13038. \******************************************/
  13039. /*! exports provided: HolographicButton */
  13040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13041. "use strict";
  13042. __webpack_require__.r(__webpack_exports__);
  13043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13044. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13045. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13046. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13047. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13048. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13049. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13050. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13051. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13052. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13053. /**
  13054. * Class used to create a holographic button in 3D
  13055. */
  13056. var HolographicButton = /** @class */ (function (_super) {
  13057. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13058. /**
  13059. * Creates a new button
  13060. * @param name defines the control name
  13061. */
  13062. function HolographicButton(name, shareMaterials) {
  13063. if (shareMaterials === void 0) { shareMaterials = true; }
  13064. var _this = _super.call(this, name) || this;
  13065. _this._shareMaterials = true;
  13066. _this._shareMaterials = shareMaterials;
  13067. // Default animations
  13068. _this.pointerEnterAnimation = function () {
  13069. if (!_this.mesh) {
  13070. return;
  13071. }
  13072. _this._frontPlate.setEnabled(true);
  13073. };
  13074. _this.pointerOutAnimation = function () {
  13075. if (!_this.mesh) {
  13076. return;
  13077. }
  13078. _this._frontPlate.setEnabled(false);
  13079. };
  13080. return _this;
  13081. }
  13082. HolographicButton.prototype._disposeTooltip = function () {
  13083. this._tooltipFade = null;
  13084. if (this._tooltipTextBlock) {
  13085. this._tooltipTextBlock.dispose();
  13086. }
  13087. if (this._tooltipTexture) {
  13088. this._tooltipTexture.dispose();
  13089. }
  13090. if (this._tooltipMesh) {
  13091. this._tooltipMesh.dispose();
  13092. }
  13093. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13094. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13095. };
  13096. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13097. get: function () {
  13098. if (this._tooltipTextBlock) {
  13099. return this._tooltipTextBlock.text;
  13100. }
  13101. return null;
  13102. },
  13103. /**
  13104. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13105. */
  13106. set: function (text) {
  13107. var _this = this;
  13108. if (!text) {
  13109. this._disposeTooltip();
  13110. return;
  13111. }
  13112. if (!this._tooltipFade) {
  13113. // Create tooltip with mesh and text
  13114. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13115. var tooltipBackground = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  13116. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13117. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13118. tooltipBackground.material = mat;
  13119. tooltipBackground.isPickable = false;
  13120. this._tooltipMesh.addChild(tooltipBackground);
  13121. tooltipBackground.position.z = 0.05;
  13122. this._tooltipMesh.scaling.y = 1 / 3;
  13123. this._tooltipMesh.position.y = 0.7;
  13124. this._tooltipMesh.position.z = -0.15;
  13125. this._tooltipMesh.isPickable = false;
  13126. this._tooltipMesh.parent = this._backPlate;
  13127. // Create text texture for the tooltip
  13128. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13129. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13130. this._tooltipTextBlock.scaleY = 3;
  13131. this._tooltipTextBlock.color = "white";
  13132. this._tooltipTextBlock.fontSize = 130;
  13133. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13134. // Add hover action to tooltip
  13135. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13136. this._tooltipFade.delay = 500;
  13137. this._tooltipMesh.addBehavior(this._tooltipFade);
  13138. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13139. if (_this._tooltipFade) {
  13140. _this._tooltipFade.fadeIn(true);
  13141. }
  13142. });
  13143. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13144. if (_this._tooltipFade) {
  13145. _this._tooltipFade.fadeIn(false);
  13146. }
  13147. });
  13148. }
  13149. if (this._tooltipTextBlock) {
  13150. this._tooltipTextBlock.text = text;
  13151. }
  13152. },
  13153. enumerable: true,
  13154. configurable: true
  13155. });
  13156. Object.defineProperty(HolographicButton.prototype, "text", {
  13157. /**
  13158. * Gets or sets text for the button
  13159. */
  13160. get: function () {
  13161. return this._text;
  13162. },
  13163. set: function (value) {
  13164. if (this._text === value) {
  13165. return;
  13166. }
  13167. this._text = value;
  13168. this._rebuildContent();
  13169. },
  13170. enumerable: true,
  13171. configurable: true
  13172. });
  13173. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13174. /**
  13175. * Gets or sets the image url for the button
  13176. */
  13177. get: function () {
  13178. return this._imageUrl;
  13179. },
  13180. set: function (value) {
  13181. if (this._imageUrl === value) {
  13182. return;
  13183. }
  13184. this._imageUrl = value;
  13185. this._rebuildContent();
  13186. },
  13187. enumerable: true,
  13188. configurable: true
  13189. });
  13190. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13191. /**
  13192. * Gets the back material used by this button
  13193. */
  13194. get: function () {
  13195. return this._backMaterial;
  13196. },
  13197. enumerable: true,
  13198. configurable: true
  13199. });
  13200. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13201. /**
  13202. * Gets the front material used by this button
  13203. */
  13204. get: function () {
  13205. return this._frontMaterial;
  13206. },
  13207. enumerable: true,
  13208. configurable: true
  13209. });
  13210. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13211. /**
  13212. * Gets the plate material used by this button
  13213. */
  13214. get: function () {
  13215. return this._plateMaterial;
  13216. },
  13217. enumerable: true,
  13218. configurable: true
  13219. });
  13220. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13221. /**
  13222. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13223. */
  13224. get: function () {
  13225. return this._shareMaterials;
  13226. },
  13227. enumerable: true,
  13228. configurable: true
  13229. });
  13230. HolographicButton.prototype._getTypeName = function () {
  13231. return "HolographicButton";
  13232. };
  13233. HolographicButton.prototype._rebuildContent = function () {
  13234. this._disposeFacadeTexture();
  13235. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13236. panel.isVertical = true;
  13237. if (this._imageUrl) {
  13238. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13239. image.source = this._imageUrl;
  13240. image.paddingTop = "40px";
  13241. image.height = "180px";
  13242. image.width = "100px";
  13243. image.paddingBottom = "40px";
  13244. panel.addControl(image);
  13245. }
  13246. if (this._text) {
  13247. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13248. text.text = this._text;
  13249. text.color = "white";
  13250. text.height = "30px";
  13251. text.fontSize = 24;
  13252. panel.addControl(text);
  13253. }
  13254. if (this._frontPlate) {
  13255. this.content = panel;
  13256. }
  13257. };
  13258. // Mesh association
  13259. HolographicButton.prototype._createNode = function (scene) {
  13260. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateBox(this.name + "BackMesh", {
  13261. width: 1.0,
  13262. height: 1.0,
  13263. depth: 0.08
  13264. }, scene);
  13265. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateBox(this.name + "FrontMesh", {
  13266. width: 1.0,
  13267. height: 1.0,
  13268. depth: 0.08
  13269. }, scene);
  13270. this._frontPlate.parent = this._backPlate;
  13271. this._frontPlate.position.z = -0.08;
  13272. this._frontPlate.isPickable = false;
  13273. this._frontPlate.setEnabled(false);
  13274. this._textPlate = _super.prototype._createNode.call(this, scene);
  13275. this._textPlate.parent = this._backPlate;
  13276. this._textPlate.position.z = -0.08;
  13277. this._textPlate.isPickable = false;
  13278. return this._backPlate;
  13279. };
  13280. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13281. this._plateMaterial.emissiveTexture = facadeTexture;
  13282. this._plateMaterial.opacityTexture = facadeTexture;
  13283. };
  13284. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13285. var _this = this;
  13286. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13287. this._backMaterial.renderHoverLight = true;
  13288. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13289. if (pickedPoint) {
  13290. _this._backMaterial.hoverPosition = pickedPoint;
  13291. _this._backMaterial.hoverColor.a = 1.0;
  13292. }
  13293. else {
  13294. _this._backMaterial.hoverColor.a = 0;
  13295. }
  13296. });
  13297. };
  13298. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13299. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13300. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13301. this._frontMaterial.alpha = 0.5; // Additive
  13302. this._frontMaterial.renderBorders = true;
  13303. };
  13304. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13305. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13306. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13307. };
  13308. HolographicButton.prototype._affectMaterial = function (mesh) {
  13309. // Back
  13310. if (this._shareMaterials) {
  13311. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13312. this._createBackMaterial(mesh);
  13313. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13314. }
  13315. else {
  13316. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13317. }
  13318. // Front
  13319. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13320. this._createFrontMaterial(mesh);
  13321. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13322. }
  13323. else {
  13324. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13325. }
  13326. }
  13327. else {
  13328. this._createBackMaterial(mesh);
  13329. this._createFrontMaterial(mesh);
  13330. }
  13331. this._createPlateMaterial(mesh);
  13332. this._backPlate.material = this._backMaterial;
  13333. this._frontPlate.material = this._frontMaterial;
  13334. this._textPlate.material = this._plateMaterial;
  13335. this._rebuildContent();
  13336. };
  13337. /**
  13338. * Releases all associated resources
  13339. */
  13340. HolographicButton.prototype.dispose = function () {
  13341. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13342. this._disposeTooltip();
  13343. if (!this.shareMaterials) {
  13344. this._backMaterial.dispose();
  13345. this._frontMaterial.dispose();
  13346. this._plateMaterial.dispose();
  13347. if (this._pickedPointObserver) {
  13348. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13349. this._pickedPointObserver = null;
  13350. }
  13351. }
  13352. };
  13353. return HolographicButton;
  13354. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13355. /***/ }),
  13356. /***/ "./3D/controls/index.ts":
  13357. /*!******************************!*\
  13358. !*** ./3D/controls/index.ts ***!
  13359. \******************************/
  13360. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13361. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13362. "use strict";
  13363. __webpack_require__.r(__webpack_exports__);
  13364. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13366. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13368. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13370. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13372. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13374. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13376. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13378. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13380. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13382. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13384. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13386. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13388. /***/ }),
  13389. /***/ "./3D/controls/meshButton3D.ts":
  13390. /*!*************************************!*\
  13391. !*** ./3D/controls/meshButton3D.ts ***!
  13392. \*************************************/
  13393. /*! exports provided: MeshButton3D */
  13394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13395. "use strict";
  13396. __webpack_require__.r(__webpack_exports__);
  13397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13398. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13399. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13400. /**
  13401. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13402. */
  13403. var MeshButton3D = /** @class */ (function (_super) {
  13404. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13405. /**
  13406. * Creates a new 3D button based on a mesh
  13407. * @param mesh mesh to become a 3D button
  13408. * @param name defines the control name
  13409. */
  13410. function MeshButton3D(mesh, name) {
  13411. var _this = _super.call(this, name) || this;
  13412. _this._currentMesh = mesh;
  13413. /**
  13414. * Provides a default behavior on hover/out & up/down
  13415. * Override those function to create your own desired behavior specific to your mesh
  13416. */
  13417. _this.pointerEnterAnimation = function () {
  13418. if (!_this.mesh) {
  13419. return;
  13420. }
  13421. _this.mesh.scaling.scaleInPlace(1.1);
  13422. };
  13423. _this.pointerOutAnimation = function () {
  13424. if (!_this.mesh) {
  13425. return;
  13426. }
  13427. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13428. };
  13429. _this.pointerDownAnimation = function () {
  13430. if (!_this.mesh) {
  13431. return;
  13432. }
  13433. _this.mesh.scaling.scaleInPlace(0.95);
  13434. };
  13435. _this.pointerUpAnimation = function () {
  13436. if (!_this.mesh) {
  13437. return;
  13438. }
  13439. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13440. };
  13441. return _this;
  13442. }
  13443. MeshButton3D.prototype._getTypeName = function () {
  13444. return "MeshButton3D";
  13445. };
  13446. // Mesh association
  13447. MeshButton3D.prototype._createNode = function (scene) {
  13448. var _this = this;
  13449. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13450. mesh.metadata = _this;
  13451. });
  13452. return this._currentMesh;
  13453. };
  13454. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13455. };
  13456. return MeshButton3D;
  13457. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13458. /***/ }),
  13459. /***/ "./3D/controls/planePanel.ts":
  13460. /*!***********************************!*\
  13461. !*** ./3D/controls/planePanel.ts ***!
  13462. \***********************************/
  13463. /*! exports provided: PlanePanel */
  13464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13465. "use strict";
  13466. __webpack_require__.r(__webpack_exports__);
  13467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13469. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13470. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13471. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13472. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13473. /**
  13474. * Class used to create a container panel deployed on the surface of a plane
  13475. */
  13476. var PlanePanel = /** @class */ (function (_super) {
  13477. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13478. function PlanePanel() {
  13479. return _super !== null && _super.apply(this, arguments) || this;
  13480. }
  13481. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13482. var mesh = control.mesh;
  13483. if (!mesh) {
  13484. return;
  13485. }
  13486. control.position = nodePosition.clone();
  13487. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13488. target.copyFrom(nodePosition);
  13489. switch (this.orientation) {
  13490. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13491. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13492. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13493. mesh.lookAt(target);
  13494. break;
  13495. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13496. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13497. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13498. mesh.lookAt(target);
  13499. break;
  13500. }
  13501. };
  13502. return PlanePanel;
  13503. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13504. /***/ }),
  13505. /***/ "./3D/controls/scatterPanel.ts":
  13506. /*!*************************************!*\
  13507. !*** ./3D/controls/scatterPanel.ts ***!
  13508. \*************************************/
  13509. /*! exports provided: ScatterPanel */
  13510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13511. "use strict";
  13512. __webpack_require__.r(__webpack_exports__);
  13513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13514. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13515. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13516. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13517. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13518. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13519. /**
  13520. * Class used to create a container panel where items get randomized planar mapping
  13521. */
  13522. var ScatterPanel = /** @class */ (function (_super) {
  13523. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13524. function ScatterPanel() {
  13525. var _this = _super !== null && _super.apply(this, arguments) || this;
  13526. _this._iteration = 100.0;
  13527. return _this;
  13528. }
  13529. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13530. /**
  13531. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13532. */
  13533. get: function () {
  13534. return this._iteration;
  13535. },
  13536. set: function (value) {
  13537. var _this = this;
  13538. if (this._iteration === value) {
  13539. return;
  13540. }
  13541. this._iteration = value;
  13542. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13543. _this._arrangeChildren();
  13544. });
  13545. },
  13546. enumerable: true,
  13547. configurable: true
  13548. });
  13549. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13550. var mesh = control.mesh;
  13551. var newPos = this._scatterMapping(nodePosition);
  13552. if (!mesh) {
  13553. return;
  13554. }
  13555. switch (this.orientation) {
  13556. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13557. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13558. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13559. break;
  13560. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13561. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13562. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13563. break;
  13564. }
  13565. control.position = newPos;
  13566. };
  13567. ScatterPanel.prototype._scatterMapping = function (source) {
  13568. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13569. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13570. return source;
  13571. };
  13572. ScatterPanel.prototype._finalProcessing = function () {
  13573. var meshes = [];
  13574. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13575. var child = _a[_i];
  13576. if (!child.mesh) {
  13577. continue;
  13578. }
  13579. meshes.push(child.mesh);
  13580. }
  13581. for (var count = 0; count < this._iteration; count++) {
  13582. meshes.sort(function (a, b) {
  13583. var distance1 = a.position.lengthSquared();
  13584. var distance2 = b.position.lengthSquared();
  13585. if (distance1 < distance2) {
  13586. return 1;
  13587. }
  13588. else if (distance1 > distance2) {
  13589. return -1;
  13590. }
  13591. return 0;
  13592. });
  13593. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13594. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13595. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13596. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13597. for (var i = 0; i < meshes.length - 1; i++) {
  13598. for (var j = i + 1; j < meshes.length; j++) {
  13599. if (i != j) {
  13600. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13601. // Ignore Z axis
  13602. difference2D.x = difference.x;
  13603. difference2D.y = difference.y;
  13604. var combinedRadius = cellSize;
  13605. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13606. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13607. distance -= minSeparation;
  13608. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13609. difference2D.normalize();
  13610. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13611. meshes[j].position.addInPlace(difference);
  13612. meshes[i].position.subtractInPlace(difference);
  13613. }
  13614. }
  13615. }
  13616. }
  13617. }
  13618. };
  13619. return ScatterPanel;
  13620. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13621. /***/ }),
  13622. /***/ "./3D/controls/spherePanel.ts":
  13623. /*!************************************!*\
  13624. !*** ./3D/controls/spherePanel.ts ***!
  13625. \************************************/
  13626. /*! exports provided: SpherePanel */
  13627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13628. "use strict";
  13629. __webpack_require__.r(__webpack_exports__);
  13630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13631. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13632. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13633. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13634. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13635. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13636. /**
  13637. * Class used to create a container panel deployed on the surface of a sphere
  13638. */
  13639. var SpherePanel = /** @class */ (function (_super) {
  13640. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13641. function SpherePanel() {
  13642. var _this = _super !== null && _super.apply(this, arguments) || this;
  13643. _this._radius = 5.0;
  13644. return _this;
  13645. }
  13646. Object.defineProperty(SpherePanel.prototype, "radius", {
  13647. /**
  13648. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13649. */
  13650. get: function () {
  13651. return this._radius;
  13652. },
  13653. set: function (value) {
  13654. var _this = this;
  13655. if (this._radius === value) {
  13656. return;
  13657. }
  13658. this._radius = value;
  13659. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13660. _this._arrangeChildren();
  13661. });
  13662. },
  13663. enumerable: true,
  13664. configurable: true
  13665. });
  13666. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13667. var mesh = control.mesh;
  13668. if (!mesh) {
  13669. return;
  13670. }
  13671. var newPos = this._sphericalMapping(nodePosition);
  13672. control.position = newPos;
  13673. switch (this.orientation) {
  13674. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13675. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13676. break;
  13677. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13678. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13679. break;
  13680. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13681. break;
  13682. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13683. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13684. break;
  13685. }
  13686. };
  13687. SpherePanel.prototype._sphericalMapping = function (source) {
  13688. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13689. var xAngle = (source.y / this._radius);
  13690. var yAngle = -(source.x / this._radius);
  13691. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13692. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13693. };
  13694. return SpherePanel;
  13695. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13696. /***/ }),
  13697. /***/ "./3D/controls/stackPanel3D.ts":
  13698. /*!*************************************!*\
  13699. !*** ./3D/controls/stackPanel3D.ts ***!
  13700. \*************************************/
  13701. /*! exports provided: StackPanel3D */
  13702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13703. "use strict";
  13704. __webpack_require__.r(__webpack_exports__);
  13705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13706. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13707. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13708. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13709. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13710. /**
  13711. * Class used to create a stack panel in 3D on XY plane
  13712. */
  13713. var StackPanel3D = /** @class */ (function (_super) {
  13714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13715. /**
  13716. * Creates new StackPanel
  13717. * @param isVertical
  13718. */
  13719. function StackPanel3D(isVertical) {
  13720. if (isVertical === void 0) { isVertical = false; }
  13721. var _this = _super.call(this) || this;
  13722. _this._isVertical = false;
  13723. /**
  13724. * Gets or sets the distance between elements
  13725. */
  13726. _this.margin = 0.1;
  13727. _this._isVertical = isVertical;
  13728. return _this;
  13729. }
  13730. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13731. /**
  13732. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13733. */
  13734. get: function () {
  13735. return this._isVertical;
  13736. },
  13737. set: function (value) {
  13738. var _this = this;
  13739. if (this._isVertical === value) {
  13740. return;
  13741. }
  13742. this._isVertical = value;
  13743. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13744. _this._arrangeChildren();
  13745. });
  13746. },
  13747. enumerable: true,
  13748. configurable: true
  13749. });
  13750. StackPanel3D.prototype._arrangeChildren = function () {
  13751. var width = 0;
  13752. var height = 0;
  13753. var controlCount = 0;
  13754. var extendSizes = [];
  13755. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13756. // Measure
  13757. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13758. var child = _a[_i];
  13759. if (!child.mesh) {
  13760. continue;
  13761. }
  13762. controlCount++;
  13763. child.mesh.computeWorldMatrix(true);
  13764. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13765. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13766. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13767. extendSizes.push(extendSize);
  13768. if (this._isVertical) {
  13769. height += extendSize.y;
  13770. }
  13771. else {
  13772. width += extendSize.x;
  13773. }
  13774. }
  13775. if (this._isVertical) {
  13776. height += (controlCount - 1) * this.margin / 2;
  13777. }
  13778. else {
  13779. width += (controlCount - 1) * this.margin / 2;
  13780. }
  13781. // Arrange
  13782. var offset;
  13783. if (this._isVertical) {
  13784. offset = -height;
  13785. }
  13786. else {
  13787. offset = -width;
  13788. }
  13789. var index = 0;
  13790. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13791. var child = _c[_b];
  13792. if (!child.mesh) {
  13793. continue;
  13794. }
  13795. controlCount--;
  13796. var extendSize = extendSizes[index++];
  13797. if (this._isVertical) {
  13798. child.position.y = offset + extendSize.y;
  13799. child.position.x = 0;
  13800. offset += extendSize.y * 2;
  13801. }
  13802. else {
  13803. child.position.x = offset + extendSize.x;
  13804. child.position.y = 0;
  13805. offset += extendSize.x * 2;
  13806. }
  13807. offset += (controlCount > 0 ? this.margin : 0);
  13808. }
  13809. };
  13810. return StackPanel3D;
  13811. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13812. /***/ }),
  13813. /***/ "./3D/controls/volumeBasedPanel.ts":
  13814. /*!*****************************************!*\
  13815. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13816. \*****************************************/
  13817. /*! exports provided: VolumeBasedPanel */
  13818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13819. "use strict";
  13820. __webpack_require__.r(__webpack_exports__);
  13821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13822. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13823. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13824. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13825. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13826. /**
  13827. * Abstract class used to create a container panel deployed on the surface of a volume
  13828. */
  13829. var VolumeBasedPanel = /** @class */ (function (_super) {
  13830. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13831. /**
  13832. * Creates new VolumeBasedPanel
  13833. */
  13834. function VolumeBasedPanel() {
  13835. var _this = _super.call(this) || this;
  13836. _this._columns = 10;
  13837. _this._rows = 0;
  13838. _this._rowThenColum = true;
  13839. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13840. /**
  13841. * Gets or sets the distance between elements
  13842. */
  13843. _this.margin = 0;
  13844. return _this;
  13845. }
  13846. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13847. /**
  13848. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13849. * | Value | Type | Description |
  13850. * | ----- | ----------------------------------- | ----------- |
  13851. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13852. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13853. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13854. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13855. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13856. */
  13857. get: function () {
  13858. return this._orientation;
  13859. },
  13860. set: function (value) {
  13861. var _this = this;
  13862. if (this._orientation === value) {
  13863. return;
  13864. }
  13865. this._orientation = value;
  13866. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13867. _this._arrangeChildren();
  13868. });
  13869. },
  13870. enumerable: true,
  13871. configurable: true
  13872. });
  13873. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13874. /**
  13875. * Gets or sets the number of columns requested (10 by default).
  13876. * The panel will automatically compute the number of rows based on number of child controls.
  13877. */
  13878. get: function () {
  13879. return this._columns;
  13880. },
  13881. set: function (value) {
  13882. var _this = this;
  13883. if (this._columns === value) {
  13884. return;
  13885. }
  13886. this._columns = value;
  13887. this._rowThenColum = true;
  13888. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13889. _this._arrangeChildren();
  13890. });
  13891. },
  13892. enumerable: true,
  13893. configurable: true
  13894. });
  13895. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13896. /**
  13897. * Gets or sets a the number of rows requested.
  13898. * The panel will automatically compute the number of columns based on number of child controls.
  13899. */
  13900. get: function () {
  13901. return this._rows;
  13902. },
  13903. set: function (value) {
  13904. var _this = this;
  13905. if (this._rows === value) {
  13906. return;
  13907. }
  13908. this._rows = value;
  13909. this._rowThenColum = false;
  13910. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13911. _this._arrangeChildren();
  13912. });
  13913. },
  13914. enumerable: true,
  13915. configurable: true
  13916. });
  13917. VolumeBasedPanel.prototype._arrangeChildren = function () {
  13918. this._cellWidth = 0;
  13919. this._cellHeight = 0;
  13920. var rows = 0;
  13921. var columns = 0;
  13922. var controlCount = 0;
  13923. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13924. // Measure
  13925. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13926. var child = _a[_i];
  13927. if (!child.mesh) {
  13928. continue;
  13929. }
  13930. controlCount++;
  13931. child.mesh.computeWorldMatrix(true);
  13932. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  13933. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  13934. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13935. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  13936. boundingBox.max.subtractToRef(boundingBox.min, diff);
  13937. diff.scaleInPlace(0.5);
  13938. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  13939. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  13940. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  13941. }
  13942. this._cellWidth += this.margin * 2;
  13943. this._cellHeight += this.margin * 2;
  13944. // Arrange
  13945. if (this._rowThenColum) {
  13946. columns = this._columns;
  13947. rows = Math.ceil(controlCount / this._columns);
  13948. }
  13949. else {
  13950. rows = this._rows;
  13951. columns = Math.ceil(controlCount / this._rows);
  13952. }
  13953. var startOffsetX = (columns * 0.5) * this._cellWidth;
  13954. var startOffsetY = (rows * 0.5) * this._cellHeight;
  13955. var nodeGrid = [];
  13956. var cellCounter = 0;
  13957. if (this._rowThenColum) {
  13958. for (var r = 0; r < rows; r++) {
  13959. for (var c = 0; c < columns; c++) {
  13960. 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));
  13961. cellCounter++;
  13962. if (cellCounter > controlCount) {
  13963. break;
  13964. }
  13965. }
  13966. }
  13967. }
  13968. else {
  13969. for (var c = 0; c < columns; c++) {
  13970. for (var r = 0; r < rows; r++) {
  13971. 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));
  13972. cellCounter++;
  13973. if (cellCounter > controlCount) {
  13974. break;
  13975. }
  13976. }
  13977. }
  13978. }
  13979. cellCounter = 0;
  13980. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13981. var child = _c[_b];
  13982. if (!child.mesh) {
  13983. continue;
  13984. }
  13985. this._mapGridNode(child, nodeGrid[cellCounter]);
  13986. cellCounter++;
  13987. }
  13988. this._finalProcessing();
  13989. };
  13990. /** Child classes can implement this function to provide additional processing */
  13991. VolumeBasedPanel.prototype._finalProcessing = function () {
  13992. };
  13993. return VolumeBasedPanel;
  13994. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13995. /***/ }),
  13996. /***/ "./3D/gui3DManager.ts":
  13997. /*!****************************!*\
  13998. !*** ./3D/gui3DManager.ts ***!
  13999. \****************************/
  14000. /*! exports provided: GUI3DManager */
  14001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14002. "use strict";
  14003. __webpack_require__.r(__webpack_exports__);
  14004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14005. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  14006. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14007. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14008. /**
  14009. * Class used to manage 3D user interface
  14010. * @see http://doc.babylonjs.com/how_to/gui3d
  14011. */
  14012. var GUI3DManager = /** @class */ (function () {
  14013. /**
  14014. * Creates a new GUI3DManager
  14015. * @param scene
  14016. */
  14017. function GUI3DManager(scene) {
  14018. var _this = this;
  14019. /** @hidden */
  14020. this._lastControlOver = {};
  14021. /** @hidden */
  14022. this._lastControlDown = {};
  14023. /**
  14024. * Observable raised when the point picked by the pointer events changed
  14025. */
  14026. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14027. // Shared resources
  14028. /** @hidden */
  14029. this._sharedMaterials = {};
  14030. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14031. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14032. _this._sceneDisposeObserver = null;
  14033. _this._utilityLayer = null;
  14034. _this.dispose();
  14035. });
  14036. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14037. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14038. this._utilityLayer.pickUtilitySceneFirst = false;
  14039. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14040. return mesh && mesh.metadata && mesh.metadata._node;
  14041. };
  14042. // Root
  14043. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14044. this._rootContainer._host = this;
  14045. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14046. // Events
  14047. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14048. _this._handlePointerOut(pointerId, true);
  14049. });
  14050. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14051. _this._doPicking(pi);
  14052. });
  14053. // Scene
  14054. this._utilityLayer.utilityLayerScene.autoClear = false;
  14055. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14056. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14057. }
  14058. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14059. /** Gets the hosting scene */
  14060. get: function () {
  14061. return this._scene;
  14062. },
  14063. enumerable: true,
  14064. configurable: true
  14065. });
  14066. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14067. /** Gets associated utility layer */
  14068. get: function () {
  14069. return this._utilityLayer;
  14070. },
  14071. enumerable: true,
  14072. configurable: true
  14073. });
  14074. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14075. var previousControlOver = this._lastControlOver[pointerId];
  14076. if (previousControlOver) {
  14077. previousControlOver._onPointerOut(previousControlOver);
  14078. delete this._lastControlOver[pointerId];
  14079. }
  14080. if (isPointerUp) {
  14081. if (this._lastControlDown[pointerId]) {
  14082. this._lastControlDown[pointerId].forcePointerUp();
  14083. delete this._lastControlDown[pointerId];
  14084. }
  14085. }
  14086. this.onPickedPointChangedObservable.notifyObservers(null);
  14087. };
  14088. GUI3DManager.prototype._doPicking = function (pi) {
  14089. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14090. return false;
  14091. }
  14092. var pointerEvent = (pi.event);
  14093. var pointerId = pointerEvent.pointerId || 0;
  14094. var buttonIndex = pointerEvent.button;
  14095. var pickingInfo = pi.pickInfo;
  14096. if (!pickingInfo || !pickingInfo.hit) {
  14097. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14098. return false;
  14099. }
  14100. var control = (pickingInfo.pickedMesh.metadata);
  14101. if (pickingInfo.pickedPoint) {
  14102. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14103. }
  14104. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14105. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14106. if (this._lastControlOver[pointerId]) {
  14107. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14108. }
  14109. delete this._lastControlOver[pointerId];
  14110. }
  14111. }
  14112. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14113. if (this._lastControlDown[pointerEvent.pointerId]) {
  14114. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14115. delete this._lastControlDown[pointerEvent.pointerId];
  14116. }
  14117. if (pointerEvent.pointerType === "touch") {
  14118. this._handlePointerOut(pointerId, false);
  14119. }
  14120. }
  14121. return true;
  14122. };
  14123. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14124. /**
  14125. * Gets the root container
  14126. */
  14127. get: function () {
  14128. return this._rootContainer;
  14129. },
  14130. enumerable: true,
  14131. configurable: true
  14132. });
  14133. /**
  14134. * Gets a boolean indicating if the given control is in the root child list
  14135. * @param control defines the control to check
  14136. * @returns true if the control is in the root child list
  14137. */
  14138. GUI3DManager.prototype.containsControl = function (control) {
  14139. return this._rootContainer.containsControl(control);
  14140. };
  14141. /**
  14142. * Adds a control to the root child list
  14143. * @param control defines the control to add
  14144. * @returns the current manager
  14145. */
  14146. GUI3DManager.prototype.addControl = function (control) {
  14147. this._rootContainer.addControl(control);
  14148. return this;
  14149. };
  14150. /**
  14151. * Removes a control from the root child list
  14152. * @param control defines the control to remove
  14153. * @returns the current container
  14154. */
  14155. GUI3DManager.prototype.removeControl = function (control) {
  14156. this._rootContainer.removeControl(control);
  14157. return this;
  14158. };
  14159. /**
  14160. * Releases all associated resources
  14161. */
  14162. GUI3DManager.prototype.dispose = function () {
  14163. this._rootContainer.dispose();
  14164. for (var materialName in this._sharedMaterials) {
  14165. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14166. continue;
  14167. }
  14168. this._sharedMaterials[materialName].dispose();
  14169. }
  14170. this._sharedMaterials = {};
  14171. if (this._pointerOutObserver && this._utilityLayer) {
  14172. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14173. this._pointerOutObserver = null;
  14174. }
  14175. this.onPickedPointChangedObservable.clear();
  14176. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14177. if (utilityLayerScene) {
  14178. if (this._pointerObserver) {
  14179. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14180. this._pointerObserver = null;
  14181. }
  14182. }
  14183. if (this._scene) {
  14184. if (this._sceneDisposeObserver) {
  14185. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14186. this._sceneDisposeObserver = null;
  14187. }
  14188. }
  14189. if (this._utilityLayer) {
  14190. this._utilityLayer.dispose();
  14191. }
  14192. };
  14193. return GUI3DManager;
  14194. }());
  14195. /***/ }),
  14196. /***/ "./3D/index.ts":
  14197. /*!*********************!*\
  14198. !*** ./3D/index.ts ***!
  14199. \*********************/
  14200. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14202. "use strict";
  14203. __webpack_require__.r(__webpack_exports__);
  14204. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14217. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14220. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14222. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14224. /***/ }),
  14225. /***/ "./3D/materials/fluentMaterial.ts":
  14226. /*!****************************************!*\
  14227. !*** ./3D/materials/fluentMaterial.ts ***!
  14228. \****************************************/
  14229. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14231. "use strict";
  14232. __webpack_require__.r(__webpack_exports__);
  14233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14235. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14236. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  14237. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14238. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14239. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14240. /** @hidden */
  14241. var FluentMaterialDefines = /** @class */ (function (_super) {
  14242. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14243. function FluentMaterialDefines() {
  14244. var _this = _super.call(this) || this;
  14245. _this.INNERGLOW = false;
  14246. _this.BORDER = false;
  14247. _this.HOVERLIGHT = false;
  14248. _this.TEXTURE = false;
  14249. _this.rebuild();
  14250. return _this;
  14251. }
  14252. return FluentMaterialDefines;
  14253. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14254. /**
  14255. * Class used to render controls with fluent desgin
  14256. */
  14257. var FluentMaterial = /** @class */ (function (_super) {
  14258. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14259. /**
  14260. * Creates a new Fluent material
  14261. * @param name defines the name of the material
  14262. * @param scene defines the hosting scene
  14263. */
  14264. function FluentMaterial(name, scene) {
  14265. var _this = _super.call(this, name, scene) || this;
  14266. /**
  14267. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14268. */
  14269. _this.innerGlowColorIntensity = 0.5;
  14270. /**
  14271. * Gets or sets the inner glow color (white by default)
  14272. */
  14273. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14274. /**
  14275. * Gets or sets alpha value (default is 1.0)
  14276. */
  14277. _this.alpha = 1.0;
  14278. /**
  14279. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14280. */
  14281. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14282. /**
  14283. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14284. */
  14285. _this.renderBorders = false;
  14286. /**
  14287. * Gets or sets border width (default is 0.5)
  14288. */
  14289. _this.borderWidth = 0.5;
  14290. /**
  14291. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14292. */
  14293. _this.edgeSmoothingValue = 0.02;
  14294. /**
  14295. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14296. */
  14297. _this.borderMinValue = 0.1;
  14298. /**
  14299. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14300. */
  14301. _this.renderHoverLight = false;
  14302. /**
  14303. * Gets or sets the radius used to render the hover light (default is 1.0)
  14304. */
  14305. _this.hoverRadius = 1.0;
  14306. /**
  14307. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14308. */
  14309. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14310. /**
  14311. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14312. */
  14313. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14314. return _this;
  14315. }
  14316. FluentMaterial.prototype.needAlphaBlending = function () {
  14317. return this.alpha !== 1.0;
  14318. };
  14319. FluentMaterial.prototype.needAlphaTesting = function () {
  14320. return false;
  14321. };
  14322. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14323. return null;
  14324. };
  14325. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14326. if (this.isFrozen) {
  14327. if (this._wasPreviouslyReady && subMesh.effect) {
  14328. return true;
  14329. }
  14330. }
  14331. if (!subMesh._materialDefines) {
  14332. subMesh._materialDefines = new FluentMaterialDefines();
  14333. }
  14334. var scene = this.getScene();
  14335. var defines = subMesh._materialDefines;
  14336. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14337. if (defines._renderId === scene.getRenderId()) {
  14338. return true;
  14339. }
  14340. }
  14341. if (defines._areTexturesDirty) {
  14342. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14343. defines.BORDER = this.renderBorders;
  14344. defines.HOVERLIGHT = this.renderHoverLight;
  14345. if (this._albedoTexture) {
  14346. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14347. return false;
  14348. }
  14349. else {
  14350. defines.TEXTURE = true;
  14351. }
  14352. }
  14353. else {
  14354. defines.TEXTURE = false;
  14355. }
  14356. }
  14357. var engine = scene.getEngine();
  14358. // Get correct effect
  14359. if (defines.isDirty) {
  14360. defines.markAsProcessed();
  14361. scene.resetCachedMaterial();
  14362. //Attributes
  14363. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14364. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14365. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14366. var shaderName = "fluent";
  14367. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14368. "hoverColor", "hoverPosition", "hoverRadius"
  14369. ];
  14370. var samplers = ["albedoSampler"];
  14371. var uniformBuffers = new Array();
  14372. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14373. uniformsNames: uniforms,
  14374. uniformBuffersNames: uniformBuffers,
  14375. samplers: samplers,
  14376. defines: defines,
  14377. maxSimultaneousLights: 4
  14378. });
  14379. var join = defines.toString();
  14380. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14381. attributes: attribs,
  14382. uniformsNames: uniforms,
  14383. uniformBuffersNames: uniformBuffers,
  14384. samplers: samplers,
  14385. defines: join,
  14386. fallbacks: null,
  14387. onCompiled: this.onCompiled,
  14388. onError: this.onError,
  14389. indexParameters: { maxSimultaneousLights: 4 }
  14390. }, engine));
  14391. }
  14392. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14393. return false;
  14394. }
  14395. defines._renderId = scene.getRenderId();
  14396. this._wasPreviouslyReady = true;
  14397. return true;
  14398. };
  14399. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14400. var scene = this.getScene();
  14401. var defines = subMesh._materialDefines;
  14402. if (!defines) {
  14403. return;
  14404. }
  14405. var effect = subMesh.effect;
  14406. if (!effect) {
  14407. return;
  14408. }
  14409. this._activeEffect = effect;
  14410. // Matrices
  14411. this.bindOnlyWorldMatrix(world);
  14412. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14413. if (this._mustRebind(scene, effect)) {
  14414. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14415. if (defines.INNERGLOW) {
  14416. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14417. }
  14418. if (defines.BORDER) {
  14419. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14420. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14421. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14422. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14423. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14424. }
  14425. if (defines.HOVERLIGHT) {
  14426. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14427. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14428. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14429. }
  14430. if (defines.TEXTURE) {
  14431. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14432. }
  14433. }
  14434. this._afterBind(mesh, this._activeEffect);
  14435. };
  14436. FluentMaterial.prototype.getActiveTextures = function () {
  14437. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14438. return activeTextures;
  14439. };
  14440. FluentMaterial.prototype.hasTexture = function (texture) {
  14441. if (_super.prototype.hasTexture.call(this, texture)) {
  14442. return true;
  14443. }
  14444. return false;
  14445. };
  14446. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14447. _super.prototype.dispose.call(this, forceDisposeEffect);
  14448. };
  14449. FluentMaterial.prototype.clone = function (name) {
  14450. var _this = this;
  14451. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14452. };
  14453. FluentMaterial.prototype.serialize = function () {
  14454. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14455. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14456. return serializationObject;
  14457. };
  14458. FluentMaterial.prototype.getClassName = function () {
  14459. return "FluentMaterial";
  14460. };
  14461. // Statics
  14462. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14463. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14464. };
  14465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14466. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14467. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14468. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14470. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14471. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14473. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14474. ], FluentMaterial.prototype, "alpha", void 0);
  14475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14476. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14477. ], FluentMaterial.prototype, "albedoColor", void 0);
  14478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14479. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14480. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14481. ], FluentMaterial.prototype, "renderBorders", void 0);
  14482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14483. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14484. ], FluentMaterial.prototype, "borderWidth", void 0);
  14485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14486. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14487. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14489. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14490. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14492. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14493. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14494. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14495. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14496. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14497. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14498. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14499. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14500. ], FluentMaterial.prototype, "hoverColor", void 0);
  14501. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14502. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14503. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14504. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14505. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14506. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14507. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14508. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14509. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14510. return FluentMaterial;
  14511. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14512. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14513. /***/ }),
  14514. /***/ "./3D/materials/index.ts":
  14515. /*!*******************************!*\
  14516. !*** ./3D/materials/index.ts ***!
  14517. \*******************************/
  14518. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14520. "use strict";
  14521. __webpack_require__.r(__webpack_exports__);
  14522. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14525. /***/ }),
  14526. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14527. /*!*************************************************!*\
  14528. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14529. \*************************************************/
  14530. /*! exports provided: fluentPixelShader */
  14531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14532. "use strict";
  14533. __webpack_require__.r(__webpack_exports__);
  14534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14535. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14536. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14537. var name = 'fluentPixelShader';
  14538. 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}";
  14539. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14540. /** @hidden */
  14541. var fluentPixelShader = { name: name, shader: shader };
  14542. /***/ }),
  14543. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14544. /*!***********************************************!*\
  14545. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14546. \***********************************************/
  14547. /*! exports provided: fluentVertexShader */
  14548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14549. "use strict";
  14550. __webpack_require__.r(__webpack_exports__);
  14551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14552. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14553. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14554. var name = 'fluentVertexShader';
  14555. 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";
  14556. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14557. /** @hidden */
  14558. var fluentVertexShader = { name: name, shader: shader };
  14559. /***/ }),
  14560. /***/ "./3D/vector3WithInfo.ts":
  14561. /*!*******************************!*\
  14562. !*** ./3D/vector3WithInfo.ts ***!
  14563. \*******************************/
  14564. /*! exports provided: Vector3WithInfo */
  14565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14566. "use strict";
  14567. __webpack_require__.r(__webpack_exports__);
  14568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14569. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14570. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  14571. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14572. /**
  14573. * Class used to transport Vector3 information for pointer events
  14574. */
  14575. var Vector3WithInfo = /** @class */ (function (_super) {
  14576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14577. /**
  14578. * Creates a new Vector3WithInfo
  14579. * @param source defines the vector3 data to transport
  14580. * @param buttonIndex defines the current mouse button index
  14581. */
  14582. function Vector3WithInfo(source,
  14583. /** defines the current mouse button index */
  14584. buttonIndex) {
  14585. if (buttonIndex === void 0) { buttonIndex = 0; }
  14586. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14587. _this.buttonIndex = buttonIndex;
  14588. return _this;
  14589. }
  14590. return Vector3WithInfo;
  14591. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14592. /***/ }),
  14593. /***/ "./index.ts":
  14594. /*!******************!*\
  14595. !*** ./index.ts ***!
  14596. \******************/
  14597. /*! 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, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14599. "use strict";
  14600. __webpack_require__.r(__webpack_exports__);
  14601. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14640. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14657. /***/ }),
  14658. /***/ "./legacy/legacy.ts":
  14659. /*!**************************!*\
  14660. !*** ./legacy/legacy.ts ***!
  14661. \**************************/
  14662. /*! 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, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14664. "use strict";
  14665. __webpack_require__.r(__webpack_exports__);
  14666. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14721. /**
  14722. * Legacy support, defining window.BABYLON.GUI (global variable).
  14723. *
  14724. * This is the entry point for the UMD module.
  14725. * The entry point for a future ESM package should be index.ts
  14726. */
  14727. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14728. if (typeof globalObject !== "undefined") {
  14729. globalObject.BABYLON = globalObject.BABYLON || {};
  14730. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14731. }
  14732. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14733. /***/ }),
  14734. /***/ "babylonjs/Misc/observable":
  14735. /*!****************************************************************************************************!*\
  14736. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14737. \****************************************************************************************************/
  14738. /*! no static exports found */
  14739. /***/ (function(module, exports) {
  14740. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  14741. /***/ })
  14742. /******/ });
  14743. });
  14744. //# sourceMappingURL=babylon.gui.js.map